Skip to content

Commit 1591dae

Browse files
authored
Merge pull request #2185 from AmbireTech/fix/wallet-get-calls-status-request-fixes
Record blockHash, gasUsed in activity
2 parents 4b0d856 + 2d1ad3d commit 1591dae

4 files changed

Lines changed: 35 additions & 6 deletions

File tree

src/controllers/activity/activity.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,9 @@ describe('Activity Controller ', () => {
493493
{
494494
...accountOp,
495495
status: 'success',
496-
blockNumber: controller.accountsOps[sessionId]!.result.items[0]!.blockNumber
496+
blockNumber: controller.accountsOps[sessionId]!.result.items[0]!.blockNumber,
497+
blockHash: controller.accountsOps[sessionId]!.result.items[0]!.blockHash,
498+
gasUsed: controller.accountsOps[sessionId]!.result.items[0]!.gasUsed
497499
}
498500
], // we expect success here
499501
itemsTotal: 1,
@@ -545,7 +547,9 @@ describe('Activity Controller ', () => {
545547
{
546548
...accountOp,
547549
status: 'failure',
548-
blockNumber: controller.accountsOps[sessionId]!.result.items[0]!.blockNumber
550+
blockNumber: controller.accountsOps[sessionId]!.result.items[0]!.blockNumber,
551+
blockHash: controller.accountsOps[sessionId]!.result.items[0]!.blockHash,
552+
gasUsed: controller.accountsOps[sessionId]!.result.items[0]!.gasUsed
549553
}
550554
], // we expect failure here
551555
itemsTotal: 1,

src/controllers/activity/activity.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { toBeHex } from 'ethers'
2+
13
import { Account, AccountId, IAccountsController } from '../../interfaces/account'
24
import { IActivityController } from '../../interfaces/activity'
35
import { Banner } from '../../interfaces/banner'
@@ -615,6 +617,12 @@ export class ActivityController extends EventEmitter implements IActivityControl
615617
// eslint-disable-next-line no-param-reassign
616618
accountOp.blockNumber = receipt.blockNumber
617619

620+
// eslint-disable-next-line no-param-reassign
621+
accountOp.blockHash = receipt.blockHash
622+
623+
// eslint-disable-next-line no-param-reassign
624+
accountOp.gasUsed = toBeHex(receipt.gasUsed)
625+
618626
// Add accounts that are recipients of the AccountOp
619627
const accountOpRecipients = getAccountOpRecipients(
620628
accountOp,

src/libs/accountOp/submittedAccountOp.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Interface, isAddress, TransactionReceipt, ZeroAddress } from 'ethers'
1+
import { Interface, isAddress, toBeHex, TransactionReceipt, ZeroAddress } from 'ethers'
22

33
import { BUNDLER } from '../../consts/bundlers'
44
import { Hex } from '../../interfaces/hex'
@@ -55,6 +55,8 @@ export interface SubmittedAccountOp extends AccountOp {
5555
isSingletonDeploy?: boolean
5656
identifiedBy: AccountOpIdentifiedBy
5757
blockNumber?: number
58+
blockHash?: string
59+
gasUsed?: string
5860
}
5961

6062
export function isIdentifiedByTxn(identifiedBy: AccountOpIdentifiedBy): boolean {
@@ -150,7 +152,7 @@ export async function fetchTxnId(
150152
const txnIds = identifiedBy.identifier.split('-')
151153
return {
152154
status: 'success',
153-
txnId: txnIds[txnIds.length - 1]
155+
txnId: txnIds[txnIds.length - 1]!
154156
}
155157
}
156158

@@ -282,15 +284,27 @@ export function updateOpStatus(
282284
if (opReference.identifiedBy.type === 'MultipleTxns') {
283285
const callIndex = getMultipleBroadcastUnconfirmedCallOrLast(opReference).callIndex
284286
// eslint-disable-next-line no-param-reassign
285-
opReference.calls[callIndex].status = status
287+
opReference.calls[callIndex]!.status = status
286288

287289
// if there's a receipt, add the fee
288290
if (receipt) {
289291
// eslint-disable-next-line no-param-reassign
290-
opReference.calls[callIndex].fee = {
292+
opReference.calls[callIndex]!.fee = {
291293
inToken: ZeroAddress,
292294
amount: receipt.fee
293295
}
296+
297+
// eslint-disable-next-line no-param-reassign
298+
opReference.calls[callIndex]!.blockHash = receipt.blockHash
299+
300+
// eslint-disable-next-line no-param-reassign
301+
opReference.calls[callIndex]!.blockNumber = receipt.blockNumber
302+
303+
// eslint-disable-next-line no-param-reassign
304+
opReference.calls[callIndex]!.blockHash = receipt.blockHash
305+
306+
// eslint-disable-next-line no-param-reassign
307+
opReference.calls[callIndex]!.gasUsed = toBeHex(receipt.gasUsed)
294308
}
295309

296310
if (callIndex === opReference.calls.length - 1) {

src/libs/accountOp/types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ export interface Call {
1818
data: string
1919
txnId?: Hex
2020
status?: AccountOpStatus
21+
blockNumber?: number
22+
blockHash?: string
23+
gasUsed?: string
2124
fee?: {
2225
inToken: string
2326
amount: bigint

0 commit comments

Comments
 (0)