types

package
v0.0.0-...-61460eb Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: MIT, MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CompressionNone = CompressionType(iota)
	CompressionZlib
)
View Source
const JSONTimeFormat = "2006-01-02T15:04:05"

Variables

View Source
var EOSSymbol = Symbol{Precision: 4, Symbol: "EOS"}

EOSSymbol represents the standard EOS symbol on the chain. It's here just to speed up things.

View Source
var REXSymbol = Symbol{Precision: 4, Symbol: "REX"}

REXSymbol represents the standard REX symbol on the chain. It's here just to speed up things.

View Source
var TNTSymbol = Symbol{Precision: 4, Symbol: "TNT"}

TNTSymbol represents the standard EOSIO Testnet symbol on the testnet chain. Temporary Network Token (TNT) is the native token of the EOSIO Testnet. It's here just to speed up things.

View Source
var TypeSize = struct {
	Bool int
	Byte int

	Int8  int
	Int16 int

	Uint8   int
	Uint16  int
	Uint32  int
	Uint64  int
	Uint128 int

	Float32 int
	Float64 int

	Checksum160 int
	Checksum256 int
	Checksum512 int

	PublicKey int
	Signature int

	Tstamp         int
	BlockTimestamp int

	CurrencyName int
}{
	Byte: 1,
	Bool: 1,

	Int8:  1,
	Int16: 2,

	Uint8:   1,
	Uint16:  2,
	Uint32:  4,
	Uint64:  8,
	Uint128: 16,

	Float32: 4,
	Float64: 8,

	Checksum160: 20,
	Checksum256: 32,
	Checksum512: 64,

	PublicKey: 34,
	Signature: 66,

	Tstamp:         8,
	BlockTimestamp: 4,

	CurrencyName: 7,
}
View Source
var WAXSymbol = Symbol{Precision: 8, Symbol: "WAX"}

WAXSymbol represents the standard WAX symbol on the chain.

Functions

func MarshalBinary

func MarshalBinary(v interface{}) ([]byte, error)

func StringToName

func StringToName(s string) (val uint64, err error)

Types

type AccountName

type AccountName Name

func AN

func AN(in string) AccountName

type Action

type Action struct {
	Account       AccountName       `json:"account"`
	Name          ActionName        `json:"name"`
	Authorization []PermissionLevel `json:"authorization,omitempty"`
	ActionData
}

func NewBuyRAM

func NewBuyRAM(payer, receiver string, quantity Asset) *Action

func NewBuyRAMBytes

func NewBuyRAMBytes(payer, receiver string, bytes uint32) *Action

NewBuyRAMBytes will buy at current market price a given number of bytes of RAM, and grant them to the `receiver` account.

func NewClaim

func NewClaim(account, owner string, assertId string) *Action

NewClaim creates a new Claim action object. ex. https://wax.bloks.io/transaction/ca77897065604decd0ff16f62624bcea6706abdd688fd1c7743c0630e8db8dda?tab=raw account example: "farmersworld"

func NewContractTransfer

func NewContractTransfer(name, from, to string, quantity Asset, memo string) *Action

NewContractTransfer creates a new ContractTransfer action object.

func NewDelegateBW

func NewDelegateBW(from, receiver string, stakeCPU, stakeNet Asset, transfer bool) *Action

NewDelegateBW returns a `delegatebw` action that lives on the `eosio.system` contract.

func NewMine

func NewMine(account, miner string, nonce string) *Action

NewMine creates a new Mine action object. account example: "m.federation"

func NewNewAccount

func NewNewAccount(creator, newAccount string, publicKey ecc.PublicKey) *Action

NewNewAccount returns a `newaccount` action that lives on the `eosio.system` contract.

func NewSellRAM

func NewSellRAM(account string, bytes uint64) *Action

NewSellRAM will sell at current market price a given number of bytes of RAM.

func NewTokenTransfer

