timelock_token

package
v1.10.16 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BurnDustWithAuthorityInstructionArgsSize = (1 +
		8) // max_amount

	BurnDustWithAuthorityInstructionAccountsSize = (32 +
		32 +
		32 +
		32 +
		32 +
		32 +
		32 +
		32) // systemProgram

	BurnDustWithAuthorityInstructionSize = (8 +
		BurnDustWithAuthorityInstructionArgsSize +
		BurnDustWithAuthorityInstructionAccountsSize) // accounts
)
View Source
const (
	CloseAccountsInstructionArgsSize = (1) // TimelockBump

	CloseAccountsInstructionAccountsSize = (32 +
		32 +
		32 +
		32 +
		32 +
		32) // systemProgram

	CloseAccountsInstructionSize = (8 +
		CloseAccountsInstructionArgsSize +
		CloseAccountsInstructionAccountsSize) // accounts
)
View Source
const (
	DeactivateInstructionArgsSize = (1) // TimelockBump

	DeactivateInstructionAccountsSize = (32 +
		32 +
		32) // payer

	DeactivateInstructionSize = (8 +
		DeactivateInstructionArgsSize +
		DeactivateInstructionAccountsSize) // accounts
)
View Source
const (
	InitializeInstructionArgsSize = (8) // UnlockDuration

	InitializeInstructionAccountsSize = (32 +
		32 +
		32 +
		32 +
		32 +
		32 +
		32 +
		32 +
		32 +
		32) // sysvarRent

	InitializeInstructionSize = (8 +
		InitializeInstructionArgsSize +
		InitializeInstructionAccountsSize) // accounts
)
View Source
const (
	RevokeLockWithAuthorityInstructionArgsSize = (1) // TimelockBump

	RevokeLockWithAuthorityInstructionAccountsSize = (32 +
		32 +
		32 +
		32 +
		32 +
		32) // systemProgram

	RevokeLockWithAuthorityInstructionSize = (8 +
		RevokeLockWithAuthorityInstructionArgsSize +
		RevokeLockWithAuthorityInstructionAccountsSize) // accounts
)
View Source
const (
	WithdrawInstructionArgsSize = (1) // TimelockBump

	WithdrawInstructionAccountsSize = (32 +
		32 +
		32 +
		32 +
		32 +
		32 +
		32) // systemProgram

	WithdrawInstructionSize = (8 +
		WithdrawInstructionArgsSize +
		WithdrawInstructionAccountsSize) // accounts
)
View Source
const (
	// Need to be very careful changing this value, as it's used in the state
	// address PDA.
	DefaultUnlockDuration = uint64(3 * 7 * 24 * time.Hour / time.Second) // 3 weeks in seconds
)
View Source
const TimelockAccountSize = (8 +
	1 +
	1 +
	1 +
	32 +
	32 +
	32 +
	32 +
	32 +
	1 +
	1 +
	32 +
	8 +
	9 +
	9 +

	32) // pda_padding

Variables

View Source
var (
	ErrInvalidProgram         = errors.New("invalid program id")
	ErrInvalidAccountData     = errors.New("unexpected account data")
	ErrInvalidInstructionData = errors.New("unexpected instruction data")
)
View Source
var (
	PROGRAM_ADDRESS = mustBase58Decode("timeDBoQGL52du9K7EtrhkJSqpiFapE9dHrmDVkuZx6")
	PROGRAM_ID      = ed25519.PublicKey(PROGRAM_ADDRESS)
)
View Source
var (
	SYSTEM_PROGRAM_ID               = ed25519.PublicKey(mustBase58Decode("11111111111111111111111111111111"))
	SPL_TOKEN_PROGRAM_ID            = ed25519.PublicKey(mustBase58Decode("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"))
	SPL_ASSOCIATED_TOKEN_PROGRAM_ID = ed25519.PublicKey(mustBase58Decode("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"))

	SYSVAR_CLOCK_PUBKEY = ed25519.PublicKey(mustBase58Decode("SysvarC1ock11111111111111111111111111111111"))
	SYSVAR_RENT_PUBKEY  = ed25519.PublicKey(mustBase58Decode("SysvarRent111111111111111111111111111111111"))
)

