Skip to content

Commit

Permalink
fix SDK bug (#1732)
Browse files Browse the repository at this point in the history
  • Loading branch information
wow-sven authored May 23, 2024
1 parent 156e63f commit 9419580
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { Button } from '@/components/ui/button'
import { Textarea } from '@/components/ui/textarea'

import CustomPagination from '@/components/custom-pagination.tsx'
import {formatCoin} from '@/utils/format.ts';

export const AssetsCoin = () => {
const account = useCurrentAccount()
Expand Down Expand Up @@ -186,7 +187,7 @@ export const AssetsCoin = () => {
{data?.data.map((coin) => (
<TableRow key={coin.name}>
<TableCell>{coin.name}</TableCell>
<TableCell>{coin.balance}</TableCell>
<TableCell>{formatCoin(Number(coin.balance), coin.decimals)}</TableCell>
<TableCell className="text-right">
<Button
variant="link"
Expand Down
5 changes: 5 additions & 0 deletions infra/rooch-portal/src/utils/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@

import { PaymentTypes } from '@/common/interface'

export const formatCoin = (balance: number, decimals: number, precision = 2) => {
const divisor = Math.pow(10, decimals)
return (balance / divisor).toFixed(precision)
}

export const formatAddress = (address?: string) => {
if (!address) {
return ''
Expand Down
11 changes: 1 addition & 10 deletions sdk/typescript/rooch-sdk-kit/src/types/WalletAccount.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// Copyright (c) RoochNetwork
// SPDX-License-Identifier: Apache-2.0

import { IAccount, IAuthorizer, RoochClient, RoochMultiChainID } from '@roochnetwork/rooch-sdk'
import { IAccount, IAuthorizer, RoochClient } from '@roochnetwork/rooch-sdk'

import { MultiChainAddress } from './address'
import { SupportChain } from '../feature'
import { chain2MultiChainID } from '../utils/chain2MultiChainID'

Expand Down Expand Up @@ -37,14 +36,6 @@ export class WalletAccount implements IAccount {
return {}
}

public toMultiChainAddress(): MultiChainAddress | null {
if (this.chain !== SupportChain.ETH) {
return new MultiChainAddress(RoochMultiChainID.Bitcoin, this.address)
}

return null
}

getAddress(): string {
return this.address
}
Expand Down

0 comments on commit 9419580

Please sign in to comment.