From 18496ad8595acd9fa8ec333fcd73de1ddfb8d62a Mon Sep 17 00:00:00 2001 From: sdtsui Date: Tue, 22 Aug 2017 16:16:56 -0700 Subject: Render TxListItem component from real data: address, identicon, status, ETH value --- ui/app/util.js | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'ui/app/util.js') diff --git a/ui/app/util.js b/ui/app/util.js index ac3f42c6b..4dd0e30f3 100644 --- a/ui/app/util.js +++ b/ui/app/util.js @@ -1,4 +1,10 @@ const ethUtil = require('ethereumjs-util') +const vreme = new (require('vreme'))() + +// formatData :: ( date: ) -> String +function formatDate (date) { + return vreme.format(new Date(date), 'March 16 2014 14:30') +} var valueTable = { wei: '1000000000000000000', @@ -36,6 +42,7 @@ module.exports = { valueTable: valueTable, bnTable: bnTable, isHex: isHex, + formatDate, } function valuesFor (obj) { -- cgit v1.2.3 From cd351e8aef59f314c170d0436d98aaf111db1c00 Mon Sep 17 00:00:00 2001 From: Dan Date: Mon, 28 Aug 2017 20:36:10 -0230 Subject: Move getTaxBN and bnMultiplyByFraction to util.js --- ui/app/util.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'ui/app/util.js') diff --git a/ui/app/util.js b/ui/app/util.js index 4dd0e30f3..4b48db0ca 100644 --- a/ui/app/util.js +++ b/ui/app/util.js @@ -1,4 +1,5 @@ const ethUtil = require('ethereumjs-util') +const hexToBn = require('../../app/scripts/lib/hex-to-bn') const vreme = new (require('vreme'))() // formatData :: ( date: ) -> String @@ -43,6 +44,8 @@ module.exports = { bnTable: bnTable, isHex: isHex, formatDate, + bnMultiplyByFraction, + getTxFeeBn, } function valuesFor (obj) { @@ -222,3 +225,24 @@ function readableDate (ms) { function isHex (str) { return Boolean(str.match(/^(0x)?[0-9a-fA-F]+$/)) } + +function bnMultiplyByFraction (targetBN, numerator, denominator) { + const numBN = new ethUtil.BN(numerator) + const denomBN = new ethUtil.BN(denominator) + return targetBN.mul(numBN).div(denomBN) +} + +function getTxFeeBn (gas, gasPrice = MIN_GAS_PRICE_BN.toString(16), blockGasLimit) { + const gasBn = hexToBn(gas) + const gasLimit = new ethUtil.BN(parseInt(blockGasLimit)) + const safeGasLimit = bnMultiplyByFraction(gasLimit, 19, 20).toString(10) + + // Gas Price + const gasPriceBn = hexToBn(gasPrice) + const txFeeBn = gasBn.mul(gasPriceBn) + + const fiatMultiplier = hexToBn((1000000000).toString(16)) + const txFeeAsFiatBn = txFeeBn.mul(fiatMultiplier) + + return txFeeAsFiatBn; +} -- cgit v1.2.3 From cd5861541c1cb871d5e3b606501931f2aee0d048 Mon Sep 17 00:00:00 2001 From: Dan Date: Tue, 29 Aug 2017 10:21:31 -0230 Subject: Use hex values only in send.js to handle limit and price; GasTooltip accepts and returns values as hex (allows user to enter floats) --- ui/app/util.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'ui/app/util.js') diff --git a/ui/app/util.js b/ui/app/util.js index 4b48db0ca..a624726e2 100644 --- a/ui/app/util.js +++ b/ui/app/util.js @@ -233,6 +233,7 @@ function bnMultiplyByFraction (targetBN, numerator, denominator) { } function getTxFeeBn (gas, gasPrice = MIN_GAS_PRICE_BN.toString(16), blockGasLimit) { + // Gas Limit const gasBn = hexToBn(gas) const gasLimit = new ethUtil.BN(parseInt(blockGasLimit)) const safeGasLimit = bnMultiplyByFraction(gasLimit, 19, 20).toString(10) @@ -240,9 +241,6 @@ function getTxFeeBn (gas, gasPrice = MIN_GAS_PRICE_BN.toString(16), blockGasLimi // Gas Price const gasPriceBn = hexToBn(gasPrice) const txFeeBn = gasBn.mul(gasPriceBn) - - const fiatMultiplier = hexToBn((1000000000).toString(16)) - const txFeeAsFiatBn = txFeeBn.mul(fiatMultiplier) - return txFeeAsFiatBn; + return txFeeBn.toString(16); } -- cgit v1.2.3 From e7b3ef0708290a81dad5c469adaa6fab3f1c45b5 Mon Sep 17 00:00:00 2001 From: Dan Date: Tue, 29 Aug 2017 12:20:48 -0230 Subject: Lint fixes --- ui/app/util.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'ui/app/util.js') diff --git a/ui/app/util.js b/ui/app/util.js index a624726e2..bea781466 100644 --- a/ui/app/util.js +++ b/ui/app/util.js @@ -2,6 +2,10 @@ const ethUtil = require('ethereumjs-util') const hexToBn = require('../../app/scripts/lib/hex-to-bn') const vreme = new (require('vreme'))() +const MIN_GAS_PRICE_GWEI_BN = new ethUtil.BN(1) +const GWEI_FACTOR = new ethUtil.BN(1e9) +const MIN_GAS_PRICE_BN = MIN_GAS_PRICE_GWEI_BN.mul(GWEI_FACTOR) + // formatData :: ( date: ) -> String function formatDate (date) { return vreme.format(new Date(date), 'March 16 2014 14:30') @@ -233,14 +237,9 @@ function bnMultiplyByFraction (targetBN, numerator, denominator) { } function getTxFeeBn (gas, gasPrice = MIN_GAS_PRICE_BN.toString(16), blockGasLimit) { - // Gas Limit const gasBn = hexToBn(gas) - const gasLimit = new ethUtil.BN(parseInt(blockGasLimit)) - const safeGasLimit = bnMultiplyByFraction(gasLimit, 19, 20).toString(10) - - // Gas Price const gasPriceBn = hexToBn(gasPrice) const txFeeBn = gasBn.mul(gasPriceBn) - return txFeeBn.toString(16); + return txFeeBn.toString(16) } -- cgit v1.2.3 From 8f31b05ac5b7d8383c720b8b0c9f7f3cecc937f5 Mon Sep 17 00:00:00 2001 From: Chi Kei Chan Date: Wed, 13 Sep 2017 01:25:39 -0700 Subject: Add token exchange rates --- ui/app/util.js | 1 + 1 file changed, 1 insertion(+) (limited to 'ui/app/util.js') diff --git a/ui/app/util.js b/ui/app/util.js index bea781466..e058dc92b 100644 --- a/ui/app/util.js +++ b/ui/app/util.js @@ -50,6 +50,7 @@ module.exports = { formatDate, bnMultiplyByFraction, getTxFeeBn, + shortenBalance, } function valuesFor (obj) { -- cgit v1.2.3 From d722c1045f70954cb1a97de52cae5084a6f14815 Mon Sep 17 00:00:00 2001 From: Chi Kei Chan Date: Wed, 13 Sep 2017 19:57:33 -0700 Subject: Update yarn.lock; Fix tx-list-item overflow; Fix gas exchange rate --- ui/app/util.js | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'ui/app/util.js') diff --git a/ui/app/util.js b/ui/app/util.js index e058dc92b..6596ebafb 100644 --- a/ui/app/util.js +++ b/ui/app/util.js @@ -1,3 +1,4 @@ +const abi = require('human-standard-token-abi') const ethUtil = require('ethereumjs-util') const hexToBn = require('../../app/scripts/lib/hex-to-bn') const vreme = new (require('vreme'))() @@ -51,6 +52,7 @@ module.exports = { bnMultiplyByFraction, getTxFeeBn, shortenBalance, + getContractAtAddress, } function valuesFor (obj) { @@ -244,3 +246,7 @@ function getTxFeeBn (gas, gasPrice = MIN_GAS_PRICE_BN.toString(16), blockGasLimi return txFeeBn.toString(16) } + +function getContractAtAddress (tokenAddress) { + return global.eth.contract(abi).at(tokenAddress) +} -- cgit v1.2.3 From 14bdc5a78c8529742754d69b8e45693b06b380fe Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 20 Sep 2017 15:07:12 -0230 Subject: Client side error handling for from, to and amount fields in send.js --- ui/app/util.js | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'ui/app/util.js') diff --git a/ui/app/util.js b/ui/app/util.js index 7aace1b3c..82a5f9f29 100644 --- a/ui/app/util.js +++ b/ui/app/util.js @@ -55,6 +55,7 @@ module.exports = { getContractAtAddress, exportAsFile: exportAsFile, isInvalidChecksumAddress, + allNull, } function valuesFor (obj) { @@ -273,3 +274,7 @@ function exportAsFile (filename, data) { document.body.removeChild(elem) } } + +function allNull (obj) { + return Object.entries(obj).every(([key, value]) => value === null) +} -- cgit v1.2.3