Skip to content
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
5 changes: 5 additions & 0 deletions backend/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
27 changes: 27 additions & 0 deletions backend/migrations/2025052200001-update-sponsorship-table.cjs
Original file line number Diff line number Diff line change
@@ -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};
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": "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": {
Expand Down
6 changes: 0 additions & 6 deletions backend/src/models/sponsorship-policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 0 additions & 3 deletions backend/src/repository/sponsorship-policy-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down
11 changes: 8 additions & 3 deletions backend/src/routes/paymaster-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ const paymasterRoutes: FastifyPluginAsync<PaymasterRoutesOpts> = 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();
Expand All @@ -255,11 +255,13 @@ const paymasterRoutes: FastifyPluginAsync<PaymasterRoutesOpts> = 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) {
Expand Down Expand Up @@ -363,7 +365,7 @@ const paymasterRoutes: FastifyPluginAsync<PaymasterRoutesOpts> = 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();
Expand All @@ -389,10 +391,12 @@ const paymasterRoutes: FastifyPluginAsync<PaymasterRoutesOpts> = 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) {
Expand Down Expand Up @@ -592,6 +596,7 @@ const paymasterRoutes: FastifyPluginAsync<PaymasterRoutesOpts> = 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)) {
Expand All @@ -607,7 +612,7 @@ const paymasterRoutes: FastifyPluginAsync<PaymasterRoutesOpts> = async (server,
}
}
return true;
}
} */
};

export default paymasterRoutes;
1 change: 0 additions & 1 deletion backend/src/types/sponsorship-policy-dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down