Skip to content

Commit d6f4727

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

File tree

1 file changed

+10
-14
lines changed
  • packages/thirdweb/src/wallets/smart

1 file changed

+10
-14
lines changed

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

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ async function createSmartAccount(
214214
}
215215
}
216216

217-
const { accountContract } = options;
217+
let accountContract = options.accountContract;
218218
const account: Account = {
219219
address: getAddress(accountContract.address),
220220
async sendTransaction(transaction: SendTransactionOption) {
@@ -241,21 +241,17 @@ async function createSmartAccount(
241241
paymasterOverride = options.overrides?.paymaster;
242242
}
243243

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-
})();
244+
// If this transaction is for a different chain than the initial one, get the account contract for that chain
245+
if (transaction.chainId !== accountContract.chain.id) {
246+
accountContract = getContract({
247+
address: account.address,
248+
chain: getCachedChain(transaction.chainId),
249+
client: options.client,
250+
});
251+
}
256252

257253
const executeTx = prepareExecute({
258-
accountContract: accountContractForTransaction,
254+
accountContract: accountContract,
259255
transaction,
260256
executeOverride: options.overrides?.execute,
261257
});

0 commit comments

Comments
 (0)