Skip to content

Commit

Permalink
Merge pull request #169 from blocknative/release/4.0.0
Browse files Browse the repository at this point in the history
Release 4.0.0
  • Loading branch information
lnbc1QWFyb24 authored Jan 26, 2022
2 parents 7fc29c3 + 8fe2ec2 commit 8202a07
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bnc-sdk",
"version": "3.7.1",
"version": "4.0.0",
"description": "SDK to connect to the blocknative backend via a websocket connection",
"keywords": [
"ethereum",
Expand Down
16 changes: 14 additions & 2 deletions src/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,8 @@ export function handleMessage(this: any, msg: { data: string }): void {

// replace originalHash to match webhook API
if (newState.originalHash) {
newState.replaceHash = newState.originalHash
newState.replaceHash = newState.hash
newState.hash = newState.originalHash
delete newState.originalHash
}

Expand Down Expand Up @@ -296,7 +297,7 @@ export function handleMessage(this: any, msg: { data: string }): void {
)
} else {
const transactionObj = this._watchedTransactions.find(
(tx: Tx) => tx.hash === transaction.hash || transaction.txid
(tx: Tx) => tx.hash === newState.hash || newState.txid
)

const emitterResult =
Expand All @@ -305,6 +306,17 @@ export function handleMessage(this: any, msg: { data: string }): void {
this._transactionHandlers.forEach((handler: TransactionHandler) =>
handler({ transaction: newState, emitterResult })
)

// replace the emitter hash to the replace hash on replacement txs
if (newState.status === 'speedup' || newState.status === 'cancel') {
this._watchedTransactions = this._watchedTransactions.map((tx: Tx) => {
if (tx.hash === newState.hash || newState.txid) {
return { ...tx, hash: newState.replaceHash }
}

return tx
})
}
}
}
}
Expand Down

0 comments on commit 8202a07

Please sign in to comment.