Skip to content

Commit ab9a148

Browse files
[SDK] feat: Add transaction tracking for smart wallets (#6020)
1 parent 8bbee03 commit ab9a148

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

.changeset/light-poets-tie.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
Better transaction tracking for smart wallets

packages/thirdweb/src/wallets/smart/index.ts

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type * as ox__TypedData from "ox/TypedData";
2+
import { trackTransaction } from "../../analytics/track/transaction.js";
23
import type { Chain } from "../../chains/types.js";
34
import { getCachedChain } from "../../chains/utils.js";
45
import type { ThirdwebClient } from "../../client/client.js";
@@ -251,7 +252,8 @@ async function createSmartAccount(
251252
transaction,
252253
executeOverride: options.overrides?.execute,
253254
});
254-
return _sendUserOp({
255+
256+
const result = await _sendUserOp({
255257
executeTx,
256258
options: {
257259
...options,
@@ -263,21 +265,39 @@ async function createSmartAccount(
263265
},
264266
},
265267
});
268+
trackTransaction({
269+
client: options.client,
270+
chainId: options.chain.id,
271+
transactionHash: result.transactionHash,
272+
walletAddress: options.accountContract.address,
273+
walletType: "smart",
274+
contractAddress: transaction.to ?? undefined,
275+
});
276+
return result;
266277
},
267278
async sendBatchTransaction(transactions: SendTransactionOption[]) {
268279
const executeTx = prepareBatchExecute({
269280
accountContract,
270281
transactions,
271282
executeBatchOverride: options.overrides?.executeBatch,
272283
});
273-
return _sendUserOp({
284+
const result = await _sendUserOp({
274285
executeTx,
275286
options: {
276287
...options,
277288
chain: getCachedChain(transactions[0]?.chainId ?? options.chain.id),
278289
accountContract,
279290
},
280291
});
292+
trackTransaction({
293+
client: options.client,
294+
chainId: options.chain.id,
295+
transactionHash: result.transactionHash,
296+
walletAddress: options.accountContract.address,
297+
walletType: "smart",
298+
contractAddress: transactions[0]?.to ?? undefined,
299+
});
300+
return result;
281301
},
282302
async signMessage({ message }: { message: SignableMessage }) {
283303
if (options.overrides?.signMessage) {
@@ -433,6 +453,16 @@ function createZkSyncAccount(args: {
433453
transaction: serializableTransaction,
434454
signedTransaction,
435455
});
456+
457+
trackTransaction({
458+
client: connectionOptions.client,
459+
chainId: chain.id,
460+
transactionHash: txHash.transactionHash,
461+
walletAddress: account.address,
462+
walletType: "smart",
463+
contractAddress: transaction.to ?? undefined,
464+
});
465+
436466
return {
437467
transactionHash: txHash.transactionHash,
438468
client: connectionOptions.client,

0 commit comments

Comments
 (0)