types

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2021 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ExtrinsicVersion4 = types.ExtrinsicVersion4
)

Variables

View Source
var (
	NewBool = types.NewBool

	NewU8   = types.NewU8
	NewU16  = types.NewU16
	NewU32  = types.NewU32
	NewU64  = types.NewU64
	NewU128 = types.NewU128

	NewI8   = types.NewI8
	NewI16  = types.NewI16
	NewI32  = types.NewI32
	NewI64  = types.NewI64
	NewI128 = types.NewI128
)
View Source
var (
	// NewHash creates a new Hash type
	NewHash = types.NewHash
	// NewHashFromHexString creates a new Hash type from a hex string
	NewHashFromHexString = types.NewHashFromHexString
)
View Source
var (
	// NewAddressFromHexAccountID creates an Address from the given hex string that contains an AccountID (public key)
	NewAddressFromHexAccountID = types.NewAddressFromHexAccountID

	// NewAddressFromAccountID creates an Address from the given AccountID (public key)
	NewAddressFromAccountID = types.NewAddressFromAccountID
)
View Source
var (
	// CreateStorageKey uses the given metadata and to derive the right hashing of method, prefix as well as arguments to
	// create a hashed StorageKey
	CreateStorageKey = types.CreateStorageKey

	// HexDecodeString decodes bytes from a hex string. Contrary to hex.DecodeString, this function does not error if "0x"
	// is prefixed, and adds an extra 0 if the hex string has an odd length.
	HexDecodeString = types.HexDecodeString

	// MustHexDecodeString panics if str cannot be decoded
	MustHexDecodeString = types.MustHexDecodeString

	// HexEncodeToString HexEncode encodes bytes to a hex string.
	// Contrary to hex.EncodeToString, this function prefixes the hex string with "0x"
	HexEncodeToString = types.HexEncodeToString
)
View Source
var (
	NewExtrinsic = types.NewExtrinsic
	NewCall      = types.NewCall
)
View Source
var (
	EncodeToBytes = types.EncodeToBytes
)
View Source
var (
	// NewAccountID creates a new AccountID type
	NewAccountID = types.NewAccountID
)
View Source
var (
	// NewUCompactFromUInt create a compact big int from uint64
	NewUCompactFromUInt = types.NewUCompactFromUInt
)

Functions

func EncodeAccountIDToSS58

func EncodeAccountIDToSS58(account AccountID) (string, error)

EncodeAccountIDToSS58 encode accountID to ss58 format

func GetDefaultSS58Prefix added in v0.2.0

func GetDefaultSS58Prefix() []byte

GetDefaultSS58Prefix get default ss58 prefix

func NewCompactBalance

func NewCompactBalance(amount uint64) types.UCompact

NewCompactBalance create a new CompactBalance

func NewCompactBalanceByInt

func NewCompactBalanceByInt(amount *big.Int) types.UCompact

NewCompactBalanceByInt create a new CompactBalance

func NewCompactGas

func NewCompactGas(gas Gas) types.UCompact

NewCompactGas creates a new compact of gas

func SetDefaultSS58Prefix added in v0.2.0

func SetDefaultSS58Prefix(p []byte)

SetDefaultSS58Prefix set default ss58 prefix

Types

type AccountID

type AccountID = types.AccountID

AccountID represents a public key (an 32 byte array)

func DecodeAccountIDFromSS58

func DecodeAccountIDFromSS58(address string) (AccountID, error)

DecodeAccountIDFromSS58 encode address SS58 to AccountID

type AccountInfo

type AccountInfo = types.AccountInfo

type Address

type Address = types.Address

Address is a wrapper around an AccountId or an AccountIndex. It is encoded with a prefix in case of an AccountID. Basically the Address is encoded as `[ <prefix-byte>, ...publicKey/...bytes ]` as per spec

func MustAddressFromHexAccount

func MustAddressFromHexAccount(str string) Address

MustAddressFromHexAccount address from hex account, panic if invalid

type Balance

type Balance = U128

Balance balance type to chain, which is BalanceIf<T>

type Bytes added in v0.2.0

type Bytes = types.Bytes

