mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Store metamaskId on metaTx instead of getTxWithParams method.
This commit is contained in:
parent
7455a0fa32
commit
532edf670e
@ -161,16 +161,6 @@ ConfigManager.prototype.getTx = function(txId) {
|
|||||||
return matching.length > 0 ? matching[0] : null
|
return matching.length > 0 ? matching[0] : null
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigManager.prototype.getTxWithParams = function(params) {
|
|
||||||
var transactions = this.getTxList()
|
|
||||||
var matching = transactions.filter((tx) => {
|
|
||||||
return Object.keys(tx.txParams).reduce((result, key) => {
|
|
||||||
return ('params' in tx) ? tx.params[key] === params[key] && result : result
|
|
||||||
}, true)
|
|
||||||
})
|
|
||||||
return matching.length > 0 ? matching[0] : null
|
|
||||||
}
|
|
||||||
|
|
||||||
ConfigManager.prototype.confirmTx = function(txId) {
|
ConfigManager.prototype.confirmTx = function(txId) {
|
||||||
this._setTxStatus(txId, 'confirmed')
|
this._setTxStatus(txId, 'confirmed')
|
||||||
}
|
}
|
||||||
|
@ -135,6 +135,7 @@ IdentityStore.prototype.addUnconfirmedTransaction = function(txParams, cb){
|
|||||||
// create txData obj with parameters and meta data
|
// create txData obj with parameters and meta data
|
||||||
var time = (new Date()).getTime()
|
var time = (new Date()).getTime()
|
||||||
var txId = createId()
|
var txId = createId()
|
||||||
|
txParams.metamaskId = txId
|
||||||
var txData = {
|
var txData = {
|
||||||
id: txId,
|
id: txId,
|
||||||
txParams: txParams,
|
txParams: txParams,
|
||||||
@ -337,10 +338,13 @@ function IdManagement(opts) {
|
|||||||
txParams.gasLimit = ethUtil.addHexPrefix(txParams.gasLimit || txParams.gas)
|
txParams.gasLimit = ethUtil.addHexPrefix(txParams.gasLimit || txParams.gas)
|
||||||
txParams.nonce = ethUtil.addHexPrefix(txParams.nonce)
|
txParams.nonce = ethUtil.addHexPrefix(txParams.nonce)
|
||||||
var tx = new Transaction(txParams)
|
var tx = new Transaction(txParams)
|
||||||
|
|
||||||
|
// Add the tx hash to the persisted meta-tx object
|
||||||
var hash = '0x' + tx.hash().toString('hex')
|
var hash = '0x' + tx.hash().toString('hex')
|
||||||
var txLog = configManager.getTxWithParams(txParams)
|
var metaTx = configManager.getTx(txParams.metamaskId)
|
||||||
txLog.hash = hash
|
metaTx.hash = hash
|
||||||
configManager.updateTx(txLog)
|
configManager.updateTx(metaTx)
|
||||||
|
|
||||||
var rawTx = '0x'+tx.serialize().toString('hex')
|
var rawTx = '0x'+tx.serialize().toString('hex')
|
||||||
return '0x'+LightwalletSigner.signTx(this.keyStore, this.derivedKey, rawTx, txParams.from, this.hdPathString)
|
return '0x'+LightwalletSigner.signTx(this.keyStore, this.derivedKey, rawTx, txParams.from, this.hdPathString)
|
||||||
}
|
}
|
||||||
|
@ -156,31 +156,5 @@ describe('config-manager', function() {
|
|||||||
assert.equal(configManager.getTx('2').status, 'confirmed')
|
assert.equal(configManager.getTx('2').status, 'confirmed')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('#getTxWithParams', function() {
|
|
||||||
it('returns a tx with the matching params', function() {
|
|
||||||
configManager.addTx({ id: '1', status: 'unconfirmed', txParams: {
|
|
||||||
from: 'from',
|
|
||||||
to: 'to',
|
|
||||||
data: 'data',
|
|
||||||
value: 'value',
|
|
||||||
}
|
|
||||||
})
|
|
||||||
configManager.addTx({ id: '2', status: 'unconfirmed', txParams: {
|
|
||||||
from: 'from1',
|
|
||||||
to: 'to',
|
|
||||||
data: 'data',
|
|
||||||
value: 'value',
|
|
||||||
}
|
|
||||||
})
|
|
||||||
var result = configManager.getTxWithParams({
|
|
||||||
from: 'from',
|
|
||||||
to: 'to',
|
|
||||||
data: 'data',
|
|
||||||
value: 'value',
|
|
||||||
})
|
|
||||||
assert.equal(result.id, '1')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user