Function: tryParseTokenClassKey()
GalaChain core SDK 1.0.0-rc.8 / index / tryParseTokenClassKey
Function: tryParseTokenClassKey()
tryParseTokenClassKey(
value):GalaChainTokenClassKey|undefined
Defined in: packages/gala-core-sdk/dist/index.d.ts:2207
The non-throwing parseTokenClassKey: the class key, or undefined when value is not
one. A string is split exactly as parseTokenClassKey splits it (| form when it contains a
|, else $, from the right, all four parts non-empty). Unlike parseTokenClassKey, an
object is VALIDATED, not just copied: all four fields must be non-empty strings. Anything else
(undefined, null, a number, an array) is undefined, so it is safe on untrusted input (a
stored token, a URL parameter, a wallet row) without a try/catch.
Use tryParseCompositeKey instead when only the $ form is valid input.
Parameters
value
unknown
Returns
GalaChainTokenClassKey | undefined
Example
const key = tryParseTokenClassKey(row.compositeKey);
if (key === undefined) return failClosed(); // no class is known: never invent one from a symbol