types

package
v0.0.0-...-bdfcca1 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2022 License: Apache-2.0 Imports: 10 Imported by: 4

README

types for contracto module on cosmos-sdk

Documentation

Index

Constants

View Source
const (
	DefaultInstructionExecutionBound = 200_000
	DefaultNumThreads                = 8
)

Variables

View Source
var NewDeserializer = bcs.NewDeserializer
View Source
var NewSerializer = bcs.NewSerializer

Functions

func DeserializeBytesVector

func DeserializeBytesVector(bz []byte) ([][]byte, error)

DeserializeBytesVector deserialize BCS bytes to bytes vector

func DeserializeUint64

func DeserializeUint64(bz []byte) (uint64, error)

DeserializeUint64 deserialize BCS bytes

func DeserializeUint64Vector

func DeserializeUint64Vector(bz []byte) ([]uint64, error)

DeserializeUint64Vector deserialize BCS bytes to bytes vector

func SerializeBytes

func SerializeBytes(bz []byte) ([]byte, error)

SerializeBytes serialize bytes to BCS bytes

func SerializeBytesVector

func SerializeBytesVector(bz [][]byte) ([]byte, error)

SerializeBytesVector serialize bytes vector to BCS bytes

func SerializeString

func SerializeString(str string) ([]byte, error)

SerializeString serialize string to BCS bytes

func SerializeUint64

func SerializeUint64(num uint64) ([]byte, error)

SerializeUint64 serialize num to BCS bytes

func SerializeUint64Vector

func SerializeUint64Vector(bz []uint64) ([]byte, error)

SerializeUint64Vector serialize bytes vector to BCS bytes

func StringifyTypeTag

func StringifyTypeTag(tt TypeTag) (string, error)

StringifyTypeTag implement .String() interface

func WithCheckStacklessVM

func WithCheckStacklessVM() func(*TestConfig)

func WithComputeCoverage

func WithComputeCoverage() func(*TestConfig)

func WithDevMode

func WithDevMode() func(*BuildConfig)

func WithFetchDepsOnly

func WithFetchDepsOnly() func(*BuildConfig)

func WithFilter

func WithFilter(filter string) func(*TestConfig)

func WithForceRecompiliation

func WithForceRecompiliation() func(*BuildConfig)

func WithGenerateABIs

func WithGenerateABIs() func(*BuildConfig)

func WithGenerateDocs

func WithGenerateDocs() func(*BuildConfig)

func WithIgnoreCompileWarnings

func WithIgnoreCompileWarnings() func(*TestConfig)

func WithInstallDir

func WithInstallDir(dir string) func(*BuildConfig)

func WithInstructionExecutionBound

func WithInstructionExecutionBound(bound uint64) func(*TestConfig)

func WithList

func WithList() func(*TestConfig)

func WithNumThreads

func WithNumThreads(n uint) func(*TestConfig)

func WithReportStatistics

func WithReportStatistics() func(*TestConfig)

func WithReportStorageOnError

func WithReportStorageOnError() func(*TestConfig)

func WithSkipFetchLatestGitDeps

func WithSkipFetchLatestGitDeps() func(*BuildConfig)

func WithTestMode

func WithTestMode() func(*BuildConfig)

func WithVerboseTestConfig

func WithVerboseTestConfig() func(*TestConfig)

Types

type AccountAddress

type AccountAddress [20]uint8
var StdAddress AccountAddress

func BcsDeserializeAccountAddress

func BcsDeserializeAccountAddress(input []byte) (AccountAddress, error)

func DeserializeAccountAddress

func DeserializeAccountAddress(deserializer serde.Deserializer) (AccountAddress, error)

func NewAccountAddress

func NewAccountAddress(hexAddr string) (AccountAddress, error)

NewAccountAddress return AccountAddress from the hex string

func NewAccountAddressFromBytes

func NewAccountAddressFromBytes(bz []byte) (AccountAddress, error)

NewAccountAddressFromBytes return AccountAddress from the bytes

func (*AccountAddress) BcsSerialize

func (obj *AccountAddress) BcsSerialize() ([]byte, error)

func (AccountAddress) Bytes

func (addr AccountAddress) Bytes() []byte

func (AccountAddress) Equals

func (a AccountAddress) Equals(b AccountAddress) bool

func (*AccountAddress) Serialize

