From 7bb4d167f7bc2e69bb9d3567d3adeecb485acae9 Mon Sep 17 00:00:00 2001 From: vignesha22 <82584664+vignesha22@users.noreply.github.com> Date: Tue, 14 Nov 2023 01:55:39 +0530 Subject: [PATCH] PRO-1968-Backward_Compatibility (#29) * fetched from params if queryString is not passed * updated readme and package description --- backend/README.md | 31 ++++++++++++++++++++++++++++++- backend/package.json | 4 ++-- backend/src/routes/index.ts | 22 +++++++++++----------- 3 files changed, 43 insertions(+), 14 deletions(-) diff --git a/backend/README.md b/backend/README.md index 9b53a3a..acd33ba 100644 --- a/backend/README.md +++ b/backend/README.md @@ -151,5 +151,34 @@ If you want to contribute, ``` And use it in routes/index.ts as server.config.newEnvVar inside routes variable 3. Test on your local machine -4. Sumbit the PR for merging the changes to master and notify us. +4. Submit the PR for merging the changes to master and notify us. 5. Also write the description of the changes made and do tell us why do you think this change is necessary and specify the env vars if needed to add + + +## Available endpoints - +## Note: All the below urls has two parameters as queryString i.e apiKey and chainId as default +- `/` - This url accepts three parameters in body as array and returns the paymasterData, verificationGasLimit, callGasLimit and preVerificationGas +Parameters: + 1. userOp object itself in JSON format + 2. entryPointAddress + 3. context object which has one required parameter mode and three optional parameter + - mode which accepts "erc20" | "sponsor" + - token (if mode is "erc20") which accepts symbol i.e "USDC" + - validAfter - timestamp in milliseconds only applicable with mode as "sponsor" used for defining the start of the paymaster validity + - validUntil - timestamp in milliseconds only applicable with mode as "sponsor" used for defining the end of the paymaster validity + +- `/pimlicoAddress` - This url accepts two parameters in body and returns the address of the deployed erc20 paymaster if exists +Parameters: + 1. entryPointAddress + 2. context object with token symbol i.e { token: "USDC" } + +- `/whitelist` - This url accepts one parameter and returns the submitted transaction hash if successful. This url is used to whitelist an array of addresses thats needed to be whitelisted for sponsorship. Please note that all addresses needs to be addresses that wasn't been whitelisted before. + 1. address - an array of addresses (max. 10 per request) + +- `/checkWhitelist` - This url accepts two parameters in body and returns if the address has been whitelisted or not + 1. sponsorAddress - The address of the sponsorer + 2. accountAddress - The address which needs to be checked + +- `/deposit` - This url accepts one parameter and returns the submitted transaction hash if successful. This url is used to deposit some funds to the entryPointAddress from the sponsor wallet + 1. amount - The amount to be deposited in ETH + diff --git a/backend/package.json b/backend/package.json index 33f5736..e631dd6 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,7 +1,7 @@ { "name": "arka", - "version": "1.1.4", - "description": "This project was bootstrapped with Fastify-CLI.", + "version": "1.1.5", + "description": "ARKA - (Albanian for Cashier's case) is the first open source Paymaster as a service software", "type": "module", "directories": { "test": "test" diff --git a/backend/src/routes/index.ts b/backend/src/routes/index.ts index 54521f2..5c0400f 100644 --- a/backend/src/routes/index.ts +++ b/backend/src/routes/index.ts @@ -59,8 +59,8 @@ const routes: FastifyPluginAsync = async (server) => { const context = body.params[2]; const gasToken = context?.token ? context.token : null; const mode = context?.mode ? String(context.mode) : null; - const chainId = query['chainId']; - const api_key = query['apiKey']; + const chainId = query['chainId'] ?? body.params[3]; + const api_key = query['apiKey'] ?? body.params[4]; if (!api_key) return reply.code(ReturnCode.FAILURE).send({ error: ErrorMessage.INVALID_API_KEY }) const AWSresponse = await client.send( @@ -145,8 +145,8 @@ const routes: FastifyPluginAsync = async (server) => { const entryPoint = body.params[0]; const context = body.params[1]; const gasToken = context ? context.token : null; - const chainId = query['chainId']; - const api_key = query['apiKey']; + const chainId = query['chainId'] ?? body.params[2]; + const api_key = query['apiKey'] ?? body.params[3]; if (!api_key) return reply.code(ReturnCode.FAILURE).send({ error: ErrorMessage.INVALID_API_KEY }) const AWSresponse = await client.send( @@ -202,7 +202,7 @@ const routes: FastifyPluginAsync = async (server) => { const entryPoint = body.params[1]; const context = body.params[2]; const gasToken = context ? context.token : null; - const api_key = query['apiKey']; + const api_key = query['apiKey'] ?? body.params[3]; if (!api_key) return reply.code(ReturnCode.FAILURE).send({ error: ErrorMessage.INVALID_API_KEY }) const AWSresponse = await client.send( @@ -239,8 +239,8 @@ const routes: FastifyPluginAsync = async (server) => { const body: any = request.body; const query: any = request.query; const address = body.params[0]; - const chainId = query['chainId']; - const api_key = query['apiKey']; + const chainId = query['chainId'] ?? body.params[1]; + const api_key = query['apiKey'] ?? body.params[2]; if (!api_key) return reply.code(ReturnCode.FAILURE).send({ error: ErrorMessage.INVALID_API_KEY }) const AWSresponse = await client.send( @@ -286,8 +286,8 @@ const routes: FastifyPluginAsync = async (server) => { const query: any = request.query; const sponsorAddress = body.params[0]; const accountAddress = body.params[1]; - const chainId = query['chainId']; - const api_key = query['apiKey']; + const chainId = query['chainId'] ?? body.params[2]; + const api_key = query['apiKey'] ?? body.params[3]; if (!api_key) return reply.code(ReturnCode.FAILURE).send({ error: ErrorMessage.INVALID_API_KEY }) const AWSresponse = await client.send( @@ -333,8 +333,8 @@ const routes: FastifyPluginAsync = async (server) => { const body: any = request.body; const query: any = request.query; const amount = body.params[0]; - const chainId = query['chainId']; - const api_key = query['apiKey']; + const chainId = query['chainId'] ?? body.params[1]; + const api_key = query['apiKey'] ?? body.params[2]; if (!api_key) return reply.code(ReturnCode.FAILURE).send({ error: ErrorMessage.INVALID_API_KEY }) const AWSresponse = await client.send(