Skip to content

Commit 6b523c0

Browse files
committed
allow forcing deploy/skip_deploy behaviour
1 parent 21938f9 commit 6b523c0

File tree

1 file changed

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

1 file changed

+14
-1
lines changed

packages/thirdweb/src/wallets/smart/lib/userop.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ export async function createUnsignedUserOp(args: {
136136
adminAddress: string;
137137
sponsorGas: boolean;
138138
waitForDeployment?: boolean;
139+
forceDeployment?: "force_deploy" | "force_skip_deploy";
139140
overrides?: SmartWalletOptions["overrides"];
140141
}): Promise<UserOperationV06 | UserOperationV07> {
141142
const {
@@ -146,6 +147,7 @@ export async function createUnsignedUserOp(args: {
146147
overrides,
147148
sponsorGas,
148149
waitForDeployment = true,
150+
forceDeployment,
149151
} = args;
150152
const chain = executeTx.chain;
151153
const client = executeTx.client;
@@ -161,9 +163,18 @@ export async function createUnsignedUserOp(args: {
161163
args.overrides?.entrypointAddress || ENTRYPOINT_ADDRESS_v0_6,
162164
);
163165

166+
const isDeployedOverride = forceDeployment
167+
? {
168+
force_deploy: true,
169+
force_skip_deploy: false,
170+
}[forceDeployment]
171+
: undefined;
172+
164173
const [isDeployed, callData, callGasLimit, gasFees, nonce] =
165174
await Promise.all([
166-
isContractDeployed(accountContract),
175+
typeof isDeployedOverride === "boolean"
176+
? isDeployedOverride
177+
: isContractDeployed(accountContract),
167178
encode(executeTx),
168179
resolvePromisedValue(executeTx.gas),
169180
getGasFees({
@@ -699,6 +710,7 @@ export async function createAndSignUserOp(options: {
699710
client: ThirdwebClient;
700711
smartWalletOptions: SmartWalletOptions;
701712
waitForDeployment?: boolean;
713+
forceDeployment?: "force_deploy" | "force_skip_deploy";
702714
}) {
703715
const config = options.smartWalletOptions;
704716
const factoryContract = getContract({
@@ -757,6 +769,7 @@ export async function createAndSignUserOp(options: {
757769
sponsorGas: "sponsorGas" in config ? config.sponsorGas : config.gasless,
758770
overrides: config.overrides,
759771
waitForDeployment: options.waitForDeployment,
772+
forceDeployment: options.forceDeployment,
760773
});
761774
const signedUserOp = await signUserOp({
762775
client: options.client,

0 commit comments

Comments
 (0)