func (obj *AccountAddress) Serialize(serializer serde.Serializer) error

func (AccountAddress) String

func (addr AccountAddress) String() string

type BuildConfig

type BuildConfig struct {
	// Compile in 'dev' mode. The 'dev-addresses' and 'dev-dependencies' fields will be used if
	// this flag is set. This flag is useful for development of packages that expose named
	// addresses that are not set to a specific value.
	DevMode bool

	// Compile in 'test' mode. The 'dev-addresses' and 'dev-dependencies' fields will be used
	// along with any code in the 'tests' directory.
	TestMode bool

	// Generate documentation for packages
	GenerateDocs bool

	// Generate ABIs for packages
	GenerateABIs bool

	// Installation directory for compiled artifacts. Defaults to current directory.
	InstallDir string

	// Force recompilation of all packages
	ForceRecompilation bool

	// Only fetch dependency repos to MOVE_HOME
	FetchDepsOnly bool

	// Skip fetching latest git dependencies
	SkipFetchLatestGitDeps bool
}

BuildConfig is a configuration set to compile move package

func DefaultBuildConfig

func DefaultBuildConfig() BuildConfig

DefaultBuildConfig returns with all-false set (except PackagePath which is set to current(.)) BuildConfig

func NewBuildConfig

func NewBuildConfig(options ...func(*BuildConfig)) BuildConfig

NewBuildConfig returns newly create BuildConfig. unset values stays default, not unset

type Coin

type Coin struct {
	Denom  string `json:"denom"`  // type, eg. "ATOM"
	Amount string `json:"amount"` // string encoing of decimal value, eg. "12.3456"
}

Coin is a string representation of the sdk.Coin type (more portable than sdk.Int)

func NewCoin

func NewCoin(amount uint64, denom string) Coin

type Coins

type Coins []Coin

Coins handles properly serializing empty amounts

func (Coins) MarshalJSON

func (c Coins) MarshalJSON() ([]byte, error)

MarshalJSON ensures that we get [] for empty arrays

func (*Coins) UnmarshalJSON

func (c *Coins) UnmarshalJSON(data []byte) error

UnmarshalJSON ensures that we get [] for empty arrays

type ContractEvent

type ContractEvent struct {
	Key            []byte
	SequenceNumber uint64
	TypeTag        TypeTag
	EventData      []byte
}

func BcsDeserializeContractEvent

func BcsDeserializeContractEvent(input []byte) (ContractEvent, error)

func DeserializeContractEvent

func DeserializeContractEvent(deserializer serde.Deserializer) (ContractEvent, error)

func (*ContractEvent) BcsSerialize

func (obj *ContractEvent) BcsSerialize() ([]byte, error)

func (*ContractEvent) Serialize

func (obj *ContractEvent) Serialize(serializer serde.Serializer) error

type EntryFunction

type EntryFunction struct {
	Module   ModuleId
	Function Identifier
	TyArgs   []TypeTag
	Args     [][]byte
}

func BcsDeserializeEntryFunction

func BcsDeserializeEntryFunction(input []byte) (EntryFunction, error)

func DeserializeEntryFunction

func DeserializeEntryFunction(deserializer serde.Deserializer) (EntryFunction, error)

func (*EntryFunction) BcsSerialize

func (obj *EntryFunction) BcsSerialize() ([]byte, error)

func (*EntryFunction) Serialize

func (obj *EntryFunction) Serialize(serializer serde.Serializer) error

type ExecutionResult

type ExecutionResult struct {
	Result        []uint8
	Events        []ContractEvent
	SizeDeltas    []SizeDelta
	StakingDeltas []StakingDelta
	GasUsed       uint64
}

func BcsDeserializeExecutionResult

func BcsDeserializeExecutionResult(input []byte) (ExecutionResult, error)

func DeserializeExecutionResult

func DeserializeExecutionResult(deserializer serde.Deserializer) (ExecutionResult, error)

func (*ExecutionResult) BcsSerialize

func (obj *ExecutionResult) BcsSerialize() ([]byte, error)

func (*ExecutionResult) Serialize

func (obj *ExecutionResult) Serialize(serializer serde.Serializer) error

type Identifier

type Identifier string

func BcsDeserializeIdentifier

func BcsDeserializeIdentifier(input []byte) (Identifier, error)

func DeserializeIdentifier

func DeserializeIdentifier(deserializer serde.Deserializer) (Identifier, error)

