diff options
author | Alexander Tseung <alextsg@gmail.com> | 2018-08-24 07:44:38 +0800 |
---|---|---|
committer | Alexander Tseung <alextsg@gmail.com> | 2018-08-24 07:45:28 +0800 |
commit | 342522c6cf23670f931e69ba822eedfd2d6ee252 (patch) | |
tree | 7aac360f85308b3022d6f673a5c572385854e690 /ui/app/helpers | |
parent | 2d76ee754b1dd2473d744ce2dba2a3501c9a149c (diff) | |
download | tangerine-wallet-browser-342522c6cf23670f931e69ba822eedfd2d6ee252.tar tangerine-wallet-browser-342522c6cf23670f931e69ba822eedfd2d6ee252.tar.gz tangerine-wallet-browser-342522c6cf23670f931e69ba822eedfd2d6ee252.tar.bz2 tangerine-wallet-browser-342522c6cf23670f931e69ba822eedfd2d6ee252.tar.lz tangerine-wallet-browser-342522c6cf23670f931e69ba822eedfd2d6ee252.tar.xz tangerine-wallet-browser-342522c6cf23670f931e69ba822eedfd2d6ee252.tar.zst tangerine-wallet-browser-342522c6cf23670f931e69ba822eedfd2d6ee252.zip |
Fix naming, add eth.getCode check for actions, fix translations for statuses
Diffstat (limited to 'ui/app/helpers')
-rw-r--r-- | ui/app/helpers/confirm-transaction/util.js | 5 | ||||
-rw-r--r-- | ui/app/helpers/transactions.util.js | 15 |
2 files changed, 13 insertions, 7 deletions
diff --git a/ui/app/helpers/confirm-transaction/util.js b/ui/app/helpers/confirm-transaction/util.js index cbbc27666..d1a4994e4 100644 --- a/ui/app/helpers/confirm-transaction/util.js +++ b/ui/app/helpers/confirm-transaction/util.js @@ -123,8 +123,3 @@ export function roundExponential (value) { // In JS, numbers with exponentials greater than 20 get displayed as an exponential. return bigNumberValue.e > 20 ? Number(bigNumberValue.toPrecision(PRECISION)) : value } - -export async function isSmartContractAddress (address) { - const code = await global.eth.getCode(address) - return code && code !== '0x' -} diff --git a/ui/app/helpers/transactions.util.js b/ui/app/helpers/transactions.util.js index e92a22e16..54df54aa8 100644 --- a/ui/app/helpers/transactions.util.js +++ b/ui/app/helpers/transactions.util.js @@ -41,8 +41,8 @@ export function isConfirmDeployContract (txData = {}) { return !txParams.to } -export function getTransactionActionKey (transaction, methodData) { - const { txParams: { data } = {}, msgParams } = transaction +export async function getTransactionActionKey (transaction, methodData) { + const { txParams: { data, to } = {}, msgParams } = transaction if (msgParams) { return SIGNATURE_REQUEST_KEY @@ -53,6 +53,12 @@ export function getTransactionActionKey (transaction, methodData) { } if (data) { + const toSmartContract = await isSmartContractAddress(to) + + if (!toSmartContract) { + return SEND_ETHER_ACTION_KEY + } + const { name } = methodData const methodName = name && name.toLowerCase() @@ -92,3 +98,8 @@ export function getLatestSubmittedTxWithNonce (transactions = [], nonce = '0x0') } }, {}) } + +export async function isSmartContractAddress (address) { + const code = await global.eth.getCode(address) + return code && code !== '0x' +} |