func NewTokenTransfer(contract, from, to string, quantity Asset, memo string) *Action

func NewTokenTransferAction

func NewTokenTransferAction(contract, from, to, amount, memo, token string, precision uint8) *Action

func NewTransfer

func NewTransfer(from, to string, quantity Asset, memo string) *Action

NewTransfer creates a new Transfer action object.

func NewUndelegateBW

func NewUndelegateBW(from, receiver string, unstakeCPU, unstakeNet Asset) *Action

NewUndelegateBW returns a `undelegatebw` action that lives on the `eosio.system` contract.

type ActionData

type ActionData struct {
	HexData []byte      `json:"hex_data,omitempty"`
	Data    interface{} `json:"data,omitempty" eos:"-"`
	// contains filtered or unexported fields
}

func NewActionData

func NewActionData(obj interface{}) ActionData

type ActionName

type ActionName Name

func ActN

func ActN(in string) ActionName

type Asset

type Asset struct {
	Amount int64
	Symbol
}

func NewAssetFromString

func NewAssetFromString(input string, symbol Symbol) (Asset, error)

func NewEOSAsset

func NewEOSAsset(amount int64) Asset

func NewEOSAssetFromString

func NewEOSAssetFromString(input string) (Asset, error)

func NewFixedSymbolAssetFromString

func NewFixedSymbolAssetFromString(symbol Symbol, input string) (out Asset, err error)

func NewWAXAsset

func NewWAXAsset(amount int64) Asset

func (Asset) MarshalJSON

func (a Asset) MarshalJSON() (data []byte, err error)

func (Asset) String

func (a Asset) String() string

type Authority

type Authority struct {
	Threshold uint32                  `json:"threshold"`
	Keys      []KeyWeight             `json:"keys,omitempty"`
	Accounts  []PermissionLevelWeight `json:"accounts,omitempty"`
	Waits     []WaitWeight            `json:"waits,omitempty"`
}

type BuyRAM

type BuyRAM struct {
	Payer    AccountName `json:"payer"`
	Receiver AccountName `json:"receiver"`
	Quantity Asset       `json:"quant"` // specified in EOS
}

BuyRAM represents the `eosio.system::buyram` action.

type BuyRAMBytes

type BuyRAMBytes struct {
	Payer    AccountName `json:"payer"`
	Receiver AccountName `json:"receiver"`
	Bytes    uint32      `json:"bytes"`
}

BuyRAMBytes represents the `eosio.system::buyrambytes` action.

type Checksum256

type Checksum256 []byte

func (Checksum256) MarshalJSON

func (t Checksum256) MarshalJSON() ([]byte, error)

func (Checksum256) String

func (t Checksum256) String() string

func (*Checksum256) UnmarshalJSON

func (t *Checksum256) UnmarshalJSON(data []byte) (err error)

type Claim

type Claim struct {
	Owner   AccountName `json:"owner"`
	AssetID string      `json:"asset_id"`
}

Claim represents the `farmersworld` action.

type CompressionType

type CompressionType uint8

func (CompressionType) String

func (c CompressionType) String() string

type ContractTransfer

type ContractTransfer struct {
	From     AccountName `json:"from"`
	To       AccountName `json:"to"`
	Quantity Asset       `json:"quantity"`
	Memo     string      `json:"memo"`
}

ContractTransfer represents the `transfer` struct on `eosio.token` contract.

type DelegateBW

type DelegateBW struct {
	From     AccountName `json:"from"`
	Receiver AccountName `json:"receiver"`
	StakeNet Asset       `json:"stake_net_quantity"`
	StakeCPU Asset       `json:"stake_cpu_quantity"`
	Transfer bool        `json:"transfer"`
}

DelegateBW represents the `eosio.system::delegatebw` action.

type Encoder

type Encoder struct {
	Order binary.ByteOrder
	// contains filtered or unexported fields
}

func NewEncoder

