Skip to content

Commit 11aa29f

Browse files
committed
fix(sdk): smart account transactions on non-original chain
1 parent 7846be4 commit 11aa29f

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

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

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ import type {
5656
UserOperationV06,
5757
UserOperationV07,
5858
} from "./types.js";
59+
import { isContractDeployed } from "../../utils/bytecode/is-contract-deployed.js";
60+
import {
61+
confirmContractDeployment,
62+
deploySmartAccount,
63+
} from "./lib/signing.js";
5964
/**
6065
* Checks if the provided wallet is a smart wallet.
6166
*
@@ -214,16 +219,16 @@ async function createSmartAccount(
214219
}
215220
}
216221

217-
const { accountContract } = options;
222+
let accountContract = options.accountContract;
218223
const account: Account = {
219224
address: getAddress(accountContract.address),
220225
async sendTransaction(transaction: SendTransactionOption) {
221226
// if erc20 paymaster - check allowance and approve if needed
222227
let paymasterOverride:
223228
| undefined
224229
| ((
225-
userOp: UserOperationV06 | UserOperationV07,
226-
) => Promise<PaymasterResult>) = undefined;
230+
userOp: UserOperationV06 | UserOperationV07,
231+
) => Promise<PaymasterResult>) = undefined;
227232
if (erc20Paymaster) {
228233
await approveERC20({
229234
accountContract,
@@ -241,21 +246,17 @@ async function createSmartAccount(
241246
paymasterOverride = options.overrides?.paymaster;
242247
}
243248

244-
const accountContractForTransaction = (() => {
245-
// If this transaction is for a different chain than the initial one, get the account contract for that chain
246-
if (transaction.chainId !== accountContract.chain.id) {
247-
return getContract({
248-
address: account.address,
249-
chain: getCachedChain(transaction.chainId),
250-
client: options.client,
251-
});
252-
}
253-
// Default to the existing account contract
254-
return accountContract;
255-
})();
249+
// If this transaction is for a different chain than the initial one, get the account contract for that chain
250+
if (transaction.chainId !== accountContract.chain.id) {
251+
accountContract = getContract({
252+
address: account.address,
253+
chain: getCachedChain(transaction.chainId),
254+
client: options.client,
255+
});
256+
}
256257

257258
const executeTx = prepareExecute({
258-
accountContract: accountContractForTransaction,
259+
accountContract: accountContract,
259260
transaction,
260261
executeOverride: options.overrides?.execute,
261262
});

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ describe.runIf(process.env.TW_SECRET_KEY)(
158158
expect(isValid).toEqual(true);
159159
});
160160

161-
it("can send a transaction on another chain", async () => {
161+
it.only("can send a transaction on another chain", async () => {
162162
const tx = await sendAndConfirmTransaction({
163163
transaction: prepareTransaction({
164164
to: TEST_WALLET_A,

0 commit comments

Comments
 (0)