Skip to content

Commit

Permalink
[AA] Option to not deploy SW on sign message (#2222)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xFirekeeper authored Jan 26, 2024
1 parent 3d63a2c commit bf90fa5
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 11 deletions.
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

0 comments on commit bf90fa5

Please sign in to comment.