func NewEncoder(w io.Writer) *Encoder

func (*Encoder) Encode

func (e *Encoder) Encode(v interface{}) (err error)

type Extension

type Extension struct {
	Type uint16
	Data []byte
}

type HexBytes

type HexBytes []byte

HexBytes is alias of []byte

func (HexBytes) MarshalJSON

func (t HexBytes) MarshalJSON() ([]byte, error)

func (HexBytes) String

func (t HexBytes) String() string

func (*HexBytes) UnmarshalJSON

func (t *HexBytes) UnmarshalJSON(data []byte) (err error)

type JSONTime

type JSONTime struct {
	time.Time
}

func ParseJSONTime

func ParseJSONTime(date string) (JSONTime, error)

ParseJSONTime will parse a string into a JSONTime object

func (JSONTime) MarshalJSON

func (t JSONTime) MarshalJSON() ([]byte, error)

func (*JSONTime) UnmarshalJSON

func (t *JSONTime) UnmarshalJSON(data []byte) (err error)

type KeyWeight

type KeyWeight struct {
	PublicKey ecc.PublicKey `json:"key"`
	Weight    uint16        `json:"weight"` // weight_type
}

type MarshalerBinary

type MarshalerBinary interface {
	MarshalBinary(encoder *Encoder) error
}

type Mine

type Mine struct {
	Miner AccountName `json:"miner"`
	Nonce string      `json:"nonce"`
}

type Name

type Name string

type NewAccount

type NewAccount struct {
	Creator AccountName `json:"creator"`
	Name    AccountName `json:"name"`
	Owner   Authority   `json:"owner"`
	Active  Authority   `json:"active"`
}

NewAccount represents a `newaccount` action on the `eosio.system` contract. It is one of the rare ones to be hard-coded into the blockchain.

type PackedTransaction

type PackedTransaction struct {
	Signatures            []ecc.Signature `json:"signatures"`
	Compression           CompressionType `json:"compression"` // in C++, it's an enum, not sure how it Binary-marshals..
	PackedContextFreeData HexBytes        `json:"packed_context_free_data"`
	PackedTransaction     HexBytes        `json:"packed_trx"`
}

PackedTransaction represents a fully packed transaction, with signatures, and all. They circulate like that on the P2P net, and that's how they are stored.

func (*PackedTransaction) ID

func (p *PackedTransaction) ID() (Checksum256, error)

type PermissionLevel

type PermissionLevel struct {
	Actor      AccountName    `json:"actor"`
	Permission PermissionName `json:"permission"`
}

type PermissionLevelWeight

type PermissionLevelWeight struct {
	Permission PermissionLevel `json:"permission"`
	Weight     uint16          `json:"weight"` // weight_type
}

type PermissionName

type PermissionName Name

func PN

func PN(in string) PermissionName

type ScopeName

type ScopeName Name

type SellRAM

type SellRAM struct {
	Account AccountName `json:"account"`
	Bytes   uint64      `json:"bytes"`
}

SellRAM represents the `eosio.system::sellram` action.

type SetCode

type SetCode struct {
	Account   AccountName `json:"account"`
	VMType    byte        `json:"vmtype"`
	VMVersion byte        `json:"vmversion"`
	Code      HexBytes    `json:"code"`
}

SetCode represents the hard-coded `setcode` action.

type SignedTransaction

type SignedTransaction struct {
	*Transaction

	Signatures      []ecc.Signature `json:"signatures"`
	ContextFreeData [][]byte        `json:"context_free_data"`
	// contains filtered or unexported fields
}

func NewSignedTransaction

func NewSignedTransaction(tx *Transaction) *SignedTransaction

func (*SignedTransaction) Pack

func (s *SignedTransaction) Pack(compression CompressionType) (*PackedTransaction, error)

func (*SignedTransaction) PackedTransactionAndCFD

