Skip to content
This repository was archived by the owner on Apr 25, 2023. It is now read-only.

Commit d621715

Browse files
authored
Merge pull request #27 from witoldsz/send_decimal_amount_fix
send panel: fixed amount rounding to integer values #26
2 parents ea61373 + 4065796 commit d621715

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

front/src/main/panels/send.tsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@ import { publishTx } from '../model/transaction'
1111
import { fetchAccount, AccountType } from '../model/account'
1212
import { addresses, getKey } from '../model/wallet'
1313
import { sem } from '../lib/format'
14+
import BigNumber from 'bignumber.js'
1415

1516
export interface SendState {
1617
accounts: WebData<AccountType[]>
1718
selectedAccountIdx: number
1819
to: string
19-
amount: Long
20+
amount: string
2021
data: string
2122
submit: WebData<{}>
2223
}
@@ -25,7 +26,7 @@ export const initialSendState: SendState = {
2526
accounts: NotAsked,
2627
selectedAccountIdx: 0,
2728
to: '',
28-
amount: Long.ZERO,
29+
amount: '0',
2930
data: '',
3031
submit: NotAsked,
3132
}
@@ -58,11 +59,7 @@ export const rawSendActions: SendActions = {
5859
from: (idx) => (state) => ({ ...state, selectedAccountIdx: idx }),
5960

6061
to: (to) => (state) => ({ ...state, to }),
61-
amount: (amount) => (state) => ({
62-
...state,
63-
amount: Long.fromString(amount).multiply(1e9),
64-
}),
65-
62+
amount: (amount) => (state) => ({ ...state, amount }),
6663
data: (data) => (state) => ({ ...state, data }),
6764

6865
submit: (rootState) => (state, actions) => {
@@ -73,7 +70,7 @@ export const rawSendActions: SendActions = {
7370
Network[info.network],
7471
TransactionType.TRANSFER,
7572
hexBytes(state.to),
76-
state.amount,
73+
Long.fromString(new BigNumber(state.amount).times(1e9).toString()),
7774
Long.fromString('5000000'),
7875
Long.fromNumber(account.nonce),
7976
Long.fromNumber(Date.now()),

0 commit comments

Comments
 (0)