1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 01:47:00 +01:00

idStore - seperate signTx and sendTx

This commit is contained in:
kumavis 2016-02-12 17:57:10 -08:00
parent bc2ec9f464
commit 970e9e2113
2 changed files with 30 additions and 13 deletions

View File

@ -80,6 +80,7 @@ function handleInternalCommunication(remotePort){
setSelectedAddress: idStore.setSelectedAddress.bind(idStore),
signTransaction: idStore.signTransaction.bind(idStore),
cancelTransaction: idStore.cancelTransaction.bind(idStore),
sendTransaction: idStore.sendTransaction.bind(idStore),
setLocked: idStore.setLocked.bind(idStore),
})
duplex.pipe(connection).pipe(duplex)

View File

@ -105,32 +105,48 @@ IdentityStore.prototype.signTransaction = function(password, txId, cb){
var txData = self._currentState.unconfTxs[txId]
var txParams = txData.txParams
self._signTransaction(txParams, function(err, rawTx, txHash){
self._signTransaction(password, txParams, function(err, rawTx, txHash){
if (err) {
throw err
cb(err)
txData.status = 'error'
txData.error = err
self._didUpdate()
return
}
txData.rawTx = rawTx
txData.hash = txHash
txData.status = 'pending'
txData.status = 'signed'
// for now just remove it
delete self._currentState.unconfTxs[txData.id]
// rpc callback
var txSigCb = self._unconfTxCbs[txId] || noop
txSigCb(null, rawTx)
// confirm tx callback
// confirm tx signed
cb()
self._didUpdate()
})
}
IdentityStore.prototype.sendTransaction = function(txId, cb){
const self = this
var txData = self._currentState.unconfTxs[txId]
if (!txData || txData.status !== 'signed') {
return cb(new Error('IdentityStore - Transaction not signed:', txId))
}
var rawTx = txData.rawTx
// for now just remove it
delete self._currentState.unconfTxs[txData.id]
// rpc callback
var txSigCb = self._unconfTxCbs[txId] || noop
txSigCb(null, rawTx)
// confirm tx sent
cb()
self._didUpdate()
}
IdentityStore.prototype.cancelTransaction = function(txId){
const self = this
@ -144,7 +160,7 @@ IdentityStore.prototype.cancelTransaction = function(txId){
//
// internal - actually signs the tx
IdentityStore.prototype._signTransaction = function(txParams, cb){
IdentityStore.prototype._signTransaction = function(password, txParams, cb){
const self = this
try {
// console.log('signing tx:', txParams)