Skip to content

Commit

Permalink
PRO-1968-Backward_Compatibility (#29)
Browse files Browse the repository at this point in the history
* fetched from params if queryString is not passed

* updated readme and package description
  • Loading branch information
vignesha22 authored Nov 13, 2023
1 parent 69e103b commit 7bb4d16
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 14 deletions.
31 changes: 30 additions & 1 deletion backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

4 changes: 2 additions & 2 deletions backend/package.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
22 changes: 11 additions & 11 deletions backend/src/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 7bb4d16

Please sign in to comment.