router

package
v3.0.0-...-e8b7a4c Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2023 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	InitializeTypeID            = calcSighash("global:initialize")              // 0xafaf6d1f0d989bed
	CreateAssociatedTokenTypeID = calcSighash("global:create_associated_token") // 0x9105c275d5740bde
	ChangeMpcTypeID             = calcSighash("global:change_mpc")              // 0x2ba8f0e21522a8ab
	SwapinMintTypeID            = calcSighash("global:swapin_mint")             // 0xbfe596d89e2bfab4
	SwapinTransferTypeID        = calcSighash("global:swapin_transfer")         // 0xc8abfa6f944bb0c4
	SwapinNativeTypeID          = calcSighash("global:swapin_native")           // 0x475cf26f2e26f77a
	SwapoutBurnTypeID           = calcSighash("global:swapout_burn")            // 0x76f70b25faacecef
	SwapoutTransferTypeID       = calcSighash("global:swapout_transfer")        // 0x9152207ca5bb83bc
	SwapoutNativeTypeID         = calcSighash("global:swapout_native")          // 0x3b8e03e8d609f08f
	SkimLamportsTypeID          = calcSighash("global:skim_lamports")           // 0xff2ebac3ceab6f31
	ApplyMpcTypeID              = calcSighash("global:apply_mpc")
	EnableSwapTradeTypeID       = calcSighash("global:enable_swap_trade")
)

typeID constants

View Source
var InstructionDefVariant = NewVariantDefinition([]VariantType{
	{ID: SwapinMintTypeID, Name: "SwapinMint", Type: (*SwapinMint)(nil)},
	{ID: SwapinTransferTypeID, Name: "SwapinTransfer", Type: (*SwapinTransfer)(nil)},
	{ID: SwapinNativeTypeID, Name: "SwapinNative", Type: (*SwapinNative)(nil)},
})

InstructionDefVariant default variant

Functions

func InitRouterProgram

func InitRouterProgram(programID types.PublicKey)

InitRouterProgram init router programID

Types

type BaseVariant

type BaseVariant struct {
	TypeID SigHash
	Impl   interface{}
}

BaseVariant base variant

func (*BaseVariant) UnmarshalBinaryVariant

func (v *BaseVariant) UnmarshalBinaryVariant(decoder *bin.Decoder, def *VariantDefinition) error

UnmarshalBinaryVariant unmarshal binary variant

type ChangeMpc

type ChangeMpc struct {
	ChangeMpcParams
	Accounts *ChangeMpcAccounts `bin:"-"`
}

ChangeMpc type

func (*ChangeMpc) SetAccounts

func (i *ChangeMpc) SetAccounts(accounts []*types.AccountMeta) error

SetAccounts set accounts

type ChangeMpcAccounts

type ChangeMpcAccounts struct {
	MPC           *types.AccountMeta `text:"linear,notype"`
	RouterAccount *types.AccountMeta `text:"linear,notype"`
	NewMPC        *types.AccountMeta `text:"linear,notype"`
}

ChangeMpc type

type ChangeMpcParams

type ChangeMpcParams struct {
	New *types.PublicKey `text:"linear,notype"`
}

ChangeMpcParams type

type CreateAT

type CreateAT struct {
	Accounts *CreateATAccounts `bin:"-"`
}

ChangeMpc type

func (*CreateAT) SetAccounts

func (i *CreateAT) SetAccounts(accounts []*types.AccountMeta) error

SetAccounts set accounts

type CreateATAccounts

type CreateATAccounts struct {
	Payer                  *types.AccountMeta `text:"linear,notype"`
	Authority              *types.AccountMeta `text:"linear,notype"`
	Mint                   *types.AccountMeta `text:"linear,notype"`
	AssociatedToken        *types.AccountMeta `text:"linear,notype"`
	Rent                   *types.AccountMeta `text:"linear,notype"`
	SystemProgram          *types.AccountMeta `text:"linear,notype"`
	TokenProgram           *types.AccountMeta `text:"linear,notype"`
	AssociatedTokenProgram *types.AccountMeta `text:"linear,notype"`
}

ChangeMpc type

type EnableSwapTrade

type EnableSwapTrade struct {
	EnableSwapTradeParams
	Accounts *EnableSwapTradeAccounts `bin:"-"`
}

func (*EnableSwapTrade) SetAccounts

func (i *EnableSwapTrade) SetAccounts(accounts []*types.AccountMeta) error

type EnableSwapTradeAccounts

type EnableSwapTradeAccounts struct {
	MPC           *types.AccountMeta `text:"linear,notype"`
	RouterAccount *types.AccountMeta `text:"linear,notype"`
}

type EnableSwapTradeParams

type EnableSwapTradeParams struct {
	Enable bool `text:"linear,notype"`
}

type ISwapinParams

type ISwapinParams interface {
	GetSwapinParams() SwapinParams
}

type Instruction

type Instruction struct {
	RouterProgramID types.PublicKey
	BaseVariant
}

Instruction type

func DecodeInstruction

func DecodeInstruction(accounts []*types.AccountMeta, data []byte) (*Instruction, error)

DecodeInstruction decode instruction

func NewApplyMPCInstruction

func NewApplyMPCInstruction(
	mpc, routerAccount, newMpc types.PublicKey,
) *Instruction

func NewChangeMPCInstruction

func NewChangeMPCInstruction(
	mpc, routerAccount, newMpc types.PublicKey,
) *Instruction