Functions

func GetStateAddress

func GetStateAddress(args *GetStateAddressArgs) (ed25519.PublicKey, uint8, error)

func GetVaultAddress

func GetVaultAddress(args *GetVaultAddressArgs) (ed25519.PublicKey, uint8, error)

func WithdrawInstructionFromBinary

func WithdrawInstructionFromBinary(data []byte) (*WithdrawInstructionArgs, *WithdrawInstructionAccounts, error)

Types

type AccountMeta

type AccountMeta struct {
	PublicKey  ed25519.PublicKey
	IsWritable bool
	IsSigner   bool
}

AccountMeta represents the account information required for building transactions.

type BurnDustWithAuthorityInstructionAccounts

type BurnDustWithAuthorityInstructionAccounts struct {
	Timelock      ed25519.PublicKey
	Vault         ed25519.PublicKey
	VaultOwner    ed25519.PublicKey
	TimeAuthority ed25519.PublicKey
	Mint          ed25519.PublicKey
	Payer         ed25519.PublicKey
}

type BurnDustWithAuthorityInstructionArgs

type BurnDustWithAuthorityInstructionArgs struct {
	TimelockBump uint8
	MaxAmount    uint64
}

type CloseAccountsInstructionAccounts

type CloseAccountsInstructionAccounts struct {
	Timelock       ed25519.PublicKey
	Vault          ed25519.PublicKey
	CloseAuthority ed25519.PublicKey
	Payer          ed25519.PublicKey
}

type CloseAccountsInstructionArgs

type CloseAccountsInstructionArgs struct {
	TimelockBump uint8
}

type DeactivateInstructionAccounts

type DeactivateInstructionAccounts struct {
	Timelock   ed25519.PublicKey
	VaultOwner ed25519.PublicKey
	Payer      ed25519.PublicKey
}

type DeactivateInstructionArgs

type DeactivateInstructionArgs struct {
	TimelockBump uint8
}

type GetStateAddressArgs

type GetStateAddressArgs struct {
	Mint           ed25519.PublicKey
	TimeAuthority  ed25519.PublicKey
	Nonce          ed25519.PublicKey
	VaultOwner     ed25519.PublicKey
	UnlockDuration uint64
}

type GetVaultAddressArgs

type GetVaultAddressArgs struct {
	State ed25519.PublicKey
}

type InitializeInstructionAccounts

type InitializeInstructionAccounts struct {
	Nonce         ed25519.PublicKey
	Timelock      ed25519.PublicKey
	Vault         ed25519.PublicKey
	VaultOwner    ed25519.PublicKey
	Mint          ed25519.PublicKey
	TimeAuthority ed25519.PublicKey
	Payer         ed25519.PublicKey
}

type InitializeInstructionArgs

type InitializeInstructionArgs struct {
	UnlockDuration uint64
}

type Instruction

type Instruction struct {
	Program  ed25519.PublicKey
	Accounts []AccountMeta
	Data     []byte
}

Instruction represents a transaction instruction.

func NewDeactivateInstruction

func NewDeactivateInstruction(
	accounts *DeactivateInstructionAccounts,
	args *DeactivateInstructionArgs,
) Instruction

func NewInitializeInstruction

func NewInitializeInstruction(
	accounts *InitializeInstructionAccounts,
	args *InitializeInstructionArgs,
) Instruction

func NewWithdrawInstruction

func NewWithdrawInstruction(
	accounts *WithdrawInstructionAccounts,
	args *WithdrawInstructionArgs,
) Instruction

func (Instruction) ToLegacyInstruction

func (i Instruction) ToLegacyInstruction() solana.Instruction

type RevokeLockWithAuthorityInstructionAccounts

type RevokeLockWithAuthorityInstructionAccounts struct {
	Timelock      ed25519.PublicKey
	Vault         ed25519.PublicKey
	TimeAuthority ed25519.PublicKey
	Payer         ed25519.PublicKey
}

