Skip to content

Commit

Permalink
Num fixes 1 (#560)
Browse files Browse the repository at this point in the history
* fix send tokens issue

* number format change and add decimals
  • Loading branch information
dvdschwrtz authored and Ejhfast committed Jan 18, 2018
1 parent af74049 commit 949d909
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
5 changes: 0 additions & 5 deletions app/core/nep5.js

This file was deleted.

20 changes: 11 additions & 9 deletions app/modules/transactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@
import { api, sc, u, wallet } from 'neon-js'
import { flatMap, keyBy } from 'lodash'

import {
setTransactionHistory,
getBalances,
getTokenBalances
} from './wallet'
import { setTransactionHistory, getBalances, getTokenBalances } from './wallet'
import {
showErrorNotification,
showInfoNotification,
Expand All @@ -25,7 +21,6 @@ import { getNetwork } from './metadata'

import { isToken, validateTransactionsBeforeSending } from '../core/wallet'
import { ASSETS } from '../core/constants'
import { adjustDecimalAmountForTokenTransfer } from '../core/nep5'
import asyncWrap from '../core/asyncHelper'
import { toNumber, toBigNumber } from '../core/math'
import { toFixedDecimals, COIN_DECIMAL_LENGTH } from '../core/formatters'
Expand Down Expand Up @@ -55,7 +50,9 @@ export const syncTransactionHistory = (
({ NEO, GAS, txid, block_index }: TransactionHistoryType) => ({
txid,
[ASSETS.NEO]: toFixedDecimals(NEO, 0),
[ASSETS.GAS]: toBigNumber(GAS).round(COIN_DECIMAL_LENGTH).toString()
[ASSETS.GAS]: toBigNumber(GAS)
.round(COIN_DECIMAL_LENGTH)
.toString()
})
)
dispatch(setIsLoadingTransaction(false))
Expand Down Expand Up @@ -123,7 +120,7 @@ const buildTransferScript = (
const args = [
u.reverseHex(fromAcct.scriptHash),
u.reverseHex(toAcct.scriptHash),
adjustDecimalAmountForTokenTransfer(amount, decimals)
sc.ContractParam.byteArray(toNumber(amount), 'fixed8', decimals)
]

scriptBuilder.emitAppCall(scriptHash, 'transfer', args)
Expand All @@ -133,7 +130,12 @@ const buildTransferScript = (
}

const makeRequest = (sendEntries: Array<SendEntryType>, config: Object) => {
const script = buildTransferScript(config.net, sendEntries, config.address, config.tokensBalanceMap)
const script = buildTransferScript(
config.net,
sendEntries,
config.address,
config.tokensBalanceMap
)

if (script === '') {
return api.sendAsset({ ...config, intents: buildIntents(sendEntries) })
Expand Down

0 comments on commit 949d909

Please sign in to comment.