Bytes represents byte slices. Bytes has a variable length, it is encoded with a scale prefix

type ChainStatus

type ChainStatus struct {
	SpecVersion        uint32 `json:"spec_version"`
	TransactionVersion uint32 `json:"tx_version"`
	BlockHash          string `json:"block_hash"`
	GenesisHash        string `json:"genesis_hash"`
}

type CodeHash

type CodeHash = Hash

CodeHash the code hash if code

type CompactBalance

type CompactBalance = types.UCompact

CompactBalance Compact<Balance> type

type CompactGas

type CompactGas = types.UCompact

CompactGas Compact<Gas> type

type Extrinsic

type Extrinsic = types.Extrinsic

type ExtrinsicEra

type ExtrinsicEra = types.ExtrinsicEra

type Gas

type Gas uint64

Gas is essentially the same as weight. It is a 1 to 1 correspondence.

type Hash

type Hash = types.Hash

Hash is the default hash that is used across the system. It is just a thin wrapper around H256

type Metadata

type Metadata = types.Metadata

type Option

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

func (Option) IsNone

func (o Option) IsNone() bool

IsNone returns true if the value is missing

func (Option) IsSome

func (o Option) IsSome() bool

IsNone returns true if a value is present

func (*Option) SetHasValue

func (o *Option) SetHasValue(h bool)

type OptionAccountID

type OptionAccountID struct {
	Option
	Value AccountID `scale:"Some"`
}

OptionAccountID is a structure that can store a AccountID or a missing value

func NewOptionAccountID

func NewOptionAccountID(value AccountID) OptionAccountID

NewOptionAccountID creates an OptionAccountID with a value

func NewOptionAccountIDEmpty

func NewOptionAccountIDEmpty() OptionAccountID

NewOptionAccountIDEmpty creates an OptionAccountID without a value

func (*OptionAccountID) Decode

func (o *OptionAccountID) Decode(decoder scale.Decoder) error

func (OptionAccountID) Encode

func (o OptionAccountID) Encode(encoder scale.Encoder) error

func (*OptionAccountID) SetNone

func (o *OptionAccountID) SetNone()

SetNone removes a value and marks it as missing

func (*OptionAccountID) SetSome

func (o *OptionAccountID) SetSome(value AccountID)

SetSome sets a value

func (OptionAccountID) String

func (o OptionAccountID) String() string

func (OptionAccountID) Unwrap

func (o OptionAccountID) Unwrap() (ok bool, value AccountID)

Unwrap returns a flag that indicates whether a value is present and the stored value

type OptionValue

type OptionValue struct {
	Option
	// contains filtered or unexported fields
}

OptionValue is a structure that can store a Value or a missing value

func NewOptionValue

func NewOptionValue(value interface{}) OptionValue

NewOptionValue creates an OptionValue with a value

func NewOptionValueEmpty

func NewOptionValueEmpty() OptionValue

NewOptionValueEmpty creates an OptionValue without a value

func (*OptionValue) Decode

func (o *OptionValue) Decode(decoder scale.Decoder) error

func (OptionValue) Encode

func (o OptionValue) Encode(encoder scale.Encoder) error

func (*OptionValue) SetNone

func (o *OptionValue) SetNone()

SetNone removes a value and marks it as missing

func (*OptionValue) SetSome

func (o *OptionValue) SetSome(value interface{})

SetSome sets a value

func (OptionValue) Unwrap

func (o OptionValue) Unwrap() (ok bool, value interface{})

Unwrap returns a flag that indicates whether a value is present and the stored value

type SS58Codec added in v0.2.0

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

func GetDefaultSS58Codec added in v0.2.0

func GetDefaultSS58Codec() *SS58Codec

GetDefaultSS58Codec get default ss58 codec

func NewSS58Codec added in v0.2.0

func NewSS58Codec(prefix []byte) *SS58Codec

func (SS58Codec) DecodeAccountID added in v0.2.0

func (c SS58Codec) DecodeAccountID(address string) (AccountID, error)

DecodeAccountID decode address SS58 to AccountID

func (SS58Codec) EncodeAccountID added in v0.2.0

