diff --git a/CHANGELOG.md b/CHANGELOG.md index 27bff91..55ca50c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.0.6 + +* Sunset all goerli chains + ## 0.0.5 * Added missing required blockParam to `eth_call` diff --git a/example/lib/main.dart b/example/lib/main.dart index c43724e..d50f80a 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -18,7 +18,8 @@ Future main() async { ethRpcUrl: rpcUrl, bundlerUrl: bundlerUrl, entrypoint: Constants.entrypoint, - accountFactory: Constants.accountFactory, + accountFactory: + EthereumAddress.fromHex("0xCCaE5F64307D86346B83E55e7865f77906F9c7b4"), chainId: 1337, explorer: ""); diff --git a/lib/src/4337/chains.dart b/lib/src/4337/chains.dart index d1d3649..d997f68 100644 --- a/lib/src/4337/chains.dart +++ b/lib/src/4337/chains.dart @@ -4,22 +4,27 @@ class Chain { final int chainId; final String explorer; final EthereumAddress entrypoint; - final EthereumAddress accountFactory; + EthereumAddress? accountFactory; String? ethRpcUrl; String? bundlerUrl; - Chain( - {required this.chainId, - required this.explorer, - this.ethRpcUrl, - this.bundlerUrl, - required this.entrypoint, - required this.accountFactory}); + Chain({ + required this.chainId, + required this.explorer, + required this.entrypoint, + this.accountFactory, + this.ethRpcUrl, + this.bundlerUrl, + }); /// asserts that [ethRpcUrl] and [bundlerUrl] is provided Chain validate() { - require(isURL(ethRpcUrl), "Chain: please provide a valid eth rpc url"); - require(isURL(bundlerUrl), "Chain: please provide a valid bundler url"); + require(isURL(ethRpcUrl), + "Chain Congig Error: please provide a valid eth rpc url"); + require(isURL(bundlerUrl), + "Chain Config Error: please provide a valid bundler url"); + require(accountFactory != null, + "Chain Config Error: please provide account factory address"); return this; } } @@ -27,98 +32,138 @@ class Chain { //predefined Chains you can use class Chains { static Map chains = { - // Ethereum Mainnet - Network.mainnet: Chain( - chainId: 1, - explorer: "https://etherscan.io/", - ethRpcUrl: "https://rpc.ankr.com/eth", - entrypoint: Constants.entrypoint, - accountFactory: Constants.accountFactory), - // Optimism Mainnet + Network.ethereum: Chain( + chainId: 1, + explorer: "https://etherscan.io/", + ethRpcUrl: "https://rpc.ankr.com/eth", + entrypoint: Constants.entrypoint, + ), + Network.polygon: Chain( + chainId: 137, + explorer: "https://polygonscan.com/", + ethRpcUrl: "https://polygon-rpc.com/", + entrypoint: Constants.entrypoint, + ), Network.optimism: Chain( - chainId: 10, - explorer: "https://explorer.optimism.io", - ethRpcUrl: "https://mainnet.optimism.io", - entrypoint: Constants.entrypoint, - accountFactory: Constants.accountFactory), - // Base Mainnet + chainId: 10, + explorer: "https://explorer.optimism.io", + ethRpcUrl: "https://mainnet.optimism.io", + entrypoint: Constants.entrypoint, + ), Network.base: Chain( - chainId: 8453, - explorer: "https://basescan.org", - ethRpcUrl: "https://mainnet.base.org", - entrypoint: Constants.entrypoint, - accountFactory: Constants.accountFactory), - // Arbitrum (one) Mainnet - Network.arbitrum: Chain( - chainId: 42161, - explorer: "https://arbiscan.io/", - ethRpcUrl: "https://arb1.arbitrum.io/rpc", - entrypoint: Constants.entrypoint, - accountFactory: Constants.accountFactory), - // Polygon Mainnet - Network.polygon: Chain( - chainId: 137, - explorer: "https://polygonscan.com/", - ethRpcUrl: "https://polygon-rpc.com/", - entrypoint: Constants.entrypoint, - accountFactory: Constants.accountFactory), - // Mantle Mainnet + chainId: 8453, + explorer: "https://basescan.org", + ethRpcUrl: "https://mainnet.base.org", + entrypoint: Constants.entrypoint, + ), + Network.arbitrumOne: Chain( + chainId: 42161, + explorer: "https://arbiscan.io/", + ethRpcUrl: "https://arb1.arbitrum.io/rpc", + entrypoint: Constants.entrypoint, + ), Network.mantle: Chain( - chainId: 5000, - explorer: "https://explorer.mantle.xyz/", - ethRpcUrl: "https://rpc.mantle.xyz/", - entrypoint: Constants.entrypoint, - accountFactory: Constants.accountFactory), - // Sepolia Testnet + chainId: 5000, + explorer: "https://explorer.mantle.xyz/", + ethRpcUrl: "https://rpc.mantle.xyz/", + entrypoint: Constants.entrypoint, + ), + Network.linea: Chain( + chainId: 59144, + explorer: "https://lineascan.build/", + ethRpcUrl: "https://rpc.linea.build", + entrypoint: Constants.entrypoint), + Network.avalanche: Chain( + chainId: 43114, + explorer: "https://snowtrace.io/", + ethRpcUrl: "https://api.avax.network/ext/bc/C/rpc", + entrypoint: Constants.entrypoint, + ), + Network.gnosis: Chain( + chainId: 100, + explorer: "https://gnosisscan.io/", + ethRpcUrl: "https://rpc.ankr.com/gnosis", + entrypoint: Constants.entrypoint, + ), + Network.celo: Chain( + chainId: 42220, + explorer: "https://celoscan.io/", + ethRpcUrl: "https://forno.celo.org", + entrypoint: Constants.entrypoint, + ), + Network.fantom: Chain( + chainId: 250, + explorer: "https://ftmscan.com/", + ethRpcUrl: "https://rpc.fantom.network", + entrypoint: Constants.entrypoint, + ), + Network.opBnB: Chain( + chainId: 204, + explorer: "http://opbnbscan.com/", + ethRpcUrl: "https://opbnb-mainnet-rpc.bnbchain.org", + entrypoint: Constants.entrypoint, + ), + Network.arbitrumNova: Chain( + chainId: 42170, + explorer: "https://nova.arbiscan.io/", + ethRpcUrl: "https://nova.arbitrum.io/rpc", + entrypoint: Constants.entrypoint, + ), + Network.polygonzkEvm: Chain( + chainId: 1101, + explorer: "https://zkevm.polygonscan.com/", + ethRpcUrl: "https://polygonzkevm-mainnet.g.alchemy.com/v2/demo", + entrypoint: Constants.entrypoint, + ), + Network.scroll: Chain( + chainId: 534352, + explorer: "https://scrollscan.com/", + ethRpcUrl: "https://rpc.scroll.io/", + entrypoint: Constants.entrypoint, + ), + Network.mode: Chain( + chainId: 34443, + explorer: "https://explorer.mode.network/", + ethRpcUrl: "https://mainnet.mode.network/", + entrypoint: Constants.entrypoint, + ), Network.sepolia: Chain( - chainId: 11155111, - explorer: "https://sepolia.etherscan.io/", - ethRpcUrl: "https://rpc.sepolia.org", - entrypoint: Constants.entrypoint, - accountFactory: Constants.accountFactory), - // Optimism Goerli Testnet - Network.opGoerli: Chain( - chainId: 420, - explorer: "https://goerli-explorer.optimism.io", - ethRpcUrl: "https://goerli.optimism.io", - entrypoint: Constants.entrypoint, - accountFactory: Constants.accountFactory), - // Base Goerli testnet - Network.baseGoerli: Chain( - chainId: 84531, - explorer: "https://goerli.basescan.org", - ethRpcUrl: "https://goerli.base.org", - entrypoint: Constants.entrypoint, - accountFactory: Constants.accountFactory), - // Mumbai Testnet + chainId: 11155111, + explorer: "https://sepolia.etherscan.io/", + ethRpcUrl: "https://rpc.sepolia.org", + entrypoint: Constants.entrypoint, + ), Network.mumbai: Chain( - chainId: 80001, - explorer: "https://mumbai.polygonscan.com/", - ethRpcUrl: "https://rpc-mumbai.maticvigil.com/", - entrypoint: Constants.entrypoint, - accountFactory: Constants.accountFactory), - // Mantle Testnet - Network.mantleTestnet: Chain( - chainId: 50001, - explorer: "https://explorer.testnet.mantle.xyz/", - ethRpcUrl: "https://rpc.testnet.mantle.xyz/", - entrypoint: Constants.entrypoint, - accountFactory: Constants.accountFactory), - // Scroll Sepolia Testnet - Network.scrollSepolia: Chain( - chainId: 534351, - explorer: "https://sepolia-blockscout.scroll.io/", - ethRpcUrl: "https://sepolia-rpc.scroll.io/", - entrypoint: Constants.entrypoint, - accountFactory: Constants.accountFactory), - // Localhost + chainId: 80001, + explorer: "https://mumbai.polygonscan.com/", + ethRpcUrl: "https://rpc-mumbai.maticvigil.com/", + entrypoint: Constants.entrypoint, + ), + Network.baseTestent: Chain( + chainId: 84531, + explorer: "https://sepolia.basescan.org", + ethRpcUrl: "https://api-sepolia.basescan.org/api", + entrypoint: Constants.entrypoint, + ), + Network.fuji: Chain( + chainId: 43113, + explorer: "https://testnet.snowtrace.io/", + ethRpcUrl: "https://api.avax-test.network/ext/bc/C/rpc", + entrypoint: Constants.entrypoint, + ), + Network.katla: Chain( + chainId: 167008, + explorer: "https://explorer.katla.taiko.xyz/", + ethRpcUrl: "https://rpc.katla.taiko.xyz", + entrypoint: Constants.entrypoint, + ), Network.localhost: Chain( - chainId: 1337, - explorer: "http://localhost:8545", - ethRpcUrl: "http://localhost:8545", - bundlerUrl: "http://localhost:3000/rpc", - entrypoint: Constants.entrypoint, - accountFactory: Constants.accountFactory) + chainId: 1337, + explorer: "http://localhost:8545", + ethRpcUrl: "http://localhost:8545", + bundlerUrl: "http://localhost:3000/rpc", + entrypoint: Constants.entrypoint, + ) }; const Chains._(); @@ -134,28 +179,35 @@ class Constants { enforceEip55: true); static EthereumAddress zeroAddress = EthereumAddress.fromHex("0x0000000000000000000000000000000000000000"); - static EthereumAddress accountFactory = EthereumAddress.fromHex( - "0xCCaE5F64307D86346B83E55e7865f77906F9c7b4", - enforceEip55: true); + Constants._(); } enum Network { // mainnet - mainnet, + ethereum, + polygon, optimism, base, - arbitrum, - polygon, + arbitrumOne, mantle, + linea, + avalanche, + gnosis, + celo, + fantom, + opBnB, + arbitrumNova, + polygonzkEvm, + scroll, + mode, // testnet sepolia, - opGoerli, - baseGoerli, mumbai, - mantleTestnet, - scrollSepolia, + baseTestent, + fuji, + katla, // localhost localhost diff --git a/lib/src/4337/wallet.dart b/lib/src/4337/wallet.dart index 5af58ca..1bec7b9 100644 --- a/lib/src/4337/wallet.dart +++ b/lib/src/4337/wallet.dart @@ -18,7 +18,7 @@ class SmartWallet with _PluginManager implements SmartWalletBase { _walletAddress = address { final rpc = RPCProvider(chain.ethRpcUrl!); final fact = _AccountFactory( - address: chain.accountFactory, chainId: chain.chainId, rpc: rpc); + address: chain.accountFactory!, chainId: chain.chainId, rpc: rpc); addPlugin('signer', signer); addPlugin('bundler', bundler); @@ -98,12 +98,12 @@ class SmartWallet with _PluginManager implements SmartWalletBase { String? get toHex => _walletAddress?.hexEip55; String get _initCode => _initCalldata != null - ? _chain.accountFactory.hexEip55 + hexlify(_initCalldata!).substring(2) + ? _chain.accountFactory!.hexEip55 + hexlify(_initCalldata!).substring(2) : "0x"; Uint8List get _initCodeBytes { if (_initCalldata == null) return Uint8List(0); - List extended = _chain.accountFactory.addressBytes.toList(); + List extended = _chain.accountFactory!.addressBytes.toList(); extended.addAll(_initCalldata!); return Uint8List.fromList(extended); } diff --git a/pubspec.lock b/pubspec.lock index 05d0ed0..c8c040c 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -189,10 +189,10 @@ packages: dependency: transitive description: name: collection - sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687 + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a url: "https://pub.dev" source: hosted - version: "1.17.2" + version: "1.18.0" convert: dependency: transitive description: @@ -575,10 +575,10 @@ packages: dependency: transitive description: name: meta - sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" + sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e url: "https://pub.dev" source: hosted - version: "1.9.1" + version: "1.10.0" mime: dependency: transitive description: @@ -924,10 +924,10 @@ packages: dependency: transitive description: name: web - sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10 + sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152 url: "https://pub.dev" source: hosted - version: "0.1.4-beta" + version: "0.3.0" web3dart: dependency: "direct main" description: @@ -993,5 +993,5 @@ packages: source: hosted version: "3.1.2" sdks: - dart: ">=3.1.0 <4.0.0" + dart: ">=3.2.0-194.0.dev <4.0.0" flutter: ">=3.13.0" diff --git a/pubspec.yaml b/pubspec.yaml index 0632ba5..b060d6a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: variance_dart description: An Account Abstraction (4337) Development kit, for quickly building mobile web3 apps and smart wallets. -version: 0.0.5 +version: 0.0.6 documentation: https://docs.variance.space homepage: https://variance.space repository: https://github.com/vaariance/variance-dart