Documentation
¶
Index ¶
- Constants
- Variables
- func GetCompactValue(val Compact) interface{}
- type Abi
- func (a *Abi) DecodeInput(methodName string, val []byte) (*InvokeBean, error)
- func (a *Abi) DecodeRet(ret []byte, methodName string) (*InvokeBean, error)
- func (a *Abi) Encode(methodName string, params ...interface{}) ([]byte, error)
- func (a *Abi) EncodeCompact(methodName string, params ...Compact) ([]byte, error)
- func (a *Abi) GetMethod(name string) (*Method, error)
- type Compact
- type CompactArray
- type CompactBool
- type CompactEnum
- type CompactString
- type CompactStruct
- type CompactTuple
- type CompactU128
- type CompactU16
- type CompactU32
- type CompactU64
- type CompactU8
- type CompactVec
- type ConstructorSpec
- type Contract
- type FixI128
- type FixI16
- type FixI32
- type FixI64
- type FixI8
- type FixU128
- type FixU16
- type FixU32
- type FixU64
- type FixU8
- type InvokeBean
- type Method
- type PrimitiveType
- type Type
- type TypeInfo
- type TypeString
Constants ¶
View Source
const ( // MoveBit for the highest six bit is has special means, in order to get origin num, must move right 2bit // also encode a number must move left 2bit MoveBit = 2 // SingleMode the higher six bit is LE for value, which is 0 to 63 SingleMode = 0b00 MaxSingle = 63 // DoubleMode the higher six bit and next byte is LE for value, which is 64 to 1<<14 - 1 DoubleMode = 0b01 MaxDouble = 1<<14 - 1 // FourByteMode the higher six bit and next three bytes is LE for value, which is 1<<14 -1 to 1<<30-1 FourByteMode = 0b10 MaxFour = 1<<30 - 1 // BigIntMode the highest six bit represent the bytes num in the next, which less than 4. // then, the next bytes contain the LE for value. the highest one can not be 0, which is // 1<<30-1 to 1<<536-1 BigIntMode = 0b11 )
View Source
const CustomParamsSection = "params"
CustomParamsSection custom section named `params` in wasm defined by us.
Variables ¶
View Source
var ( U8OutOfRange = errors.New("out of range Compact<u8>") U16OutOfRange = errors.New("out of range Compact<u16>") U32OutOfRange = errors.New("out of range Compact<u32>") U64OutOfRange = errors.New("out of range Compact<u64>") U128OutOfRange = errors.New("out of range Compact<u128>") )
View Source
var BaseIntEncode littleEncode
Functions ¶
func GetCompactValue ¶
func GetCompactValue(val Compact) interface{}
Types ¶
type Abi ¶
type Abi struct {
Contract Contract `json:"contract"`
Methods []Method `json:"methods"`
Types []Type `json:"types"`
// contains filtered or unexported fields
}
func (*Abi) DecodeInput ¶
func (a *Abi) DecodeInput(methodName string, val []byte) (*InvokeBean, error)
func (*Abi) EncodeCompact ¶
type Compact ¶
type Compact interface {
Encode() ([]byte, error)
Decode(val []byte) (int, error)
GetVal() interface{}
GetType() TypeString
CloneNew() Compact
}
Compact base interface for encoding and decoding. We redefine the way to encode and decode all the types in abi file. For more details see [SCALE Codec](https://docs.substrate.io/v3/advanced/scale-codec/)
type CompactArray ¶
type CompactArray struct {
Val []Compact
Len int
NextList []TypeString
}
func (*CompactArray) CloneNew ¶
func (c *CompactArray) CloneNew() Compact
func (*CompactArray) Encode ¶
func (c *CompactArray) Encode() ([]byte, error)
func (*CompactArray) GetType ¶
func (c *CompactArray) GetType() TypeString
func (*CompactArray) GetVal ¶
func (c *CompactArray) GetVal() interface{}
type CompactBool ¶
type CompactBool struct {
Val bool
}
func (*CompactBool) CloneNew ¶
func (c *CompactBool) CloneNew() Compact
func (*CompactBool) Encode ¶
func (c *CompactBool) Encode() ([]byte, error)
func (*CompactBool) GetType ¶
func (c *CompactBool) GetType() TypeString
func (*CompactBool) GetVal ¶
func (c *CompactBool) GetVal() interface{}
type CompactEnum ¶ added in v1.4.0
type CompactEnum struct {
Val Compact
// contains filtered or unexported fields
}
func (*CompactEnum) CloneNew ¶ added in v1.4.0
func (c *CompactEnum) CloneNew() Compact
func (*CompactEnum) Decode ¶ added in v1.4.0
func (c *CompactEnum) Decode(value []byte) (int, error)
func (*CompactEnum) Encode ¶ added in v1.4.0
func (c *CompactEnum) Encode() ([]byte, error)
func (*CompactEnum) GetType ¶ added in v1.4.0
func (c *CompactEnum) GetType() TypeString
func (*CompactEnum) GetVal ¶ added in v1.4.0
func (c *CompactEnum) GetVal() interface{}
type CompactString ¶
type CompactString struct {
Val string
Type TypeString
}
func (*CompactString) CloneNew ¶
func (c *CompactString) CloneNew() Compact
func (*CompactString) Encode ¶
func (c *CompactString) Encode() ([]byte, error)
func (*CompactString) GetType ¶
func (c *CompactString) GetType() TypeString
func (*CompactString) GetVal ¶
func (c *CompactString) GetVal() interface{}
type CompactStruct ¶
type CompactStruct struct {
Val []Compact
}
func (*CompactStruct) CloneNew ¶
func (c *CompactStruct) CloneNew() Compact
func (*CompactStruct) Encode ¶
func (c *CompactStruct) Encode() ([]byte, error)
func (*CompactStruct) GetType ¶
func (c *CompactStruct) GetType() TypeString
func (*CompactStruct) GetVal ¶
func (c *CompactStruct) GetVal() interface{}
type CompactTuple ¶ added in v1.4.0
type CompactTuple struct {
Val []Compact
}
func (*CompactTuple) CloneNew ¶ added in v1.4.0
func (c *CompactTuple) CloneNew() Compact
func (*CompactTuple) Decode ¶ added in v1.4.0
func (c *CompactTuple) Decode(value []byte) (int, error)
func (*CompactTuple) Encode ¶ added in v1.4.0
func (c *CompactTuple) Encode() ([]byte, error)
func (*CompactTuple) GetType ¶ added in v1.4.0
func (c *CompactTuple) GetType() TypeString
func (*CompactTuple) GetVal ¶ added in v1.4.0
func (c *CompactTuple) GetVal() interface{}
type CompactU128 ¶
func (*CompactU128) CloneNew ¶
func (c *CompactU128) CloneNew() Compact
func (*CompactU128) Encode ¶
func (c *CompactU128) Encode() ([]byte, error)
func (*CompactU128) GetType ¶
func (c *CompactU128) GetType() TypeString
func (*CompactU128) GetVal ¶
func (c *CompactU128) GetVal() interface{}
type CompactU16 ¶
type CompactU16 struct {
Val uint16
}
CompactU16 two bytes uint in compact mode
func (*CompactU16) CloneNew ¶
func (u *CompactU16) CloneNew() Compact
func (*CompactU16) Encode ¶
func (u *CompactU16) Encode() ([]byte, error)
func (*CompactU16) GetType ¶
func (u *CompactU16) GetType() TypeString
func (*CompactU16) GetVal ¶
func (u *CompactU16) GetVal() interface{}
type CompactU32 ¶
type CompactU32 struct {
Val uint32
}
CompactU32 four bytes uint
func (*CompactU32) CloneNew ¶
func (u *CompactU32) CloneNew() Compact
func (*CompactU32) Encode ¶
func (u *CompactU32) Encode() ([]byte, error)
func (*CompactU32) GetType ¶
func (u *CompactU32) GetType() TypeString
func (*CompactU32) GetVal ¶
func (u *CompactU32) GetVal() interface{}
type CompactU64 ¶
type CompactU64 struct {
Val uint64
}
func (*CompactU64) CloneNew ¶
func (c *CompactU64) CloneNew() Compact
func (*CompactU64) Encode ¶
func (c *CompactU64) Encode() ([]byte, error)
func (*CompactU64) GetType ¶
func (c *CompactU64) GetType() TypeString
func (*CompactU64) GetVal ¶
func (c *CompactU64) GetVal() interface{}
type CompactU8 ¶
type CompactU8 struct {
Val uint8
}
CompactU8 one byte uint in compact mode
func (*CompactU8) GetType ¶
func (c *CompactU8) GetType() TypeString
type CompactVec ¶
type CompactVec struct {
Val []Compact
NextList []TypeString
}
func (*CompactVec) Clear ¶
func (c *CompactVec) Clear()
func (*CompactVec) CloneNew ¶
func (c *CompactVec) CloneNew() Compact
func (*CompactVec) Encode ¶
func (c *CompactVec) Encode() ([]byte, error)
func (*CompactVec) GetType ¶
func (c *CompactVec) GetType() TypeString
func (*CompactVec) GetVal ¶
func (c *CompactVec) GetVal() interface{}
type ConstructorSpec ¶
type ConstructorSpec struct {
Input []TypeInfo `json:"input"`
}
type Contract ¶
type Contract struct {
Name string `json:"name"`
Constructor ConstructorSpec `json:"constructor"`
}
type FixI16 ¶
type FixI16 struct {
Val int16
}
func (*FixI16) GetType ¶
func (f *FixI16) GetType() TypeString
type FixI32 ¶
type FixI32 struct {
Val int32
}
func (*FixI32) GetType ¶
func (f *FixI32) GetType() TypeString
type FixI64 ¶
type FixI64 struct {
Val int64
}
func (*FixI64) GetType ¶
func (f *FixI64) GetType() TypeString
type FixI8 ¶
type FixI8 struct {
Val int8
}
func (*FixI8) GetType ¶
func (f *FixI8) GetType() TypeString
type FixU16 ¶
type FixU16 struct {
Val uint16
}
func (*FixU16) GetType ¶
func (f *FixU16) GetType() TypeString
type FixU32 ¶
type FixU32 struct {
Val uint32
}
func (*FixU32) GetType ¶
func (f *FixU32) GetType() TypeString
type FixU64 ¶
type FixU64 struct {
Val uint64
}
func (*FixU64) GetType ¶
func (f *FixU64) GetType() TypeString
type FixU8 ¶
type FixU8 struct {
Val uint8
}
func (*FixU8) GetType ¶
func (f *FixU8) GetType() TypeString
type InvokeBean ¶
type PrimitiveType ¶
type PrimitiveType int
const ( None PrimitiveType = iota String Struct Uint8 Int8 CompactUInt8 Uint16 Int16 CompactUint16 Uint32 Int32 CompactUint32 Uint64 Int64 CompactUint64 BigInt BigUint CompactBigInt Bool Vec Primitive Array Tuple Enum )
type TypeString ¶
type TypeString string
const ( NoneName TypeString = TypeString("None") StringName TypeString = "String" StructName TypeString = "struct" Uint8Name TypeString = "u8" Int8Name TypeString = "i8" CompactUInt8Name TypeString = "Compact < u8 >" Uint16Name TypeString = "u16" Int16Name TypeString = "i16" CompactUint16Name TypeString = "Compact < u16 >" Uint32Name TypeString = "u32" Int32Name TypeString = "i32" CompactUint32Name TypeString = "Compact < u32 >" Uint64Name TypeString = "u64" Int64Name TypeString = "i64" CompactUint64Name TypeString = "Compact < u64 >" BigIntName TypeString = "i128" BigUIntName TypeString = "u128" CompactBigIntName TypeString = "Compact < u128 >" BoolName TypeString = "bool" VecName TypeString = "Vec" PrimitiveName TypeString = "primitive" ArrayName TypeString = "Array" TupleName TypeString = "tuple" EnumName TypeString = "enum" )
func (TypeString) String ¶
func (t TypeString) String() string
Click to show internal directories.
Click to hide internal directories.