aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/helpers/utils/transactions.util.js
diff options
context:
space:
mode:
Diffstat (limited to 'ui/app/helpers/utils/transactions.util.js')
-rw-r--r--ui/app/helpers/utils/transactions.util.js20
1 files changed, 15 insertions, 5 deletions
diff --git a/ui/app/helpers/utils/transactions.util.js b/ui/app/helpers/utils/transactions.util.js
index c84053ec7..b65bda5b2 100644
--- a/ui/app/helpers/utils/transactions.util.js
+++ b/ui/app/helpers/utils/transactions.util.js
@@ -103,6 +103,20 @@ export function getFourBytePrefix (data = '') {
}
/**
+ * Given an transaction category, returns a boolean which indicates whether the transaction is calling an erc20 token method
+ *
+ * @param {string} transactionCategory - The category of transaction being evaluated
+ * @returns {boolean} - whether the transaction is calling an erc20 token method
+ */
+export function isTokenMethodAction (transactionCategory) {
+ return [
+ TOKEN_METHOD_TRANSFER,
+ TOKEN_METHOD_APPROVE,
+ TOKEN_METHOD_TRANSFER_FROM,
+ ].includes(transactionCategory)
+}
+
+/**
* Returns the action of a transaction as a key to be passed into the translator.
* @param {Object} transaction - txData object
* @returns {string|undefined}
@@ -122,11 +136,7 @@ export function getTransactionActionKey (transaction) {
return DEPLOY_CONTRACT_ACTION_KEY
}
- const isTokenAction = [
- TOKEN_METHOD_TRANSFER,
- TOKEN_METHOD_APPROVE,
- TOKEN_METHOD_TRANSFER_FROM,
- ].find(actionName => actionName === transactionCategory)
+ const isTokenAction = isTokenMethodAction(transactionCategory)
const isNonTokenSmartContract = transactionCategory === CONTRACT_INTERACTION_KEY
if (isTokenAction || isNonTokenSmartContract) {