serialize

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CreateAccountAction = iota
	DeployContractAction
	FunctionCallAction
	TransferAction
	StakeAction
	AddKeyAction
	DeleteKeyAction
	DeleteAccountAccount
)

Variables

View Source
var (
	NearPrefix    = "ed25519:"
	Ed25519Prefix = "ed25519"
)

Functions

func TryParse

func TryParse(s string) ([]byte, error)

Types

type AccessKey

type AccessKey struct {
	Nonce      U64
	Permission AccessKeyPermission
}

func (*AccessKey) Serialize

func (s *AccessKey) Serialize() ([]byte, error)

type AccessKeyPermission

type AccessKeyPermission struct {
	FunctionCall *FunctionCallPermission
	FullAccess   *FullAccessPermission
}

func (*AccessKeyPermission) Serialize

func (s *AccessKeyPermission) Serialize() ([]byte, error)

type AddKeyAct

type AddKeyAct struct {
	Action    uint8
	PublicKey PublicKey
	AccessKey AccessKey
}

func CreateAddFullAccessKey

func CreateAddFullAccessKey(publicKeyHex string) (*AddKeyAct, error)

func CreateAddFunctionCallAccessKey

func CreateAddFunctionCallAccessKey(publicKeyHex string, allowance, receiverId string, methodNames []string) (*AddKeyAct, error)

func (*AddKeyAct) GetActionIndex

func (s *AddKeyAct) GetActionIndex() uint8

func (*AddKeyAct) Serialize

func (s *AddKeyAct) Serialize() ([]byte, error)

type BlockHash

type BlockHash struct {
	Value []byte
}

func (*BlockHash) Serialize

func (s *BlockHash) Serialize() ([]byte, error)

type CreateAccount

type CreateAccount struct {
	Action uint8
}

func CreateCreateAccount

func CreateCreateAccount() (*CreateAccount, error)

func (*CreateAccount) GetActionIndex

func (s *CreateAccount) GetActionIndex() uint8

func (*CreateAccount) Serialize

func (s *CreateAccount) Serialize() ([]byte, error)

type DeleteAccountAct

type DeleteAccountAct struct {
	Action        uint8
	BeneficiaryId String
}

func CreateDeleteAccount

func CreateDeleteAccount(beneficiaryId string) (*DeleteAccountAct, error)

func (*DeleteAccountAct) GetActionIndex

func (s *DeleteAccountAct) GetActionIndex() uint8

func (*DeleteAccountAct) Serialize

func (s *DeleteAccountAct) Serialize() ([]byte, error)

type DeleteKeyAct

type DeleteKeyAct struct {
	Action    uint8
	PublicKey PublicKey
}

func CreateDeleteKey

func CreateDeleteKey(publicKeyHex string) (*DeleteKeyAct, error)

func (*DeleteKeyAct) GetActionIndex

func (s *DeleteKeyAct) GetActionIndex() uint8

func (*DeleteKeyAct) Serialize

func (s *DeleteKeyAct) Serialize() ([]byte, error)

type DeployContract

type DeployContract struct {
	Action uint8
	Code   []U8 //Uint8Array
}

func CreateDeployContract

func CreateDeployContract(code []byte) (*DeployContract, error)

func (*DeployContract) GetActionIndex

func (s *DeployContract) GetActionIndex() uint8

func (*DeployContract) Serialize

func (s *DeployContract) Serialize() ([]byte, error)

type FullAccessPermission

type FullAccessPermission struct {
}

func (*FullAccessPermission) Serialize

func (s *FullAccessPermission) Serialize() ([]byte, error)

type FunctionCall

type FunctionCall struct {
	Action     uint8
	MethodName String
	Args       []U8
	Gas        U64
	Deposit    U128
}

func CreateFunctionCall

func CreateFunctionCall(methodName string, args []uint8, gas, deposit *big.Int) (*FunctionCall, error)

func (*FunctionCall) GetActionIndex

func (s *FunctionCall) GetActionIndex() uint8

func (*FunctionCall) Serialize

func (s *FunctionCall) Serialize() ([]byte, error)

type FunctionCallPermission

type FunctionCallPermission struct {
	Allowance   *U128
	ReceiverId  String
	MethodNames []String
}

func (*FunctionCallPermission) Serialize

func (s *FunctionCallPermission) Serialize() ([]byte, error)

type IAction

type IAction interface {
	ISerialize
	GetActionIndex() uint8
}

type ISerialize

type ISerialize interface {
	Serialize() ([]byte, error)
}

type PublicKey

type PublicKey struct {
	KeyType uint8
	Value   []byte
}

func TryParsePubKey

func TryParsePubKey(s string) (*PublicKey, error)

func (*PublicKey) Serialize

func (s *PublicKey) Serialize() ([]byte, error)

type SignMessagePayload

type SignMessagePayload struct {
	Message     String
	Nonce       []byte
	Recipient   String
	CallbackUrl *String
	// contains filtered or unexported fields
}

func NewSignMessagePayload

func NewSignMessagePayload(message string, nonce []byte, recipient string, callbackUrl string) *SignMessagePayload

func (*SignMessagePayload) Serialize

func (self *SignMessagePayload) Serialize() ([]byte, error)

type Signature

type Signature struct {
	KeyType uint8
	Value   []byte
}

func (*Signature) Serialize

func (s *Signature) Serialize() ([]byte, error)

type Stake

type Stake struct {
	Action    uint8
	Stake     U128
	PublicKey PublicKey
}

func CreateStake

func CreateStake(publicKeyHex string, allowance string) (*Stake, error)

func (*Stake) GetActionIndex

func (s *Stake) GetActionIndex() uint8

func (*Stake) Serialize

func (s *Stake) Serialize() ([]byte, error)

type String

type String struct {
	Value string
}

func (*String) Serialize

func (s *String) Serialize() ([]byte, error)

type Transfer

type Transfer struct {
	Action uint8
	Value  U128
}

Action

func CreateTransfer

func CreateTransfer(amount string) (*Transfer, error)

func (*Transfer) GetActionIndex

func (s *Transfer) GetActionIndex() uint8

func (*Transfer) Serialize

func (s *Transfer) Serialize() ([]byte, error)

type U8

type U8 struct {
	Value uint8
}

func (*U8) Serialize

func (u *U8) Serialize() ([]byte, error)

type U32

type U32 struct {
	Value uint32
}

func (*U32) Serialize

func (u *U32) Serialize() ([]byte, error)

type U64

type U64 struct {
	Value uint64
}

func (*U64) Serialize

func (u *U64) Serialize() ([]byte, error)

type U128

type U128 struct {
	Value *big.Int
}

func (*U128) Serialize

func (u *U128) Serialize() ([]byte, error)

Jump to

Keyboard shortcuts

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