Skip to content

[AA] Option to not deploy SW on sign message #2222

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/cool-planets-help.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@thirdweb-dev/wallets": patch
---

[AA] Option to not deploy SW on sign message
1 change: 1 addition & 0 deletions packages/unity-js-bridge/src/thirdweb-bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ class ThirdwebBridge implements TWBridge {
paymasterUrl: sdkOptions.smartWalletConfig?.paymasterUrl,
// paymasterAPI: sdkOptions.smartWalletConfig?.paymasterAPI,
entryPointAddress: sdkOptions.smartWalletConfig?.entryPointAddress,
deployOnSign: sdkOptions.smartWalletConfig?.deployOnSign,
};
walletInstance = new SmartWallet(config);
break;
Expand Down
2 changes: 2 additions & 0 deletions packages/wallets/src/evm/connectors/smart-wallet/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export class SmartWalletConnector extends Connector<SmartWalletConnectionArgs> {
this.config.paymasterUrl ||
`https://${this.chainId}.bundler.thirdweb.com/v2`;
const entryPointAddress = config.entryPointAddress || ENTRYPOINT_ADDRESS;
const deployOnSign = config.deployOnSign ?? true;
const localSigner = await params.personalWallet.getSigner();
const providerConfig: ProviderConfig = {
chain: config.chain,
Expand All @@ -69,6 +70,7 @@ export class SmartWalletConnector extends Connector<SmartWalletConnectionArgs> {
this.config.secretKey,
),
gasless: config.gasless,
deployOnSign: deployOnSign,
factoryAddress: config.factoryAddress,
accountAddress: params.accountAddress,
factoryInfo: config.factoryInfo || this.defaultFactoryInfo(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,18 @@ Code: ${errorCode}`;
}

async signMessage(message: Bytes | string): Promise<string> {
const isNotDeployed = await this.smartAccountAPI.checkAccountPhantom();
if (isNotDeployed) {
console.log(
"Account contract not deployed yet. Deploying account before signing message",
);
const tx = await this.sendTransaction({
to: await this.getAddress(),
data: "0x",
});
await tx.wait();
}
const isNotDeployed = await this.smartAccountAPI.checkAccountPhantom();
if (isNotDeployed && this.config.deployOnSign) {
console.log(
"Account contract not deployed yet. Deploying account before signing message",
);
const tx = await this.sendTransaction({
to: await this.getAddress(),
data: "0x",
});
await tx.wait();
}

return await this.originalSigner.signMessage(message);
}

Expand Down
2 changes: 2 additions & 0 deletions packages/wallets/src/evm/connectors/smart-wallet/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export type SmartWalletConfig = {
paymasterUrl?: string;
paymasterAPI?: PaymasterAPI;
entryPointAddress?: string;
deployOnSign?: boolean;
} & ContractInfoInput &
WalletConnectReceiverConfig;

Expand All @@ -42,6 +43,7 @@ export interface ProviderConfig extends ContractInfo {
accountAddress?: string;
paymasterAPI: PaymasterAPI;
gasless: boolean;
deployOnSign?: boolean;
}

export type ContractInfoInput = {
Expand Down