Skip to content

Commit

Permalink
fix: fix tokenDecimals i32 parsing after abi update
Browse files Browse the repository at this point in the history
  • Loading branch information
ribeirojose committed Sep 18, 2024
1 parent 1e8e3c4 commit 574fb40
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/modules/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ export namespace tokens {
let tokenName = erc20Token.try_name()
let tokenSymbol = erc20Token.try_symbol()
token.decimals = !tokenDecimals.reverted
? tokenDecimals.value
: DEFAULT_DECIMALS
? I32.parseInt(tokenDecimals.value.toString()) as i32
: DEFAULT_DECIMALS
token.name = !tokenName.reverted ? tokenName.value : ""
token.symbol = !tokenSymbol.reverted ? tokenSymbol.value : ""
token.totalVolume = ZERO_BI
Expand Down Expand Up @@ -80,7 +80,9 @@ export namespace tokens {
let erc20Token = ERC20.bind(tokenAddress)
let tokenDecimals = erc20Token.try_decimals()

return tokenDecimals.reverted ? DEFAULT_DECIMALS : tokenDecimals.value
return !tokenDecimals.reverted
? I32.parseInt(tokenDecimals.value.toString()) as i32
: DEFAULT_DECIMALS
}

export function createTokenTradingEvent(timestamp: i32, tokenId: string, tradeId: string, amount: BigInt, amountEth: BigDecimal | null, amountUsd: BigDecimal | null, tokenPrice: BigDecimal | null): void {
Expand Down

0 comments on commit 574fb40

Please sign in to comment.