token

package
v0.59.0 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2020 License: MIT Imports: 6 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 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 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 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 DecompiledTransferAccount

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

func DecompileTransferAccount

func DecompileTransferAccount(m solana.Message, index int) (*DecompiledTransferAccount, error)

Jump to

Keyboard shortcuts

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