diff --git a/backend/migrations/2024080800001-create-contract-whitelist.cjs b/backend/migrations/2024080800001-create-contract-whitelist.cjs index a3b2f6f..99e5178 100644 --- a/backend/migrations/2024080800001-create-contract-whitelist.cjs +++ b/backend/migrations/2024080800001-create-contract-whitelist.cjs @@ -16,7 +16,7 @@ async function up({ context: queryInterface }) { type: Sequelize.TEXT, allowNull: false, }, - EVENT_NAMES: { + FUNCTION_SELECTORS: { type: Sequelize.ARRAY(Sequelize.TEXT), allowNull: false, }, diff --git a/backend/src/models/contract-whitelist.ts b/backend/src/models/contract-whitelist.ts index 50e402f..89d3e74 100644 --- a/backend/src/models/contract-whitelist.ts +++ b/backend/src/models/contract-whitelist.ts @@ -4,7 +4,7 @@ export class ContractWhitelist extends Model { public id!: number; public walletAddress!: string; public contractAddress!: string; - public eventNames!: string[]; + public functionSelectors!: string[]; public abi!: string; public chainId!: number; public createdAt!: Date; @@ -29,10 +29,10 @@ export function initializeContractWhitelistModel(sequelize: Sequelize, schema: s allowNull: false, field: 'CONTRACT_ADDRESS' }, - eventNames: { + functionSelectors: { type: DataTypes.ARRAY(DataTypes.TEXT), allowNull: false, - field: 'EVENT_NAMES' + field: 'FUNCTION_SELECTORS' }, abi: { type: DataTypes.TEXT, diff --git a/backend/src/repository/contract-whitelist-repository.ts b/backend/src/repository/contract-whitelist-repository.ts index ccb7a1b..4a4045b 100644 --- a/backend/src/repository/contract-whitelist-repository.ts +++ b/backend/src/repository/contract-whitelist-repository.ts @@ -15,7 +15,7 @@ export class ContractWhitelistRepository { const result = await this.sequelize.models.ContractWhitelist.create({ walletAddress: record.walletAddress, contractAddress: record.contractAddress, - eventNames: record.eventNames, + functionSelectors: record.functionSelectors, abi: record.abi, chainId: record.chainId, }) as ContractWhitelist; @@ -69,7 +69,7 @@ export class ContractWhitelistRepository { async updateOneById(record: ContractWhitelist): Promise { const result = await this.sequelize.models.ContractWhitelist.update({ - eventNames: record.eventNames, + functionSelectors: record.functionSelectors, contractAddress: record.contractAddress, abi: record.abi }, { diff --git a/backend/src/routes/paymaster-routes.ts b/backend/src/routes/paymaster-routes.ts index a01c6c5..83cc7f7 100644 --- a/backend/src/routes/paymaster-routes.ts +++ b/backend/src/routes/paymaster-routes.ts @@ -369,7 +369,7 @@ const paymasterRoutes: FastifyPluginAsync = async (server) => { if (contractRecord) { const iface1 = new ethers.utils.Interface(contractRecord.abi); const functionName = iface1.getFunction(transactionData.substring(0, 10)) - if (contractRecord.eventNames.includes(functionName.name)) { + if (contractRecord.functionSelectors.includes(functionName.name)) { return true; } } @@ -393,7 +393,7 @@ const paymasterRoutes: FastifyPluginAsync = async (server) => { if (contractRecord) { const iface1 = new ethers.utils.Interface(contractRecord.abi); const functionName = iface1.getFunction(transactionData.substring(0, 10)) - if (contractRecord.eventNames.includes(functionName.name)) { + if (contractRecord.functionSelectors.includes(functionName.name)) { return true; } } diff --git a/backend/src/routes/whitelist-routes.ts b/backend/src/routes/whitelist-routes.ts index 8f2a587..5b9f101 100644 --- a/backend/src/routes/whitelist-routes.ts +++ b/backend/src/routes/whitelist-routes.ts @@ -479,10 +479,10 @@ const whitelistRoutes: FastifyPluginAsync = async (server) => { } ) - server.post("/contractAddWhitelist", + server.post("/whitelistContractAddress", async function (request, reply) { try { - printRequest("/contractAddWhitelist", request, server.log); + printRequest("/whitelistContractAddress", request, server.log); const contractWhitelistDto: ContractWhitelistDto = JSON.parse(JSON.stringify(request.body)) as ContractWhitelistDto; const query: any = request.query; @@ -544,10 +544,10 @@ const whitelistRoutes: FastifyPluginAsync = async (server) => { } ) - server.post("/contractUpdateWhitelist", + server.post("/updateWhitelistContractAddress", async function (request, reply) { try { - printRequest("/contractUpdateWhitelist", request, server.log); + printRequest("/updateWhitelistContractAddress", request, server.log); const contractWhitelistDto: ContractWhitelistDto = JSON.parse(JSON.stringify(request.body)) as ContractWhitelistDto; const query: any = request.query; const chainId = query['chainId']; @@ -591,7 +591,7 @@ const whitelistRoutes: FastifyPluginAsync = async (server) => { if (!existingRecord) return reply.code(ReturnCode.FAILURE).send({ error: ErrorMessage.NO_CONTRACT_WHITELIST_FOUND }) existingRecord.contractAddress = contractWhitelistDto.contractAddress; - existingRecord.eventNames = contractWhitelistDto.eventNames; + existingRecord.functionSelectors = contractWhitelistDto.functionSelectors; existingRecord.abi = contractWhitelistDto.abi; const result = await server.contractWhitelistRepository.updateOneById(existingRecord); @@ -610,10 +610,10 @@ const whitelistRoutes: FastifyPluginAsync = async (server) => { ) - server.post("/contractDeleteWhitelist", + server.post("/deleteContractWhitelist", async function (request, reply) { try { - printRequest("/contractDeleteWhitelist", request, server.log); + printRequest("/deleteContractWhitelist", request, server.log); const contractWhitelistDto: ContractWhitelistDto = JSON.parse(JSON.stringify(request.body)) as ContractWhitelistDto; const query: any = request.query; const chainId = query['chainId']; diff --git a/backend/src/types/contractWhitelist-dto.ts b/backend/src/types/contractWhitelist-dto.ts index ac4c10e..f6435fa 100644 --- a/backend/src/types/contractWhitelist-dto.ts +++ b/backend/src/types/contractWhitelist-dto.ts @@ -2,7 +2,7 @@ export interface ContractWhitelistDto { walletAddress: string; contractAddress: string; - eventNames: string[]; + functionSelectors: string[]; abi: string; chainId: number; } \ No newline at end of file