Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I#3669 ignore known transactions on first broadcast and continue with normal flow #7328

Merged
merged 2 commits into from
Oct 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion app/scripts/controllers/transactions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -439,8 +439,19 @@ class TransactionController extends EventEmitter {
const txMeta = this.txStateManager.getTx(txId)
txMeta.rawTx = rawTx
this.txStateManager.updateTx(txMeta, 'transactions#publishTransaction')
const txHash = await this.query.sendRawTransaction(rawTx)
let txHash
try {
txHash = await this.query.sendRawTransaction(rawTx)
} catch (error) {
if (error.message.toLowerCase().includes('known transaction')) {
txHash = ethUtil.sha3(ethUtil.addHexPrefix(rawTx)).toString('hex')
txHash = ethUtil.addHexPrefix(txHash)
} else {
throw error
}
}
this.setTxHash(txId, txHash)

this.txStateManager.setTxStatusSubmitted(txId)
}

Expand Down
10 changes: 10 additions & 0 deletions test/unit/app/controllers/transactions/tx-controller-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,16 @@ describe('Transaction Controller', function () {
assert.equal(publishedTx.hash, hash)
assert.equal(publishedTx.status, 'submitted')
})

it('should ignore the error "Transaction Failed: known transaction" and be as usual', async function () {
providerResultStub['eth_sendRawTransaction'] = async (_, __, ___, end) => { end('Transaction Failed: known transaction') }
const rawTx = '0xf86204831e848082520894f231d46dd78806e1dd93442cf33c7671f853874880802ca05f973e540f2d3c2f06d3725a626b75247593cb36477187ae07ecfe0a4db3cf57a00259b52ee8c58baaa385fb05c3f96116e58de89bcc165cb3bfdfc708672fed8a'
txController.txStateManager.addTx(txMeta)
await txController.publishTransaction(txMeta.id, rawTx)
const publishedTx = txController.txStateManager.getTx(1)
assert.equal(publishedTx.hash, '0x2cc5a25744486f7383edebbf32003e5a66e18135799593d6b5cdd2bb43674f09')
assert.equal(publishedTx.status, 'submitted')
})
})

describe('#retryTransaction', function () {
Expand Down