Skip to content

Commit

Permalink
chore: remove unused saveGMP API
Browse files Browse the repository at this point in the history
  • Loading branch information
canhtrinh committed Jan 12, 2024
1 parent 83210e7 commit 12f2b7c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 71 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [0.13.10] - 2024-JANUARY-12

- Remove unused internal APIs

## [0.13.8] - 2023-DECEMBER-18

- Add `Immutable` to mainnet configs; update `Immutable` testnet RPC
Expand Down
41 changes: 0 additions & 41 deletions src/libs/TransactionRecoveryApi/AxelarGMPRecoveryAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,25 +172,6 @@ export class AxelarGMPRecoveryAPI extends AxelarRecoveryApi {
});
}

private async saveGMP(
sourceTransactionHash: string,
relayerAddress: string,
sourceTransactionIndex?: number,
sourceTransactionLogIndex?: number,
transactionHash?: string,
error?: any
) {
return await this.execPost(super.getAxelarGMPApiUrl, "", {
method: "saveGMP",
sourceTransactionHash,
transactionHash,
sourceTransactionIndex,
sourceTransactionLogIndex,
relayerAddress,
error,
});
}

public getCidFromSrcTxHash(destChainId: string, txHash: string, eventIndex: number) {
return getCommandId(destChainId, txHash, eventIndex, this.environment, rpcInfo);
}
Expand Down Expand Up @@ -1147,28 +1128,6 @@ export class AxelarGMPRecoveryAPI extends AxelarRecoveryApi {
}
});

// Submit execute data to axelarscan if the contract execution is success.
const signerAddress = await signer.getAddress();
const executeTxHash = txResult.transaction?.transactionHash;
if (executeTxHash) {
await this.saveGMP(
srcTxHash,
signerAddress,
srcTxInfo.transactionIndex,
srcTxInfo.logIndex,
executeTxHash
).catch(() => undefined);
} else {
await this.saveGMP(
srcTxHash,
signerAddress,
srcTxInfo.transactionIndex,
srcTxInfo.logIndex,
"",
txResult.error
).catch(() => undefined);
}

return txResult;
}

Expand Down
30 changes: 0 additions & 30 deletions src/libs/test/TransactionRecoveryAPI/AxelarGMPRecoveryAPI.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1525,23 +1525,11 @@ describe("AxelarGMPRecoveryAPI", () => {
const error = new Error(ContractCallHelper.CALL_EXECUTE_ERROR.REVERT);
vitest.spyOn(ContractCallHelper, "callExecute").mockRejectedValueOnce(error);

// Mock private saveGMP
const mockGMPApi = vitest.spyOn(AxelarGMPRecoveryAPI.prototype as any, "saveGMP");
mockGMPApi.mockImplementation(() => Promise.resolve(undefined));

const sourceTxHash = "0x86e5f91eff5a8a815e90449ca32e02781508f3b94620bbdf521f2ba07c41d9ae";
const response = await api.execute(sourceTxHash, undefined, evmWalletDetails);

// Expect returns error
expect(response).toEqual(ExecutionRevertedError(executeParams));

// Expect we don't call saveGMP api
expect(mockGMPApi).toHaveBeenCalledWith(
sourceTxHash,
new ethers.Wallet(evmWalletDetails.privateKey as string).address,
"",
response.error
);
});

test("it calls 'execute' and return revert error given 'callExecute' throws 'CALL_EXECUTE_ERROR.INSUFFICIENT_FUNDS' error", async () => {
Expand All @@ -1557,23 +1545,11 @@ describe("AxelarGMPRecoveryAPI", () => {
const error = new Error(ContractCallHelper.CALL_EXECUTE_ERROR.INSUFFICIENT_FUNDS);
vitest.spyOn(ContractCallHelper, "callExecute").mockRejectedValueOnce(error);

// Mock private saveGMP
const mockGMPApi = vitest.spyOn(AxelarGMPRecoveryAPI.prototype as any, "saveGMP");
mockGMPApi.mockImplementation(() => Promise.resolve(undefined));

const sourceTxHash = "0x86e5f91eff5a8a815e90449ca32e02781508f3b94620bbdf521f2ba07c41d9ae";
const response = await api.execute(sourceTxHash, undefined, evmWalletDetails);

// Expect returns error
expect(response).toEqual(InsufficientFundsError(executeParams));

// Expect we don't call saveGMP api
expect(mockGMPApi).toHaveBeenCalledWith(
sourceTxHash,
new ethers.Wallet(evmWalletDetails.privateKey as string).address,
"",
response.error
);
});

test("it should call 'execute' and return success = true", async () => {
Expand All @@ -1588,10 +1564,6 @@ describe("AxelarGMPRecoveryAPI", () => {
// Mock contract call is successful
vitest.spyOn(ContractCallHelper, "callExecute").mockResolvedValueOnce(contractReceiptStub());

// Mock private saveGMP
const mockGMPApi = vitest.spyOn(AxelarGMPRecoveryAPI.prototype as any, "saveGMP");
mockGMPApi.mockImplementation(() => Promise.resolve(undefined));

const response = await api.execute(
"0x86e5f91eff5a8a815e90449ca32e02781508f3b94620bbdf521f2ba07c41d9ae",
undefined,
Expand Down Expand Up @@ -1624,8 +1596,6 @@ describe("AxelarGMPRecoveryAPI", () => {
},
},
});

expect(mockGMPApi).toHaveBeenCalledTimes(1);
});
});
});

0 comments on commit 12f2b7c

Please sign in to comment.