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

feat: support cosmos-to-cosmos gmp tx recovery #304

Merged
merged 4 commits into from
Mar 7, 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

- Improved the accuracy of `estimateGasFee` function by incorporating L1 rollup fee for destination L2 chain.
- Fix for `manualRelayToDestinationChain` to respect optional `provider` parameter
- Add support for recovery of cosmos-to-cosmos GMP calls

Breaking Changes:

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.14.2",
"version": "0.15.0-alpha.1",
"description": "The JavaScript SDK for Axelar Network",
"repository": {
"type": "git",
Expand Down
35 changes: 34 additions & 1 deletion src/libs/TransactionRecoveryApi/AxelarGMPRecoveryAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
COSMOS_TO_EVM = "cosmos_to_evm",
EVM_TO_COSMOS = "evm_to_cosmos",
EVM_TO_EVM = "evm_to_evm",
COSMOS_TO_COSMOS = "cosmos_to_cosmos",
}

export type SendOptions = {
Expand Down Expand Up @@ -473,7 +474,9 @@
if (routeDir === RouteDir.COSMOS_TO_EVM) {
return this.recoverCosmosToEvmTx(txHash, _evmWalletDetails, messageId);
} else if (routeDir === RouteDir.EVM_TO_COSMOS) {
return this.recoverEvmToCosmosTx(srcChain, txHash, eventIndex, _evmWalletDetails);
return this.recoverEvmToCosmosTx(srcChain, txHash, eventIndex);
} else if (routeDir === RouteDir.COSMOS_TO_COSMOS) {
return this.recoverCosmosToCosmosTx(txHash);
} else {
return this.recoverEvmToEvmTx(
srcChain,
Expand All @@ -491,11 +494,41 @@
return RouteDir.COSMOS_TO_EVM;
} else if (srcChain.module === "evm" && destChain.module === "axelarnet") {
return RouteDir.EVM_TO_COSMOS;
} else if (srcChain.module === "axelarnet" && destChain.module === "axelarnet") {
return RouteDir.COSMOS_TO_COSMOS;
} else {
return RouteDir.EVM_TO_EVM;
}
}

private async recoverCosmosToCosmosTx(txHash: string) {
const gmpTx = await this.fetchGMPTransaction(txHash);

// Fetch all necessary data to send the route message tx
const payload = gmpTx.call.returnValues.payload;
const messageId = gmpTx.call.id;

// Send the route message tx
const routeMessageTx = await this.routeMessageRequest(messageId, payload, -1).catch(
() => undefined
);

// If the `success` flag is false, return the error response
if (!routeMessageTx) {
return {
success: false,
error: "Failed to send RouteMessage to Axelar",
};
}

// Return the success response
return {
success: true,
routeMessageTx,
infoLogs: [`Successfully sent RouteMessage tx for given tx hash ${txHash}`],
};
}

private async recoverEvmToCosmosTx(
srcChain: string,
txHash: string,
Expand Down Expand Up @@ -1116,7 +1149,7 @@

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

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

View workflow job for this annotation

GitHub Actions / ESLint

src/libs/TransactionRecoveryApi/AxelarGMPRecoveryAPI.ts#L1152

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

const signer = this.getSigner(
destinationChain,
Expand Down
Loading