Documentation
¶
Index ¶
- Variables
- func AwaitConfirmedTransaction(ctx context.Context, cl *rpc.Client, txSig solana.Signature) (*rpc.GetTransactionResult, error)
- func ChainID(ctx context.Context, cl *rpc.Client) (uint64, error)
- func Deploy(ctx context.Context, rpcAddr string, program Program, ...) (*rpc.GetTransactionResult, error)
- func EnsureATA(ctx context.Context, cl *rpc.Client, mint solana.PublicKey, ...) (solana.PublicKey, error)
- func EnsureATAs(ctx context.Context, cl *rpc.Client, mint solana.PublicKey, ...) (map[solana.PublicKey]solana.PublicKey, error)
- func FillHash(orderID [32]byte, srcChainID uint64, destChainID uint64, fillDeadline uint32, ...) (common.Hash, error)
- func FilterDataLogs(logs []string, program solana.PublicKey) ([]string, bool, error)
- func GetAccountDataInto(ctx context.Context, cl *rpc.Client, address solana.PublicKey, val any) (*rpc.GetAccountInfoResult, error)
- func GetBlock(ctx context.Context, cl *rpc.Client, slot uint64, ...) (*rpc.GetBlockResult, bool, error)
- func MapEVMKey(key *ecdsa.PrivateKey) solana.PrivateKey
- func NativeBalanceAt(ctx context.Context, cl *rpc.Client, addr solana.PublicKey) (*big.Int, error)
- func RandomU96() bin.Uint128
- func Redeploy(ctx context.Context, rpcAddr string, program Program, ...) (*rpc.GetTransactionResult, error)
- func SavePrivateKey(key solana.PrivateKey, path string) error
- func Send(ctx context.Context, cl *rpc.Client, opts ...func(*sendOpts)) (solana.Signature, error)
- func SendSimple(ctx context.Context, cl *rpc.Client, privkey solana.PrivateKey, ...) (solana.Signature, error)
- func Start(ctx context.Context, composeDir string) (*rpc.Client, string, solana.PrivateKey, func(), error)
- func Stream(ctx context.Context, cl *rpc.Client, req StreamReq, callback StreamCallback) error
- func TokenBalanceAt(ctx context.Context, cl *rpc.Client, mint, wallet solana.PublicKey) (*big.Int, error)
- func U128(i *big.Int) (bin.Uint128, error)
- func WithInstructions(instrs ...solana.Instruction) func(*sendOpts)
- func WithPrivateKeys(privkeys ...solana.PrivateKey) func(*sendOpts)
- func WrapRPCError(err error, endpoint string, attrs ...any) error
- type CreateMintResp
- type Program
- type StreamCallback
- type StreamReq
Constants ¶
This section is empty.
Variables ¶
var ( // DevnetUSDCMint is the USDC mint private key on local devnet. DevnetUSDCMint = solana.PrivateKey(ed25519.NewKeyFromSeed([]byte(usdcSeed))) )
var Version = "stable"
Functions ¶
func AwaitConfirmedTransaction ¶
func AwaitConfirmedTransaction(ctx context.Context, cl *rpc.Client, txSig solana.Signature) (*rpc.GetTransactionResult, error)
AwaitConfirmedTransaction waits for a transaction to be confirmed.
func Deploy ¶
func Deploy(ctx context.Context, rpcAddr string, program Program, deployer, upgrader solana.PrivateKey) (*rpc.GetTransactionResult, error)
Deploy deploys a program to the rpc network using the provided keys. It returns the confirmed transaction result or an error.
func EnsureATA ¶
func EnsureATA(ctx context.Context, cl *rpc.Client, mint solana.PublicKey, owner solana.PrivateKey) (solana.PublicKey, error)
EnsureATA returns (and possibly creates) the owner's associated token account (ATA) for the given mint.
func EnsureATAs ¶
func EnsureATAs(ctx context.Context, cl *rpc.Client, mint solana.PublicKey, owners ...solana.PrivateKey) (map[solana.PublicKey]solana.PublicKey, error)
EnsureATAs finds or creates the owners' associated token account (ATA) for the given mint.
func FillHash ¶
func FillHash( orderID [32]byte, srcChainID uint64, destChainID uint64, fillDeadline uint32, callTarget common.Address, callSelector [4]byte, callValue *big.Int, callParams []byte, expenseSpender common.Address, expenseToken common.Address, expenseAmount *big.Int, ) (common.Hash, error)
FillHash returns the fill hash for the given parameters.
func FilterDataLogs ¶
FilterDataLogs filters the logs for a specific program, returning only the data logs and true if logs were not truncated.
func GetAccountDataInto ¶
func GetAccountDataInto(ctx context.Context, cl *rpc.Client, address solana.PublicKey, val any) (*rpc.GetAccountInfoResult, error)
GetAccountDataInto retrieves account data and decodes it into the provided value. It uses commitment level of "confirmed".
func GetBlock ¶
func GetBlock(ctx context.Context, cl *rpc.Client, slot uint64, details rpc.TransactionDetailsType) (*rpc.GetBlockResult, bool, error)
GetBlock is a convenience function returning the block for the given slot, or false if no block found for the slot, or and error.
func MapEVMKey ¶
func MapEVMKey(key *ecdsa.PrivateKey) solana.PrivateKey
MapEVMKey returns a deterministic mapping of an EVM secp256k1 private key to a Solana ed25519 private key.
func NativeBalanceAt ¶
func Redeploy ¶
func Redeploy(ctx context.Context, rpcAddr string, program Program, upgrader solana.PrivateKey) (*rpc.GetTransactionResult, error)
Redeploy redeployes/upgrades the program to the rpc network using the provided keys. It returns the confirmed transaction result or an error.
func SavePrivateKey ¶
func SavePrivateKey(key solana.PrivateKey, path string) error
SavePrivateKey saves a Solana private key to a file in JSON format.
func SendSimple ¶
func Start ¶
func Start(ctx context.Context, composeDir string) (*rpc.Client, string, solana.PrivateKey, func(), error)
Start starts a genesis solana node and returns a client, a funded private key and a stop function or an error. The dir parameter is the location of the docker compose.
func TokenBalanceAt ¶
func WithInstructions ¶
func WithInstructions(instrs ...solana.Instruction) func(*sendOpts)
func WithPrivateKeys ¶
func WithPrivateKeys(privkeys ...solana.PrivateKey) func(*sendOpts)
Types ¶
type CreateMintResp ¶
type CreateMintResp struct {
MintAccount solana.PublicKey
Authority solana.PrivateKey
ATAs map[solana.PublicKey]solana.PublicKey // Map of funded associated token accounts
}
func CreateMint ¶
func CreateMint( ctx context.Context, cl *rpc.Client, authority solana.PrivateKey, mint solana.PrivateKey, decimals uint8, toFund ...solana.PublicKey, ) (CreateMintResp, error)
func (CreateMintResp) AuthATA ¶
func (r CreateMintResp) AuthATA() solana.PublicKey
type Program ¶
Program represents a Solana executable program (smart contract).
func Rebuild ¶
func Rebuild(ctx context.Context, program Program, key solana.PrivateKey, anchorDir string) (Program, error)
Rebuild rebuilds the program's so file with the provided private key. This effectively changes the program ID.
func (Program) KeyPairFile ¶
func (Program) MustPrivateKey ¶
func (p Program) MustPrivateKey() solana.PrivateKey
func (Program) MustPublicKey ¶
type StreamCallback ¶
type StreamCallback func(ctx context.Context, sig *rpc.TransactionSignature) error
StreamCallback abstracts the logic that handles a stream of transaction signatures. The logic must be idempotent.