func (*Identifier) BcsSerialize

func (obj *Identifier) BcsSerialize() ([]byte, error)

func (*Identifier) Serialize

func (obj *Identifier) Serialize(serializer serde.Serializer) error

type InitiaCompilerArgument

type InitiaCompilerArgument struct {
	PackagePath string
	Verbose     bool
	BuildConfig BuildConfig
}

func NewInitiaCompilerArgument

func NewInitiaCompilerArgument(packagePath string, verbose bool, buildConfig BuildConfig) InitiaCompilerArgument

func NewInitiaCompilerArgumentWithBuildOption

func NewInitiaCompilerArgumentWithBuildOption(packagePath string, verbose bool, options ...func(*BuildConfig)) InitiaCompilerArgument

type InvalidRequest

type InvalidRequest struct {
	Err     string `json:"error"`
	Request []byte `json:"request"`
}

func (InvalidRequest) Error

func (e InvalidRequest) Error() string

type InvalidResponse

type InvalidResponse struct {
	Err      string `json:"error"`
	Response []byte `json:"response"`
}

func (InvalidResponse) Error

func (e InvalidResponse) Error() string

type Module

type Module struct {
	Code []uint8
}

func BcsDeserializeModule

func BcsDeserializeModule(input []byte) (Module, error)

func DeserializeModule

func DeserializeModule(deserializer serde.Deserializer) (Module, error)

func NewModule

func NewModule(code []byte) Module

NewModule return module instance

func (*Module) BcsSerialize

func (obj *Module) BcsSerialize() ([]byte, error)

func (*Module) Serialize

func (obj *Module) Serialize(serializer serde.Serializer) error

type ModuleBundle

type ModuleBundle struct {
	Codes []Module
}

func BcsDeserializeModuleBundle

func BcsDeserializeModuleBundle(input []byte) (ModuleBundle, error)

func DeserializeModuleBundle

func DeserializeModuleBundle(deserializer serde.Deserializer) (ModuleBundle, error)

func NewModuleBundle

func NewModuleBundle(modules ...Module) ModuleBundle

NewModuleBundle return module bundle

func (*ModuleBundle) BcsSerialize

func (obj *ModuleBundle) BcsSerialize() ([]byte, error)

func (*ModuleBundle) Serialize

func (obj *ModuleBundle) Serialize(serializer serde.Serializer) error

type ModuleId

type ModuleId struct {
	Address AccountAddress
	Name    Identifier
}

func BcsDeserializeModuleId

func BcsDeserializeModuleId(input []byte) (ModuleId, error)

func DeserializeModuleId

func DeserializeModuleId(deserializer serde.Deserializer) (ModuleId, error)

func (*ModuleId) BcsSerialize

func (obj *ModuleId) BcsSerialize() ([]byte, error)

func (*ModuleId) Serialize

func (obj *ModuleId) Serialize(serializer serde.Serializer) error

type NoSuchContract

type NoSuchContract struct {
	Addr string `json:"addr,omitempty"`
}

func (NoSuchContract) Error

func (e NoSuchContract) Error() string

type OutOfGasError

type OutOfGasError struct{}

func (OutOfGasError) Error

func (o OutOfGasError) Error() string

type ResourceKey

type ResourceKey struct {
	Address AccountAddress
	Type    StructTag
}

func BcsDeserializeResourceKey

func BcsDeserializeResourceKey(input []byte) (ResourceKey, error)

func DeserializeResourceKey

func DeserializeResourceKey(deserializer serde.Deserializer) (ResourceKey, error)

func (*ResourceKey) BcsSerialize

func (obj *ResourceKey) BcsSerialize() ([]byte, error)

func (*ResourceKey) Serialize

func (obj *ResourceKey) Serialize(serializer serde.Serializer) error

type Script

type Script struct {
	Code   []byte
	TyArgs []TypeTag
	Args   [][]byte
}

func BcsDeserializeScript

func BcsDeserializeScript(input []byte) (Script, error)

func DeserializeScript

func DeserializeScript(deserializer serde.Deserializer) (Script, error)

func (*Script) BcsSerialize

func (obj *Script) BcsSerialize() ([]byte, error)

func (*Script) Serialize

func (obj *Script) Serialize(serializer serde.Serializer) error

type SizeDelta

