token

package
v0.85.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 18, 2021 License: MIT Imports: 7 Imported by: 17

Documentation

Index

Constants

View Source
const (
	// nolint:varcheck,deadcode,unused
	ErrorNotRentExempt solana.CustomError = iota
	// nolint:varcheck,deadcode,unused
	ErrorInsufficientFunds
	// nolint:varcheck,deadcode,unused
	ErrorInvalidMint
	// nolint:varcheck,deadcode,unused
	ErrorMintMismatch
	// nolint:varcheck,deadcode,unused
	ErrorOwnerMismatch
	// nolint:varcheck,deadcode,unused
	ErrorFixedSupply
	// nolint:varcheck,deadcode,unused
	ErrorAlreadyInUse
	// nolint:varcheck,deadcode,unused
	ErrorInvalidNumberOfProvidedSigners
	// nolint:varcheck,deadcode,unused
	ErrorInvalidNumberOfRequiredSigners
	// nolint:varcheck,deadcode,unused
	ErrorUninitializedState
	// nolint:varcheck,deadcode,unused
	ErrorNativeNotSupported
	// nolint:varcheck,deadcode,unused
	ErrorNonNativeHasBalance
	// nolint:varcheck,deadcode,unused
	ErrorInvalidInstruction
	// nolint:varcheck,deadcode,unused
	ErrorInvalidState
	// nolint:varcheck,deadcode,unused
	ErrorOverflow
	// nolint:varcheck,deadcode,unused
	ErrorAuthorityTypeNotSupported
	// nolint:varcheck,deadcode,unused
	ErrorMintCannotFreeze
	// nolint:varcheck,deadcode,unused
	ErrorAccountFrozen
	// nolint:varcheck,deadcode,unused
	ErrorMintDecimalsMismatch
)
View Source
const AccountSize = 165

Reference: https://github.com/solana-labs/solana-program-library/blob/11b1e3eefdd4e523768d63f7c70a7aa391ea0d02/token/program/src/state.rs#L125

View Source
const MultisigAccountSize = 355

Reference: https://github.com/solana-labs/solana-program-library/blob/8944f428fe693c3a4226bf766a79be9c75e8e520/token/program/src/state.rs#L214

Variables

View Source
var (
	// ErrAccountNotFound indicates there is no account for the given address.
	ErrAccountNotFound = errors.New("account not found")
	// ErrInvalidTokenAccount indicates that a Solana account exists at the
	// given address, but it is either not initialized, or not configured correctly.
	ErrInvalidTokenAccount = errors.New("invalid token account")
)
View Source
var AssociatedTokenAccountProgramKey = ed25519.PublicKey{140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142, 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216, 219, 233, 248, 89}

AssociatedTokenAccountProgramKey is the address of the associated token account program that should be used.

Current key: ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL

View Source
var ProgramKey = ed25519.PublicKey{6, 221, 246, 225, 215, 101, 161, 147, 217, 203, 225, 70, 206, 235, 121, 172, 28, 180, 133, 237, 95, 91, 55, 145, 58, 140, 245, 133, 126, 255, 0, 169}

ProgramKey is the address of the token program that should be used.

Current key: TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA

todo: lock this in, or make configurable.

Functions

func GetAssociatedAccount added in v0.74.0

func GetAssociatedAccount(wallet, mint ed25519.PublicKey) (ed25519.PublicKey, error)

GetAssociatedAccount returns the associated account address for an SPL token.

Reference: https://spl.solana.com/associated-token-account#finding-the-associated-token-account-address

func SetAuthorityMultisig added in v0.61.0

func SetAuthorityMultisig(account, multisigOwner, newAuthority ed25519.PublicKey, authorityType AuthorityType, signers []ed25519.PublicKey) solana.Instruction

func TransferMultisig added in v0.50.0

func TransferMultisig(source, dest, multisigOwner ed25519.PublicKey, amount uint64, signers ...ed25519.PublicKey) solana.Instruction

Types

type Account

type Account struct {
	// The mint associated with this account
	Mint ed25519.PublicKey
	// The owner of this account.
	Owner ed25519.PublicKey
	// The amount of tokens this account holds.
	Amount uint64
	// If set, then the 'DelegatedAmount' represents the amount
	// authorized by the delegate.
	Delegate ed25519.PublicKey
	/// The account's state
	State AccountState
	// If set, this is a native token, and the value logs the rent-exempt reserve. An Account
	// is required to be rent-exempt, so the value is used by the Processor to ensure that wrapped
	// SOL accounts do not drop below this threshold.
	IsNative *uint64
	// The amount delegated
	DelegatedAmount uint64
	// Optional authority to close the account.
	CloseAuthority ed25519.PublicKey
}