func NewCreateATAInstruction

func NewCreateATAInstruction(
	payer, owner, tokenProgramID, ownertokenATA types.PublicKey,
) *Instruction

func NewEnableSwapTradeInstruction

func NewEnableSwapTradeInstruction(
	enable bool, mpc, routerAccount types.PublicKey,
) *Instruction

func NewSwapinMintInstruction

func NewSwapinMintInstruction(
	tx string, amount, fromChainID uint64,
	mpc, routerAccount, to, tokenMint, tokenProgram types.PublicKey,
) *Instruction

NewSwapinMintInstruction new SwapinMint instruction

func NewSwapinNativeInstruction

func NewSwapinNativeInstruction(
	tx string, amount, fromChainID uint64,
	mpc, routerAccount, to, systemProgram types.PublicKey,
) *Instruction

NewSwapinNativeInstruction new SwapinNative instruction

func NewSwapinTransferInstruction

func NewSwapinTransferInstruction(
	tx string, amount, fromChainID uint64,
	mpc, routerAccount, from, to, tokenMint, tokenProgram types.PublicKey,
) *Instruction

NewSwapinTransferInstruction new SwapinTransfer instruction

func (*Instruction) Accounts

func (i *Instruction) Accounts() (out []*types.AccountMeta)

Accounts get accounts

func (*Instruction) Data

func (i *Instruction) Data() ([]byte, error)

Data get data

func (*Instruction) MarshalBinary

func (i *Instruction) MarshalBinary(encoder *bin.Encoder) error

MarshalBinary marshal binary

func (*Instruction) ProgramID

func (i *Instruction) ProgramID() types.PublicKey

ProgramID get proram ID

func (*Instruction) UnmarshalBinary

func (i *Instruction) UnmarshalBinary(decoder *bin.Decoder) (err error)

UnmarshalBinary unmarshal binary

type SigHash

type SigHash [8]byte

SigHash the first 8 bytes to identify tx instruction

func (*SigHash) SetUint64

func (s *SigHash) SetUint64(i uint64) *SigHash

SetUint64 set uint64

func (*SigHash) Uint64

func (s *SigHash) Uint64() uint64

Uint64 to uint64

type SwapinMint

type SwapinMint struct {
	SwapinParams
	Accounts *SwapinMintAccounts `bin:"-"`
}

SwapinMint type

func (*SwapinMint) GetSwapinParams

func (i *SwapinMint) GetSwapinParams() SwapinParams

func (*SwapinMint) SetAccounts

func (i *SwapinMint) SetAccounts(accounts []*types.AccountMeta) error

SetAccounts set accounts

type SwapinMintAccounts

type SwapinMintAccounts struct {
	MPC           *types.AccountMeta `text:"linear,notype"`
	RouterAccount *types.AccountMeta `text:"linear,notype"`
	To            *types.AccountMeta `text:"linear,notype"`
	TokenMint     *types.AccountMeta `text:"linear,notype"`
	TokenProgram  *types.AccountMeta `text:"linear,notype"`
}

SwapinMintAccounts type

type SwapinNative

type SwapinNative struct {
	SwapinParams
	Accounts *SwapinNativeAccounts `bin:"-"`
}

SwapinNative type

func (*SwapinNative) GetSwapinParams

func (i *SwapinNative) GetSwapinParams() SwapinParams

func (*SwapinNative) SetAccounts

func (i *SwapinNative) SetAccounts(accounts []*types.AccountMeta) error

SetAccounts set accounts

type SwapinNativeAccounts

type SwapinNativeAccounts struct {
	MPC           *types.AccountMeta `text:"linear,notype"`
	RouterAccount *types.AccountMeta `text:"linear,notype"`
	To            *types.AccountMeta `text:"linear,notype"`
	SystemProgram *types.AccountMeta `text:"linear,notype"`
}

SwapinNativeAccounts type

type SwapinParams

type SwapinParams struct {
	Tx          types.BorshString
	Amount      uint64
	FromChainID uint64
}

SwapinParams swapin params

func (*SwapinParams) String

func (p *SwapinParams) String() string

type SwapinTransfer

type SwapinTransfer struct {
	SwapinParams
	Accounts *SwapinTransferAccounts `bin:"-"`
}

SwapinTransfer type

func (*SwapinTransfer) GetSwapinParams

func (i *SwapinTransfer) GetSwapinParams() SwapinParams

func (*SwapinTransfer) SetAccounts

func (i *SwapinTransfer) SetAccounts(accounts []*types.AccountMeta) error

SetAccounts set accounts

type SwapinTransferAccounts

type SwapinTransferAccounts struct {
	MPC           *types.AccountMeta `text:"linear,notype"`
	RouterAccount *types.AccountMeta `text:"linear,notype"`
	From          *types.AccountMeta `text:"linear,notype"`
	To            *types.AccountMeta `text:"linear,notype"`
	TokenMint     *types.AccountMeta `text:"linear,notype"`
	TokenProgram  *types.AccountMeta `text:"linear,notype"`
}

SwapinTransferAccounts type

type VariantDefinition

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

VariantDefinition definition

func NewVariantDefinition

func NewVariantDefinition(types []VariantType) *VariantDefinition

NewVariantDefinition creates a variant definition based on the *ordered* provided types.

type VariantType

type VariantType struct {
	ID   SigHash
	Name string
	Type interface{}
}

VariantType type

Jump to

Keyboard shortcuts

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