type SizeDelta struct {
	Address      AccountAddress
	Amount       uint64
	IsDecreasing bool
}

func BcsDeserializeSizeDelta

func BcsDeserializeSizeDelta(input []byte) (SizeDelta, error)

func DeserializeSizeDelta

func DeserializeSizeDelta(deserializer serde.Deserializer) (SizeDelta, error)

func (*SizeDelta) BcsSerialize

func (obj *SizeDelta) BcsSerialize() ([]byte, error)

func (*SizeDelta) Serialize

func (obj *SizeDelta) Serialize(serializer serde.Serializer) error

type StakingDelta

type StakingDelta struct {
	Validator []uint8
	Amount    uint64
	Sign      bool
}

func BcsDeserializeStakingDelta

func BcsDeserializeStakingDelta(input []byte) (StakingDelta, error)

func DeserializeStakingDelta

func DeserializeStakingDelta(deserializer serde.Deserializer) (StakingDelta, error)

func (*StakingDelta) BcsSerialize

func (obj *StakingDelta) BcsSerialize() ([]byte, error)

func (*StakingDelta) Serialize

func (obj *StakingDelta) Serialize(serializer serde.Serializer) error

type StructTag

type StructTag struct {
	Address  AccountAddress
	Module   Identifier
	Name     Identifier
	TypeArgs []TypeTag
}

func BcsDeserializeStructTag

func BcsDeserializeStructTag(input []byte) (StructTag, error)

func DeserializeStructTag

func DeserializeStructTag(deserializer serde.Deserializer) (StructTag, error)

func StructTagFromString

func StructTagFromString(str string) (tag StructTag, err error)

StructTagFromString parse string to *StructTag

func (*StructTag) BcsSerialize

func (obj *StructTag) BcsSerialize() ([]byte, error)

func (*StructTag) Serialize

func (obj *StructTag) Serialize(serializer serde.Serializer) error

func (StructTag) String

func (st StructTag) String() (string, error)

String implement stringify StructTag

type SystemError

type SystemError struct {
	InvalidRequest     *InvalidRequest     `json:"invalid_request,omitempty"`
	InvalidResponse    *InvalidResponse    `json:"invalid_response,omitempty"`
	NoSuchContract     *NoSuchContract     `json:"no_such_contract,omitempty"`
	Unknown            *Unknown            `json:"unknown,omitempty"`
	UnsupportedRequest *UnsupportedRequest `json:"unsupported_request,omitempty"`
}

SystemError captures all errors returned from the Rust code as SystemError. Exactly one of the fields should be set.

func ToSystemError

func ToSystemError(err error) *SystemError

ToSystemError will try to convert the given error to an SystemError. This is important to returning any Go error back to Rust.

If it is already StdError, return self. If it is an error, which could be a sub-field of StdError, embed it. If it is anything else, **return nil**

This may return nil on an unknown error, whereas ToStdError will always create a valid error type.

func (SystemError) Error

func (a SystemError) Error() string

type TestConfig

type TestConfig struct {
	// Bound the number of instructions that can be executed by any one test.
	// set 0 to no-boundary
	InstructionExecutionBound uint64

	// A filter string to determine which unit tests to run. A unit test will be run only if it
	// contains this string in its fully qualified (<addr>::<module_name>::<fn_name>) name.
	Filter []byte

	// List all tests
	List bool

	// Number of threads to use for running tests.
	NumThreads uint

	// Report test statistics at the end of testing
	ReportStatistics bool

	// Show the storage state at the end of execution of a failing test
	ReportStorageOnError bool

	// Ignore compiler's warning, and continue run tests
	IgnoreCompileWarnings bool

	// Use the stackless bytecode interpreter to run the tests and cross check its results with
	// the execution result from Move VM.
	CheckStacklessVM bool

	// Verbose mode
	VerboseMode bool

	// Collect coverage information for later use with the various `package coverage` subcommands
	ComputeCoverage bool
}

TestConfig is a configuration set to test move package

func DefaultTestConfig

func DefaultTestConfig() TestConfig

DefaultTestConfig returns TestConfig with default value

func NewTestConfig

func NewTestConfig(options ...func(*TestConfig)) TestConfig

NewTestConfig returns newly create TestConfig. unset values stays default, not unset

type TypeTag

type TypeTag interface {
	Serialize(serializer serde.Serializer) error
	BcsSerialize() ([]byte, error)
	// contains filtered or unexported methods
}

