Skip to content

Commit

Permalink
changed parameter and API route path names
Browse files Browse the repository at this point in the history
  • Loading branch information
vignesha22 committed Aug 9, 2024
1 parent 856f4b8 commit 57e7b85
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down
6 changes: 3 additions & 3 deletions backend/src/models/contract-whitelist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions backend/src/repository/contract-whitelist-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -69,7 +69,7 @@ export class ContractWhitelistRepository {

async updateOneById(record: ContractWhitelist): Promise<ContractWhitelist | null> {
const result = await this.sequelize.models.ContractWhitelist.update({
eventNames: record.eventNames,
functionSelectors: record.functionSelectors,
contractAddress: record.contractAddress,
abi: record.abi
}, {
Expand Down
4 changes: 2 additions & 2 deletions backend/src/routes/paymaster-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand All @@ -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;
}
}
Expand Down
14 changes: 7 additions & 7 deletions backend/src/routes/whitelist-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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'];
Expand Down Expand Up @@ -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);
Expand All @@ -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'];
Expand Down
2 changes: 1 addition & 1 deletion backend/src/types/contractWhitelist-dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
export interface ContractWhitelistDto {
walletAddress: string;
contractAddress: string;
eventNames: string[];
functionSelectors: string[];
abi: string;
chainId: number;
}

0 comments on commit 57e7b85

Please sign in to comment.