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

Commit

Permalink
Merge pull request #27 from witoldsz/send_decimal_amount_fix
Browse files Browse the repository at this point in the history
send panel: fixed amount rounding to integer values #26
  • Loading branch information
witoldsz authored Aug 6, 2018
2 parents ea61373 + 4065796 commit d621715
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions front/src/main/panels/send.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ import { publishTx } from '../model/transaction'
import { fetchAccount, AccountType } from '../model/account'
import { addresses, getKey } from '../model/wallet'
import { sem } from '../lib/format'
import BigNumber from 'bignumber.js'

export interface SendState {
accounts: WebData<AccountType[]>
selectedAccountIdx: number
to: string
amount: Long
amount: string
data: string
submit: WebData<{}>
}
Expand All @@ -25,7 +26,7 @@ export const initialSendState: SendState = {
accounts: NotAsked,
selectedAccountIdx: 0,
to: '',
amount: Long.ZERO,
amount: '0',
data: '',
submit: NotAsked,
}
Expand Down Expand Up @@ -58,11 +59,7 @@ export const rawSendActions: SendActions = {
from: (idx) => (state) => ({ ...state, selectedAccountIdx: idx }),

to: (to) => (state) => ({ ...state, to }),
amount: (amount) => (state) => ({
...state,
amount: Long.fromString(amount).multiply(1e9),
}),

amount: (amount) => (state) => ({ ...state, amount }),
data: (data) => (state) => ({ ...state, data }),

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

0 comments on commit d621715

Please sign in to comment.