Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PRO-2585-Arka_Changes #124

Merged
merged 3 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
1 change: 1 addition & 0 deletions backend/src/constants/ReturnCode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ export default {
NOT_FOUND: 404,
INTERNAL_SERVER_ERROR: 500,
NOT_AUTHORIZED: 403,
CONFLICT: 409
}
8 changes: 4 additions & 4 deletions backend/src/routes/whitelist-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand Down Expand Up @@ -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);
Expand All @@ -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 })
Expand Down
Loading