Skip to content

@gala-chain/testAPI


API > writesMap

Function: writesMap()

writesMap(...records): Record\<string, string>

Converts write records into a key-value map suitable for blockchain state.

Handles different record types appropriately: - ChainObjects: Uses composite key and serialization - RangedChainObjects: Uses ranged key and serialization - Deletions: Maps to empty string value - Key-value pairs: Uses as-is

Parameters

▪ ...records: WriteRecord[]

Array of write records to convert

Returns

Object mapping blockchain keys to their string values

Example

const writes = writesMap(
  tokenClass,  // ChainObject
  { key: "custom-key", value: "custom-value" },
  { key: "deleted-key", isDelete: true }
);

Source

chain-test/src/unit/writes.ts:61