on master help sign in
Merge pull request #321 from urbit/mino-bignum-2
b8ac70bFang
src/lib/error.js+3−3
@@ -1,4 +1,4 @@
1−import { fromWei } from 'web3-utils';
1+import { fromWei, toBN } from 'web3-utils';
2
2
3const BRIDGE_ERROR = {
3const BRIDGE_ERROR = {
4 MISSING_WEB3: 'no web3 object found',
4 MISSING_WEB3: 'no web3 object found',
@@ -18,13 +18,13 @@ const BRIDGE_ERROR = {
18const renderTxnError = (web3, msg) => {
18const renderTxnError = (web3, msg) => {
19 const txnCost = (web3, msg) => {
19 const txnCost = (web3, msg) => {
20 const costWei = msg.match(/upfront cost is: ([0-9]+)/);
20 const costWei = msg.match(/upfront cost is: ([0-9]+)/);
21− const costEth = fromWei(costWei[1], 'ether');
21+ const costEth = fromWei(toBN(costWei[1]), 'ether');
22 return parseFloat(costEth).toFixed(4);
22 return parseFloat(costEth).toFixed(4);
23 };
23 };
24
24
25 const acctBalance = (web3, msg) => {
25 const acctBalance = (web3, msg) => {
26 const balWei = msg.match(/sender's account only has: ([0-9]+)/);
26 const balWei = msg.match(/sender's account only has: ([0-9]+)/);
27− const balEth = fromWei(balWei[1], 'ether');
27+ const balEth = fromWei(toBN(balWei[1]), 'ether');
28 return parseFloat(balEth).toFixed(4);
28 return parseFloat(balEth).toFixed(4);
29 };
29 };
30
30
src/lib/txn.js+2−2
@@ -1,5 +1,5 @@
1import Tx from 'ethereumjs-tx';
1import Tx from 'ethereumjs-tx';
2−import { toWei, fromWei, toHex } from 'web3-utils';
2+import { toWei, fromWei, toHex, toBN } from 'web3-utils';
3import retry from 'async-retry';
3import retry from 'async-retry';
4
4
5import { NETWORK_TYPES } from './network';
5import { NETWORK_TYPES } from './network';
@@ -193,7 +193,7 @@ const getTxnInfo = async (web3, addr) => {
193 return {
193 return {
194 nonce: nonce,
194 nonce: nonce,
195 chainId: chainId,
195 chainId: chainId,
196− gasPrice: fromWei(gasPrice, 'gwei'),
196+ gasPrice: fromWei(toBN(gasPrice), 'gwei'),
197 };
197 };
198};
198};
199
199