Skip to content

Commit

Permalink
api endpoint changes for policy related apis (#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhilkumar1612 authored Jan 27, 2025
1 parent 236b05f commit 43755be
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 16 deletions.
18 changes: 18 additions & 0 deletions backend/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
# Changelog

## [3.0.0] - 2025-01-09
### Breaking Changes
- changed `pimlicoAddress` endpoint name to `tokenPaymasterAddress` the functionality remains the same
- Changed the following endpoint names to be camelCases:-
- `/policy/wallet-address/:walletAddress` to `/policy/walletAddress/:walletAddress`
- `/policy/wallet-address/:walletAddress/ep-version/:epVersion` to `/policy/walletAddress/:walletAddress/epVersion/:epVersion`
- `/policy/wallet-address/:walletAddress/ep-version/:epVersion/chain-id/:chainId` to `/policy/walletAddress/:walletAddress/epVersion/:epVersion/chainId/:chainId`
- `/policy/wallet-address/:walletAddress/latest` to `/policy/walletAddress/:walletAddress/latest`
- `/policy/wallet-address/:walletAddress/chain-id/:chainId/latest` to `/policy/walletAddress/:walletAddress/chainId/:chainId/latest`
- `/policy/wallet-address/:walletAddress/ep-version/:epVersion/latest` to `/policy/walletAddress/:walletAddress/epVersion/:epVersion/latest`
- `/policy/wallet-address/:walletAddress/ep-version/:epVersion/chainId/:chain-id/latest` to `/policy/walletAddress/:walletAddress/epVersion/:epVersion/chainId/:chainId/latest`
- `/add-policy` to `/addPolicy`
- `/delete-policy/:id` to `/deletePolicy/:id`
- `/update-policy` to `/updatePolicy`
- `/enable-policy/:id` to `/enablePolicy/:id`
- `/disable-policy/:id` to `/disablePolicy/:id`

## [2.1.1] - 2025-01-21
### Bug Fixes
- Updated from master branch on bug fixes for MTP
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": "2.1.1",
"version": "3.0.0",
"description": "ARKA - (Albanian for Cashier's case) is the first open source Paymaster as a service software",
"type": "module",
"directories": {
Expand Down
6 changes: 3 additions & 3 deletions backend/src/routes/pimlico-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ const pimlicoRoutes: FastifyPluginAsync = async (server) => {
}
}

server.post("/pimlicoAddress",
server.post("/tokenPaymasterAddress",
ResponseSchema,
async function (request, reply) {
try {
printRequest("/pimlicoAddress", request, server.log);
printRequest("/tokenPaymasterAddress", request, server.log);
const query: any = request.query;
const body: any = request.body;
const entryPoint = body.params[0];
Expand Down Expand Up @@ -91,7 +91,7 @@ const pimlicoRoutes: FastifyPluginAsync = async (server) => {
if (!(PAYMASTER_ADDRESS[chainId] && PAYMASTER_ADDRESS[chainId][gasToken])) return reply.code(ReturnCode.FAILURE).send({ error: "Invalid network/token" })
result = { message: PAYMASTER_ADDRESS[chainId][gasToken] }
}
server.log.info(result, 'PimlicoAddress Response sent: ');
server.log.info(result, 'tokenPaymasterAddress Response sent: ');
if (body.jsonrpc)
return reply.code(ReturnCode.SUCCESS).send({ jsonrpc: body.jsonrpc, id: body.id, message: result.message, error: null })
return reply.code(ReturnCode.SUCCESS).send(result);
Expand Down
24 changes: 12 additions & 12 deletions backend/src/routes/sponsorship-policy-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const sponsorshipPolicyRoutes: FastifyPluginAsync = async (server) => {
})

// find all by walletAddress
server.get<{ Params: RouteParams }>("/policy/wallet-address/:walletAddress", async (request, reply) => {
server.get<{ Params: RouteParams }>("/policy/walletAddress/:walletAddress", async (request, reply) => {
try {
const walletAddress = request.params.walletAddress;

Expand All @@ -74,7 +74,7 @@ const sponsorshipPolicyRoutes: FastifyPluginAsync = async (server) => {
})

// find all by walletAddress And EPVersion
server.get<{ Params: RouteParams }>("/policy/wallet-address/:walletAddress/ep-version/:epVersion", async (request, reply) => {
server.get<{ Params: RouteParams }>("/policy/walletAddress/:walletAddress/epVersion/:epVersion", async (request, reply) => {
try {
const walletAddress = request.params.walletAddress;
const epVersion = request.params.epVersion;
Expand All @@ -96,7 +96,7 @@ const sponsorshipPolicyRoutes: FastifyPluginAsync = async (server) => {
})

// Get all policies for a given walletAddress, epVersion, and chainId
server.get<{ Params: RouteParams }>("/policy/wallet-address/:walletAddress/ep-version/:epVersion/chain-id/:chainId", async (request, reply) => {
server.get<{ Params: RouteParams }>("/policy/walletAddress/:walletAddress/epVersion/:epVersion/chainId/:chainId", async (request, reply) => {
try {
const walletAddress = request.params.walletAddress;
const epVersion = request.params.epVersion;
Expand All @@ -119,7 +119,7 @@ const sponsorshipPolicyRoutes: FastifyPluginAsync = async (server) => {
})

// find latest by walletAddress
server.get<{ Params: RouteParams }>("/policy/wallet-address/:walletAddress/latest", async (request, reply) => {
server.get<{ Params: RouteParams }>("/policy/walletAddress/:walletAddress/latest", async (request, reply) => {
try {
const walletAddress = request.params.walletAddress;

Expand All @@ -140,7 +140,7 @@ const sponsorshipPolicyRoutes: FastifyPluginAsync = async (server) => {
})

// find latest by walletAddress And chainId
server.get<{ Params: RouteParams }>("/policy/wallet-address/:walletAddress/chain-id/:chainId/latest", async (request, reply) => {
server.get<{ Params: RouteParams }>("/policy/walletAddress/:walletAddress/chainId/:chainId/latest", async (request, reply) => {
try {
const walletAddress = request.params.walletAddress;
const chainId = request.params.chainId;
Expand All @@ -162,7 +162,7 @@ const sponsorshipPolicyRoutes: FastifyPluginAsync = async (server) => {
})

// find latest By WalletAddress And EPVersion
server.get<{ Params: RouteParams }>("/policy/wallet-address/:walletAddress/ep-version/:epVersion/latest", async (request, reply) => {
server.get<{ Params: RouteParams }>("/policy/walletAddress/:walletAddress/epVersion/:epVersion/latest", async (request, reply) => {
try {
const walletAddress = request.params.walletAddress;
const epVersion = request.params.epVersion;
Expand All @@ -184,7 +184,7 @@ const sponsorshipPolicyRoutes: FastifyPluginAsync = async (server) => {
})

// find latest policy for a given walletAddress, epVersion, and chainId
server.get<{ Params: RouteParams }>("/policy/wallet-address/:walletAddress/ep-version/:epVersion/chain-id/:chainId/latest", async (request, reply) => {
server.get<{ Params: RouteParams }>("/policy/walletAddress/:walletAddress/epVersion/:epVersion/chainId/:chainId/latest", async (request, reply) => {
try {
const walletAddress = request.params.walletAddress;
const epVersion = request.params.epVersion;
Expand Down Expand Up @@ -236,7 +236,7 @@ const sponsorshipPolicyRoutes: FastifyPluginAsync = async (server) => {
}

// create a new policy
server.post("/add-policy", async function (request, reply) {
server.post("/addPolicy", async function (request, reply) {
try {
// parse the request body as JSON
const sponsorshipPolicyDto: SponsorshipPolicyDto = JSON.parse(JSON.stringify(request.body)) as SponsorshipPolicyDto;
Expand Down Expand Up @@ -304,7 +304,7 @@ const sponsorshipPolicyRoutes: FastifyPluginAsync = async (server) => {
})

// delete a policy
server.delete<{ Params: RouteParams }>("/delete-policy/:id", async (request, reply) => {
server.delete<{ Params: RouteParams }>("/deletePolicy/:id", async (request, reply) => {
try {
const id = Number(request.params.id);
if (isNaN(id)) {
Expand Down Expand Up @@ -341,7 +341,7 @@ const sponsorshipPolicyRoutes: FastifyPluginAsync = async (server) => {
});

// update a policy
server.put<{ Body: SponsorshipPolicyDto }>("/update-policy", async (request, reply) => {
server.put<{ Body: SponsorshipPolicyDto }>("/updatePolicy", async (request, reply) => {
try {
const sponsorshipPolicyDto: SponsorshipPolicyDto = JSON.parse(JSON.stringify(request.body)) as SponsorshipPolicyDto;
const id = sponsorshipPolicyDto.id;
Expand Down Expand Up @@ -382,7 +382,7 @@ const sponsorshipPolicyRoutes: FastifyPluginAsync = async (server) => {
});

// enable policy
server.put<{ Params: RouteParams }>("/enable-policy/:id", async (request, reply) => {
server.put<{ Params: RouteParams }>("/enablePolicy/:id", async (request, reply) => {
try {
const id = Number(request.params.id);
if (isNaN(id)) {
Expand Down Expand Up @@ -419,7 +419,7 @@ const sponsorshipPolicyRoutes: FastifyPluginAsync = async (server) => {
});

// disable policy
server.put<{ Params: RouteParams }>("/disable-policy/:id", async (request, reply) => {
server.put<{ Params: RouteParams }>("/disablePolicy/:id", async (request, reply) => {
try {
const id = Number(request.params.id);
if (isNaN(id)) {
Expand Down

0 comments on commit 43755be

Please sign in to comment.