@@ -15,30 +15,38 @@ class WalletProvider extends ChangeNotifier {
1515 String get errorMessage => _errorMessage;
1616
1717 final EthereumAddress nft =
18- EthereumAddress .fromHex ("0x4B509a7e891Dc8fd45491811d67a8B9e7ef547B9 " );
18+ EthereumAddress .fromHex ("0x3661b40C520a273214d281bd84730BA68604d874 " );
1919 final EthereumAddress erc20 =
20- EthereumAddress .fromHex ("0xAEaF19097D8a8da728438D6B57edd9Bc5DAc4795 " );
20+ EthereumAddress .fromHex ("0x69583ED4AA579fdc83FB6CCF13A5Ffd9B39F62aF " );
2121 final EthereumAddress deployer =
2222 EthereumAddress .fromHex ("0xf5bb7f874d8e3f41821175c0aa9910d30d10e193" );
23+ final EthereumAddress sharedSigner =
24+ EthereumAddress .fromHex ("0x94a4F6affBd8975951142c3999aEAB7ecee555c2" );
25+ final EthereumAddress p256Verifier =
26+ EthereumAddress .fromHex ("0xc2b78104907F722DABAc4C69f826a522B2754De4" );
2327
2428 final salt = Uint256 .zero;
25- static const rpc = "https://api.pimlico.io/v2/84532/rpc?apikey=API_KEY" ;
29+ static const rpc =
30+ "https://api.pimlico.io/v2/123/rpc?apikey=${"PIMLICO_API_KEY" }" ;
2631
2732 WalletProvider ()
28- : _chain = Chains .getChain (Network .baseTestnet)
29- ..accountFactory = Constants .lightAccountFactoryAddressv07
30- ..bundlerUrl = rpc
31- ..paymasterUrl = rpc;
33+ : _chain = Chain (
34+ bundlerUrl: rpc,
35+ // paymasterUrl: rpc, // for fuse network, not really working.
36+ testnet: true ,
37+ chainId: 123 ,
38+ jsonRpcUrl: "https://rpc.fusespark.io" ,
39+ accountFactory: Constants .safeProxyFactoryAddress,
40+ explorer: "https://explorer.fusespark.io/" ,
41+ entrypoint: EntryPointAddress .v07);
3242
3343 Future <void > registerWithPassKey (String name,
3444 {bool ? requiresUserVerification}) async {
35- _chain.accountFactory = Constants .safeProxyFactoryAddress;
36-
3745 final options = PassKeysOptions (
38- name: "variance" ,
39- namespace: "variance.space" ,
40- sharedWebauthnSigner: EthereumAddress . fromHex (
41- "0xfD90FAd33ee8b58f32c00aceEad1358e4AFC23f9" ) );
46+ name: "variance" ,
47+ namespace: "variance.space" ,
48+ sharedWebauthnSigner: sharedSigner,
49+ );
4250 final pkpSigner = PassKeySigner (options: options);
4351
4452 try {
@@ -48,8 +56,8 @@ class WalletProvider extends ChangeNotifier {
4856 "${DateTime .timestamp ().millisecondsSinceEpoch }@variance.space" ,
4957 name);
5058 _wallet = await walletFactory.createSafeAccountWithPasskey (
51- keypair, salt, options.sharedWebauthnSigner);
52-
59+ keypair, salt, options.sharedWebauthnSigner, p256Verifier );
60+ overrideGas ();
5361 log ("wallet created ${_wallet ?.address .hex } " );
5462 } catch (e) {
5563 _errorMessage = e.toString ();
@@ -60,6 +68,8 @@ class WalletProvider extends ChangeNotifier {
6068 }
6169
6270 Future <void > createEOAWallet () async {
71+ _chain.accountFactory = Constants .lightAccountFactoryAddressv07;
72+
6373 final signer = EOAWallet .createWallet (
6474 WordLength .word_12, const SignatureOptions (prefix: [0 ]));
6575 final SmartWalletFactory walletFactory = SmartWalletFactory (_chain, signer);
@@ -75,6 +85,8 @@ class WalletProvider extends ChangeNotifier {
7585 }
7686
7787 Future <void > createPrivateKeyWallet () async {
88+ _chain.accountFactory = Constants .lightAccountFactoryAddressv07;
89+
7890 final signer = PrivateKeySigner .createRandom (
7991 "password" , const SignatureOptions (prefix: [0 ]));
8092 final SmartWalletFactory walletFactory = SmartWalletFactory (_chain, signer);
@@ -90,13 +102,12 @@ class WalletProvider extends ChangeNotifier {
90102 }
91103
92104 Future <void > createSafeWallet () async {
93- _chain.accountFactory = Constants .safeProxyFactoryAddress;
94-
95105 final signer = EOAWallet .createWallet ();
96106 final SmartWalletFactory walletFactory = SmartWalletFactory (_chain, signer);
97107
98108 try {
99109 _wallet = await walletFactory.createSafeAccount (salt);
110+ overrideGas ();
100111 log ("wallet created ${_wallet ?.address .hex } " );
101112 } catch (e) {
102113 log ("something happened: $e " );
@@ -132,11 +143,21 @@ class WalletProvider extends ChangeNotifier {
132143 final etherAmount = EtherAmount .fromBigInt (
133144 EtherUnit .wei, BigInt .from (double .parse (amount) * math.pow (10 , 18 )));
134145
135- final response = await _wallet? .send (
136- EthereumAddress .fromHex ("0xF5bB7F874D8e3f41821175c0Aa9910d30d10e193" ),
137- etherAmount);
146+ final response = await _wallet? .send (deployer, etherAmount);
138147 final receipt = await response? .wait ();
139148
140149 log ("Transaction receipt Hash: ${receipt ?.userOpHash }" );
141150 }
151+
152+ overrideGas () {
153+ //@dev use only when using contract verifier,
154+ // do not use this function with precompiles.
155+ // for the safe deployment transaction do not use the multiplier
156+ // multiply verification gas until it exceeds 400k gas
157+ _wallet? .gasSettings = GasSettings (
158+ verificationGasMultiplierPercentage:
159+ 650 , //7.5x higher than base - about 410k. adjust if needed
160+ userDefinedMaxFeePerGas: BigInt .from (24500000000 ),
161+ userDefinedMaxPriorityFeePerGas: BigInt .from (12300000000 ));
162+ }
142163}
0 commit comments