func (s *SignedTransaction) PackedTransactionAndCFD() ([]byte, []byte, error)

func (*SignedTransaction) String

func (s *SignedTransaction) String() string

type Symbol

type Symbol struct {
	Precision uint8
	Symbol    string
	// contains filtered or unexported fields
}

Symbol NOTE: there's also a new ExtendedSymbol (which includes the contract (as AccountName) on which it is)

func (Symbol) MarshalJSON

func (s Symbol) MarshalJSON() ([]byte, error)

func (Symbol) MustSymbolCode

func (s Symbol) MustSymbolCode() (SymbolCode, error)

func (Symbol) String

func (s Symbol) String() string

func (Symbol) SymbolCode

func (s Symbol) SymbolCode() (SymbolCode, error)

func (Symbol) ToUint64

func (s Symbol) ToUint64() (uint64, error)

type SymbolCode

type SymbolCode uint64

func StringToSymbolCode

func StringToSymbolCode(str string) (SymbolCode, error)

func (SymbolCode) MarshalJSON

func (sc SymbolCode) MarshalJSON() (data []byte, err error)

func (SymbolCode) String

func (sc SymbolCode) String() string

type TableName

type TableName Name

type Transaction

type Transaction struct {
	TransactionHeader

	ContextFreeActions []*Action    `json:"context_free_actions"`
	Actions            []*Action    `json:"actions"`
	Extensions         []*Extension `json:"transaction_extensions"`
}

func (*Transaction) Fill

func (tx *Transaction) Fill(headBlockID Checksum256, delaySecs, maxNetUsageWords uint32,
	maxCPUUsageMS uint8, expiration time.Duration)

func (*Transaction) SetExpiration

func (tx *Transaction) SetExpiration(in time.Duration)

SetExpiration sets the expiration of the transaction.

type TransactionHeader

type TransactionHeader struct {
	Expiration     JSONTime `json:"expiration"`
	RefBlockNum    uint16   `json:"ref_block_num"`
	RefBlockPrefix uint32   `json:"ref_block_prefix"`

	MaxNetUsageWords Varuint32 `json:"max_net_usage_words"`
	MaxCPUUsageMS    uint8     `json:"max_cpu_usage_ms"`
	DelaySec         Varuint32 `json:"delay_sec"` // number of secs to delay, making it cancellable for that duration
}

TransactionHeader Tx is an EOS transaction.

type Transfer

type Transfer struct {
	From     AccountName `json:"from"`
	To       AccountName `json:"to"`
	Quantity Asset       `json:"quantity"`
	Memo     string      `json:"memo"`
}

Transfer represents the `transfer` struct on `eosio.token` contract.

type TxOptions

type TxOptions struct {
	ChainID          Checksum256 // If specified, we won't hit the API to fetch it
	HeadBlockID      Checksum256 // If provided, don't hit API to fetch it.  This allows offline transaction signing.
	MaxNetUsageWords uint32
	DelaySecs        uint32
	MaxCPUUsageMS    uint8 // If you want to override the CPU usage (in counts of 1024)
	//ExtraKCPUUsage uint32 // If you want to *add* some CPU usage to the estimated amount (in counts of 1024)
	Compress   CompressionType
	Expiration time.Duration
}

TxOptions represents options you want to pass to the transaction you're sending.

type UndelegateBW

type UndelegateBW struct {
	From       AccountName `json:"from"`
	Receiver   AccountName `json:"receiver"`
	UnstakeNet Asset       `json:"unstake_net_quantity"`
	UnstakeCPU Asset       `json:"unstake_cpu_quantity"`
}

UndelegateBW represents the `eosio.system::undelegatebw` action.

type Varuint32

type Varuint32 uint32

type WaitWeight

type WaitWeight struct {
	WaitSec uint32 `json:"wait_sec"`
	Weight  uint16 `json:"weight"` // weight_type
}

Jump to

Keyboard shortcuts

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