mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Fix action translations edge cases
This commit is contained in:
parent
c8521e49ad
commit
c474f30929
@ -31,7 +31,7 @@ export default class TransactionAction extends PureComponent {
|
|||||||
const { transactionAction } = this.state
|
const { transactionAction } = this.state
|
||||||
const { transaction, methodData } = this.props
|
const { transaction, methodData } = this.props
|
||||||
const { data, done } = methodData
|
const { data, done } = methodData
|
||||||
const { name } = data
|
const { name = '' } = data
|
||||||
|
|
||||||
if (!done || transactionAction) {
|
if (!done || transactionAction) {
|
||||||
return
|
return
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
export function camelCaseToCapitalize (str) {
|
export function camelCaseToCapitalize (str = '') {
|
||||||
return str
|
return str
|
||||||
.replace(/([A-Z])/g, ' $1')
|
.replace(/([A-Z])/g, ' $1')
|
||||||
.replace(/^./, str => str.toUpperCase())
|
.replace(/^./, str => str.toUpperCase())
|
||||||
|
@ -5,6 +5,10 @@ describe('Common utils', () => {
|
|||||||
describe('camelCaseToCapitalize', () => {
|
describe('camelCaseToCapitalize', () => {
|
||||||
it('should return a capitalized string from a camel-cased string', () => {
|
it('should return a capitalized string from a camel-cased string', () => {
|
||||||
const tests = [
|
const tests = [
|
||||||
|
{
|
||||||
|
test: undefined,
|
||||||
|
expected: '',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
test: '',
|
test: '',
|
||||||
expected: '',
|
expected: '',
|
||||||
|
@ -44,6 +44,12 @@ export function isConfirmDeployContract (txData = {}) {
|
|||||||
return !txParams.to
|
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) {
|
export async function getTransactionActionKey (transaction, methodData) {
|
||||||
const { txParams: { data, to } = {}, msgParams, type } = transaction
|
const { txParams: { data, to } = {}, msgParams, type } = transaction
|
||||||
|
|
||||||
@ -80,6 +86,8 @@ export async function getTransactionActionKey (transaction, methodData) {
|
|||||||
return APPROVE_ACTION_KEY
|
return APPROVE_ACTION_KEY
|
||||||
case TOKEN_METHOD_TRANSFER_FROM:
|
case TOKEN_METHOD_TRANSFER_FROM:
|
||||||
return TRANSFER_FROM_ACTION_KEY
|
return TRANSFER_FROM_ACTION_KEY
|
||||||
|
default:
|
||||||
|
return undefined
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return SEND_ETHER_ACTION_KEY
|
return SEND_ETHER_ACTION_KEY
|
||||||
|
Loading…
Reference in New Issue
Block a user