A node representing an object or struct with named fields. Each field is represented by a dedicated StructFieldTypeNode
. Each field is encoded and decoded in the order they are defined.
Attribute | Type | Description |
---|---|---|
kind |
"structTypeNode" |
The node discriminator. |
Attribute | Type | Description |
---|---|---|
fields |
StructFieldTypeNode [] |
The fields of the struct. |
Helper function that creates a StructTypeNode
object from an array of StructFieldTypeNode
objects.
const node = structTypeNode([
structFieldTypeNode({ name: 'authority', type: publicKeyTypeNode() }),
structFieldTypeNode({ name: 'amount', type: numberTypeNode('u64') }),
]);
structTypeNode([
structFieldTypeNode({ name: 'name', type: fixedSizeTypeNode(stringTypeNode('utf8'), 10) }),
structFieldTypeNode({ name: 'age', type: numberTypeNode('u8') }),
]);
// { name: Alice, age: 42 } => 0x416C69636500000000002A