Skip to content

Commit

Permalink
use BN for chain amount conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
bgits committed Jun 16, 2020
1 parent 2235f1b commit 3e7ed35
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/utils/currencies.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*global web3*/
import SNT from '../embarkArtifacts/contracts/SNT'
import SwapProxy from '../embarkArtifacts/contracts/SwapProxy'
import { toEther, toWei } from './conversions'
import { toEther, toWei, toBN } from './conversions'

export const TOKEN_ICON_API = 'https://raw.githubusercontent.com/TrustWallet/tokens/master/images'
export const TOKEN_COIN_API = 'https://raw.githubusercontent.com/TrustWallet/tokens/master/coins'
Expand Down Expand Up @@ -72,10 +72,10 @@ export const generateSetApprovalFn = contract =>
(amount, spender = SwapProxy) => transferApproval(contract, amount, spender)

export const generateHumanReadibleFn = decimals =>
num => (num / (10**decimals)).toString()
num => (toBN(num).div(toBN(10**decimals))).toString()

export const generateChainReadibleFn = decimals =>
num => (num * (10**decimals)).toString()
num => (toBN(num).mul(toBN(10**decimals))).toString()

const order = ['ETH', 'SNT', 'DAI'].reverse()
export const currencyOrder = (a, b) => order.indexOf(b.label) - order.indexOf(a.label)

0 comments on commit 3e7ed35

Please sign in to comment.