diff --git a/admin_frontend/src/constants/defaultNetworks.json b/admin_frontend/src/constants/defaultNetworks.json index 8f927a8..7c6d48a 100644 --- a/admin_frontend/src/constants/defaultNetworks.json +++ b/admin_frontend/src/constants/defaultNetworks.json @@ -1,253 +1,282 @@ [ - { - "chainId": 1, - "bundler": "https://ethereum-bundler.etherspot.io/", - "contracts": { - "etherspotPaymasterAddress": "0x7F690e93CecFca5A31E6e1dF50A33F6d3059048c" - }, - "thresholdValue": "0.016", - "MultiTokenPaymasterOracleUsed": "chainlink" - }, - { - "chainId": 10, - "bundler": "https://optimism-bundler.etherspot.io", - "contracts": { - "etherspotPaymasterAddress": "0x805650ce74561C85baA44a8Bd13E19633Fd0F79d" - }, - "thresholdValue": "21.8", - "MultiTokenPaymasterOracleUsed": "chainlink" - }, - { - "chainId": 14, - "bundler": "https://flare-bundler.etherspot.io", - "contracts": { - "etherspotPaymasterAddress": "0x8A41594e5c6Fe492e437414c24eA6f401186b8d2" - }, - "thresholdValue": "1556", - "MultiTokenPaymasterOracleUsed": "chainlink" - }, - { - "chainId": 30, - "bundler": "https://rootstock-bundler.etherspot.io", - "contracts": { - "etherspotPaymasterAddress": "0xe893A26dD53b325bFFaACdFA224692EFF4C448C4" - }, - "thresholdValue": "0.00079", - "MultiTokenPaymasterOracleUsed": "chainlink" - }, - { - "chainId": 31, - "bundler": "https://testnet-rpc.etherspot.io/v1/31", - "contracts": { - "etherspotPaymasterAddress": "0xD302BE6e9D3fE0fBf8122a0C34611E31c0D0E792" - }, - "thresholdValue": "0.00079", - "MultiTokenPaymasterOracleUsed": "chainlink" - }, - { - "chainId": 56, - "bundler": "https://bnb-bundler.etherspot.io/", - "contracts": { - "etherspotPaymasterAddress": "0xEA5ecE95D3A28f9faB161779d20128b449F9EC9C" - }, - "thresholdValue": "0.09", - "MultiTokenPaymasterOracleUsed": "chainlink" - }, - { - "chainId": 97, - "bundler": "https://testnet-rpc.etherspot.io/v1/97", - "contracts": { - "etherspotPaymasterAddress": "0x153e26707DF3787183945B88121E4Eb188FDCAAA" - }, - "thresholdValue": "0.09", - "MultiTokenPaymasterOracleUsed": "chainlink" - }, - { - "chainId": 100, - "bundler": "https://gnosis-bundler.etherspot.io/", - "contracts": { - "etherspotPaymasterAddress": "0x373aBcF1EA9e5802778E32870e7f72C8A6a90349" - }, - "thresholdValue": "50", - "MultiTokenPaymasterOracleUsed": "chainlink" - }, - { - "chainId": 114, - "bundler": "https://testnet-rpc.etherspot.io/v1/114", - "contracts": { - "etherspotPaymasterAddress": "0x2a18C360b525824B3e5656B5a705554f2a5036Be" - }, - "thresholdValue": "1556", - "MultiTokenPaymasterOracleUsed": "chainlink" - }, - { - "chainId": 122, - "bundler": "https://fuse-bundler.etherspot.io", - "contracts": { - "etherspotPaymasterAddress": "0xEC2EE24E79C73DB13Dd9bC782856a5296626b7eb" - }, - "thresholdValue": "669" - }, - { - "chainId": 123, - "bundler": "https://testnet-rpc.etherspot.io/v1/123", - "contracts": { - "etherspotPaymasterAddress": "0xAF628C207513c5E51d894b3733056B8080634923" - }, - "thresholdValue": "669", - "MultiTokenPaymasterOracleUsed": "chainlink" - }, - { - "chainId": 137, - "bundler": "https://polygon-bundler.etherspot.io", - "contracts": { - "etherspotPaymasterAddress": "0x26FeC24b0D467C9de105217B483931e8f944ff50" - }, - "thresholdValue": "69.85", - "MultiTokenPaymasterOracleUsed": "chainlink" - }, - { - "chainId": 5000, - "bundler": "https://mantle-bundler.etherspot.io/", - "contracts": { - "etherspotPaymasterAddress": "0x8A41594e5c6Fe492e437414c24eA6f401186b8d2" - }, - "thresholdValue": "44.24", - "MultiTokenPaymasterOracleUsed": "chainlink" - }, - { - "chainId": 5003, - "bundler": "https://testnet-rpc.etherspot.io/v1/5003", - "contracts": { - "etherspotPaymasterAddress": "0x8350355c08aDAC387b443782124A30A8942BeC2e" - }, - "thresholdValue": "44.24", - "MultiTokenPaymasterOracleUsed": "chainlink" - }, - { - "chainId": 8217, - "bundler": "https://klaytn-bundler.etherspot.io/", - "contracts": { - "etherspotPaymasterAddress": "0x4ebd86AAF89151b5303DB072e0205C668e31E5E7" - }, - "thresholdValue": "275.2", - "MultiTokenPaymasterOracleUsed": "chainlink" - }, - { - "chainId": 8453, - "bundler": "https://base-bundler.etherspot.io/", - "contracts": { - "etherspotPaymasterAddress": "0x810FA4C915015b703db0878CF2B9344bEB254a40" - }, - "thresholdValue": "15.19", - "MultiTokenPaymasterOracleUsed": "chainlink" - }, - { - "chainId": 42161, - "bundler": "https://arbitrum-bundler.etherspot.io", - "contracts": { - "etherspotPaymasterAddress": "0xEC2EE24E79C73DB13Dd9bC782856a5296626b7eb" - }, - "thresholdValue": "43.10", - "MultiTokenPaymasterOracleUsed": "chainlink" - }, - { - "chainId": 43114, - "bundler": "https://avalanche-bundler.etherspot.io/", - "contracts": { - "etherspotPaymasterAddress": "0x527569794781671319f20374A050BDbef4181aB3" - }, - "thresholdValue": "1.4", - "MultiTokenPaymasterOracleUsed": "chainlink" - }, - { - "chainId": 59144, - "bundler": "https://linea-bundler.etherspot.io/", - "contracts": { - "etherspotPaymasterAddress": "0xB3AD9B9B06c6016f81404ee8FcCD0526F018Cf0C" - }, - "thresholdValue": "0.016", - "MultiTokenPaymasterOracleUsed": "chainlink" - }, - { - "chainId": 84532, - "bundler": "https://testnet-rpc.etherspot.io/v1/84532", - "contracts": { - "etherspotPaymasterAddress": "0xe893A26DD53b325BffAacDfA224692EfF4C448c4" - }, - "thresholdValue": "15.19", - "MultiTokenPaymasterOracleUsed": "chainlink" - }, - { - "chainId": 421614, - "bundler": "https://testnet-rpc.etherspot.io/v1/421614", - "contracts": { - "etherspotPaymasterAddress": "0xe893A26DD53b325BffAacDfA224692EfF4C448c4" - }, - "thresholdValue": "43.10", - "MultiTokenPaymasterOracleUsed": "chainlink" - }, - { - "chainId": 534351, - "bundler": "https://testnet-rpc.etherspot.io/v1/534351", - "contracts": { - "etherspotPaymasterAddress": "0xe893A26DD53b325BffAacDfA224692EfF4C448c4" - }, - "thresholdValue": "0.016", - "MultiTokenPaymasterOracleUsed": "chainlink" - }, - { - "chainId": 534352, - "bundler": "https://scroll-bundler.etherspot.io", - "contracts": { - "etherspotPaymasterAddress": "0xB3AD9B9B06c6016f81404ee8FcCD0526F018Cf0C" - }, - "thresholdValue": "0.016", - "MultiTokenPaymasterOracleUsed": "chainlink" - }, - { - "chainId": 11155111, - "bundler": "https://testnet-rpc.etherspot.io/v1/11155111", - "contracts": { - "etherspotPaymasterAddress": "0xcaDBADcFeD5530A49762DFc9d1d712CcD6b09b25" - }, - "thresholdValue": "0.016", - "MultiTokenPaymasterOracleUsed": "chainlink" - }, - { - "chainId": 28122024, - "bundler": "https://testnet-rpc.etherspot.io/v1/28122024", - "contracts": { - "etherspotPaymasterAddress": "0xe893A26DD53b325BffAacDfA224692EfF4C448c4" - }, - "thresholdValue": "0.016", - "MultiTokenPaymasterOracleUsed": "orochi" - }, - { - "chainId": 11155420, - "bundler": "https://testnet-rpc.etherspot.io/v1/11155420", - "contracts": { - "etherspotPaymasterAddress": "0xB3AD9B9B06c6016f81404ee8FcCD0526F018Cf0C" - }, - "thresholdValue": "21.8", - "MultiTokenPaymasterOracleUsed": "chainlink" - }, - { - "chainId": 888888888, - "bundler": "https://ancient8-bundler.etherspot.io", - "contracts": { - "etherspotPaymasterAddress": "0x810FA4C915015b703db0878CF2B9344bEB254a40" - }, - "thresholdValue": "0.016", - "MultiTokenPaymasterOracleUsed": "orochi" - }, - { - "chainId": 80002, - "bundler": "https://testnet-rpc.etherspot.io/v1/80002", - "contracts": { - "etherspotPaymasterAddress": "0xe893a26dd53b325bffaacdfa224692eff4c448c4" - }, - "thresholdValue": "0.01", - "MultiTokenPaymasterOracleUsed": "chainlink" - } + { + "chainId": 1, + "bundler": "https://ethereum-bundler.etherspot.io/", + "contracts": { + "etherspotPaymasterAddress": "0x7F690e93CecFca5A31E6e1dF50A33F6d3059048c" + }, + "thresholdValue": "0.016", + "MultiTokenPaymasterOracleUsed": "chainlink", + "entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + }, + { + "chainId": 10, + "bundler": "https://optimism-bundler.etherspot.io", + "contracts": { + "etherspotPaymasterAddress": "0x805650ce74561C85baA44a8Bd13E19633Fd0F79d" + }, + "thresholdValue": "21.8", + "MultiTokenPaymasterOracleUsed": "chainlink", + "entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + }, + { + "chainId": 14, + "bundler": "https://flare-bundler.etherspot.io", + "contracts": { + "etherspotPaymasterAddress": "0x8A41594e5c6Fe492e437414c24eA6f401186b8d2" + }, + "thresholdValue": "1556", + "MultiTokenPaymasterOracleUsed": "chainlink", + "entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + }, + { + "chainId": 30, + "bundler": "https://rootstock-bundler.etherspot.io", + "contracts": { + "etherspotPaymasterAddress": "0xe893A26dD53b325bFFaACdFA224692EFF4C448C4" + }, + "thresholdValue": "0.00079", + "MultiTokenPaymasterOracleUsed": "chainlink", + "entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + }, + { + "chainId": 31, + "bundler": "https://testnet-rpc.etherspot.io/v1/31", + "contracts": { + "etherspotPaymasterAddress": "0xD302BE6e9D3fE0fBf8122a0C34611E31c0D0E792" + }, + "thresholdValue": "0.00079", + "MultiTokenPaymasterOracleUsed": "chainlink", + "entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + }, + { + "chainId": 56, + "bundler": "https://bnb-bundler.etherspot.io/", + "contracts": { + "etherspotPaymasterAddress": "0xEA5ecE95D3A28f9faB161779d20128b449F9EC9C" + }, + "thresholdValue": "0.09", + "MultiTokenPaymasterOracleUsed": "chainlink", + "entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + }, + { + "chainId": 97, + "bundler": "https://testnet-rpc.etherspot.io/v1/97", + "contracts": { + "etherspotPaymasterAddress": "0x153e26707DF3787183945B88121E4Eb188FDCAAA" + }, + "thresholdValue": "0.09", + "MultiTokenPaymasterOracleUsed": "chainlink", + "entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + }, + { + "chainId": 100, + "bundler": "https://gnosis-bundler.etherspot.io/", + "contracts": { + "etherspotPaymasterAddress": "0x373aBcF1EA9e5802778E32870e7f72C8A6a90349" + }, + "thresholdValue": "50", + "MultiTokenPaymasterOracleUsed": "chainlink", + "entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + }, + { + "chainId": 114, + "bundler": "https://testnet-rpc.etherspot.io/v1/114", + "contracts": { + "etherspotPaymasterAddress": "0x2a18C360b525824B3e5656B5a705554f2a5036Be" + }, + "thresholdValue": "1556", + "MultiTokenPaymasterOracleUsed": "chainlink", + "entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + }, + { + "chainId": 122, + "bundler": "https://fuse-bundler.etherspot.io", + "contracts": { + "etherspotPaymasterAddress": "0xEC2EE24E79C73DB13Dd9bC782856a5296626b7eb" + }, + "thresholdValue": "669", + "MultiTokenPaymasterOracleUsed": "chainlink", + "entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + }, + { + "chainId": 123, + "bundler": "https://testnet-rpc.etherspot.io/v1/123", + "contracts": { + "etherspotPaymasterAddress": "0xAF628C207513c5E51d894b3733056B8080634923" + }, + "thresholdValue": "669", + "MultiTokenPaymasterOracleUsed": "chainlink", + "entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + }, + { + "chainId": 137, + "bundler": "https://polygon-bundler.etherspot.io", + "contracts": { + "etherspotPaymasterAddress": "0x26FeC24b0D467C9de105217B483931e8f944ff50" + }, + "thresholdValue": "69.85", + "MultiTokenPaymasterOracleUsed": "chainlink", + "entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + }, + { + "chainId": 5000, + "bundler": "https://mantle-bundler.etherspot.io/", + "contracts": { + "etherspotPaymasterAddress": "0x8A41594e5c6Fe492e437414c24eA6f401186b8d2" + }, + "thresholdValue": "44.24", + "MultiTokenPaymasterOracleUsed": "chainlink", + "entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + }, + { + "chainId": 5003, + "bundler": "https://testnet-rpc.etherspot.io/v1/5003", + "contracts": { + "etherspotPaymasterAddress": "0x8350355c08aDAC387b443782124A30A8942BeC2e" + }, + "thresholdValue": "44.24", + "MultiTokenPaymasterOracleUsed": "chainlink", + "entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + }, + { + "chainId": 8217, + "bundler": "https://klaytn-bundler.etherspot.io/", + "contracts": { + "etherspotPaymasterAddress": "0x4ebd86AAF89151b5303DB072e0205C668e31E5E7" + }, + "thresholdValue": "275.2", + "MultiTokenPaymasterOracleUsed": "chainlink", + "entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + }, + { + "chainId": 8453, + "bundler": "https://base-bundler.etherspot.io/", + "contracts": { + "etherspotPaymasterAddress": "0x810FA4C915015b703db0878CF2B9344bEB254a40" + }, + "thresholdValue": "15.19", + "MultiTokenPaymasterOracleUsed": "chainlink", + "entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + }, + { + "chainId": 42161, + "bundler": "https://arbitrum-bundler.etherspot.io", + "contracts": { + "etherspotPaymasterAddress": "0xEC2EE24E79C73DB13Dd9bC782856a5296626b7eb" + }, + "thresholdValue": "43.10", + "MultiTokenPaymasterOracleUsed": "chainlink", + "entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + }, + { + "chainId": 43114, + "bundler": "https://avalanche-bundler.etherspot.io/", + "contracts": { + "etherspotPaymasterAddress": "0x527569794781671319f20374A050BDbef4181aB3" + }, + "thresholdValue": "1.4", + "MultiTokenPaymasterOracleUsed": "chainlink", + "entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + }, + { + "chainId": 59144, + "bundler": "https://linea-bundler.etherspot.io/", + "contracts": { + "etherspotPaymasterAddress": "0xB3AD9B9B06c6016f81404ee8FcCD0526F018Cf0C" + }, + "thresholdValue": "0.016", + "MultiTokenPaymasterOracleUsed": "chainlink", + "entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + }, + { + "chainId": 84532, + "bundler": "https://testnet-rpc.etherspot.io/v1/84532", + "contracts": { + "etherspotPaymasterAddress": "0xe893A26DD53b325BffAacDfA224692EfF4C448c4" + }, + "thresholdValue": "15.19", + "MultiTokenPaymasterOracleUsed": "chainlink", + "entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + }, + { + "chainId": 421614, + "bundler": "https://testnet-rpc.etherspot.io/v1/421614", + "contracts": { + "etherspotPaymasterAddress": "0xe893A26DD53b325BffAacDfA224692EfF4C448c4" + }, + "thresholdValue": "43.10", + "MultiTokenPaymasterOracleUsed": "chainlink", + "entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + }, + { + "chainId": 534351, + "bundler": "https://testnet-rpc.etherspot.io/v1/534351", + "contracts": { + "etherspotPaymasterAddress": "0xe893A26DD53b325BffAacDfA224692EfF4C448c4" + }, + "thresholdValue": "0.016", + "MultiTokenPaymasterOracleUsed": "chainlink", + "entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + }, + { + "chainId": 534352, + "bundler": "https://scroll-bundler.etherspot.io", + "contracts": { + "etherspotPaymasterAddress": "0xB3AD9B9B06c6016f81404ee8FcCD0526F018Cf0C" + }, + "thresholdValue": "0.016", + "MultiTokenPaymasterOracleUsed": "chainlink", + "entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + }, + { + "chainId": 11155111, + "bundler": "https://testnet-rpc.etherspot.io/v1/11155111", + "contracts": { + "etherspotPaymasterAddress": "0xcaDBADcFeD5530A49762DFc9d1d712CcD6b09b25" + }, + "thresholdValue": "0.016", + "MultiTokenPaymasterOracleUsed": "chainlink", + "entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + }, + { + "chainId": 28122024, + "bundler": "https://testnet-rpc.etherspot.io/v1/28122024", + "contracts": { + "etherspotPaymasterAddress": "0xe893A26DD53b325BffAacDfA224692EfF4C448c4" + }, + "thresholdValue": "0.016", + "MultiTokenPaymasterOracleUsed": "orochi", + "entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + }, + { + "chainId": 11155420, + "bundler": "https://testnet-rpc.etherspot.io/v1/11155420", + "contracts": { + "etherspotPaymasterAddress": "0xB3AD9B9B06c6016f81404ee8FcCD0526F018Cf0C" + }, + "thresholdValue": "21.8", + "MultiTokenPaymasterOracleUsed": "chainlink", + "entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + }, + { + "chainId": 888888888, + "bundler": "https://ancient8-bundler.etherspot.io", + "contracts": { + "etherspotPaymasterAddress": "0x810FA4C915015b703db0878CF2B9344bEB254a40" + }, + "thresholdValue": "0.016", + "MultiTokenPaymasterOracleUsed": "orochi", + "entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + }, + { + "chainId": 80002, + "bundler": "https://testnet-rpc.etherspot.io/v1/80002", + "contracts": { + "etherspotPaymasterAddress": "0xe893a26dd53b325bffaacdfa224692eff4c448c4" + }, + "thresholdValue": "0.01", + "MultiTokenPaymasterOracleUsed": "chainlink", + "entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + } ] diff --git a/backend/config.json.default b/backend/config.json.default new file mode 100644 index 0000000..d8ae092 --- /dev/null +++ b/backend/config.json.default @@ -0,0 +1,292 @@ +[ + { + "chainId": 1, + "bundler": "https://ethereum-bundler.etherspot.io/", + "contracts": { + "etherspotPaymasterAddress": "0x7F690e93CecFca5A31E6e1dF50A33F6d3059048c" + }, + "thresholdValue": "0.016", + "MultiTokenPaymasterOracleUsed": "chainlink", + "entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + }, + { + "chainId": 10, + "bundler": "https://optimism-bundler.etherspot.io", + "contracts": { + "etherspotPaymasterAddress": "0x805650ce74561C85baA44a8Bd13E19633Fd0F79d" + }, + "thresholdValue": "21.8", + "MultiTokenPaymasterOracleUsed": "chainlink", + "entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + }, + { + "chainId": 14, + "bundler": "https://flare-bundler.etherspot.io", + "contracts": { + "etherspotPaymasterAddress": "0x8A41594e5c6Fe492e437414c24eA6f401186b8d2" + }, + "thresholdValue": "1556", + "MultiTokenPaymasterOracleUsed": "chainlink", + "entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + }, + { + "chainId": 30, + "bundler": "https://rootstock-bundler.etherspot.io", + "contracts": { + "etherspotPaymasterAddress": "0xe893A26dD53b325bFFaACdFA224692EFF4C448C4" + }, + "thresholdValue": "0.00079", + "MultiTokenPaymasterOracleUsed": "chainlink", + "entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + }, + { + "chainId": 31, + "bundler": "https://testnet-rpc.etherspot.io/v1/31", + "contracts": { + "etherspotPaymasterAddress": "0xD302BE6e9D3fE0fBf8122a0C34611E31c0D0E792" + }, + "thresholdValue": "0.00079", + "MultiTokenPaymasterOracleUsed": "chainlink", + "entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + }, + { + "chainId": 56, + "bundler": "https://bnb-bundler.etherspot.io/", + "contracts": { + "etherspotPaymasterAddress": "0xEA5ecE95D3A28f9faB161779d20128b449F9EC9C" + }, + "thresholdValue": "0.09", + "MultiTokenPaymasterOracleUsed": "chainlink", + "entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + }, + { + "chainId": 97, + "bundler": "https://testnet-rpc.etherspot.io/v1/97", + "contracts": { + "etherspotPaymasterAddress": "0x153e26707DF3787183945B88121E4Eb188FDCAAA" + }, + "thresholdValue": "0.09", + "MultiTokenPaymasterOracleUsed": "chainlink", + "entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + }, + { + "chainId": 100, + "bundler": "https://gnosis-bundler.etherspot.io/", + "contracts": { + "etherspotPaymasterAddress": "0x373aBcF1EA9e5802778E32870e7f72C8A6a90349" + }, + "thresholdValue": "50", + "MultiTokenPaymasterOracleUsed": "chainlink", + "entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + }, + { + "chainId": 114, + "bundler": "https://testnet-rpc.etherspot.io/v1/114", + "contracts": { + "etherspotPaymasterAddress": "0x2a18C360b525824B3e5656B5a705554f2a5036Be" + }, + "thresholdValue": "1556", + "MultiTokenPaymasterOracleUsed": "chainlink", + "entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + }, + { + "chainId": 122, + "bundler": "https://fuse-bundler.etherspot.io", + "contracts": { + "etherspotPaymasterAddress": "0xEC2EE24E79C73DB13Dd9bC782856a5296626b7eb" + }, + "thresholdValue": "669", + "MultiTokenPaymasterOracleUsed": "chainlink", + "entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + }, + { + "chainId": 123, + "bundler": "https://testnet-rpc.etherspot.io/v1/123", + "contracts": { + "etherspotPaymasterAddress": "0xAF628C207513c5E51d894b3733056B8080634923" + }, + "thresholdValue": "669", + "MultiTokenPaymasterOracleUsed": "chainlink", + "entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + }, + { + "chainId": 137, + "bundler": "https://polygon-bundler.etherspot.io", + "contracts": { + "etherspotPaymasterAddress": "0x26FeC24b0D467C9de105217B483931e8f944ff50" + }, + "thresholdValue": "69.85", + "MultiTokenPaymasterOracleUsed": "chainlink", + "entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + }, + { + "chainId": 5000, + "bundler": "https://mantle-bundler.etherspot.io/", + "contracts": { + "etherspotPaymasterAddress": "0x8A41594e5c6Fe492e437414c24eA6f401186b8d2" + }, + "thresholdValue": "44.24", + "MultiTokenPaymasterOracleUsed": "chainlink", + "entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + }, + { + "chainId": 5003, + "bundler": "https://testnet-rpc.etherspot.io/v1/5003", + "contracts": { + "etherspotPaymasterAddress": "0x8350355c08aDAC387b443782124A30A8942BeC2e" + }, + "thresholdValue": "44.24", + "MultiTokenPaymasterOracleUsed": "chainlink", + "entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + }, + { + "chainId": 8217, + "bundler": "https://klaytn-bundler.etherspot.io/", + "contracts": { + "etherspotPaymasterAddress": "0x4ebd86AAF89151b5303DB072e0205C668e31E5E7" + }, + "thresholdValue": "275.2", + "MultiTokenPaymasterOracleUsed": "chainlink", + "entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + }, + { + "chainId": 8453, + "bundler": "https://base-bundler.etherspot.io/", + "contracts": { + "etherspotPaymasterAddress": "0x810FA4C915015b703db0878CF2B9344bEB254a40" + }, + "thresholdValue": "15.19", + "MultiTokenPaymasterOracleUsed": "chainlink", + "entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + }, + { + "chainId": 42161, + "bundler": "https://arbitrum-bundler.etherspot.io", + "contracts": { + "etherspotPaymasterAddress": "0xEC2EE24E79C73DB13Dd9bC782856a5296626b7eb" + }, + "thresholdValue": "43.10", + "MultiTokenPaymasterOracleUsed": "chainlink", + "entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + }, + { + "chainId": 43114, + "bundler": "https://avalanche-bundler.etherspot.io/", + "contracts": { + "etherspotPaymasterAddress": "0x527569794781671319f20374A050BDbef4181aB3" + }, + "thresholdValue": "1.4", + "MultiTokenPaymasterOracleUsed": "chainlink", + "entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + }, + { + "chainId": 59144, + "bundler": "https://linea-bundler.etherspot.io/", + "contracts": { + "etherspotPaymasterAddress": "0xB3AD9B9B06c6016f81404ee8FcCD0526F018Cf0C" + }, + "thresholdValue": "0.016", + "MultiTokenPaymasterOracleUsed": "chainlink", + "entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + }, + { + "chainId": 84532, + "bundler": "https://testnet-rpc.etherspot.io/v1/84532", + "contracts": { + "etherspotPaymasterAddress": "0xe893A26DD53b325BffAacDfA224692EfF4C448c4" + }, + "thresholdValue": "15.19", + "MultiTokenPaymasterOracleUsed": "chainlink", + "entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + }, + { + "chainId": 421614, + "bundler": "https://testnet-rpc.etherspot.io/v1/421614", + "contracts": { + "etherspotPaymasterAddress": "0xe893A26DD53b325BffAacDfA224692EfF4C448c4" + }, + "thresholdValue": "43.10", + "MultiTokenPaymasterOracleUsed": "chainlink", + "entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + }, + { + "chainId": 534351, + "bundler": "https://testnet-rpc.etherspot.io/v1/534351", + "contracts": { + "etherspotPaymasterAddress": "0xe893A26DD53b325BffAacDfA224692EfF4C448c4" + }, + "thresholdValue": "0.016", + "MultiTokenPaymasterOracleUsed": "chainlink", + "entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + }, + { + "chainId": 534352, + "bundler": "https://scroll-bundler.etherspot.io", + "contracts": { + "etherspotPaymasterAddress": "0xB3AD9B9B06c6016f81404ee8FcCD0526F018Cf0C" + }, + "thresholdValue": "0.016", + "MultiTokenPaymasterOracleUsed": "chainlink", + "entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + }, + { + "chainId": 11155111, + "bundler": "https://testnet-rpc.etherspot.io/v1/11155111", + "contracts": { + "etherspotPaymasterAddress": "0xcaDBADcFeD5530A49762DFc9d1d712CcD6b09b25" + }, + "thresholdValue": "0.016", + "MultiTokenPaymasterOracleUsed": "chainlink", + "entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + }, + { + "chainId": 28122024, + "bundler": "https://testnet-rpc.etherspot.io/v1/28122024", + "contracts": { + "etherspotPaymasterAddress": "0xe893A26DD53b325BffAacDfA224692EfF4C448c4" + }, + "thresholdValue": "0.016", + "MultiTokenPaymasterOracleUsed": "orochi", + "entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + }, + { + "chainId": 11155420, + "bundler": "https://testnet-rpc.etherspot.io/v1/11155420", + "contracts": { + "etherspotPaymasterAddress": "0xB3AD9B9B06c6016f81404ee8FcCD0526F018Cf0C" + }, + "thresholdValue": "21.8", + "MultiTokenPaymasterOracleUsed": "chainlink", + "entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + }, + { + "chainId": 888888888, + "bundler": "https://ancient8-bundler.etherspot.io", + "contracts": { + "etherspotPaymasterAddress": "0x810FA4C915015b703db0878CF2B9344bEB254a40" + }, + "thresholdValue": "0.016", + "MultiTokenPaymasterOracleUsed": "orochi", + "entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + }, + { + "chainId": 80002, + "bundler": "https://testnet-rpc.etherspot.io/v1/80002", + "contracts": { + "etherspotPaymasterAddress": "0xe893a26dd53b325bffaacdfa224692eff4c448c4" + }, + "thresholdValue": "0.01", + "MultiTokenPaymasterOracleUsed": "chainlink", + "entryPoint": "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789" + }, + { + "chainId": 80002, + "bundler": "https://testnet-rpc.etherspot.io/v2/80002", + "contracts": { + "etherspotPaymasterAddress": "0x810FA4C915015b703db0878CF2B9344bEB254a40" + }, + "thresholdValue": "0.01", + "MultiTokenPaymasterOracleUsed": "chainlink", + "entryPoint": "0x0000000071727De22E5E9d8BAf0edAc6f37da032" + } +] diff --git a/backend/demo.env b/backend/demo.env new file mode 100644 index 0000000..f78986c --- /dev/null +++ b/backend/demo.env @@ -0,0 +1,16 @@ +NODE_ENV=development +LOG_LEVEL=debug +UNSAFE_MODE=false + +API_HOST=127.0.0.1 +API_PORT=5050 + +STACKUP_API_KEY= +SUPPORTED_NETWORKS= +ADMIN_WALLET_ADDRESS= +DEFAULT_INDEXER_ENDPOINT=http://localhost:3003 +FEE_MARKUP= +MULTI_TOKEN_MARKUP=1150000 +ETHERSCAN_GAS_ORACLES= +DEFAULT_API_KEY= +WEBHOOK_URL= diff --git a/backend/src/paymaster/index.ts b/backend/src/paymaster/index.ts index 7644edf..92e7ac4 100644 --- a/backend/src/paymaster/index.ts +++ b/backend/src/paymaster/index.ts @@ -1,69 +1,40 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ -import { - providers, - Wallet, - ethers, - Contract, - BigNumber, - BigNumberish, - utils, -} from "ethers"; -import { - arrayify, - BytesLike, - defaultAbiCoder, - hexConcat, - hexZeroPad, -} from "ethers/lib/utils.js"; -import { FastifyBaseLogger } from "fastify"; -import EtherspotAbiV06 from "../abi/EtherspotAbi.js"; +import { providers, Wallet, ethers, Contract, BigNumber, BigNumberish, utils } from 'ethers'; +import { arrayify, BytesLike, defaultAbiCoder, hexConcat, hexZeroPad } from 'ethers/lib/utils.js'; +import { FastifyBaseLogger } from 'fastify'; +import EtherspotAbiV06 from '../abi/EtherspotAbi.js'; import EtherspotAbiV07 from "../abi/EtherspotVerifyingSignerAbi.js"; -import { PimlicoPaymaster } from "./pimlico.js"; -import ErrorMessage from "../constants/ErrorMessage.js"; -import { PAYMASTER_ADDRESS } from "../constants/Pimlico.js"; -import { getEtherscanFee } from "../utils/common.js"; -import MultiTokenPaymasterAbi from "../abi/MultiTokenPaymasterAbi.js"; -import OrochiOracleAbi from "../abi/OrochiOracleAbi.js"; -import ChainlinkOracleAbi from "../abi/ChainlinkOracleAbi.js"; +import { PimlicoPaymaster } from './pimlico.js'; +import ErrorMessage from '../constants/ErrorMessage.js'; +import { PAYMASTER_ADDRESS } from '../constants/Pimlico.js'; +import { getEtherscanFee } from '../utils/common.js'; +import MultiTokenPaymasterAbi from '../abi/MultiTokenPaymasterAbi.js'; +import OrochiOracleAbi from '../abi/OrochiOracleAbi.js'; +import ChainlinkOracleAbi from '../abi/ChainlinkOracleAbi.js'; export class Paymaster { feeMarkUp: BigNumber; multiTokenMarkUp: Number; constructor(feeMarkUp: string, multiTokenMarkUp: string) { - this.feeMarkUp = ethers.utils.parseUnits(feeMarkUp, "gwei"); - if (isNaN(Number(multiTokenMarkUp))) - this.multiTokenMarkUp = 1150000; // 15% more of the actual cost. Can be anything between 1e6 to 2e6 + this.feeMarkUp = ethers.utils.parseUnits(feeMarkUp, 'gwei'); + if (isNaN(Number(multiTokenMarkUp))) this.multiTokenMarkUp = 1150000 // 15% more of the actual cost. Can be anything between 1e6 to 2e6 else this.multiTokenMarkUp = Number(multiTokenMarkUp); } - packUint(high128: BigNumberish, low128: BigNumberish): string { - return hexZeroPad( - BigNumber.from(high128).shl(128).add(low128).toHexString(), - 32 - ); + packUint (high128: BigNumberish, low128: BigNumberish): string { + return hexZeroPad(BigNumber.from(high128).shl(128).add(low128).toHexString(), 32) } - packPaymasterData( - paymaster: string, - paymasterVerificationGasLimit: BigNumberish, - postOpGasLimit: BigNumberish, - paymasterData?: BytesLike - ): BytesLike { + packPaymasterData (paymaster: string, paymasterVerificationGasLimit: BigNumberish, postOpGasLimit: BigNumberish, paymasterData?: BytesLike): BytesLike { return ethers.utils.hexConcat([ paymaster, this.packUint(paymasterVerificationGasLimit, postOpGasLimit), - paymasterData ?? "0x", - ]); + paymasterData ?? '0x' + ]) } - async getPaymasterData( - userOp: any, - validUntil: string, - validAfter: string, - paymasterContract: Contract, - signer: Wallet - ) { + async getPaymasterData(userOp: any, validUntil: string, validAfter: string, paymasterContract: Contract, signer: Wallet) { // actual signing... const hash = await paymasterContract.getHash( userOp, @@ -74,52 +45,32 @@ export class Paymaster { const sig = await signer.signMessage(arrayify(hash)); const paymasterData = hexConcat([ - defaultAbiCoder.encode(["uint48", "uint48"], [validUntil, validAfter]), + defaultAbiCoder.encode( + ['uint48', 'uint48'], + [validUntil, validAfter] + ), sig, ]); return paymasterData; } - async signV07( - userOp: any, - validUntil: string, - validAfter: string, - entryPoint: string, - paymasterAddress: string, - bundlerRpc: string, - signer: Wallet, - estimate: boolean, - log?: FastifyBaseLogger - ) { + async signV07(userOp: any, validUntil: string, validAfter: string, entryPoint: string, paymasterAddress: string, + bundlerRpc: string, signer: Wallet, estimate: boolean, log?: FastifyBaseLogger) { try { const provider = new providers.JsonRpcProvider(bundlerRpc); - const paymasterContract = new ethers.Contract( - paymasterAddress, - EtherspotAbiV07, - provider - ); - if (!userOp.signature) userOp.signature = "0x"; - if (userOp.factory && userOp.factoryData) - userOp.initCode = hexConcat([userOp.factory, userOp.factoryData ?? ""]); + const paymasterContract = new ethers.Contract(paymasterAddress, EtherspotAbiV07, provider); + if (!userOp.signature) userOp.signature = '0x'; + if (userOp.factory && userOp.factoryData) userOp.initCode = hexConcat([userOp.factory, userOp.factoryData ?? '']) if (!userOp.initCode) userOp.initCode = "0x"; if (estimate) { - const response = await provider.send("eth_estimateUserOperationGas", [ - userOp, - entryPoint, - ]); + const response = await provider.send('eth_estimateUserOperationGas', [userOp, entryPoint]); userOp.verificationGasLimit = response.verificationGasLimit; userOp.callGasLimit = response.callGasLimit; userOp.preVerificationGas = response.preVerificationGas; } - const accountGasLimits = this.packUint( - userOp.verificationGasLimit, - userOp.callGasLimit - ); - const gasFees = this.packUint( - userOp.maxPriorityFeePerGas, - userOp.maxFeePerGas - ); + const accountGasLimits = this.packUint(userOp.verificationGasLimit, userOp.callGasLimit) + const gasFees = this.packUint(userOp.maxPriorityFeePerGas, userOp.maxFeePerGas); let packedUserOp = { sender: userOp.sender, nonce: userOp.nonce, @@ -128,21 +79,11 @@ export class Paymaster { accountGasLimits: accountGasLimits, preVerificationGas: userOp.preVerificationGas, gasFees: gasFees, - paymasterAndData: this.packPaymasterData( - paymasterAddress, - BigNumber.from(30000), - "0x1" - ), - signature: userOp.signature, - }; + paymasterAndData: this.packPaymasterData(paymasterAddress, BigNumber.from(30000), "0x1"), + signature: userOp.signature + } - let paymasterData = await this.getPaymasterData( - packedUserOp, - validUntil, - validAfter, - paymasterContract, - signer - ); + let paymasterData = await this.getPaymasterData(packedUserOp, validUntil, validAfter, paymasterContract, signer); let returnValue; if (estimate) { returnValue = { @@ -152,32 +93,23 @@ export class Paymaster { verificationGasLimit: userOp.verificationGasLimit, callGasLimit: userOp.callGasLimit, paymasterVerificationGasLimit: BigNumber.from(30000).toString(), - paymasterPostOpGasLimit: "0x1", - }; + paymasterPostOpGasLimit: "0x1" + } } else { returnValue = { paymaster: paymasterAddress, paymasterData: paymasterData, - }; + } } return returnValue; } catch (err: any) { - if (log) log.error(err, "signv07"); - throw new Error( - "Failed to process request to bundler. Please contact support team RawErrorMsg:" + - err.message - ); + if (log) log.error(err, 'signv07'); + throw new Error('Failed to process request to bundler. Please contact support team RawErrorMsg:' + err.message) } } - async getPaymasterAndData( - userOp: any, - validUntil: string, - validAfter: string, - paymasterContract: Contract, - signer: Wallet - ) { + async getPaymasterAndData(userOp: any, validUntil: string, validAfter: string, paymasterContract: Contract, signer: Wallet) { // actual signing... const hash = await paymasterContract.getHash( userOp, @@ -189,55 +121,30 @@ export class Paymaster { const paymasterAndData = hexConcat([ paymasterContract.address, - defaultAbiCoder.encode(["uint48", "uint48"], [validUntil, validAfter]), + defaultAbiCoder.encode( + ['uint48', 'uint48'], + [validUntil, validAfter] + ), sig, ]); return paymasterAndData; } - async signV06( - userOp: any, - validUntil: string, - validAfter: string, - entryPoint: string, - paymasterAddress: string, - bundlerRpc: string, - signer: Wallet, - estimate: boolean, - log?: FastifyBaseLogger - ) { + async signV06(userOp: any, validUntil: string, validAfter: string, entryPoint: string, paymasterAddress: string, + bundlerRpc: string, signer: Wallet, estimate: boolean, log?: FastifyBaseLogger) { try { const provider = new providers.JsonRpcProvider(bundlerRpc); - const paymasterContract = new ethers.Contract( - paymasterAddress, - EtherspotAbiV06, - provider - ); - userOp.paymasterAndData = await this.getPaymasterAndData( - userOp, - validUntil, - validAfter, - paymasterContract, - signer - ); - if (!userOp.signature) userOp.signature = "0x"; + const paymasterContract = new ethers.Contract(paymasterAddress, EtherspotAbiV06, provider); + userOp.paymasterAndData = await this.getPaymasterAndData(userOp, validUntil, validAfter, paymasterContract, signer); + if (!userOp.signature) userOp.signature = '0x'; if (estimate) { - const response = await provider.send("eth_estimateUserOperationGas", [ - userOp, - entryPoint, - ]); + const response = await provider.send('eth_estimateUserOperationGas', [userOp, entryPoint]); userOp.verificationGasLimit = response.verificationGasLimit; userOp.preVerificationGas = response.preVerificationGas; userOp.callGasLimit = response.callGasLimit; } - const paymasterAndData = await this.getPaymasterAndData( - userOp, - validUntil, - validAfter, - paymasterContract, - signer - ); + const paymasterAndData = await this.getPaymasterAndData(userOp, validUntil, validAfter, paymasterContract, signer); let returnValue; if (estimate) { returnValue = { @@ -245,32 +152,22 @@ export class Paymaster { verificationGasLimit: userOp.verificationGasLimit, preVerificationGas: userOp.preVerificationGas, callGasLimit: userOp.callGasLimit, - }; + } } else { returnValue = { - paymasterAndData, - }; + paymasterAndData + } } return returnValue; } catch (err: any) { - if (log) log.error(err, "signV06"); - throw new Error( - "Failed to process request to bundler. Please contact support team RawErrorMsg:" + - err.message - ); + if (log) log.error(err, 'signV06'); + throw new Error('Failed to process request to bundler. Please contact support team RawErrorMsg:' + err.message) } - } + } - async getPaymasterAndDataForMultiTokenPaymaster( - userOp: any, - validUntil: string, - validAfter: string, - feeToken: string, - ethPrice: string, - paymasterContract: Contract, - signer: Wallet - ) { + async getPaymasterAndDataForMultiTokenPaymaster(userOp: any, validUntil: string, validAfter: string, feeToken: string, + ethPrice: string, paymasterContract: Contract, signer: Wallet) { const exchangeRate = 1000000; // This is for setting min tokens required for the txn that gets validated on estimate const rate = ethers.BigNumber.from(exchangeRate).mul(ethPrice); const priceMarkup = this.multiTokenMarkUp; @@ -284,24 +181,17 @@ export class Paymaster { feeToken, ethers.constants.AddressZero, rate.toNumber().toFixed(0), - priceMarkup + priceMarkup, ); const sig = await signer.signMessage(arrayify(hash)); const paymasterAndData = hexConcat([ paymasterContract.address, - "0x00", + '0x00', defaultAbiCoder.encode( - ["uint48", "uint48", "address", "address", "uint256", "uint32"], - [ - validUntil, - validAfter, - feeToken, - ethers.constants.AddressZero, - rate.toNumber().toFixed(0), - priceMarkup, - ] + ['uint48', 'uint48', 'address', 'address', 'uint256', 'uint32'], + [validUntil, validAfter, feeToken, ethers.constants.AddressZero, rate.toNumber().toFixed(0), priceMarkup] ), sig, ]); @@ -309,108 +199,50 @@ export class Paymaster { return paymasterAndData; } - async signMultiTokenPaymaster( - userOp: any, - validUntil: string, - validAfter: string, - entryPoint: string, - paymasterAddress: string, - feeToken: string, - oracleAggregator: string, - bundlerRpc: string, - signer: Wallet, - oracleName: string, - log?: FastifyBaseLogger - ) { + async signMultiTokenPaymaster(userOp: any, validUntil: string, validAfter: string, entryPoint: string, paymasterAddress: string, + feeToken: string, oracleAggregator: string, bundlerRpc: string, signer: Wallet, oracleName: string, log?: FastifyBaseLogger) { try { const provider = new providers.JsonRpcProvider(bundlerRpc); - const paymasterContract = new ethers.Contract( - paymasterAddress, - MultiTokenPaymasterAbi, - provider - ); + const paymasterContract = new ethers.Contract(paymasterAddress, MultiTokenPaymasterAbi, provider); let ethPrice = ""; if (oracleName === "orochi") { - const oracleContract = new ethers.Contract( - oracleAggregator, - OrochiOracleAbi, - provider - ); - const result = await oracleContract.getLatestData( - 1, - ethers.utils.hexlify(ethers.utils.toUtf8Bytes("ETH")).padEnd(42, "0") - ); + const oracleContract = new ethers.Contract(oracleAggregator, OrochiOracleAbi, provider); + const result = await oracleContract.getLatestData(1, ethers.utils.hexlify(ethers.utils.toUtf8Bytes('ETH')).padEnd(42, '0')) ethPrice = Number(ethers.utils.formatEther(result)).toFixed(0); } else { - const chainlinkContract = new ethers.Contract( - oracleAggregator, - ChainlinkOracleAbi, - provider - ); + const chainlinkContract = new ethers.Contract(oracleAggregator, ChainlinkOracleAbi, provider); const decimals = await chainlinkContract.decimals(); const result = await chainlinkContract.latestAnswer(); - ethPrice = Number(ethers.utils.formatUnits(result, decimals)).toFixed( - 0 - ); + ethPrice = Number(ethers.utils.formatUnits(result, decimals)).toFixed(0); } - userOp.paymasterAndData = - await this.getPaymasterAndDataForMultiTokenPaymaster( - userOp, - validUntil, - validAfter, - feeToken, - ethPrice, - paymasterContract, - signer - ); - - if (!userOp.signature) userOp.signature = "0x"; - const response = await provider.send("eth_estimateUserOperationGas", [ - userOp, - entryPoint, - ]); + userOp.paymasterAndData = await this.getPaymasterAndDataForMultiTokenPaymaster(userOp, validUntil, validAfter, feeToken, ethPrice, paymasterContract, signer); + + if (!userOp.signature) userOp.signature = '0x'; + const response = await provider.send('eth_estimateUserOperationGas', [userOp, entryPoint]); userOp.verificationGasLimit = response.verificationGasLimit; userOp.preVerificationGas = response.preVerificationGas; userOp.callGasLimit = response.callGasLimit; - const paymasterAndData = - await this.getPaymasterAndDataForMultiTokenPaymaster( - userOp, - validUntil, - validAfter, - feeToken, - ethPrice, - paymasterContract, - signer - ); + const paymasterAndData = await this.getPaymasterAndDataForMultiTokenPaymaster(userOp, validUntil, validAfter, feeToken, ethPrice, paymasterContract, signer); const returnValue = { paymasterAndData, verificationGasLimit: response.verificationGasLimit, preVerificationGas: response.preVerificationGas, callGasLimit: response.callGasLimit, - }; + } return returnValue; } catch (err: any) { - if (log) log.error(err, "signCombinedPaymaster"); - throw new Error( - "Failed to process request to bundler. Please contact support team RawErrorMsg:" + - err.message - ); + if (log) log.error(err, 'signCombinedPaymaster'); + throw new Error('Failed to process request to bundler. Please contact support team RawErrorMsg:' + err.message) } } - async pimlico( - userOp: any, - bundlerRpc: string, - entryPoint: string, - PaymasterAddress: string, - log?: FastifyBaseLogger - ) { + async pimlico(userOp: any, bundlerRpc: string, entryPoint: string, PaymasterAddress: string, log?: FastifyBaseLogger) { try { const provider = new providers.JsonRpcProvider(bundlerRpc); - const erc20Paymaster = new PimlicoPaymaster(PaymasterAddress, provider); - if (!userOp.signature) userOp.signature = "0x"; + const erc20Paymaster = new PimlicoPaymaster(PaymasterAddress, provider) + if (!userOp.signature) userOp.signature = '0x'; // The minimum ABI to get the ERC20 Token balance const minABI = [ @@ -418,46 +250,27 @@ export class Paymaster { { constant: true, - inputs: [{ name: "_owner", type: "address" }], + inputs: [{ name: '_owner', type: 'address' }], - name: "balanceOf", + name: 'balanceOf', - outputs: [{ name: "balance", type: "uint256" }], + outputs: [{ name: 'balance', type: 'uint256' }], - type: "function", + type: 'function', }, - ]; - const tokenAmountRequired = await erc20Paymaster.calculateTokenAmount( - userOp - ); - const tokenContract = new Contract( - await erc20Paymaster.tokenAddress, - minABI, - provider - ); + ] + const tokenAmountRequired = await erc20Paymaster.calculateTokenAmount(userOp); + const tokenContract = new Contract(await erc20Paymaster.tokenAddress, minABI, provider) const tokenBalance = await tokenContract.balanceOf(userOp.sender); - if (tokenAmountRequired.gte(tokenBalance)) - throw new Error( - `The required token amount ${tokenAmountRequired.toString()} is more than what the sender has ${tokenBalance}` - ); + if (tokenAmountRequired.gte(tokenBalance)) + throw new Error(`The required token amount ${tokenAmountRequired.toString()} is more than what the sender has ${tokenBalance}`) - let paymasterAndData = - await erc20Paymaster.generatePaymasterAndDataForTokenAmount( - userOp, - tokenAmountRequired - ); + let paymasterAndData = await erc20Paymaster.generatePaymasterAndDataForTokenAmount(userOp, tokenAmountRequired) userOp.paymasterAndData = paymasterAndData; - const response = await provider.send("eth_estimateUserOperationGas", [ - userOp, - entryPoint, - ]); - userOp.verificationGasLimit = ethers.BigNumber.from( - response.verificationGasLimit - ) - .add(100000) - .toString(); + const response = await provider.send('eth_estimateUserOperationGas', [userOp, entryPoint]); + userOp.verificationGasLimit = ethers.BigNumber.from(response.verificationGasLimit).add(100000).toString(); userOp.preVerificationGas = response.preVerificationGas; userOp.callGasLimit = response.callGasLimit; paymasterAndData = await erc20Paymaster.generatePaymasterAndData(userOp); @@ -469,62 +282,35 @@ export class Paymaster { callGasLimit: response.callGasLimit, }; } catch (err: any) { - if (err.message.includes("The required token amount")) - throw new Error(err.message); - if (log) log.error(err, "pimlico"); - throw new Error( - "Failed to process request to bundler. Please contact support team RawErrorMsg: " + - err.message - ); + if (err.message.includes('The required token amount')) throw new Error(err.message); + if (log) log.error(err, 'pimlico'); + throw new Error('Failed to process request to bundler. Please contact support team RawErrorMsg: ' + err.message) } } - async pimlicoAddress( - gasToken: string, - chainId: number, - log?: FastifyBaseLogger - ) { + async pimlicoAddress(gasToken: string, chainId: number, log?: FastifyBaseLogger) { try { return { - message: - PAYMASTER_ADDRESS[chainId][gasToken] ?? - "Requested Token Paymaster is not available/deployed", - }; + message: PAYMASTER_ADDRESS[chainId][gasToken] ?? 'Requested Token Paymaster is not available/deployed', + } } catch (err: any) { - if (log) log.error(err, "pimlicoAddress"); - throw new Error(err.message); + if (log) log.error(err, 'pimlicoAddress'); + throw new Error(err.message) } } - async whitelistAddresses( - address: string[], - paymasterAddress: string, - bundlerRpc: string, - relayerKey: string, - chainId: number, - log?: FastifyBaseLogger - ) { + async whitelistAddresses(address: string[], paymasterAddress: string, bundlerRpc: string, relayerKey: string, chainId: number, log?: FastifyBaseLogger) { try { const provider = new providers.JsonRpcProvider(bundlerRpc); - const paymasterContract = new ethers.Contract( - paymasterAddress, - EtherspotAbiV06, - provider - ); - const signer = new Wallet(relayerKey, provider); + const paymasterContract = new ethers.Contract(paymasterAddress, EtherspotAbiV06, provider); + const signer = new Wallet(relayerKey, provider) for (let i = 0; i < address.length; i++) { - const isAdded = await paymasterContract.check( - signer.address, - address[i] - ); + const isAdded = await paymasterContract.check(signer.address, address[i]); if (isAdded) { - throw new Error(`${address[i]} already whitelisted`); + throw new Error(`${address[i]} already whitelisted`) } } - const encodedData = paymasterContract.interface.encodeFunctionData( - "addBatchToWhitelist", - [address] - ); + const encodedData = paymasterContract.interface.encodeFunctionData('addBatchToWhitelist', [address]); const etherscanFeeData = await getEtherscanFee(chainId); let feeData; @@ -532,15 +318,9 @@ export class Paymaster { feeData = etherscanFeeData; } else { feeData = await provider.getFeeData(); - feeData.gasPrice = feeData.gasPrice - ? feeData.gasPrice.add(this.feeMarkUp) - : null; - feeData.maxFeePerGas = feeData.maxFeePerGas - ? feeData.maxFeePerGas.add(this.feeMarkUp) - : null; - feeData.maxPriorityFeePerGas = feeData.maxPriorityFeePerGas - ? feeData.maxPriorityFeePerGas.add(this.feeMarkUp) - : null; + feeData.gasPrice = feeData.gasPrice ? feeData.gasPrice.add(this.feeMarkUp) : null; + feeData.maxFeePerGas = feeData.maxFeePerGas ? feeData.maxFeePerGas.add(this.feeMarkUp) : null; + feeData.maxPriorityFeePerGas = feeData.maxPriorityFeePerGas ? feeData.maxPriorityFeePerGas.add(this.feeMarkUp) : null; } let tx: providers.TransactionResponse; @@ -549,7 +329,7 @@ export class Paymaster { to: paymasterAddress, data: encodedData, gasPrice: feeData.gasPrice ?? undefined, - }); + }) } else { tx = await signer.sendTransaction({ to: paymasterAddress, @@ -563,63 +343,37 @@ export class Paymaster { // await tx.wait(); return { - message: `Successfully whitelisted with transaction Hash ${tx.hash}`, + message: `Successfully whitelisted with transaction Hash ${tx.hash}` }; } catch (err: any) { - if (err.message.includes("already whitelisted")) - throw new Error(err.message); - if (log) log.error(err, "whitelistAddresses"); - throw new Error( - ErrorMessage.ERROR_ON_SUBMITTING_TXN + ` RawErrorMsg: ${err.message}` - ); + if (err.message.includes('already whitelisted')) throw new Error(err.message); + if (log) log.error(err, 'whitelistAddresses') + throw new Error(ErrorMessage.ERROR_ON_SUBMITTING_TXN + ` RawErrorMsg: ${err.message}`); } } - async removeWhitelistAddress( - address: string[], - paymasterAddress: string, - bundlerRpc: string, - relayerKey: string, - chainId: number, - log?: FastifyBaseLogger - ) { + async removeWhitelistAddress(address: string[], paymasterAddress: string, bundlerRpc: string, relayerKey: string, chainId: number, log?: FastifyBaseLogger) { try { const provider = new providers.JsonRpcProvider(bundlerRpc); - const paymasterContract = new ethers.Contract( - paymasterAddress, - EtherspotAbiV06, - provider - ); - const signer = new Wallet(relayerKey, provider); + const paymasterContract = new ethers.Contract(paymasterAddress, EtherspotAbiV06, provider); + const signer = new Wallet(relayerKey, provider) for (let i = 0; i < address.length; i++) { - const isAdded = await paymasterContract.check( - signer.address, - address[i] - ); + const isAdded = await paymasterContract.check(signer.address, address[i]); if (!isAdded) { - throw new Error(`${address[i]} is not whitelisted`); + throw new Error(`${address[i]} is not whitelisted`) } } - const encodedData = paymasterContract.interface.encodeFunctionData( - "removeBatchFromWhitelist", - [address] - ); + const encodedData = paymasterContract.interface.encodeFunctionData('removeBatchFromWhitelist', [address]); const etherscanFeeData = await getEtherscanFee(chainId); let feeData; if (etherscanFeeData) { feeData = etherscanFeeData; } else { feeData = await provider.getFeeData(); - feeData.gasPrice = feeData.gasPrice - ? feeData.gasPrice.add(this.feeMarkUp) - : null; - feeData.maxFeePerGas = feeData.maxFeePerGas - ? feeData.maxFeePerGas.add(this.feeMarkUp) - : null; - feeData.maxPriorityFeePerGas = feeData.maxPriorityFeePerGas - ? feeData.maxPriorityFeePerGas.add(this.feeMarkUp) - : null; + feeData.gasPrice = feeData.gasPrice ? feeData.gasPrice.add(this.feeMarkUp) : null; + feeData.maxFeePerGas = feeData.maxFeePerGas ? feeData.maxFeePerGas.add(this.feeMarkUp) : null; + feeData.maxPriorityFeePerGas = feeData.maxPriorityFeePerGas ? feeData.maxPriorityFeePerGas.add(this.feeMarkUp) : null; } let tx: providers.TransactionResponse; @@ -628,7 +382,7 @@ export class Paymaster { to: paymasterAddress, data: encodedData, gasPrice: feeData.gasPrice ?? undefined, - }); + }) } else { tx = await signer.sendTransaction({ to: paymasterAddress, @@ -642,82 +396,49 @@ export class Paymaster { // await tx.wait(); return { - message: `Successfully removed whitelisted addresses with transaction Hash ${tx.hash}`, + message: `Successfully removed whitelisted addresses with transaction Hash ${tx.hash}` }; } catch (err: any) { - if (err.message.includes("is not whitelisted")) - throw new Error(err.message); - if (log) log.error(err, "removeWhitelistAddress"); + if (err.message.includes('is not whitelisted')) throw new Error(err.message); + if (log) log.error(err, 'removeWhitelistAddress'); throw new Error(ErrorMessage.ERROR_ON_SUBMITTING_TXN); } } - async checkWhitelistAddress( - accountAddress: string, - paymasterAddress: string, - bundlerRpc: string, - relayerKey: string, - log?: FastifyBaseLogger - ) { + async checkWhitelistAddress(accountAddress: string, paymasterAddress: string, bundlerRpc: string, relayerKey: string, log?: FastifyBaseLogger) { try { const provider = new providers.JsonRpcProvider(bundlerRpc); - const signer = new Wallet(relayerKey, provider); - const paymasterContract = new ethers.Contract( - paymasterAddress, - EtherspotAbiV06, - provider - ); + const signer = new Wallet(relayerKey, provider) + const paymasterContract = new ethers.Contract(paymasterAddress, EtherspotAbiV06, provider); return paymasterContract.check(signer.address, accountAddress); } catch (err) { - if (log) log.error(err, "checkWhitelistAddress"); + if (log) log.error(err, 'checkWhitelistAddress'); throw new Error(ErrorMessage.RPC_ERROR); } } - async deposit( - amount: string, - paymasterAddress: string, - bundlerRpc: string, - relayerKey: string, - chainId: number, - log?: FastifyBaseLogger - ) { + async deposit(amount: string, paymasterAddress: string, bundlerRpc: string, relayerKey: string, chainId: number, isEpv06: boolean, log?: FastifyBaseLogger) { try { const provider = new providers.JsonRpcProvider(bundlerRpc); - const paymasterContract = new ethers.Contract( - paymasterAddress, - EtherspotAbiV06, - provider - ); - const signer = new Wallet(relayerKey, provider); + const paymasterContract = new ethers.Contract(paymasterAddress, isEpv06 ? EtherspotAbiV06 : EtherspotAbiV07, provider); + const signer = new Wallet(relayerKey, provider) const balance = await signer.getBalance(); const amountInWei = ethers.utils.parseEther(amount.toString()); if (amountInWei.gte(balance)) - throw new Error( - `${signer.address} Balance is less than the amount to be deposited` - ); + throw new Error(`${signer.address} Balance is less than the amount to be deposited`) - const encodedData = paymasterContract.interface.encodeFunctionData( - "depositFunds", - [] - ); + const encodedData = paymasterContract.interface.encodeFunctionData(isEpv06 ? 'depositFunds': 'deposit', []); const etherscanFeeData = await getEtherscanFee(chainId); - console.log("etherscanFeeData: ", etherscanFeeData); + console.log('etherscanFeeData: ', etherscanFeeData); let feeData; if (etherscanFeeData) { feeData = etherscanFeeData; } else { feeData = await provider.getFeeData(); - feeData.gasPrice = feeData.gasPrice - ? feeData.gasPrice.add(this.feeMarkUp) - : null; - feeData.maxFeePerGas = feeData.maxFeePerGas - ? feeData.maxFeePerGas.add(this.feeMarkUp) - : null; - feeData.maxPriorityFeePerGas = feeData.maxPriorityFeePerGas - ? feeData.maxPriorityFeePerGas.add(this.feeMarkUp) - : null; + feeData.gasPrice = feeData.gasPrice ? feeData.gasPrice.add(this.feeMarkUp) : null; + feeData.maxFeePerGas = feeData.maxFeePerGas ? feeData.maxFeePerGas.add(this.feeMarkUp) : null; + feeData.maxPriorityFeePerGas = feeData.maxPriorityFeePerGas ? feeData.maxPriorityFeePerGas.add(this.feeMarkUp) : null; } let tx: providers.TransactionResponse; @@ -727,7 +448,7 @@ export class Paymaster { data: encodedData, value: amountInWei, gasPrice: feeData.gasPrice ?? undefined, - }); + }) } else { tx = await signer.sendTransaction({ to: paymasterAddress, @@ -739,17 +460,14 @@ export class Paymaster { }); } // commented the below line to avoid timeouts for long delays in transaction confirmation. - // await tx.wait(); + // await tx.wait(); return { - message: `Successfully deposited with transaction Hash ${tx.hash}`, + message: `Successfully deposited with transaction Hash ${tx.hash}` }; } catch (err: any) { - if (log) log.error(err, "deposit"); - if ( - err.message.includes("Balance is less than the amount to be deposited") - ) - throw new Error(err.message); + if (log) log.error(err, 'deposit'); + if (err.message.includes('Balance is less than the amount to be deposited')) throw new Error(err.message); throw new Error(ErrorMessage.ERROR_ON_SUBMITTING_TXN); } }