Registers all available CBOR decoders globally with the cbor2 library.
This function currently registers the following decoders:
AccountAddress
TokenAmount
CborMemo
An array of functions to clean up decoder registrations, i.e. restore the decoders registered prior to registering the Concordium-specific ones.
// Register all CBOR decoders globally const oldDecoders = registerDecoders(); // Now cbor2.decode will automatically handle known Concordium types const address = decode(cborBytes); const tokenAmount = decode(tokenCborBytes); // Restore old decoders oldDecoders.forEach((cleanup) => { cleanup(); });
cbor2.decode
Generated using TypeDoc
Registers all available CBOR decoders globally with the cbor2 library.
This function currently registers the following decoders:
AccountAddress(tag 40307): For decoding Concordium account addressesTokenAmount(tag 4): For decoding protocol-level token amounts as decimal fractionsCborMemo(tag 24): For decoding protocol-level token memos as cbor encoded data itemsReturns
An array of functions to clean up decoder registrations, i.e. restore the decoders registered prior to registering the Concordium-specific ones.
Example
// Register all CBOR decoders globally const oldDecoders = registerDecoders(); // Now
cbor2.decodewill automatically handle known Concordium types const address = decode(cborBytes); const tokenAmount = decode(tokenCborBytes); // Restore old decoders oldDecoders.forEach((cleanup) => { cleanup(); });