types

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2021 License: Apache-2.0 Imports: 13 Imported by: 51

Documentation

Overview

TODO: Move this package to the Go client-sdk.

Index

Constants

View Source
const LatestTransactionVersion = 1

LatestTransactionVersion is the latest transaction format version.

View Source
const MaxDenominationSize = 32

MaxDenominationSize is the maximum length of a denomination.

Variables

View Source
var (
	// AddressV0Ed25519Context is the unique context for v0 Ed25519-based addresses.
	// It is shared with the consensus layer addresses on purpose.
	AddressV0Ed25519Context = staking.AddressV0Context
	// AddressV0Secp256k1Context is the unique context for v0 Ed25519-based addresses.
	AddressV0Secp256k1Context = address.NewContext("oasis-runtime-sdk/address: secp256k1", 0)
	// AddressV0MultisigContext is the unique context for v0 multisig addresses.
	AddressV0MultisigContext = address.NewContext("oasis-runtime-sdk/address: multisig", 0)
	// AddressBech32HRP is the unique human readable part of Bech32 encoded
	// staking account addresses.
	AddressBech32HRP = staking.AddressBech32HRP
)
View Source
var NativeDenomination = Denomination([]byte{})

NativeDenomination is the denomination in native token.

View Source
var SignatureContextBase = []byte("oasis-runtime-sdk/tx: v0")

SignatureContextBase is the transaction signature domain separation context base.

Functions

This section is empty.

Types

type Address

type Address address.Address

Address is the account address.

func NewAddress

func NewAddress(pk signature.PublicKey) (a Address)

NewAddress creates a new address from the given public key.

func NewAddressFromBech32

func NewAddressFromBech32(data string) (a Address)

NewAddressFromBech32 creates a new address from the given bech-32 encoded string.

Panics in case of errors -- use UnmarshalText if you want to handle errors.

func NewAddressFromMultisig

func NewAddressFromMultisig(config *MultisigConfig) Address

NewAddressFromMultisig creates a new address from the given multisig configuration.

func (Address) Equal

func (a Address) Equal(cmp Address) bool

Equal compares vs another address for equality.

func (Address) MarshalBinary

func (a Address) MarshalBinary() ([]byte, error)

MarshalBinary encodes an address into binary form.

func (Address) MarshalText

func (a Address) MarshalText() ([]byte, error)

MarshalText encodes an address into text form.

func (Address) String

func (a Address) String() string

String returns the string representation of an address.

func (*Address) UnmarshalBinary

func (a *Address) UnmarshalBinary(data []byte) error

UnmarshalBinary decodes a binary marshaled address.

func (*Address) UnmarshalText

func (a *Address) UnmarshalText(text []byte) error

UnmarshalText decodes a text marshaled address.

type AddressSpec

type AddressSpec struct {
	// Signature is for signature authentication.
	Signature *PublicKey `json:"signature,omitempty"`
	// Multisig is for multisig authentication.
	Multisig *MultisigConfig `json:"multisig,omitempty"`
}

AddressSpec is common information that specifies an address as well as how to authenticate.

func (*AddressSpec) Address

func (as *AddressSpec) Address() (Address, error)

Address derives the address.

func (*AddressSpec) Batch

func (as *AddressSpec) Batch(ap AuthProof) ([]PublicKey, [][]byte, error)

Batch checks that the address specification and the authentication proof are acceptable. Returns vectors of public keys and signatures for batch verification of included signatures.

type AuthInfo

type AuthInfo struct {
	SignerInfo []SignerInfo `json:"si"`
	Fee        Fee          `json:"fee"`
}

AuthInfo contains transaction authentication information.

type AuthProof

type AuthProof struct {
	// Signature is for signature authentication.
	Signature []byte `json:"signature,omitempty"`
	// Multisig is for multisig authentication.
	Multisig [][]byte `json:"multisig,omitempty"`
}

AuthProof is a container for data that authenticates a transaction.

type BaseUnits

type BaseUnits struct {
	Amount       quantity.Quantity
	Denomination Denomination
	// contains filtered or unexported fields
}

BaseUnits is the token amount of given denomination in base units.

func NewBaseUnits

func NewBaseUnits(amount quantity.Quantity, denomination Denomination) BaseUnits

NewBaseUnits creates a new token amount of given denomination.

func (BaseUnits) String

func (bu BaseUnits) String() string

String returns a string representation of this token amount.

type Call

type Call struct {
	Method string          `json:"method"`
	Body   cbor.RawMessage `json:"body"`
}

Call is a method call.

type CallResult

type CallResult struct {
	Ok     cbor.RawMessage   `json:"ok,omitempty"`
	Failed *FailedCallResult `json:"fail,omitempty"`
}

CallResult is the method call result.

func (*CallResult) IsSuccess

func (cr *CallResult) IsSuccess() bool

IsSuccess checks whether the call result indicates success.

type Denomination

type Denomination string

Denomination is the name/type of the token.

func (Denomination) IsNative

func (d Denomination) IsNative() bool

IsNative checks whether the denomination represents the native token.

func (Denomination) MarshalBinary

func (d Denomination) MarshalBinary() ([]byte, error)

MarshalBinary encodes a denomination into binary form.

func (Denomination) String