func (*Account) Marshal

func (a *Account) Marshal() []byte

func (*Account) Unmarshal

func (a *Account) Unmarshal(b []byte) bool

type AccountState

type AccountState byte
const (
	AccountStateUninitialized AccountState = iota
	AccountStateInitialized
	AccountStateFrozen
)

type AuthorityType

type AuthorityType byte
const (
	AuthorityTypeMintTokens AuthorityType = iota
	AuthorityTypeFreezeAccount
	AuthorityTypeAccountHolder
	AuthorityTypeCloseAccount
)

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client provides utilities for accessing token accounts for a given token.

func NewClient

func NewClient(sc solana.Client, token ed25519.PublicKey) *Client

NewClient creates a new Client.

func (*Client) GetAccount

func (c *Client) GetAccount(accountID ed25519.PublicKey, commitment solana.Commitment) (*Account, error)

GetAccount returns the token account info for the specified account.

If the account is not initialized, or belongs to a different mint, then ErrInvalidTokenAccount is returned.

func (*Client) Token

func (c *Client) Token() ed25519.PublicKey

type Command added in v0.74.0

type Command byte
const (
	// nolint:varcheck,deadcode,unused
	CommandInitializeMint Command = iota
	CommandInitializeAccount
	CommandInitializeMultisig
	CommandTransfer
	// nolint:varcheck,deadcode,unused
	CommandApprove
	// nolint:varcheck,deadcode,unused
	CommandRevoke
	CommandSetAuthority
	// nolint:varcheck,deadcode,unused
	CommandMintTo
	// nolint:varcheck,deadcode,unused
	CommandBurn
	CommandCloseAccount
	// nolint:varcheck,deadcode,unused
	CommandFreezeAccount
	// nolint:varcheck,deadcode,unused
	CommandThawAccount
	// nolint:varcheck,deadcode,unused
	CommandTransfer2
	// nolint:varcheck,deadcode,unused
	CommandApprove2
	// nolint:varcheck,deadcode,unused
	CommandMintTo2
	// nolint:varcheck,deadcode,unused
	CommandBurn2

	CommandUnknown = Command(math.MaxUint8)
)

func GetCommand added in v0.74.0

func GetCommand(m solana.Message, index int) (Command, error)

type DecompiledCloseAccount added in v0.74.0

type DecompiledCloseAccount struct {
	Account     ed25519.PublicKey
	Destination ed25519.PublicKey
	Owner       ed25519.PublicKey
}

func DecompileCloseAccount added in v0.74.0

func DecompileCloseAccount(m solana.Message, index int) (*DecompiledCloseAccount, error)

type DecompiledCreateAssociatedAccount added in v0.76.0

type DecompiledCreateAssociatedAccount struct {
	Subsidizer ed25519.PublicKey
	Address    ed25519.PublicKey
	Owner      ed25519.PublicKey
	Mint       ed25519.PublicKey
}

func DecompileCreateAssociatedAccount added in v0.76.0

func DecompileCreateAssociatedAccount(m solana.Message, index int) (*DecompiledCreateAssociatedAccount, error)

type DecompiledInitializeAccount

type DecompiledInitializeAccount struct {
	Account ed25519.PublicKey
	Mint    ed25519.PublicKey
	Owner   ed25519.PublicKey
}

func DecompileInitializeAccount

func DecompileInitializeAccount(m solana.Message, index int) (*DecompiledInitializeAccount, error)

type DecompiledSetAuthority

type DecompiledSetAuthority struct {
	Account          ed25519.PublicKey
	CurrentAuthority ed25519.PublicKey
	NewAuthority     ed25519.PublicKey
	Type             AuthorityType
}

func DecompileSetAuthority

func DecompileSetAuthority(m solana.Message, index int) (*DecompiledSetAuthority, error)

type DecompiledTransfer added in v0.74.0

type DecompiledTransfer struct {
	Source      ed25519.PublicKey
	Destination ed25519.PublicKey
	Owner       ed25519.PublicKey
	Amount      uint64
}

func DecompileTransfer added in v0.74.0

func DecompileTransfer(m solana.Message, index int) (*DecompiledTransfer, error)

type DecompiledTransfer2 added in v0.77.0

type DecompiledTransfer2 struct {
	Source      ed25519.PublicKey
	Mint        ed25519.PublicKey
	Destination ed25519.PublicKey
	Owner       ed25519.PublicKey
	Amount      uint64
	Decimals    byte
}

func DecompileTransfer2 added in v0.77.0

func DecompileTransfer2(m solana.Message, index int) (*DecompiledTransfer2, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL