Skip to content

Commit 39174a3

Browse files
changeset
1 parent 556ad8e commit 39174a3

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

.changeset/cuddly-kings-listen.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
"@thirdweb-dev/wallets": patch
3+
---
4+
5+
Expose function to estimate SmartWallet transactions, handling pre and post deployment state
6+
7+
```ts
8+
const cost = smartWallet.estimate(preparedTx);
9+
const costBatch = smartWallet.estimateBatch(preparedTxs);
10+
```
11+
12+
Also works with raw transactions
13+
14+
```ts
15+
const cost = smartWallet.estimateRaw(rawTx);
16+
const costBatch = smartWallet.estimateBatchRaw(rawTxs);
17+
```

packages/wallets/src/evm/wallets/smart-wallet.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,23 +181,43 @@ export class SmartWallet
181181
return connector.executeRaw(transaction);
182182
}
183183

184+
/**
185+
* Estimate the gas cost of a single transaction
186+
* @param transaction
187+
* @returns
188+
*/
184189
async estimate(transaction: Transaction<any>) {
185190
const connector = await this.getConnector();
186191
return connector.estimate(transaction);
187192
}
188193

194+
/**
195+
* Estimate the gas cost of a batch of transactions
196+
* @param transaction
197+
* @returns
198+
*/
189199
async estimateBatch(transactions: Transaction<any>[]) {
190200
const connector = await this.getConnector();
191201
return connector.estimateBatch(transactions);
192202
}
193203

204+
/**
205+
* Estimate the gas cost of a single raw transaction
206+
* @param transaction
207+
* @returns
208+
*/
194209
async estimateRaw(
195210
transactions: utils.Deferrable<providers.TransactionRequest>,
196211
) {
197212
const connector = await this.getConnector();
198213
return connector.estimateRaw(transactions);
199214
}
200215

216+
/**
217+
* Estimate the gas cost of a batch of raw transactions
218+
* @param transaction
219+
* @returns
220+
*/
201221
async estimateBatchRaw(
202222
transactions: utils.Deferrable<providers.TransactionRequest>[],
203223
) {

0 commit comments

Comments
 (0)