func (d Denomination) String() string

String returns a string representation of this denomination.

func (*Denomination) UnmarshalBinary

func (d *Denomination) UnmarshalBinary(data []byte) error

UnmarshalBinary decodes a binary marshaled denomination.

type FailedCallResult

type FailedCallResult struct {
	Module  string `json:"module"`
	Code    uint32 `json:"code"`
	Message string `json:"message,omitempty"`
}

FailedCallResult is a failed call result.

func (FailedCallResult) Error

func (cr FailedCallResult) Error() string

Error is a trivial implementation of error.

func (FailedCallResult) String

func (cr FailedCallResult) String() string

String returns the string representation of a failed call result.

type Fee

type Fee struct {
	Amount BaseUnits `json:"amount"`
	Gas    uint64    `json:"gas"`
}

Fee contains the transaction fee information.

type MultisigConfig

type MultisigConfig struct {
	Signers   []MultisigSigner `json:"signers"`
	Threshold uint64           `json:"threshold"`
}

MultisigConfig is a multisig configuration. A set of signers with total "weight" greater than or equal to a "threshold" can authenticate for the configuration.

func (*MultisigConfig) Batch

func (mc *MultisigConfig) Batch(signatureSet [][]byte) ([]PublicKey, [][]byte, error)

Batch checks that enough signers have signed and returns vectors of public keys and signatures for batch verification of those signatures. This internally calls `ValidateBasic`.

func (*MultisigConfig) ValidateBasic

func (mc *MultisigConfig) ValidateBasic() error

ValidateBasic performs some sanity checks. This looks at the configuration only. There is no cryptographic verification of any signatures.

type MultisigSigner

type MultisigSigner struct {
	PublicKey PublicKey `json:"public_key"`
	Weight    uint64    `json:"weight"`
}

MultisigSigner is one of the signers in a multisig configuration.

type PublicKey

type PublicKey struct {
	signature.PublicKey
}

PublicKey is a serializable public key.

func (*PublicKey) MarshalCBOR

func (pk *PublicKey) MarshalCBOR() ([]byte, error)

MarshalCBOR encodes the public key as CBOR.

func (*PublicKey) MarshalJSON

func (pk *PublicKey) MarshalJSON() ([]byte, error)

MarshalJSON encodes the public key as JSON.

func (*PublicKey) UnmarshalCBOR

func (pk *PublicKey) UnmarshalCBOR(data []byte) error

UnmarshalCBOR decodes the public key from CBOR.

func (*PublicKey) UnmarshalJSON

func (pk *PublicKey) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes the public key from JSON.

type Quantity

type Quantity = quantity.Quantity

Quantity is a arbitrary precision unsigned integer that never underflows.

type RuntimeInfo

type RuntimeInfo struct {
	// ID is the runtime identifier.
	ID common.Namespace
	// ChainContext is the chain domain separation context used by the runtime.
	ChainContext signature.Context
}

RuntimeInfo is information about a runtime.

type SignerInfo

type SignerInfo struct {
	AddressSpec AddressSpec `json:"address_spec"`
	Nonce       uint64      `json:"nonce"`
}

SignerInfo contains transaction signer information.

type Transaction

type Transaction struct {
	cbor.Versioned

	Call     Call     `json:"call"`
	AuthInfo AuthInfo `json:"ai"`
}

Transaction is a runtime transaction.

func NewTransaction

func NewTransaction(fee *Fee, method string, body interface{}) *Transaction

NewTransaction creates a new unsigned transaction.

func (*Transaction) AppendAuthMultisig

func (t *Transaction) AppendAuthMultisig(config *MultisigConfig, nonce uint64)

AppendAuthMultisig appends a new transaction signer information with a multisig address specification to the transaction.

func (*Transaction) AppendAuthSignature

func (t *Transaction) AppendAuthSignature(pk signature.PublicKey, nonce uint64)

AppendAuthSignature appends a new transaction signer information with a signature address specification to the transaction.

func (*Transaction) AppendSignerInfo

func (t *Transaction) AppendSignerInfo(addressSpec AddressSpec, nonce uint64)

AppendSignerInfo appends a new transaction signer information to the transaction.

func (*Transaction) PrepareForSigning

func (t *Transaction) PrepareForSigning() *TransactionSigner

func (*Transaction) ValidateBasic

func (t *Transaction) ValidateBasic() error

ValidateBasic performs basic validation on the transaction.

type TransactionSigner

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

func (*TransactionSigner) AppendSign

func (ts *TransactionSigner) AppendSign(ctx signature.Context, signer signature.Signer) error

AppendSign signs the transaction and appends the signature.

The signer must be specified in the AuthInfo.

func (*TransactionSigner) UnverifiedTransaction

func (ts *TransactionSigner) UnverifiedTransaction() *UnverifiedTransaction

UnverifiedTransaction returns the (signed) unverified transaction.

type UnverifiedTransaction

type UnverifiedTransaction struct {
	Body       []byte
	AuthProofs []AuthProof
	// contains filtered or unexported fields
}

UnverifiedTransaction is an unverified transaction.

func (*UnverifiedTransaction) Verify

Verify verifies and deserializes the unverified transaction.

Jump to

Keyboard shortcuts

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