diff --git a/typescript-sdk/playground/holesky-to-stargaze.ts b/typescript-sdk/playground/holesky-to-stargaze.ts index 16474c720f..f472ebfae1 100644 --- a/typescript-sdk/playground/holesky-to-stargaze.ts +++ b/typescript-sdk/playground/holesky-to-stargaze.ts @@ -59,6 +59,11 @@ if (quoteToken.isErr()) { process.exit(1) } +if (quoteToken.value.type === "NO_QUOTE_AVAILABLE") { + consola.info("no quote token available") + process.exit(1) +} + consola.info("quote token", quoteToken.value) const transferArgs = { diff --git a/typescript-sdk/src/query/offchain/ucs03-channels.ts b/typescript-sdk/src/query/offchain/ucs03-channels.ts index 718bb0f1ab..1f63037791 100644 --- a/typescript-sdk/src/query/offchain/ucs03-channels.ts +++ b/typescript-sdk/src/query/offchain/ucs03-channels.ts @@ -51,11 +51,20 @@ export type Channel = { destination_connection_id: number } +function isPositiveInteger(str: string): boolean { + return /^[1-9]\d*$/.test(str) +} + export const getQuoteToken = async ( source_chain_id: string, base_token: string, channel: Channel -): Promise> => { +): Promise< + Result< + { quote_token: string; type: "UNWRAPPED" | "NEW_WRAPPED" } | { type: "NO_QUOTE_AVAILABLE" }, + Error + > +> => { // check if the denom is wrapped let wrapping = await ResultAsync.fromPromise( request(GRAQPHQL_URL, tokenWrappingQuery, { @@ -83,6 +92,12 @@ export const getQuoteToken = async ( } } + // HACK: to check evm vs cosmos we check if te destination chain id is a number + if (!isPositiveInteger(channel.destination_chain_id)) { + // we donn't support sending new assets to cosmos chains yet. + return ok({ type: "NO_QUOTE_AVAILABLE" }) + } + // if it is unknown, calculate the quotetoken const destinationChainClient = createPublicClient({ chain: evmChainFromChainId(channel.destination_chain_id),