Class: Symbols
Symbol registry client for the current GalaChainDex contract.
Constructors
Constructor
new Symbols(
gateway,options?):Symbols
Create a symbol service backed by the swap backend. onInvalidEntry is told about every
registry row that was skipped as unusable (see InvalidEntryHandler).
Parameters
| Parameter | Type |
|---|---|
gateway | Pick<ChainGateway, "httpRequestor" | "dexBackendBaseUrl"> & object |
options? | { onInvalidEntry?: InvalidEntryHandler; } |
options.onInvalidEntry? | InvalidEntryHandler |
Returns
Symbols
on invalid entry chain gateway http requestor dex backend base url handler
Methods
invalidate()
invalidate():
void
Invalidate the cached symbol registry after a write changes registration state.
Returns
void
Example
gSwap.symbols.invalidate();
list()
list():
Promise<TradingSymbol[]>
List all registered GalaChainDex trading symbols, cached for 60 seconds. A registry row that
is not a usable symbol is skipped (and reported to onInvalidEntry) instead of failing the
whole list.
Returns
Promise<TradingSymbol[]>
trading symbol on invalid entry
orderPair()
orderPair(
a,b):Promise<{flipped:boolean;token0:TradingSymbol;token1:TradingSymbol; }>
Resolve and put two token references in canonical trading-symbol order.
Parameters
| Parameter | Type |
|---|---|
a | TokenRef |
b | TokenRef |
Returns
Promise<{ flipped: boolean; token0: TradingSymbol; token1: TradingSymbol; }>
order pair trading symbol token ref
proposeSymbol()
proposeSymbol(
classKey,displaySymbol,options?):Promise<string>
The trading symbol to put in a token's first CreatePool.
- The symbol ALREADY registered for exactly this class key, if any: proposing another one fails the gateway's registry-conflict check.
- Otherwise
displaySymbol(the token's curated symbol), when it is proposable (isProposableTradingSymbol). - Otherwise a
NO_VALID_TRADING_SYMBOLerror: a symbol is never derived from the key (BNB's collection isGBNB, a launchpad token's is the reserved wordToken).
registryFailure: 'ignore' treats an unreachable registry as an empty one and falls through
to step 2 (the gateway still rejects a conflicting symbol); the default 'throw' propagates
the failure.
Parameters
| Parameter | Type |
|---|---|
classKey | GalaChainTokenClassKey |
displaySymbol | string |
options? | { registryFailure?: "throw" | "ignore"; } |
options.registryFailure? | "throw" | "ignore" |
Returns
Promise<string>
Example
const symbol = await gSwap.symbols.proposeSymbol(
{ collection: 'GALA_TEST1', category: 'Unit', type: 'none', additionalKey: 'none' },
'GALATEST',
);
propose symbol class key display no valid trading registry failure gala chain token
refresh()
refresh():
Promise<TradingSymbol[]>
Force one registry refresh, bypassing the cache.
Returns
Promise<TradingSymbol[]>
Example
const symbols = await gSwap.symbols.refresh();
trading symbol
resolve()
resolve(
ref):Promise<TradingSymbol>
Resolve a symbol or token class key to its registered symbol metadata.
Parameters
| Parameter | Type |
|---|---|
ref | TokenRef |
Returns
Promise<TradingSymbol>
trading symbol token ref