diff --git a/admin_frontend/.gitignore b/admin_frontend/.gitignore index 4d29575..532eddc 100644 --- a/admin_frontend/.gitignore +++ b/admin_frontend/.gitignore @@ -21,3 +21,5 @@ npm-debug.log* yarn-debug.log* yarn-error.log* + +.env \ No newline at end of file diff --git a/admin_frontend/package.json b/admin_frontend/package.json index 4cbb426..4efc7c9 100644 --- a/admin_frontend/package.json +++ b/admin_frontend/package.json @@ -1,6 +1,6 @@ { "name": "admin_frontend", - "version": "1.2.4", + "version": "1.2.5", "private": true, "dependencies": { "@emotion/react": "11.11.3", diff --git a/admin_frontend/src/constants/defaultNetworks.json b/admin_frontend/src/constants/defaultNetworks.json index 6adae86..8f927a8 100644 --- a/admin_frontend/src/constants/defaultNetworks.json +++ b/admin_frontend/src/constants/defaultNetworks.json @@ -1,170 +1,253 @@ [ { - "chainId": 1, - "bundler": "https://ethereum-bundler.etherspot.io/", - "contracts": { - "etherspotPaymasterAddress": "0x7F690e93CecFca5A31E6e1dF50A33F6d3059048c" - } - }, - { - "chainId": 5, - "bundler": "https://goerli-bundler.etherspot.io", - "contracts": { - "etherspotPaymasterAddress": "0xcaDBADcFeD5530A49762DFc9d1d712CcD6b09b25" - } - }, - { - "chainId": 10, - "bundler": "https://optimism-bundler.etherspot.io", - "contracts": { - "etherspotPaymasterAddress": "0x805650ce74561C85baA44a8Bd13E19633Fd0F79d" - } - }, - { - "chainId": 14, - "bundler": "https://flare-bundler.etherspot.io", - "contracts": { - "etherspotPaymasterAddress": "0x8A41594e5c6Fe492e437414c24eA6f401186b8d2" - } - }, - { - "chainId": 56, - "bundler": "https://bnb-bundler.etherspot.io/", - "contracts": { - "etherspotPaymasterAddress": "0xEA5ecE95D3A28f9faB161779d20128b449F9EC9C" - } - }, - { - "chainId": 97, - "bundler": "https://bnbtestnet-bundler.etherspot.io/", - "contracts": { - "etherspotPaymasterAddress": "0x153e26707DF3787183945B88121E4Eb188FDCAAA" - } - }, - { - "chainId": 100, - "bundler": "https://gnosis-bundler.etherspot.io/", - "contracts": { - "etherspotPaymasterAddress": "0x373aBcF1EA9e5802778E32870e7f72C8A6a90349" - } - }, - { - "chainId": 114, - "bundler": "https://flaretestnet-bundler.etherspot.io/", - "contracts": { - "etherspotPaymasterAddress": "0x2a18C360b525824B3e5656B5a705554f2a5036Be" - } - }, - { - "chainId": 122, - "bundler": "https://fuse-bundler.etherspot.io", - "contracts": { - "etherspotPaymasterAddress": "0xEC2EE24E79C73DB13Dd9bC782856a5296626b7eb" - } - }, - { - "chainId": 137, - "bundler": "https://polygon-bundler.etherspot.io", - "contracts": { - "etherspotPaymasterAddress": "0x26FeC24b0D467C9de105217B483931e8f944ff50" - } - }, - { - "chainId": 420, - "bundler": "https://optimismgoerli-bundler.etherspot.io", - "contracts": { - "etherspotPaymasterAddress": "0x898c530A5fA37720DcF1843AeCC34b6B0cBaEB8a" - } - }, - { - "chainId": 1001, - "bundler": "https://klaytntestnet-bundler.etherspot.io/", - "contracts": { - "etherspotPaymasterAddress": "0x810FA4C915015b703db0878CF2B9344bEB254a40" - } - }, - { - "chainId": 5000, - "bundler": "https://mantle-bundler.etherspot.io/", - "contracts": { - "etherspotPaymasterAddress": "0x8A41594e5c6Fe492e437414c24eA6f401186b8d2" - } - }, - { - "chainId": 5001, - "bundler": "https://mantletestnet-bundler.etherspot.io/", - "contracts": { - "etherspotPaymasterAddress": "0xb56eC212C60C47fb7385f13b7247886FFa5E9D5C" - } - }, - { - "chainId": 8217, - "bundler": "https://klaytn-bundler.etherspot.io/", - "contracts": { - "etherspotPaymasterAddress": "0x4ebd86AAF89151b5303DB072e0205C668e31E5E7" - } - }, - { - "chainId": 8453, - "bundler": "https://base-bundler.etherspot.io/", - "contracts": { - "etherspotPaymasterAddress": "0x810FA4C915015b703db0878CF2B9344bEB254a40" - } - }, - { - "chainId": 42161, - "bundler": "https://arbitrum-bundler.etherspot.io", - "contracts": { - "etherspotPaymasterAddress": "0xEC2EE24E79C73DB13Dd9bC782856a5296626b7eb" - } - }, - { - "chainId": 43114, - "bundler": "https://avalanche-bundler.etherspot.io/", - "contracts": { - "etherspotPaymasterAddress": "0x527569794781671319f20374A050BDbef4181aB3" - } - }, - { - "chainId": 59144, - "bundler": "https://linea-bundler.etherspot.io/", - "contracts": { - "etherspotPaymasterAddress": "0xB3AD9B9B06c6016f81404ee8FcCD0526F018Cf0C" - } - }, - { - "chainId": 80001, - "bundler": "https://mumbai-bundler.etherspot.io", - "contracts": { - "etherspotPaymasterAddress": "0x8350355c08aDAC387b443782124A30A8942BeC2e" - } - }, - { - "chainId": 84531, - "bundler": "https://basegoerli-bundler.etherspot.io", - "contracts": { - "etherspotPaymasterAddress": "0x898c530A5fA37720DcF1843AeCC34b6B0cBaEB8a" - } - }, - { - "chainId": 421613, - "bundler": "https://arbitrumgoerli-bundler.etherspot.io", - "contracts": { - "etherspotPaymasterAddress": "0x898c530A5fA37720DcF1843AeCC34b6B0cBaEB8a" - } - }, - { - "chainId": 534351, - "bundler": "https://scrollsepolia-bundler.etherspot.io/", - "contracts": { - "etherspotPaymasterAddress": "0xe893A26DD53b325BffAacDfA224692EfF4C448c4" - } - }, - { - "chainId": 11155111, - "bundler": "https://sepolia-bundler.etherspot.io", - "contracts": { - "etherspotPaymasterAddress": "0xcaDBADcFeD5530A49762DFc9d1d712CcD6b09b25" - } + "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" } ] diff --git a/backend/package.json b/backend/package.json index 11d1509..9c920e9 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "arka", - "version": "1.2.4", + "version": "1.2.5", "description": "ARKA - (Albanian for Cashier's case) is the first open source Paymaster as a service software", "type": "module", "directories": { diff --git a/backend/src/routes/admin.ts b/backend/src/routes/admin.ts index 5c851b9..778a350 100644 --- a/backend/src/routes/admin.ts +++ b/backend/src/routes/admin.ts @@ -14,9 +14,7 @@ const adminRoutes: FastifyPluginAsync = async (server) => { const body: any = JSON.parse(request.body as string); if (!body) return reply.code(ReturnCode.FAILURE).send({ error: ErrorMessage.EMPTY_BODY }); if (!body.WALLET_ADDRESS) return reply.code(ReturnCode.FAILURE).send({ error: ErrorMessage.INVALID_DATA }); - console.log(body, server.config.ADMIN_WALLET_ADDRESS) - if (ethers.utils.getAddress(body.WALLET_ADDRESS) === server.config.ADMIN_WALLET_ADDRESS) return reply.code(ReturnCode.SUCCESS).send({error: null, message: "Successfully Logged in"}); - return reply.code(ReturnCode.FAILURE).send({ error: ErrorMessage.INVALID_USER }); + if (ethers.utils.getAddress(body.WALLET_ADDRESS) === ethers.utils.getAddress(server.config.ADMIN_WALLET_ADDRESS)) return reply.code(ReturnCode.SUCCESS).send({error: null, message: "Successfully Logged in"}); return reply.code(ReturnCode.FAILURE).send({ error: ErrorMessage.INVALID_USER }); } catch (err: any) { return reply.code(ReturnCode.FAILURE).send({ error: ErrorMessage.INVALID_USER }); } @@ -86,8 +84,10 @@ const adminRoutes: FastifyPluginAsync = async (server) => { resolve(row); }) }) - if (result && result.length > 0) + if (result && result.length > 0){ + request.log.error(`Duplicate record found: ${JSON.stringify(result)}`) return reply.code(ReturnCode.FAILURE).send({ error: ErrorMessage.DUPLICATE_RECORD }); + } const privateKey = body.PRIVATE_KEY; const hmac = encode(privateKey); await new Promise((resolve, reject) => { @@ -153,7 +153,10 @@ const adminRoutes: FastifyPluginAsync = async (server) => { WHERE API_KEY = ?", [body.SUPPORTED_NETWORKS, body.ERC20_PAYMASTERS, body.TRANSACTION_LIMIT ?? 0, body.NO_OF_TRANSACTIONS_IN_A_MONTH ?? 10, body.INDEXER_ENDPOINT ?? process.env.DEFAULT_INDEXER_ENDPOINT, body.API_KEY ], (err: any, row: any) => { - if (err) reject(err); + if (err) { + request.log.error(`Error while saving APIKeys: ${err}`) + reject(err); + } resolve(row); }) }); diff --git a/backend/src/routes/metadata.ts b/backend/src/routes/metadata.ts index 4007af3..30bc946 100644 --- a/backend/src/routes/metadata.ts +++ b/backend/src/routes/metadata.ts @@ -1,13 +1,13 @@ import { GetSecretValueCommand, SecretsManagerClient } from "@aws-sdk/client-secrets-manager"; import { FastifyPluginAsync } from "fastify"; -import { Wallet, providers } from "ethers"; +import { Contract, Wallet, providers } from "ethers"; import SupportedNetworks from "../../config.json" assert { type: "json" }; import { getNetworkConfig, printRequest, getSQLdata } from "../utils/common.js"; import ReturnCode from "../constants/ReturnCode.js"; import ErrorMessage from "../constants/ErrorMessage.js"; import { decode } from "../utils/crypto.js"; import { PAYMASTER_ADDRESS } from "../constants/Pimlico.js"; - +import * as EtherspotAbi from "../abi/EtherspotAbi.js"; const metadataRoutes: FastifyPluginAsync = async (server) => { @@ -87,8 +87,13 @@ const metadataRoutes: FastifyPluginAsync = async (server) => { if (!networkConfig) return reply.code(ReturnCode.FAILURE).send({ error: ErrorMessage.UNSUPPORTED_NETWORK }); const provider = new providers.JsonRpcProvider(networkConfig.bundler); const signer = new Wallet(privateKey, provider) - const balance = await signer.getBalance(); - const address = await signer.getAddress(); + const sponsorWalletBalance = await signer.getBalance(); + const sponsorAddress = await signer.getAddress(); + + //get native balance of the sponsor in the EtherSpotPaymaster-contract + const paymasterContract = new Contract(networkConfig.contracts.etherspotPaymasterAddress, EtherspotAbi.default, provider); + const sponsorBalance = await paymasterContract.getSponsorBalance(sponsorAddress); + const chainsSupported: {chainId: number, entryPoint: string}[] = []; if (supportedNetworks) { const buffer = Buffer.from(supportedNetworks, 'base64'); @@ -106,8 +111,9 @@ const metadataRoutes: FastifyPluginAsync = async (server) => { ...customPaymasters, } return reply.code(ReturnCode.SUCCESS).send({ - sponsorAddress: address, - sponsorWalletBalance: balance, + sponsorAddress: sponsorAddress, + sponsorWalletBalance: sponsorWalletBalance, + sponsorBalance: sponsorBalance, chainsSupported: chainsSupported, tokenPaymasters: tokenPaymasterAddresses, multiTokenPaymasters, diff --git a/frontend/package.json b/frontend/package.json index 630bf15..d7032b3 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,6 @@ { "name": "arka_frontend", - "version": "1.2.4", + "version": "1.2.5", "private": true, "dependencies": { "@babel/plugin-proposal-private-property-in-object": "7.21.11",