aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Tseung <alextsg@users.noreply.github.com>2018-10-06 04:37:00 +0800
committerGitHub <noreply@github.com>2018-10-06 04:37:00 +0800
commit874a86a6abac2fb152a8bc9492c4d80b8722b0e6 (patch)
treec6681af2ce10c793ecdd98a3c4dc960bed60efd3
parentc8521e49adc253cf3c18812dc062c67075b42fc5 (diff)
parentc474f30929e91fc2aeadba7de9faef70d4ce2e07 (diff)
downloadtangerine-wallet-browser-874a86a6abac2fb152a8bc9492c4d80b8722b0e6.tar
tangerine-wallet-browser-874a86a6abac2fb152a8bc9492c4d80b8722b0e6.tar.gz
tangerine-wallet-browser-874a86a6abac2fb152a8bc9492c4d80b8722b0e6.tar.bz2
tangerine-wallet-browser-874a86a6abac2fb152a8bc9492c4d80b8722b0e6.tar.lz
tangerine-wallet-browser-874a86a6abac2fb152a8bc9492c4d80b8722b0e6.tar.xz
tangerine-wallet-browser-874a86a6abac2fb152a8bc9492c4d80b8722b0e6.tar.zst
tangerine-wallet-browser-874a86a6abac2fb152a8bc9492c4d80b8722b0e6.zip
Merge pull request #5440 from alextsg/fix-translate
Fix action translations edge cases
-rw-r--r--ui/app/components/transaction-action/transaction-action.component.js2
-rw-r--r--ui/app/helpers/common.util.js2
-rw-r--r--ui/app/helpers/tests/common.util.test.js4
-rw-r--r--ui/app/helpers/transactions.util.js8
4 files changed, 14 insertions, 2 deletions
diff --git a/ui/app/components/transaction-action/transaction-action.component.js b/ui/app/components/transaction-action/transaction-action.component.js
index 85761c089..1de91cb71 100644
--- a/ui/app/components/transaction-action/transaction-action.component.js
+++ b/ui/app/components/transaction-action/transaction-action.component.js
@@ -31,7 +31,7 @@ export default class TransactionAction extends PureComponent {
const { transactionAction } = this.state
const { transaction, methodData } = this.props
const { data, done } = methodData
- const { name } = data
+ const { name = '' } = data
if (!done || transactionAction) {
return
diff --git a/ui/app/helpers/common.util.js b/ui/app/helpers/common.util.js
index d4acb9968..0c02481e6 100644
--- a/ui/app/helpers/common.util.js
+++ b/ui/app/helpers/common.util.js
@@ -1,4 +1,4 @@
-export function camelCaseToCapitalize (str) {
+export function camelCaseToCapitalize (str = '') {
return str
.replace(/([A-Z])/g, ' $1')
.replace(/^./, str => str.toUpperCase())
diff --git a/ui/app/helpers/tests/common.util.test.js b/ui/app/helpers/tests/common.util.test.js
index 891e19ef5..a52b91a10 100644
--- a/ui/app/helpers/tests/common.util.test.js
+++ b/ui/app/helpers/tests/common.util.test.js
@@ -6,6 +6,10 @@ describe('Common utils', () => {
it('should return a capitalized string from a camel-cased string', () => {
const tests = [
{
+ test: undefined,
+ expected: '',
+ },
+ {
test: '',
expected: '',
},
diff --git a/ui/app/helpers/transactions.util.js b/ui/app/helpers/transactions.util.js
index fdad63a96..f7d249e63 100644
--- a/ui/app/helpers/transactions.util.js
+++ b/ui/app/helpers/transactions.util.js
@@ -44,6 +44,12 @@ export function isConfirmDeployContract (txData = {}) {
return !txParams.to
}
+/**
+ * Returns the action of a transaction as a key to be passed into the translator.
+ * @param {Object} transaction - txData object
+ * @param {Object} methodData - Data returned from eth-method-registry
+ * @returns {string|undefined}
+ */
export async function getTransactionActionKey (transaction, methodData) {
const { txParams: { data, to } = {}, msgParams, type } = transaction
@@ -80,6 +86,8 @@ export async function getTransactionActionKey (transaction, methodData) {
return APPROVE_ACTION_KEY
case TOKEN_METHOD_TRANSFER_FROM:
return TRANSFER_FROM_ACTION_KEY
+ default:
+ return undefined
}
} else {
return SEND_ETHER_ACTION_KEY