Skip to main content

bridge/classes/BridgeableTokenService.md

Service for the tokens bridgeable to Ethereum and Solana.

Reads go through a DexApiReader (a GalaConnectClient, or launchpad-sdk's DEX API HttpClient). Failures are GalaSDKErrors: BRIDGE_READ_RESPONSE_INVALID for an answer without a token list, INVALID_TOKEN_REFERENCE for a token id that is not one, and the read's own (GALACONNECT_HTTP_ERROR, TRANSPORT_ERROR, ...).

Constructors​

Constructor​

new BridgeableTokenService(dexApi): BridgeableTokenService

Parameters​

ParameterTypeDescription
dexApiDexApiReaderReads the DEX API platform's token list

Returns​

BridgeableTokenService

Methods​

clearCache()​

clearCache(network?): void

Forget the cached tokens of network, or of every network.

Parameters​

ParameterType
network?BridgeableNetwork

Returns​

void


fetchAllBridgeableTokensByNetwork()​

fetchAllBridgeableTokensByNetwork(network): Promise<FetchBridgeableTokensResult>

Fetch every token bridgeable to a network (every page), or the cached ones.

Parameters​

ParameterTypeDescription
networkBridgeableNetworkETHEREUM or SOLANA

Returns​

Promise<FetchBridgeableTokensResult>


fetchAllTokensBridgeableToEthereum()​

fetchAllTokensBridgeableToEthereum(): Promise<FetchBridgeableTokensResult>

Every token bridgeable to Ethereum.

Returns​

Promise<FetchBridgeableTokensResult>


fetchAllTokensBridgeableToSolana()​

fetchAllTokensBridgeableToSolana(): Promise<FetchBridgeableTokensResult>

Every token bridgeable to Solana.

Returns​

Promise<FetchBridgeableTokensResult>


fetchBridgeableTokensByNetwork()​

fetchBridgeableTokensByNetwork(options): Promise<FetchBridgeableTokensResult>

Fetch one page of the tokens bridgeable to a network. Not cached: the cache holds only the full list (a page standing in for it would hide every token on the other pages).

Parameters​

ParameterTypeDescription
optionsFetchBridgeableTokensOptionsNetwork, offset (default 0) and limit (default and at most 1000)

Returns​

Promise<FetchBridgeableTokensResult>


getCacheStats()​

getCacheStats(): BridgeableTokenCacheStats

What the cache holds.

Returns​

BridgeableTokenCacheStats


getContractAddress()​

getContractAddress(symbol, network): Promise<string | undefined>

The contract address on network of the token with symbol, if any.

Parameters​

ParameterType
symbolstring
networkBridgeableNetwork

Returns​

Promise<string | undefined>


getSupportedTokenSymbols()​

getSupportedTokenSymbols(network): Promise<string[]>

The symbols of the tokens bridgeable to network.

Parameters​

ParameterType
networkBridgeableNetwork

Returns​

Promise<string[]>


getTokenBySymbol()​

getTokenBySymbol(symbol, network): Promise<BridgeableToken | undefined>

The token bridgeable to network with symbol (any case; the first listed), if any.

Parameters​

ParameterType
symbolstring
networkBridgeableNetwork

Returns​

Promise<BridgeableToken | undefined>


getTokenByTokenId()​

getTokenByTokenId(tokenId, network): Promise<BridgeableToken | undefined>

The token bridgeable to network with the token id tokenId (a pipe class key, matched exactly: class keys are case-sensitive), if any.

Parameters​

ParameterType
tokenIdstring
networkBridgeableNetwork

Returns​

Promise<BridgeableToken | undefined>


isTokenBridgeableToEthereum()​

isTokenBridgeableToEthereum(tokenId): Promise<IsTokenBridgeableResult>

Whether a token is bridgeable to Ethereum.

Parameters​

ParameterType
tokenIdTokenClassKeyInput

Returns​

Promise<IsTokenBridgeableResult>


isTokenBridgeableToNetwork()​

isTokenBridgeableToNetwork(options): Promise<IsTokenBridgeableResult>

Whether a token (by token id) is bridgeable to a network, with its symbol and contract address there. The symbol is the cached token's, never derived from the token id.

Parameters​

ParameterType
optionsIsTokenBridgeableOptions

Returns​

Promise<IsTokenBridgeableResult>


isTokenBridgeableToSolana()​

isTokenBridgeableToSolana(tokenId): Promise<IsTokenBridgeableResult>

Whether a token is bridgeable to Solana.

Parameters​

ParameterType
tokenIdTokenClassKeyInput

Returns​

Promise<IsTokenBridgeableResult>


preload()​

preload(): Promise<void>

Read both networks' token lists.

Returns​

Promise<void>