type RevokeLockWithAuthorityInstructionArgs

type RevokeLockWithAuthorityInstructionArgs struct {
	TimelockBump uint8
}

type TimelockAccount

type TimelockAccount struct {
	DataVersion    TimelockDataVersion
	PdaVersion     TimelockPdaVersion
	InitOffset     uint8
	Nonce          ed25519.PublicKey
	TimeAuthority  ed25519.PublicKey
	CloseAuthority ed25519.PublicKey
	Mint           ed25519.PublicKey
	Vault          ed25519.PublicKey
	VaultBump      uint8
	VaultState     TimelockState
	VaultOwner     ed25519.PublicKey
	UnlockDuration uint64
	UnlockAt       *uint64 // optional
	LockedAt       *uint64 // optional
	PdaPadding     [ed25519.PublicKeySize]byte
}

Arguments used to create {@link TimelockAccount}

func NewTimelockAccount

func NewTimelockAccount(
	dataVersion TimelockDataVersion,
	pdaVersion TimelockPdaVersion,
	initOffset uint8,
	nonce ed25519.PublicKey,
	timeAuthority ed25519.PublicKey,
	closeAuthority ed25519.PublicKey,
	mint ed25519.PublicKey,
	vault ed25519.PublicKey,
	vaultBump uint8,
	vaultState TimelockState,
	vaultOwner ed25519.PublicKey,
	unlockDuration uint64,
	unlockAt *uint64,
	lockedAt *uint64,
) *TimelockAccount

Holds the data for the {@link TimelockAccount} Account and provides de/serialization functionality for that data

func (*TimelockAccount) Clone

func (obj *TimelockAccount) Clone() *TimelockAccount

Clones a {@link TimelockAccount} instance.

func (*TimelockAccount) Marshal

func (obj *TimelockAccount) Marshal() []byte

Serializes the {@link TimelockAccount} into a Buffer. @returns the created []byte buffer

func (*TimelockAccount) ToString

func (obj *TimelockAccount) ToString() string

func (*TimelockAccount) Unmarshal

func (obj *TimelockAccount) Unmarshal(data []byte) error

Deserializes the {@link TimelockAccount} from the provided data Buffer. @returns an error if the deserialize operation was unsuccessful.

type TimelockDataVersion

type TimelockDataVersion uint8
const (
	UnknownDataVersion TimelockDataVersion = iota
	DataVersion1
)

type TimelockPdaVersion

type TimelockPdaVersion uint8
const (
	UnknownPdaVersion TimelockPdaVersion = iota
	PdaVersion1
)

type TimelockState

type TimelockState uint8
const (
	Unknown TimelockState = iota
	Unlocked
	WaitingForTimeout
	Locked
	Closed
)

func (TimelockState) String

func (s TimelockState) String() string

type TimelockTokenError

type TimelockTokenError uint32
const (
	// Invalid timelock state for this instruction
	ErrInvalidTimelockState TimelockTokenError = iota + 0x1770

	// Invalid timelock duration provided
	ErrInvalidTimelockDuration

	// Invalid vault account
	ErrInvalidVaultAccount

	// The timelock period has not yet been reached
	ErrInsufficientTimeElapsed

	// Insufficient vault funds
	ErrInsufficientVaultBalance

	// Invalid time authority
	ErrInvalidTimeAuthority

	// Invalid vault owner
	ErrInvalidVaultOwner

	// Invalid close authority
	ErrInvalidCloseAuthority

	// Invalid token balance. Token balance must be zero.
	ErrNonZeroTokenBalance
)

type WithdrawInstructionAccounts

type WithdrawInstructionAccounts struct {
	Timelock    ed25519.PublicKey
	Vault       ed25519.PublicKey
	VaultOwner  ed25519.PublicKey
	Destination ed25519.PublicKey
	Payer       ed25519.PublicKey
}

type WithdrawInstructionArgs

type WithdrawInstructionArgs struct {
	TimelockBump uint8
}

Jump to

Keyboard shortcuts

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