From 8f2861a9e42db2af26344e1776d1c5490d9a0e45 Mon Sep 17 00:00:00 2001 From: Vignesh Date: Thu, 22 May 2025 22:12:57 +0530 Subject: [PATCH 1/2] removed whitelist and isPublic --- ...2025052200001-update-sponsorship-table.cjs | 27 +++++++++++++++++++ backend/src/models/sponsorship-policy.ts | 6 ----- .../sponsorship-policy-repository.ts | 3 --- backend/src/routes/paymaster-routes.ts | 11 +++++--- backend/src/types/sponsorship-policy-dto.ts | 1 - 5 files changed, 35 insertions(+), 13 deletions(-) create mode 100644 backend/migrations/2025052200001-update-sponsorship-table.cjs diff --git a/backend/migrations/2025052200001-update-sponsorship-table.cjs b/backend/migrations/2025052200001-update-sponsorship-table.cjs new file mode 100644 index 0000000..64587c8 --- /dev/null +++ b/backend/migrations/2025052200001-update-sponsorship-table.cjs @@ -0,0 +1,27 @@ +require('dotenv').config(); +const { DataTypes } = require('sequelize'); + +async function up({ context: queryInterface }) { + await queryInterface.removeColumn( + {schema: process.env.DATABASE_SCHEMA_NAME, tableName: 'sponsorship_policies'}, + 'IS_PUBLIC', + { + type: DataTypes.TEXT, + allowNull: true + } + ); +} + +async function down({ context: queryInterface }) { + await queryInterface.addColumn( + {schema: process.env.DATABASE_SCHEMA_NAME, tableName: 'sponsorship_policies'}, + 'IS_PUBLIC', + { + type: DataTypes.TEXT, + allowNull: true + } + ); +} + +/** @type {import('sequelize-cli').Migration} */ +module.exports = {up, down}; diff --git a/backend/src/models/sponsorship-policy.ts b/backend/src/models/sponsorship-policy.ts index 7f988ba..c3a672e 100644 --- a/backend/src/models/sponsorship-policy.ts +++ b/backend/src/models/sponsorship-policy.ts @@ -6,7 +6,6 @@ export class SponsorshipPolicy extends Model { public walletAddress!: string; public name!: string; public description!: string | null; - public isPublic: boolean = false; public isEnabled: boolean = false; public isApplicableToAllNetworks!: boolean; public enabledChains?: number[]; @@ -96,11 +95,6 @@ export function initializeSponsorshipPolicyModel(sequelize: Sequelize, schema: s allowNull: true, field: 'DESCRIPTION' }, - isPublic: { - type: DataTypes.BOOLEAN, - defaultValue: false, - field: 'IS_PUBLIC' - }, isEnabled: { type: DataTypes.BOOLEAN, defaultValue: false, diff --git a/backend/src/repository/sponsorship-policy-repository.ts b/backend/src/repository/sponsorship-policy-repository.ts index f2f4ac7..151cefe 100644 --- a/backend/src/repository/sponsorship-policy-repository.ts +++ b/backend/src/repository/sponsorship-policy-repository.ts @@ -351,7 +351,6 @@ export class SponsorshipPolicyRepository { walletAddress: sponsorshipPolicy.walletAddress, name: sponsorshipPolicy.name, description: sponsorshipPolicy.description, - isPublic: sponsorshipPolicy.isPublic, isEnabled: sponsorshipPolicy.isEnabled, isApplicableToAllNetworks: sponsorshipPolicy.isApplicableToAllNetworks, enabledChains: sponsorshipPolicy.enabledChains, @@ -493,8 +492,6 @@ export class SponsorshipPolicyRepository { existingSponsorshipPolicy.perOpMaximumNative = null; } - existingSponsorshipPolicy.isPublic = sponsorshipPolicy.isPublic; - if (existingSponsorshipPolicy.addressAllowList && existingSponsorshipPolicy.addressAllowList.length > 0) { existingSponsorshipPolicy.addressAllowList = sponsorshipPolicy.addressAllowList as string[]; } else { diff --git a/backend/src/routes/paymaster-routes.ts b/backend/src/routes/paymaster-routes.ts index ed340ac..a6f1076 100644 --- a/backend/src/routes/paymaster-routes.ts +++ b/backend/src/routes/paymaster-routes.ts @@ -230,7 +230,7 @@ const paymasterRoutes: FastifyPluginAsync = async (server, // get supported networks from sponsorshipPolicy const supportedNetworks: number[] | undefined | null = sponsorshipPolicy.enabledChains; - if (!supportedNetworks || !supportedNetworks.includes(chainId.chainId)) return reply.code(ReturnCode.FAILURE).send({ error: ErrorMessage.UNSUPPORTED_NETWORK }); + if ((!supportedNetworks || !supportedNetworks.includes(chainId.chainId)) && !sponsorshipPolicy.isApplicableToAllNetworks) return reply.code(ReturnCode.FAILURE).send({ error: ErrorMessage.UNSUPPORTED_NETWORK }); if (txnMode) { const signerAddress = await signer.getAddress(); @@ -255,11 +255,13 @@ const paymasterRoutes: FastifyPluginAsync = async (server, const contractWhitelistResult = await checkContractWhitelist(userOp.callData, chainId.chainId, signer.address); if (!contractWhitelistResult) throw new Error('Contract Method not whitelisted'); } + /* Removed Whitelist for now const isWhitelisted = await checkWhitelist(api_key, epVersion, userOp.sender, sponsorshipPolicy.id); // For EPV_06 we still use the old paymaster which whitelists the address on-chain if its verifyingPaymaster it goes to case vps for EPV_06 which checks on db if (!isWhitelisted && epVersion !== EPVersions.EPV_06) { throw new Error('This sender address has not been whitelisted yet'); } + */ if (epVersion === EPVersions.EPV_06) result = await paymaster.signV06(userOp, str, str1, entryPoint, networkConfig.contracts.etherspotPaymasterAddress, bundlerUrl, signer, estimate, server.log); else if (epVersion === EPVersions.EPV_07) { @@ -363,7 +365,7 @@ const paymasterRoutes: FastifyPluginAsync = async (server, // get supported networks from sponsorshipPolicy const supportedNetworks: number[] | undefined | null = sponsorshipPolicy.enabledChains; - if (!supportedNetworks || !supportedNetworks.includes(chainId.chainId)) return reply.code(ReturnCode.FAILURE).send({ error: ErrorMessage.UNSUPPORTED_NETWORK }); + if ((!supportedNetworks || !supportedNetworks.includes(chainId.chainId)) && !sponsorshipPolicy.isApplicableToAllNetworks) return reply.code(ReturnCode.FAILURE).send({ error: ErrorMessage.UNSUPPORTED_NETWORK }); if (txnMode) { const signerAddress = await signer.getAddress(); @@ -389,10 +391,12 @@ const paymasterRoutes: FastifyPluginAsync = async (server, if (!contractWhitelistResult) throw new Error('Contract Method not whitelisted'); } + /* Removed Whitelist const isWhitelisted = await checkWhitelist(api_key, epVersion, userOp.sender, sponsorshipPolicy.id); if (!isWhitelisted) { throw new Error('This sender address has not been whitelisted yet'); } + */ if (epVersion === EPVersions.EPV_06) { if (!apiKeyEntity.verifyingPaymasters) { @@ -592,6 +596,7 @@ const paymasterRoutes: FastifyPluginAsync = async (server, return returnValue; } + /* Removed Whitelist async function checkWhitelist(api_key: string, epVersion: EPVersions, senderAddress: string, policyId: number) { const globalWhitelistRecord = await server.whitelistRepository.findOneByApiKeyAndPolicyId(api_key); if (!globalWhitelistRecord?.addresses?.includes(senderAddress)) { @@ -607,7 +612,7 @@ const paymasterRoutes: FastifyPluginAsync = async (server, } } return true; - } + } */ }; export default paymasterRoutes; \ No newline at end of file diff --git a/backend/src/types/sponsorship-policy-dto.ts b/backend/src/types/sponsorship-policy-dto.ts index 1529786..fd6f6b7 100644 --- a/backend/src/types/sponsorship-policy-dto.ts +++ b/backend/src/types/sponsorship-policy-dto.ts @@ -4,7 +4,6 @@ export interface SponsorshipPolicyDto { walletAddress: string; // The wallet address associated with the API key name: string; // Name of the sponsorship policy description: string; // Description of the sponsorship policy - isPublic: boolean; // Flag to indicate if the policy is public isEnabled: boolean; // Flag to indicate if the policy is enabled isApplicableToAllNetworks: boolean; // Flag to indicate if the policy is universal enabledChains?: number[]; // Array of enabled chain IDs From 3325646e3c37999ff00bfca285ee9af6418d28e0 Mon Sep 17 00:00:00 2001 From: Vignesh Date: Thu, 22 May 2025 22:15:19 +0530 Subject: [PATCH 2/2] updated package version --- backend/CHANGELOG.md | 5 +++++ backend/package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/backend/CHANGELOG.md b/backend/CHANGELOG.md index 1400acb..873c8b5 100644 --- a/backend/CHANGELOG.md +++ b/backend/CHANGELOG.md @@ -1,4 +1,9 @@ # Changelog +## [4.1.0] - 2025-05-22 +### Fixes +- If `isApplicableTOAllChains` is true then dont check `enabledChains` on policy +- Removed whitelist validation for now + ## [4.0.2] - 2025-04-29 ### Fixes - Added oracle decimals as constants for multiTokenPaymaster as some rpc endpoints return error diff --git a/backend/package.json b/backend/package.json index 823f308..7682899 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "arka", - "version": "4.0.2", + "version": "4.1.0", "description": "ARKA - (Albanian for Cashier's case) is the first open source Paymaster as a service software", "type": "module", "directories": {