Skip to content

Commit 82c8726

Browse files
fix: respect custom paymaster callback (#5246)
1 parent 60629e3 commit 82c8726

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

.changeset/smart-donkeys-jam.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+
Fix custom paymaster callback not being respected

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,8 @@ async function createSmartAccount(
225225
};
226226
};
227227
paymasterOverride = options.overrides?.paymaster || paymasterCallback;
228+
} else {
229+
paymasterOverride = options.overrides?.paymaster;
228230
}
229231
const executeTx = prepareExecute({
230232
accountContract,

packages/thirdweb/src/wallets/smart/smart-wallet-integration.test.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ import { setContractURI } from "../../extensions/marketplace/__generated__/IMark
1818
import { estimateGasCost } from "../../transaction/actions/estimate-gas-cost.js";
1919
import { sendAndConfirmTransaction } from "../../transaction/actions/send-and-confirm-transaction.js";
2020
import { sendBatchTransaction } from "../../transaction/actions/send-batch-transaction.js";
21+
import { sendTransaction } from "../../transaction/actions/send-transaction.js";
2122
import { waitForReceipt } from "../../transaction/actions/wait-for-tx-receipt.js";
23+
import { prepareTransaction } from "../../transaction/prepare-transaction.js";
2224
import { isContractDeployed } from "../../utils/bytecode/is-contract-deployed.js";
2325
import { sleep } from "../../utils/sleep.js";
2426
import type { Account, Wallet } from "../interfaces/wallet.js";
@@ -364,5 +366,36 @@ describe.runIf(process.env.TW_SECRET_KEY).sequential(
364366
});
365367
expect(balance).toEqual(2n);
366368
});
369+
370+
it("can use a different paymaster", async () => {
371+
const wallet = smartWallet({
372+
chain,
373+
factoryAddress: factoryAddress,
374+
gasless: true,
375+
overrides: {
376+
paymaster: async () => {
377+
return {
378+
paymaster: "0x",
379+
paymasterData: "0x",
380+
};
381+
},
382+
},
383+
});
384+
const newSmartAccount = await wallet.connect({
385+
client: TEST_CLIENT,
386+
personalAccount,
387+
});
388+
const transaction = prepareTransaction({
389+
client: TEST_CLIENT,
390+
chain,
391+
value: 0n,
392+
});
393+
await expect(
394+
sendTransaction({
395+
transaction,
396+
account: newSmartAccount,
397+
}),
398+
).rejects.toThrowError(/AA21 didn't pay prefund/);
399+
});
367400
},
368401
);

0 commit comments

Comments
 (0)