name: Struct

description: A Struct defines an Object with key/values - where the values are Codec values. It removes a lot of repetition from the actual coding, define a structure type, pass it the key/Codec values in the constructor and it manages the decoding. It is important that the constructor values matches 100% to the order in th Rust code, i.e. don't go crazy and make it alphabetical, it needs to decoded in the specific defined order.

Type parameters

S : ConstructorDef

T : object

V : object

E : object

Hierarchy

Map<keyof S, Codec>

↳ Struct

↳ CandidateReceipt

↳ AttestedCandidate

↳ FunctionArgumentMetadata

↳ FunctionMetadata

↳ CallMetadata

↳ ModuleMetadata

↳ StorageFunctionType$Map

↳ StorageFunctionMetadata

↳ StorageMetadata

↳ RuntimeModuleMetadata

↳ Method

↳ SignaturePayload

↳ ExtrinsicSignature

↳ Extrinsic

↳ Digest

↳ Header

↳ Block

↳ OuterDispatchCall

↳ OuterDispatchMetadata

↳ EventMetadata

↳ OuterEventMetadata

↳ Metadata

↳ Event

↳ EventRecord

↳ Health

↳ KeyValue

↳ BftAtReport

↳ BftProposeOutOfTurn

↳ MisbehaviorReport

↳ RhdJustification

↳ ReferendumInfo

↳ RuntimeVersion

↳ SignedBlock

↳ StorageChangeSet

↳ StoredPendingChange

↳ ValidatorPrefs

Implements

Constructors

constructor

⊕ new Struct(Types: S, value?: V | Map<any, any> | Array<any>, jsonMap?: Map<keyof S, string>): Struct

Defined in codec/Struct.ts:31

Parameters:

Name Type Default value
Types S -
Default value value V Map<any, any> Array<any> {} as V
Default value jsonMap Map<keyof S, string> new Map()

Returns: Struct


Properties

<Static> Map

● Map: MapConstructor

Defined in /home/travis/build/polkadot-js/api/node_modules/typescript/lib/lib.es2015.collection.d.ts:36


Accessors

Type

getType(): E

Defined in codec/Struct.ts:142

description: Returns the Type description to sthe structure

Returns: E


encodedLength

getencodedLength(): number

Defined in codec/Struct.ts:149

description: The length of the value when encoded as a Uint8Array

Returns: number


Methods

get

▸ get(name: keyof S): Codec | undefined

Overrides Map.get

Defined in codec/Struct.ts:159

description: Returns a specific names entry in the structure

Parameters:

Name Type Description
name keyof S The name of the entry to retrieve

Returns: Codec | undefined


getAtIndex

▸ getAtIndex(index: number): Codec

Defined in codec/Struct.ts:166

description: Returns the values of a member at a specific index (Rather use get(name) for performance)

Parameters:

Name Type
index number

Returns: Codec


toArray

▸ toArray(): Array<Codec>

Defined in codec/Struct.ts:173

description: Converts the Object to an standard JavaScript Array

Returns: Array<Codec>


toHex

▸ toHex(): string

Implementation of Codec.toHex

Defined in codec/Struct.ts:180

description: Returns a hex string representation of the value

Returns: string


toJSON

▸ toJSON(): any

Implementation of Codec.toJSON

Defined in codec/Struct.ts:187

description: Converts the Object to JSON, typically used for RPC transfers

Returns: any


toString

▸ toString(): string

Implementation of Codec.toString

Defined in codec/Struct.ts:201

description: Returns the string representation of the value

Returns: string


toU8a

▸ toU8a(isBare?: undefined | false | true): Uint8Array

Defined in codec/Struct.ts:209

description: Encodes the value as a Uint8Array as per the parity-codec specifications

Parameters:

Name Type Description
Optional isBare undefined false true true when the value has none of the type-specific prefixes (internal)

Returns: Uint8Array


<Static> with

▸ with<S>(Types: S): Constructor<Struct<S>>

Defined in codec/Struct.ts:122

Type parameters:

S : ConstructorDef

Parameters:

Name Type
Types S

Returns: Constructor<Struct<S>>


results matching ""

    No results matching ""