Skip to content

Commit

Permalink
Fix existing tests and add new ones after refactoring to use axelar g…
Browse files Browse the repository at this point in the history
…mp api.
  • Loading branch information
raress96 committed Sep 4, 2024
1 parent e51fe45 commit b5d36fd
Show file tree
Hide file tree
Showing 27 changed files with 1,075 additions and 1,023 deletions.
2 changes: 1 addition & 1 deletion .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ CONTRACT_WEGLD_SWAP=erd1qqqqqqqqqqqqqpgqhe8t5jewej70zupmh44jurgn29psua5l2jps3ntj

AXELAR_CONTRACT_VOTING_VERIFIER=axelar1jjtc5zemkt9tn6nfvk78xl6f8svrrsvyqcdcca

AXELAR_API_URL=localhost:5000
AXELAR_GMP_API_URL=localhost:5000

CHAIN_ID=test

Expand Down
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = {
},
rules: {
"@typescript-eslint/no-explicit-any": ["off"],
"@typescript-eslint/no-unused-vars": ["off"],
"@typescript-eslint/no-unused-vars": ["error"],
"@typescript-eslint/ban-ts-comment": ["off"],
"@typescript-eslint/no-empty-function": ["off"],
"@typescript-eslint/ban-types": ["off"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import { GatewayContract } from '@mvx-monorepo/common/contracts/gateway.contract
import { PendingTransaction } from './entities/pending-transaction';
import { CONSTANTS } from '@mvx-monorepo/common/utils/constants.enum';
import { Components } from '@mvx-monorepo/common/api/entities/axelar.gmp.api';
import { MessageApprovedRepository } from '@mvx-monorepo/common/database/repository/message-approved.repository';
import { MessageApprovedStatus } from '@prisma/client';
import TaskItem = Components.Schemas.TaskItem;
import GatewayTransactionTask = Components.Schemas.GatewayTransactionTask;
import ExecuteTask = Components.Schemas.ExecuteTask;
import { MessageApprovedRepository } from '@mvx-monorepo/common/database/repository/message-approved.repository';
import { MessageApprovedStatus } from '@prisma/client';
import RefundTask = Components.Schemas.RefundTask;

const MAX_NUMBER_OF_RETRIES = 3;
Expand Down Expand Up @@ -72,8 +72,9 @@ export class ApprovalsProcessorService {

await this.redisCacheService.set(CacheInfo.LastTaskUUID().key, lastTaskUUID, CacheInfo.LastTaskUUID().ttl);
} catch (e) {
this.logger.error(`Could not process task ${task.id}`, task);
this.logger.error(`Could not process task ${task.id}`, task, e);

// Stop processing in case of an error and retry from the sam task
return;
}
}
Expand Down Expand Up @@ -206,15 +207,20 @@ export class ApprovalsProcessorService {
sourceAddress: response.message.sourceAddress,
contractAddress: response.message.destinationAddress,
payloadHash: response.message.payloadHash,
payload: Buffer.from(response.payload.slice(2), 'hex'),
payload: Buffer.from(response.payload, 'hex'),
retry: 0,
});

if (!messageApproved) {
throw new Error(`Couldn't save message approved to database for message id ${response.message.messageID}`);
this.logger.warn(
`Couldn't save message approved to database, duplicate exists for source chain ${response.message.sourceChain} and message id ${response.message.messageID}`,
);

return;
}
}

// TODO: Handle refunds
private processRefundTask(response: RefundTask) {
this.logger.warn(
`Received a refund task for ${response.message.messageID}. However refunds are not currently supported`,
Expand Down
Loading

0 comments on commit b5d36fd

Please sign in to comment.