@@ -46,7 +46,7 @@ class SmartWalletFactory implements SmartWalletFactoryBase {
4646 @override
4747 Future <SmartWallet > createSafeAccountWithPasskey (PassKeyPair keyPair,
4848 Uint256 salt, EthereumAddress safeWebauthnSharedSigner,
49- [EthereumAddress ? p256Verifier]) {
49+ [EthereumAddress ? p256Verifier, SafeSingletonAddress ? singleton ]) {
5050 final module = Safe4337ModuleAddress .fromVersion (_chain.entrypoint.version);
5151 final verifier = p256Verifier ?? Constants .p256VerifierAddress;
5252
@@ -70,15 +70,16 @@ class SmartWalletFactory implements SmartWalletFactoryBase {
7070 }
7171
7272 return _createSafeAccount (
73- salt, safeWebauthnSharedSigner, module, encodeWebauthnSetup);
73+ salt, safeWebauthnSharedSigner, module, encodeWebauthnSetup, singleton );
7474 }
7575
7676 @override
77- Future <SmartWallet > createSafeAccount (Uint256 salt) {
77+ Future <SmartWallet > createSafeAccount (Uint256 salt,
78+ [SafeSingletonAddress ? singleton]) {
7879 final signer = EthereumAddress .fromHex (_signer.getAddress ());
7980 final module = Safe4337ModuleAddress .fromVersion (_chain.entrypoint.version);
8081
81- return _createSafeAccount (salt, signer, module);
82+ return _createSafeAccount (salt, signer, module, null , singleton );
8283 }
8384
8485 @override
@@ -114,10 +115,11 @@ class SmartWalletFactory implements SmartWalletFactoryBase {
114115
115116 Future <SmartWallet > _createSafeAccount (
116117 Uint256 salt, EthereumAddress signer, Safe4337ModuleAddress module,
117- [Uint8List Function (Uint8List Function ())? setup]) async {
118- final singleton = _chain.chainId == 1
119- ? Constants .safeSingletonAddress
120- : Constants .safeL2SingletonAddress;
118+ [Uint8List Function (Uint8List Function ())? setup,
119+ SafeSingletonAddress ? singleton]) async {
120+ singleton = _chain.chainId == 1
121+ ? SafeSingletonAddress .l1
122+ : singleton ?? SafeSingletonAddress .l2;
121123
122124 // Get the initializer data for the Safe account
123125 final initializer =
@@ -128,7 +130,7 @@ class SmartWalletFactory implements SmartWalletFactoryBase {
128130
129131 // Predict the address of the Safe account
130132 final address = _safeProxyFactory.getPredictedSafe (
131- initializer, salt, creation, singleton);
133+ initializer, salt, creation, singleton.address );
132134
133135 // Encode the call data for the `createProxyWithNonce` function
134136 // This function is used to create the Safe account with the given initializer data and salt
0 commit comments