func (c SS58Codec) EncodeAccountID(id AccountID) (string, error)

func (SS58Codec) GetPrefix added in v0.2.0

func (c SS58Codec) GetPrefix() []byte

GetPrefix get ss58 prefix

type Schedule

type Schedule struct {
	// Version of the schedule.
	Version uint32 `scale:"version"`

	// PutCodePerByteCost Cost of putting a byte of code into storage.
	PutCodePerByteCost Gas `scale:"put_code_per_byte_cost"`

	// GrowMemCost Gas cost of a growing memory by single page.
	GrowMemCost Gas `scale:"grow_mem_cost"`

	// RegularOpCost Gas cost of a regular operation.
	RegularOpCost Gas `scale:"regular_op_cost"`

	// ReturnDataPerByteCost Gas cost per one byte returned.
	ReturnDataPerByteCost Gas `scale:"return_data_per_byte_cost"`

	// EventDataPerByteCost Gas cost to deposit an event; the per-byte portion.
	EventDataPerByteCost Gas `scale:"event_data_per_byte_cost"`

	// EventPerTopicCost Gas cost to deposit an event; the cost per topic.
	EventPerTopicCost Gas `scale:"event_per_topic_cost"`

	// EventBaseCost Gas cost to deposit an event; the base.
	EventBaseCost Gas `scale:"event_base_cost"`

	// CallBaseCost Base gas cost to call into a contract.
	CallBaseCost Gas `scale:"call_base_cost"`

	// InstantiateBaseCost Base gas cost to instantiate a contract.
	InstantiateBaseCost Gas `scale:"instantiate_base_cost"`

	// DispatchBaseCost Base gas cost to dispatch a runtime call.
	DispatchBaseCost Gas `scale:"dispatch_base_cost"`

	// SandboxDataReadCost Gas cost per one byte read from the sandbox memory.
	SandboxDataReadCost Gas `scale:"sandbox_data_read_cost"`

	// SandboxDataWriteCost Gas cost per one byte written to the sandbox memory.
	SandboxDataWriteCost Gas `scale:"sandbox_data_write_cost"`

	// TransferCost Cost for a simple balance transfer.
	TransferCost Gas `scale:"transfer_cost"`

	// InstantiateCost Cost for instantiating a new contract.
	InstantiateCost Gas `scale:"instantiate_cost"`

	// MaxEventTopics The maximum number of topics supported by an event.
	MaxEventTopics uint32 `scale:"max_event_topics"`

	// MaxStackHeight Maximum allowed stack height.
	//
	// See https://wiki.parity.io/WebAssembly-StackHeight to find out
	// how the stack frame cost is calculated.
	MaxStackHeight uint32 `scale:"max_stack_height"`

	// MaxMemoryPages Maximum number of memory pages allowed for a contract.
	MaxMemoryPages uint32 `scale:"max_memory_pages"`

	// MaxTableSize Maximum allowed size of a declared table.
	MaxTableSize uint32 `scale:"max_table_size"`

	// EnablePrintln Whether the `seal_println` function is allowed to be used contracts.
	// MUST only be enabled for `dev` chains, NOT for production chains
	EnablePrintln bool `scale:"enable_println"`

	// MaxSubjectLen The maximum length of a subject used for PRNG generation.
	MaxSubjectLen uint32 `scale:"max_subject_len"`

	// MaxCodeSize The maximum length of a contract code in bytes. This limit applies to the uninstrumented
	// and pristine form of the code as supplied to `put_code`.
	MaxCodeSize uint32 `scale:"max_code_size"`
}

Schedule Definition of the cost schedule and other parameterizations for wasm vm.

type SignatureOptions

type SignatureOptions = types.SignatureOptions

type U128

type U128 = types.U128

U128 is an unsigned 128-bit integer, it is represented as a big.Int in Go.

func NewBalanceByU64

func NewBalanceByU64(amount uint64) U128

NewBalanceByU64 new balance from uint64

type U32

type U32 = types.U32

type U64

type U64 = types.U64

type UCompact

type UCompact = types.UCompact

UCompact for big int

Jump to

Keyboard shortcuts

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