diff --git a/backend/README.md b/backend/README.md index 32a8320..5284cbf 100644 --- a/backend/README.md +++ b/backend/README.md @@ -181,6 +181,22 @@ Parameters: - `/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 + +- `/whitelist/v2` - This url accepts one parameter and returns a message indicating whether the offchain whitelist was successful. This url is used to whitelist an array of addresses thats needed to be whitelisted for sponsorship. If all the addresses were already whitelisted, an error message will be thrown. If some of the addresses were already whitelisted the rest of the addresses will be whitelisted. + 1. address - an array of addresses (max. 10 per request) + +- `/removeWhitelist/v2` - This url accepts one parameter and returns a message indicating whether the offchain whitelist removal was successful. This url is used to remove whitelist of an array of addresses. If all the addresses were not whitelisted, an error message will be thrown. If some of the addresses were not whitelisted the rest of the addresses will be removed from whitelist. + 1. address - an array of addresses (max. 10 per request) + +- `/checkWhitelist/v2` - This url accepts one parameter and returns if the address has been whitelisted or not + 1. address - The address which needs to be checked. + 2. policyId - Optional policy id. + +- `/deposit/v2` - 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. + +- `/getAllWhitelist/v2` - This url accepts optionally one parameter and returns all the addresses which are whitelisted for the apiKey/policyId. + 1. policyId - Optional policy id. ## Local Docker Networks diff --git a/backend/package.json b/backend/package.json index ce00744..e370afc 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "arka", - "version": "1.4.1", + "version": "1.4.2", "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/constants/ReturnCode.ts b/backend/src/constants/ReturnCode.ts index fcecb19..a925156 100644 --- a/backend/src/constants/ReturnCode.ts +++ b/backend/src/constants/ReturnCode.ts @@ -5,4 +5,5 @@ export default { NOT_FOUND: 404, INTERNAL_SERVER_ERROR: 500, NOT_AUTHORIZED: 403, + CONFLICT: 409 } diff --git a/backend/src/routes/whitelist-routes.ts b/backend/src/routes/whitelist-routes.ts index 5b9f101..3b7ab8e 100644 --- a/backend/src/routes/whitelist-routes.ts +++ b/backend/src/routes/whitelist-routes.ts @@ -258,14 +258,14 @@ const whitelistRoutes: FastifyPluginAsync = async (server) => { existingWhitelistRecord.addresses.splice(existingWhitelistRecord.addresses.indexOf(ele), 1); } }); - if (toBeRemoved.length < 1) return reply.code(ReturnCode.FAILURE).send({ error: ErrorMessage.ADDRESS_ALREADY_ADDED }); + if (toBeRemoved.length < 1) return reply.code(ReturnCode.CONFLICT).send({ error: ErrorMessage.ADDRESS_NOT_WHITELISTED }); if (existingWhitelistRecord.addresses.length < 1) await server.whitelistRepository.deleteById(existingWhitelistRecord.id); else await server.whitelistRepository.updateOneById(existingWhitelistRecord); } else { throw new Error(ErrorMessage.NO_WHITELIST_FOUND); } - const result = { message: "Successfully deleted from Whitelist" } + const result = { message: "Successfully removed whitelisted addresses" } server.log.info(result, 'Response sent: '); if (body.jsonrpc) return reply.code(ReturnCode.SUCCESS).send({ jsonrpc: body.jsonrpc, id: body.id, result, error: null }) @@ -392,7 +392,7 @@ const whitelistRoutes: FastifyPluginAsync = async (server) => { address.filter(ele => { if (!existingWhitelistRecord.addresses.includes(ele)) toBeAdded.push(ele); }); - if (toBeAdded.length < 1) return reply.code(ReturnCode.FAILURE).send({ error: ErrorMessage.ADDRESS_ALREADY_ADDED }); + if (toBeAdded.length < 1) return reply.code(ReturnCode.CONFLICT).send({ error: ErrorMessage.ADDRESS_ALREADY_ADDED }); const allAddresses = toBeAdded.concat(existingWhitelistRecord.addresses); existingWhitelistRecord.addresses = allAddresses; await server.whitelistRepository.updateOneById(existingWhitelistRecord); @@ -405,7 +405,7 @@ const whitelistRoutes: FastifyPluginAsync = async (server) => { await server.whitelistRepository.create(addWhitelistDto); } - const result = { message: "Successfully added to Whitelist" } + const result = { message: "Successfully whitelisted" } server.log.info(result, 'Response sent: '); if (body.jsonrpc) return reply.code(ReturnCode.SUCCESS).send({ jsonrpc: body.jsonrpc, id: body.id, result, error: null })