diff options
author | Chi Kei Chan <chikeichan@gmail.com> | 2017-10-26 10:46:42 +0800 |
---|---|---|
committer | Chi Kei Chan <chikeichan@gmail.com> | 2017-10-26 10:46:42 +0800 |
commit | db5326dfc288015a4d9f792653a71fd4d7abca33 (patch) | |
tree | cb93f52f999816d07a6146274093aaebdb7ed8d3 /ui/app/components/send/send-utils.js | |
parent | a9a841ba01f6bffa29a3e0491e3a88f6aff72ac7 (diff) | |
parent | b2e440e4ffba6db29cf8a928a41534c1f204d485 (diff) | |
download | tangerine-wallet-browser-db5326dfc288015a4d9f792653a71fd4d7abca33.tar tangerine-wallet-browser-db5326dfc288015a4d9f792653a71fd4d7abca33.tar.gz tangerine-wallet-browser-db5326dfc288015a4d9f792653a71fd4d7abca33.tar.bz2 tangerine-wallet-browser-db5326dfc288015a4d9f792653a71fd4d7abca33.tar.lz tangerine-wallet-browser-db5326dfc288015a4d9f792653a71fd4d7abca33.tar.xz tangerine-wallet-browser-db5326dfc288015a4d9f792653a71fd4d7abca33.tar.zst tangerine-wallet-browser-db5326dfc288015a4d9f792653a71fd4d7abca33.zip |
Merge branch 'NewUI-flat' into uat
Diffstat (limited to 'ui/app/components/send/send-utils.js')
-rw-r--r-- | ui/app/components/send/send-utils.js | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/ui/app/components/send/send-utils.js b/ui/app/components/send/send-utils.js new file mode 100644 index 000000000..bf096d610 --- /dev/null +++ b/ui/app/components/send/send-utils.js @@ -0,0 +1,39 @@ +const { addCurrencies, conversionGreaterThan } = require('../../conversion-util') + +function isBalanceSufficient({ + amount, + gasTotal, + balance, + primaryCurrency, + selectedToken, + amountConversionRate, + conversionRate, +}) { + const totalAmount = addCurrencies(amount, gasTotal, { + aBase: 16, + bBase: 16, + toNumericBase: 'hex', + }) + + const balanceIsSufficient = conversionGreaterThan( + { + value: balance, + fromNumericBase: 'hex', + fromCurrency: primaryCurrency, + conversionRate, + }, + { + value: totalAmount, + fromNumericBase: 'hex', + conversionRate: amountConversionRate, + fromCurrency: selectedToken || primaryCurrency, + conversionRate: amountConversionRate, + }, + ) + + return balanceIsSufficient +} + +module.exports = { + isBalanceSufficient, +}
\ No newline at end of file |