mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
transactions - lint fixes
This commit is contained in:
parent
2d7c3c2b00
commit
5494aa4f9c
@ -7,7 +7,7 @@ module.exports = {
|
|||||||
normalizeTxParams,
|
normalizeTxParams,
|
||||||
validateTxParams,
|
validateTxParams,
|
||||||
validateFrom,
|
validateFrom,
|
||||||
validateRecipient
|
validateRecipient,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -48,18 +48,18 @@ function validateTxParams (txParams) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function validateFrom (txParams) {
|
function validateFrom (txParams) {
|
||||||
if ( !(typeof txParams.from === 'string') ) throw new Error(`Invalid from address ${txParams.from} not a string`)
|
if (!(typeof txParams.from === 'string')) throw new Error(`Invalid from address ${txParams.from} not a string`)
|
||||||
if (!isValidAddress(txParams.from)) throw new Error('Invalid from address')
|
if (!isValidAddress(txParams.from)) throw new Error('Invalid from address')
|
||||||
}
|
}
|
||||||
|
|
||||||
function validateRecipient (txParams) {
|
function validateRecipient (txParams) {
|
||||||
if (txParams.to === '0x' || txParams.to === null ) {
|
if (txParams.to === '0x' || txParams.to === null) {
|
||||||
if (txParams.data) {
|
if (txParams.data) {
|
||||||
delete txParams.to
|
delete txParams.to
|
||||||
} else {
|
} else {
|
||||||
throw new Error('Invalid recipient address')
|
throw new Error('Invalid recipient address')
|
||||||
}
|
}
|
||||||
} else if ( txParams.to !== undefined && !isValidAddress(txParams.to) ) {
|
} else if (txParams.to !== undefined && !isValidAddress(txParams.to)) {
|
||||||
throw new Error('Invalid recipient address')
|
throw new Error('Invalid recipient address')
|
||||||
}
|
}
|
||||||
return txParams
|
return txParams
|
||||||
|
@ -92,7 +92,7 @@ module.exports = class TransactionStateManager extends EventEmitter {
|
|||||||
// or rejected tx's.
|
// or rejected tx's.
|
||||||
// not tx's that are pending or unapproved
|
// not tx's that are pending or unapproved
|
||||||
if (txCount > txHistoryLimit - 1) {
|
if (txCount > txHistoryLimit - 1) {
|
||||||
let index = transactions.findIndex((metaTx) => {
|
const index = transactions.findIndex((metaTx) => {
|
||||||
return this.getFinalStates().includes(metaTx.status)
|
return this.getFinalStates().includes(metaTx.status)
|
||||||
})
|
})
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
@ -145,7 +145,7 @@ module.exports = class TransactionStateManager extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validates txParams members by type
|
// validates txParams members by type
|
||||||
validateTxParams(txParams) {
|
validateTxParams (txParams) {
|
||||||
Object.keys(txParams).forEach((key) => {
|
Object.keys(txParams).forEach((key) => {
|
||||||
const value = txParams[key]
|
const value = txParams[key]
|
||||||
// validate types
|
// validate types
|
||||||
@ -263,10 +263,10 @@ module.exports = class TransactionStateManager extends EventEmitter {
|
|||||||
// returns an array of states that can be considered final
|
// returns an array of states that can be considered final
|
||||||
getFinalStates () {
|
getFinalStates () {
|
||||||
return [
|
return [
|
||||||
'rejected', // the user has responded no!
|
'rejected', // the user has responded no!
|
||||||
'confirmed', // the tx has been included in a block.
|
'confirmed', // the tx has been included in a block.
|
||||||
'failed', // the tx failed for some reason, included on tx data.
|
'failed', // the tx failed for some reason, included on tx data.
|
||||||
'dropped', // the tx nonce was already used
|
'dropped', // the tx nonce was already used
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user