forked from MystenLabs/sui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wallet-ext: improve validation for token transfer and staking (Mysten…
…Labs#6706) * take into account that only one single coin is used for gas
- Loading branch information
1 parent
6caf520
commit 3271796
Showing
11 changed files
with
153 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
apps/wallet/src/ui/app/pages/home/transfer-coin/TransferCoinForm/utils.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import BigNumber from 'bignumber.js'; | ||
|
||
export function parseAmount(amount: string, coinDecimals: number) { | ||
try { | ||
return BigInt( | ||
new BigNumber(amount) | ||
.shiftedBy(coinDecimals) | ||
.integerValue() | ||
.toString() | ||
); | ||
} catch (e) { | ||
return BigInt(0); | ||
} | ||
} |
Oops, something went wrong.