Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove unused saveGMP API #295

Merged
merged 4 commits into from
Feb 9, 2024
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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ 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-FEBRUARY-9

- Remove unused internal APIs
- Add Fraxtal testnet

## [0.13.8] - 2023-DECEMBER-18

- Add `Immutable` to mainnet configs; update `Immutable` testnet RPC
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@axelar-network/axelarjs-sdk",
"version": "0.13.9",
"version": "0.13.10",
"description": "The JavaScript SDK for Axelar Network",
"repository": {
"type": "git",
Expand Down
1 change: 1 addition & 0 deletions src/chains/supported-chains-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const CHAINS = {
FANTOM: "Fantom",
FETCH: "fetch",
FILECOIN: "filecoin-2",
FRAXTAL: "fraxtal",
HAQQ: "haqq",
HERO: "hero",
HIGHRISE: "highrise",
Expand Down
1 change: 1 addition & 0 deletions src/constants/EvmChain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ export enum EvmChain {
IMMUTABLE = "immutable",
CENTRIFUGE_TESTNET = "centrifuge-2",
CENTRIFUGE = "centrifuge",
FRAXTAL = "fraxtal",
}
2 changes: 2 additions & 0 deletions src/constants/GasToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export enum GasToken {
SEPOLIA = "ETH",
ARBITRUM_SEPOLIA = "ETH",
CENTRIFUGE = "CFG",
FRAXTAL = "frxETH",
}

export const nativeGasTokenSymbol: Record<string, Record<EvmChain | string, GasToken>> = {
Expand All @@ -53,6 +54,7 @@ export const nativeGasTokenSymbol: Record<string, Record<EvmChain | string, GasT
[EvmChain.IMMUTABLE]: GasToken.IMMUTABLE,
[EvmChain.ARBITRUM_SEPOLIA]: GasToken.ARBITRUM_SEPOLIA,
[EvmChain.CENTRIFUGE_TESTNET]: GasToken.CENTRIFUGE,
[EvmChain.FRAXTAL]: GasToken.FRAXTAL,
},
mainnet: {
[EvmChain.AVALANCHE]: GasToken.AVAX,
Expand Down
1 change: 1 addition & 0 deletions src/libs/AxelarGateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export const AXELAR_GATEWAY: Record<Environment, Partial<Record<EvmChain, string
[EvmChain.IMMUTABLE]: "0xe432150cce91c13a887f7D836923d5597adD8E31",
[EvmChain.CENTRIFUGE_TESTNET]: "0xe432150cce91c13a887f7D836923d5597adD8E31",
[EvmChain.ARBITRUM_SEPOLIA]: "0xe432150cce91c13a887f7D836923d5597adD8E31",
[EvmChain.FRAXTAL]: "0xe432150cce91c13a887f7D836923d5597adD8E31",
},
[Environment.DEVNET]: {
[EvmChain.ETHEREUM]: "0x7358799e0c8250f0B7D1164824F6Dd5bA31C9Cd6",
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 @@
});
}

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 @@ -291,7 +272,7 @@
destChain: string,
txHash: string,
txEventIndex: number | undefined,
evmWalletDetails: EvmWalletDetails

Check warning on line 275 in src/libs/TransactionRecoveryApi/AxelarGMPRecoveryAPI.ts

View workflow job for this annotation

GitHub Actions / ESLint

src/libs/TransactionRecoveryApi/AxelarGMPRecoveryAPI.ts#L275

'evmWalletDetails' is defined but never used (@typescript-eslint/no-unused-vars)
): Promise<ConfirmTxSDKResponse> {
if (this.debugMode)
console.debug(`confirmation: checking whether ${txHash} needs to be confirmed on Axelar`);
Expand Down Expand Up @@ -1100,7 +1081,7 @@

const executeParams = response.data as ExecuteParams;
const gasLimitBuffer = evmWalletDetails?.gasLimitBuffer || 0;
const { destinationChain, destinationContractAddress, srcTxInfo } = executeParams;

Check warning on line 1084 in src/libs/TransactionRecoveryApi/AxelarGMPRecoveryAPI.ts

View workflow job for this annotation

GitHub Actions / ESLint

src/libs/TransactionRecoveryApi/AxelarGMPRecoveryAPI.ts#L1084

'srcTxInfo' is assigned a value but never used (@typescript-eslint/no-unused-vars)

const signer = this.getSigner(
destinationChain,
Expand Down Expand Up @@ -1147,28 +1128,6 @@
}
});

// 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
5 changes: 5 additions & 0 deletions src/libs/TransactionRecoveryApi/constants/chain/testnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const rpcMap: Record<EvmChain | string, string> = {
[EvmChain.ARBITRUM_SEPOLIA]: "https://sepolia-rollup.arbitrum.io/rpc",
[EvmChain.CENTRIFUGE_TESTNET]:
"https://node-7118620155331796992.gx.onfinality.io/jsonrpc?apikey=00538f2d-6297-44e3-8812-4b9d579524b2",
[EvmChain.FRAXTAL]: "https://rpc.testnet.frax.com",
};

export const networkInfo: Record<EvmChain | string, Network> = {
Expand Down Expand Up @@ -116,4 +117,8 @@ export const networkInfo: Record<EvmChain | string, Network> = {
chainId: 13473,
name: EvmChain.IMMUTABLE,
},
[EvmChain.FRAXTAL]: {
chainId: 2522,
name: EvmChain.FRAXTAL,
},
};
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);
});
});
});
Loading