Skip to content

Commit 472a56d

Browse files
authored
fix(app2): calculating tokenmeta dynamically (#4241)
2 parents 8edd876 + b3374ed commit 472a56d

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

ts-sdk/src/ucs03/fungible-asset-order.ts

+14-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { toHex, type Address, type Hex } from "viem"
2-
import { Effect, Schema as S } from "effect"
2+
import { Effect, pipe, Schema as S } from "effect"
3+
import * as Either from "effect/Either"
34
import { ViemPublicClient, ViemPublicClientSource } from "../evm/client.js"
45
import { readErc20Meta } from "../evm/erc20.js"
56
import { predictQuoteToken as predictEvmQuoteToken } from "../evm/quote-token.js"
@@ -117,17 +118,18 @@ export const createCosmosToEvmFungibleAssetOrder = (intent: {
117118
yield* guardAgainstZeroAmount(intent)
118119
const sourceClient = (yield* CosmWasmClientSource).client
119120

120-
// HACK: special cased for ubbn for now
121-
const tokenMeta =
122-
intent.baseToken === "ubbn"
123-
? {
124-
symbol: "ubbn",
125-
name: "ubbn",
126-
decimals: 0
127-
}
128-
: yield* readCw20TokenInfo(intent.baseToken).pipe(
129-
Effect.provideService(CosmWasmClientContext, { client: sourceClient })
130-
)
121+
const tokenMeta = yield* pipe(
122+
readCw20TokenInfo(intent.baseToken),
123+
Effect.provideService(CosmWasmClientContext, { client: sourceClient }),
124+
Effect.either,
125+
Effect.map(
126+
Either.getOrElse(() => ({
127+
symbol: intent.baseToken,
128+
name: intent.baseToken,
129+
decimals: 0
130+
}))
131+
)
132+
)
131133

132134
const quoteToken = yield* predictEvmQuoteToken(toHex(intent.baseToken))
133135

0 commit comments

Comments
 (0)