func BcsDeserializeTypeTag

func BcsDeserializeTypeTag(input []byte) (TypeTag, error)

func DeserializeTypeTag

func DeserializeTypeTag(deserializer serde.Deserializer) (TypeTag, error)

func TypeTagFromString

func TypeTagFromString(str string) (TypeTag, error)

TypeTagFromString parse string to TypeTag

type TypeTag__Address

type TypeTag__Address struct {
}

func (*TypeTag__Address) BcsSerialize

func (obj *TypeTag__Address) BcsSerialize() ([]byte, error)

func (*TypeTag__Address) Serialize

func (obj *TypeTag__Address) Serialize(serializer serde.Serializer) error

type TypeTag__Bool

type TypeTag__Bool struct {
}

func (*TypeTag__Bool) BcsSerialize

func (obj *TypeTag__Bool) BcsSerialize() ([]byte, error)

func (*TypeTag__Bool) Serialize

func (obj *TypeTag__Bool) Serialize(serializer serde.Serializer) error

type TypeTag__Signer

type TypeTag__Signer struct {
}

func (*TypeTag__Signer) BcsSerialize

func (obj *TypeTag__Signer) BcsSerialize() ([]byte, error)

func (*TypeTag__Signer) Serialize

func (obj *TypeTag__Signer) Serialize(serializer serde.Serializer) error

type TypeTag__Struct

type TypeTag__Struct struct {
	Value StructTag
}

func (*TypeTag__Struct) BcsSerialize

func (obj *TypeTag__Struct) BcsSerialize() ([]byte, error)

func (*TypeTag__Struct) Serialize

func (obj *TypeTag__Struct) Serialize(serializer serde.Serializer) error

type TypeTag__U128

type TypeTag__U128 struct {
}

func (*TypeTag__U128) BcsSerialize

func (obj *TypeTag__U128) BcsSerialize() ([]byte, error)

func (*TypeTag__U128) Serialize

func (obj *TypeTag__U128) Serialize(serializer serde.Serializer) error

type TypeTag__U16

type TypeTag__U16 struct {
}

func (*TypeTag__U16) BcsSerialize

func (obj *TypeTag__U16) BcsSerialize() ([]byte, error)

func (*TypeTag__U16) Serialize

func (obj *TypeTag__U16) Serialize(serializer serde.Serializer) error

type TypeTag__U256

type TypeTag__U256 struct {
}

func (*TypeTag__U256) BcsSerialize

func (obj *TypeTag__U256) BcsSerialize() ([]byte, error)

func (*TypeTag__U256) Serialize

func (obj *TypeTag__U256) Serialize(serializer serde.Serializer) error

type TypeTag__U32

type TypeTag__U32 struct {
}

func (*TypeTag__U32) BcsSerialize

func (obj *TypeTag__U32) BcsSerialize() ([]byte, error)

func (*TypeTag__U32) Serialize

func (obj *TypeTag__U32) Serialize(serializer serde.Serializer) error

type TypeTag__U64

type TypeTag__U64 struct {
}

func (*TypeTag__U64) BcsSerialize

func (obj *TypeTag__U64) BcsSerialize() ([]byte, error)

func (*TypeTag__U64) Serialize

func (obj *TypeTag__U64) Serialize(serializer serde.Serializer) error

type TypeTag__U8

type TypeTag__U8 struct {
}

func (*TypeTag__U8) BcsSerialize

func (obj *TypeTag__U8) BcsSerialize() ([]byte, error)

func (*TypeTag__U8) Serialize

func (obj *TypeTag__U8) Serialize(serializer serde.Serializer) error

type TypeTag__Vector

type TypeTag__Vector struct {
	Value TypeTag
}

func (*TypeTag__Vector) BcsSerialize

func (obj *TypeTag__Vector) BcsSerialize() ([]byte, error)

func (*TypeTag__Vector) Serialize

func (obj *TypeTag__Vector) Serialize(serializer serde.Serializer) error

type Unknown

type Unknown struct{}

func (Unknown) Error

func (e Unknown) Error() string

type UnsupportedRequest

type UnsupportedRequest struct {
	Kind string `json:"kind,omitempty"`
}

func (UnsupportedRequest) Error

func (e UnsupportedRequest) Error() string

Jump to

Keyboard shortcuts

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