diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e2b7bd3..b95a87e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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: diff --git a/package.json b/package.json index e9f00413..b48b5f13 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/libs/TransactionRecoveryApi/AxelarGMPRecoveryAPI.ts b/src/libs/TransactionRecoveryApi/AxelarGMPRecoveryAPI.ts index 238f2184..df979507 100644 --- a/src/libs/TransactionRecoveryApi/AxelarGMPRecoveryAPI.ts +++ b/src/libs/TransactionRecoveryApi/AxelarGMPRecoveryAPI.ts @@ -104,6 +104,7 @@ export enum RouteDir { 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 = { @@ -473,7 +474,9 @@ export class AxelarGMPRecoveryAPI extends AxelarRecoveryApi { 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, @@ -491,11 +494,41 @@ export class AxelarGMPRecoveryAPI extends AxelarRecoveryApi { 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,