Files
api/packages/types
Jaco GreeffandAndrew Jones 453dd9e49a Updated ABI definitions & parsing (#1662)
* Updated ABI definitions & parsing

* Run type generation

* Definitions (should be ok-ish)

* Cleanup names

* Allow aliasses on structs (JSON parsing)

* Cleanup json mapping passing

* s/types/lookup/

* Parsing as per current output

* InkSelector

* MtRegistryIndex

* String lookup tests

* Remove serd ovverride comments (it works as-is)

* inkRegistry tests

* Extract primitive types

* s/ty/id/

* Start of parsing into types (actually to be TypeDef)

* Parsing

* stringify struct fields

* Small cleanups

* Add type index to project lookup

* Prefix with index

* Fix interface generation

* Latest contract metadata (#2118)

* Add new (provisional) incrementer contract metadata

* Update and regenerate type definitions

* WIP: generate new format scale-info types

* WIP: implementing variants

* Implement variants

* Fix up type resolution

* Fix registry spec tests

* Fix lints and some tests

* Fix inkTypes tests

* Fix some lints

* Make imports same line like original

* Comment out (temporarily) sanitize import to make CI pass

* Sanitize

* Remove indices

* Remove index

* Adjust ContractAbi interface (empty rpc)

* linting

* Pull in Andrew's changes

* Cleanups

* Some more cleanups

* Update with v3 contracts

* Adjust with actual types

* Regenerate

* Update ABI parsing (#2695)

* Adjust ABI code

* Cleanup

* Merge non-code

* Type naming

* Simplify Base

* Rename 1

* rename 2

* Rename 3

* Simplify

* Add index to AbiMessage

* Pass actual message or index for call

* Rename param

* Simplify

* Expose call & exec

* s/call/read/

* Cleanup asserts

* AccountId as per spec

* displayName is path

* Update definitions

* Flatten ABIType into TypeDef

* Rewrite

* Fix tests

* Updates

Co-authored-by: Andrew Jones <ascjones@gmail.com>
2020-10-09 18:33:31 +02:00
..
2018-11-21 13:37:27 +01:00
2020-10-09 14:48:20 +00:00
2020-01-19 21:05:58 +01:00

@polkadot/types

Implementation of the types and their (de-)serialisation via SCALE codec.
On the Rust side, the codec types and primitive types are implemented via the parity-codec.

Codec types

These are the base types of the codec. They are typically not used directly, but rather inherited from to create specific types. They are the building blocks for declaring custom types:

Types
Compact A compact length-encoding codec wrapper. Mostly used by other types to add length-prefixed encoding
Enum A codec wrapper for an enum. Enums are encoded as a single byte, where the byte is a zero-indexed value
Int A generic signed integer codec
Option An Option is an optional field. The first byte indicates that there is a value to follow
Set An Set is an array of string values, represented an an encoded type by a bitwise representation of the values
Struct A Struct defines an Object with key-value pairs - where the values are Codec values.
Tuple A Tuple defines an anonymous fixed-length array, where each element has its own type
Raw A basic wrapper around Uint8Array. It will consume the full Uint8Array as passed to it
U8aFixed A U8a that manages a a sequence of bytes up to the specified bitLength
UInt A generic unsigned integer codec. It handles the encoding and decoding of Little Endian encoded numbers in Substrate
Vec This manages codec arrays. Internally it keeps track of the length (as decoded)
VecAny This manages codec arrays, assuming that the inputs are already of type Codec

Primitive types

These primitive types are available:

Types
AccountId A wrapper around an AccountId/PublicKey representation
AccountIndex A wrapper around an AccountIndex, which is a shortened, variable-length encoding for an Account
Address A wrapper around an AccountId and/or AccountIndex that is encoded with a prefix
bool Representation for a boolean value in the system
Bytes A Bytes wrapper for Vec<u8>
Call Extrinsic function descriptor, as defined in the extrinsic format for a node
Event Wrapper for the actual data that forms part of an Event
EventRecord A record for an Event (as specified by Metadata) with the specific Phase of application
Extrinsic Representation of an Extrinsic in the system
ExtrinsicEra The era for an extrinsic, indicating either a mortal or immortal extrinsic
ExtrinsicPayload A signing payload for an Extrinsic. For the final encoding, it is variable length based on the contents included
H160 Hash containing 160 bits (20 bytes), typically used in blocks, extrinsics and as a sane default
H256 Hash containing 256 bits (32 bytes), typically used in blocks, extrinsics and as a sane default
H512 Hash containing 512 bits (64 bytes), typically used for signatures
Hash The default hash that is used accross the system. It is just a thin wrapper around H256
i8 An 8-bit signed integer
i16 A 16-bit signed integer
i32 A 32-bit signed integer
i64 A 64-bit signed integer
i128 A 128-bit signed integer
i256 A 256-bit signed integer
Moment A wrapper around seconds/timestamps. Internally the representation only has second precicion (aligning with Rust)
Null Implements a type that does not contain anything (apart from null)
Signature The default signature that is used accross the system
StorageData Data retrieved via Storage queries and data for key-value pairs
StorageKey A representation of a storage key (typically hashed) in the system
Text This is a string wrapper, along with the length.
Type This is a extended version of String, specifically to handle types
u8 An 8-bit unsigned integer
u16 A 16-bit unsigned integer
u32 A 32-bit unsigned integer
u64 A 64-bit unsigned integer
u128 A 128-bit unsigned integer
u256 A 256-bit unsigned integer