Skip to content

Commit

Permalink
fix: don't mark tx as REVERTED when in block, check tx receipt status…
Browse files Browse the repository at this point in the history
… instead.

    * fixes decentraland#81
  • Loading branch information
tmilar committed Sep 1, 2020
1 parent 5c6c262 commit b74a133
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/modules/transaction/txUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,21 @@ export async function getTransaction(

const receipt = await eth.getTransactionReceipt(hash)

if (receipt == null) {
// pending (in block, but not yet mined)
const tx: PendingTransaction = {
status: TransactionStatus.PENDING,
...response
}
return tx
}

// reverted
if (receipt == null || !receipt.status) {
if (!receipt.status) {
const tx: RevertedTransaction = {
status: TransactionStatus.REVERTED,
...response
...response,
receipt
}
return tx
}
Expand Down
1 change: 1 addition & 0 deletions src/modules/transaction/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export type PendingTransaction = TransactionResponse & {

export type RevertedTransaction = TransactionResponse & {
status: TransactionStatus.REVERTED
receipt: TransactionReceipt
}

export type ConfirmedTransaction = TransactionResponse & {
Expand Down

0 comments on commit b74a133

Please sign in to comment.