Skip to main content

bridge/classes/WrappableTokenService.md

Service for the wrappable tokens.

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 WrappableTokenService(dexApi): WrappableTokenService

Parameters​

ParameterTypeDescription
dexApiDexApiReaderReads the DEX API platform's token list

Returns​

WrappableTokenService

Methods​

clearCache()​

clearCache(): void

Forget the cached tokens.

Returns​

void


fetchAllWrappableTokens()​

fetchAllWrappableTokens(): Promise<FetchWrappableTokensResult>

Fetch every wrappable token (every page), or the cached ones.

Returns​

Promise<FetchWrappableTokensResult>


fetchWrappableTokens()​

fetchWrappableTokens(options?): Promise<FetchWrappableTokensResult>

Fetch one page of the wrappable tokens. 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
options?FetchWrappableTokensOptionsOffset (default 0) and limit (default and at most 1000)

Returns​

Promise<FetchWrappableTokensResult>


getCacheStats()​

getCacheStats(): WrappableTokenCacheStats

What the cache holds.

Returns​

WrappableTokenCacheStats


getWrapCounterpart()​

getWrapCounterpart(tokenId): Promise<WrappableToken | undefined>

The token a wrappable token wraps to or unwraps from, if both are wrappable.

Parameters​

ParameterType
tokenIdTokenClassKeyInput

Returns​

Promise<WrappableToken | undefined>


getWrappableToken()​

getWrappableToken(tokenId): Promise<WrappableToken | undefined>

The wrappable token with tokenId, if any.

Parameters​

ParameterType
tokenIdTokenClassKeyInput

Returns​

Promise<WrappableToken | undefined>


isTokenWrappable()​

isTokenWrappable(tokenId): Promise<IsTokenWrappableResult>

Whether a token is wrappable, with its counterpart.

Parameters​

ParameterType
tokenIdTokenClassKeyInput

Returns​

Promise<IsTokenWrappableResult>