@axelar-network/axelarjs-sdk 0.13.4 → 0.13.5-alpha-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/dist/artifacts/contracts/deposit-service/DepositReceiver.sol/DepositReceiver.json +0 -31
- package/dist/artifacts/contracts/deposit-service/ReceiverImplementation.sol/ReceiverImplementation.json +0 -180
- package/dist/src/assets/index.d.ts +0 -3
- package/dist/src/assets/index.d.ts.map +0 -1
- package/dist/src/assets/index.js +0 -45
- package/dist/src/assets/index.js.map +0 -1
- package/dist/src/assets/test/loadAssets.spec.d.ts +0 -2
- package/dist/src/assets/test/loadAssets.spec.d.ts.map +0 -1
- package/dist/src/assets/test/loadAssets.spec.js +0 -40
- package/dist/src/assets/test/loadAssets.spec.js.map +0 -1
- package/dist/src/assets/types/index.d.ts +0 -35
- package/dist/src/assets/types/index.d.ts.map +0 -1
- package/dist/src/assets/types/index.js +0 -3
- package/dist/src/assets/types/index.js.map +0 -1
- package/dist/src/chains/index.d.ts +0 -5
- package/dist/src/chains/index.d.ts.map +0 -1
- package/dist/src/chains/index.js +0 -84
- package/dist/src/chains/index.js.map +0 -1
- package/dist/src/chains/supported-chains-list.d.ts +0 -80
- package/dist/src/chains/supported-chains-list.d.ts.map +0 -1
- package/dist/src/chains/supported-chains-list.js +0 -83
- package/dist/src/chains/supported-chains-list.js.map +0 -1
- package/dist/src/chains/test/loadChains.spec.d.ts +0 -2
- package/dist/src/chains/test/loadChains.spec.d.ts.map +0 -1
- package/dist/src/chains/test/loadChains.spec.js +0 -40
- package/dist/src/chains/test/loadChains.spec.js.map +0 -1
- package/dist/src/chains/types/index.d.ts +0 -76
- package/dist/src/chains/types/index.d.ts.map +0 -1
- package/dist/src/chains/types/index.js +0 -17
- package/dist/src/chains/types/index.js.map +0 -1
- package/dist/src/constants/index.d.ts +0 -14
- package/dist/src/constants/index.d.ts.map +0 -1
- package/dist/src/constants/index.js +0 -67
- package/dist/src/constants/index.js.map +0 -1
- package/dist/src/index.d.ts +0 -9
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/index.js +0 -25
- package/dist/src/index.js.map +0 -1
- package/dist/src/libs/AxelarAssetTransfer.d.ts +0 -103
- package/dist/src/libs/AxelarAssetTransfer.d.ts.map +0 -1
- package/dist/src/libs/AxelarAssetTransfer.js +0 -411
- package/dist/src/libs/AxelarAssetTransfer.js.map +0 -1
- package/dist/src/libs/AxelarGateway.d.ts +0 -35
- package/dist/src/libs/AxelarGateway.d.ts.map +0 -1
- package/dist/src/libs/AxelarGateway.js +0 -145
- package/dist/src/libs/AxelarGateway.js.map +0 -1
- package/dist/src/libs/AxelarQueryAPI.d.ts +0 -162
- package/dist/src/libs/AxelarQueryAPI.d.ts.map +0 -1
- package/dist/src/libs/AxelarQueryAPI.js +0 -434
- package/dist/src/libs/AxelarQueryAPI.js.map +0 -1
- package/dist/src/libs/AxelarQueryClient/index.d.ts +0 -8
- package/dist/src/libs/AxelarQueryClient/index.d.ts.map +0 -1
- package/dist/src/libs/AxelarQueryClient/index.js +0 -32
- package/dist/src/libs/AxelarQueryClient/index.js.map +0 -1
- package/dist/src/libs/AxelarQueryClient/types/index.d.ts +0 -13
- package/dist/src/libs/AxelarQueryClient/types/index.d.ts.map +0 -1
- package/dist/src/libs/AxelarQueryClient/types/index.js +0 -19
- package/dist/src/libs/AxelarQueryClient/types/index.js.map +0 -1
- package/dist/src/libs/AxelarSigningClient/const/index.d.ts +0 -3
- package/dist/src/libs/AxelarSigningClient/const/index.d.ts.map +0 -1
- package/dist/src/libs/AxelarSigningClient/const/index.js +0 -13
- package/dist/src/libs/AxelarSigningClient/const/index.js.map +0 -1
- package/dist/src/libs/AxelarSigningClient/index.d.ts +0 -21
- package/dist/src/libs/AxelarSigningClient/index.d.ts.map +0 -1
- package/dist/src/libs/AxelarSigningClient/index.js +0 -80
- package/dist/src/libs/AxelarSigningClient/index.js.map +0 -1
- package/dist/src/libs/AxelarSigningClient/types/AxelarnetTxTypes.d.ts +0 -3
- package/dist/src/libs/AxelarSigningClient/types/AxelarnetTxTypes.d.ts.map +0 -1
- package/dist/src/libs/AxelarSigningClient/types/AxelarnetTxTypes.js +0 -28
- package/dist/src/libs/AxelarSigningClient/types/AxelarnetTxTypes.js.map +0 -1
- package/dist/src/libs/AxelarSigningClient/types/EvmTxTypes.d.ts +0 -3
- package/dist/src/libs/AxelarSigningClient/types/EvmTxTypes.d.ts.map +0 -1
- package/dist/src/libs/AxelarSigningClient/types/EvmTxTypes.js +0 -38
- package/dist/src/libs/AxelarSigningClient/types/EvmTxTypes.js.map +0 -1
- package/dist/src/libs/GatewayTx.d.ts +0 -11
- package/dist/src/libs/GatewayTx.d.ts.map +0 -1
- package/dist/src/libs/GatewayTx.js +0 -22
- package/dist/src/libs/GatewayTx.js.map +0 -1
- package/dist/src/libs/TransactionRecoveryApi/AxelarDepositRecoveryAPI.d.ts +0 -44
- package/dist/src/libs/TransactionRecoveryApi/AxelarDepositRecoveryAPI.d.ts.map +0 -1
- package/dist/src/libs/TransactionRecoveryApi/AxelarDepositRecoveryAPI.js +0 -85
- package/dist/src/libs/TransactionRecoveryApi/AxelarDepositRecoveryAPI.js.map +0 -1
- package/dist/src/libs/TransactionRecoveryApi/AxelarGMPRecoveryAPI.d.ts +0 -122
- package/dist/src/libs/TransactionRecoveryApi/AxelarGMPRecoveryAPI.d.ts.map +0 -1
- package/dist/src/libs/TransactionRecoveryApi/AxelarGMPRecoveryAPI.js +0 -761
- package/dist/src/libs/TransactionRecoveryApi/AxelarGMPRecoveryAPI.js.map +0 -1
- package/dist/src/libs/TransactionRecoveryApi/AxelarRecoveryApi.d.ts +0 -144
- package/dist/src/libs/TransactionRecoveryApi/AxelarRecoveryApi.d.ts.map +0 -1
- package/dist/src/libs/TransactionRecoveryApi/AxelarRecoveryApi.js +0 -422
- package/dist/src/libs/TransactionRecoveryApi/AxelarRecoveryApi.js.map +0 -1
- package/dist/src/libs/TransactionRecoveryApi/AxelarTransferAPI.d.ts +0 -10
- package/dist/src/libs/TransactionRecoveryApi/AxelarTransferAPI.d.ts.map +0 -1
- package/dist/src/libs/TransactionRecoveryApi/AxelarTransferAPI.js +0 -62
- package/dist/src/libs/TransactionRecoveryApi/AxelarTransferAPI.js.map +0 -1
- package/dist/src/libs/TransactionRecoveryApi/client/AxelarRpcClient.d.ts +0 -11
- package/dist/src/libs/TransactionRecoveryApi/client/AxelarRpcClient.d.ts.map +0 -1
- package/dist/src/libs/TransactionRecoveryApi/client/AxelarRpcClient.js +0 -37
- package/dist/src/libs/TransactionRecoveryApi/client/AxelarRpcClient.js.map +0 -1
- package/dist/src/libs/TransactionRecoveryApi/client/EVMClient/index.d.ts +0 -13
- package/dist/src/libs/TransactionRecoveryApi/client/EVMClient/index.d.ts.map +0 -1
- package/dist/src/libs/TransactionRecoveryApi/client/EVMClient/index.js +0 -55
- package/dist/src/libs/TransactionRecoveryApi/client/EVMClient/index.js.map +0 -1
- package/dist/src/libs/TransactionRecoveryApi/client/helpers/cosmos.d.ts +0 -6
- package/dist/src/libs/TransactionRecoveryApi/client/helpers/cosmos.d.ts.map +0 -1
- package/dist/src/libs/TransactionRecoveryApi/client/helpers/cosmos.js +0 -38
- package/dist/src/libs/TransactionRecoveryApi/client/helpers/cosmos.js.map +0 -1
- package/dist/src/libs/TransactionRecoveryApi/client/helpers/retryRpc.d.ts +0 -3
- package/dist/src/libs/TransactionRecoveryApi/client/helpers/retryRpc.d.ts.map +0 -1
- package/dist/src/libs/TransactionRecoveryApi/client/helpers/retryRpc.js +0 -37
- package/dist/src/libs/TransactionRecoveryApi/client/helpers/retryRpc.js.map +0 -1
- package/dist/src/libs/TransactionRecoveryApi/constants/chain/index.d.ts +0 -4
- package/dist/src/libs/TransactionRecoveryApi/constants/chain/index.d.ts.map +0 -1
- package/dist/src/libs/TransactionRecoveryApi/constants/chain/index.js +0 -20
- package/dist/src/libs/TransactionRecoveryApi/constants/chain/index.js.map +0 -1
- package/dist/src/libs/TransactionRecoveryApi/constants/chain/mainnet.d.ts +0 -5
- package/dist/src/libs/TransactionRecoveryApi/constants/chain/mainnet.d.ts.map +0 -1
- package/dist/src/libs/TransactionRecoveryApi/constants/chain/mainnet.js +0 -84
- package/dist/src/libs/TransactionRecoveryApi/constants/chain/mainnet.js.map +0 -1
- package/dist/src/libs/TransactionRecoveryApi/constants/chain/testnet.d.ts +0 -5
- package/dist/src/libs/TransactionRecoveryApi/constants/chain/testnet.d.ts.map +0 -1
- package/dist/src/libs/TransactionRecoveryApi/constants/chain/testnet.js +0 -84
- package/dist/src/libs/TransactionRecoveryApi/constants/chain/testnet.js.map +0 -1
- package/dist/src/libs/TransactionRecoveryApi/constants/contract.d.ts +0 -19
- package/dist/src/libs/TransactionRecoveryApi/constants/contract.d.ts.map +0 -1
- package/dist/src/libs/TransactionRecoveryApi/constants/contract.js +0 -23
- package/dist/src/libs/TransactionRecoveryApi/constants/contract.js.map +0 -1
- package/dist/src/libs/TransactionRecoveryApi/constants/error.d.ts +0 -74
- package/dist/src/libs/TransactionRecoveryApi/constants/error.d.ts.map +0 -1
- package/dist/src/libs/TransactionRecoveryApi/constants/error.js +0 -99
- package/dist/src/libs/TransactionRecoveryApi/constants/error.js.map +0 -1
- package/dist/src/libs/TransactionRecoveryApi/constants/s3.d.ts +0 -7
- package/dist/src/libs/TransactionRecoveryApi/constants/s3.d.ts.map +0 -1
- package/dist/src/libs/TransactionRecoveryApi/constants/s3.js +0 -8
- package/dist/src/libs/TransactionRecoveryApi/constants/s3.js.map +0 -1
- package/dist/src/libs/TransactionRecoveryApi/helpers/axelarHelper.d.ts +0 -13
- package/dist/src/libs/TransactionRecoveryApi/helpers/axelarHelper.d.ts.map +0 -1
- package/dist/src/libs/TransactionRecoveryApi/helpers/axelarHelper.js +0 -207
- package/dist/src/libs/TransactionRecoveryApi/helpers/axelarHelper.js.map +0 -1
- package/dist/src/libs/TransactionRecoveryApi/helpers/contractCallHelper.d.ts +0 -8
- package/dist/src/libs/TransactionRecoveryApi/helpers/contractCallHelper.d.ts.map +0 -1
- package/dist/src/libs/TransactionRecoveryApi/helpers/contractCallHelper.js +0 -56
- package/dist/src/libs/TransactionRecoveryApi/helpers/contractCallHelper.js.map +0 -1
- package/dist/src/libs/TransactionRecoveryApi/helpers/contractEventHelper.d.ts +0 -17
- package/dist/src/libs/TransactionRecoveryApi/helpers/contractEventHelper.d.ts.map +0 -1
- package/dist/src/libs/TransactionRecoveryApi/helpers/contractEventHelper.js +0 -137
- package/dist/src/libs/TransactionRecoveryApi/helpers/contractEventHelper.js.map +0 -1
- package/dist/src/libs/TransactionRecoveryApi/helpers/getCommandId.d.ts +0 -4
- package/dist/src/libs/TransactionRecoveryApi/helpers/getCommandId.d.ts.map +0 -1
- package/dist/src/libs/TransactionRecoveryApi/helpers/getCommandId.js +0 -22
- package/dist/src/libs/TransactionRecoveryApi/helpers/getCommandId.js.map +0 -1
- package/dist/src/libs/TransactionRecoveryApi/helpers/index.d.ts +0 -6
- package/dist/src/libs/TransactionRecoveryApi/helpers/index.d.ts.map +0 -1
- package/dist/src/libs/TransactionRecoveryApi/helpers/index.js +0 -22
- package/dist/src/libs/TransactionRecoveryApi/helpers/index.js.map +0 -1
- package/dist/src/libs/TransactionRecoveryApi/helpers/mappers.d.ts +0 -4
- package/dist/src/libs/TransactionRecoveryApi/helpers/mappers.d.ts.map +0 -1
- package/dist/src/libs/TransactionRecoveryApi/helpers/mappers.js +0 -24
- package/dist/src/libs/TransactionRecoveryApi/helpers/mappers.js.map +0 -1
- package/dist/src/libs/TransactionRecoveryApi/helpers/providerHelper.d.ts +0 -3
- package/dist/src/libs/TransactionRecoveryApi/helpers/providerHelper.d.ts.map +0 -1
- package/dist/src/libs/TransactionRecoveryApi/helpers/providerHelper.js +0 -14
- package/dist/src/libs/TransactionRecoveryApi/helpers/providerHelper.js.map +0 -1
- package/dist/src/libs/TransactionRecoveryApi/index.d.ts +0 -6
- package/dist/src/libs/TransactionRecoveryApi/index.d.ts.map +0 -1
- package/dist/src/libs/TransactionRecoveryApi/index.js +0 -22
- package/dist/src/libs/TransactionRecoveryApi/index.js.map +0 -1
- package/dist/src/libs/TransactionRecoveryApi/interface/index.d.ts +0 -31
- package/dist/src/libs/TransactionRecoveryApi/interface/index.d.ts.map +0 -1
- package/dist/src/libs/TransactionRecoveryApi/interface/index.js +0 -10
- package/dist/src/libs/TransactionRecoveryApi/interface/index.js.map +0 -1
- package/dist/src/libs/abi/IAxelarExecutable.d.ts +0 -38
- package/dist/src/libs/abi/IAxelarExecutable.d.ts.map +0 -1
- package/dist/src/libs/abi/IAxelarExecutable.js +0 -100
- package/dist/src/libs/abi/IAxelarExecutable.js.map +0 -1
- package/dist/src/libs/abi/erc20Abi.json +0 -222
- package/dist/src/libs/index.d.ts +0 -8
- package/dist/src/libs/index.d.ts.map +0 -1
- package/dist/src/libs/index.js +0 -24
- package/dist/src/libs/index.js.map +0 -1
- package/dist/src/libs/types/index.d.ts +0 -227
- package/dist/src/libs/types/index.d.ts.map +0 -1
- package/dist/src/libs/types/index.js +0 -98
- package/dist/src/libs/types/index.js.map +0 -1
- package/dist/src/services/RestService.d.ts +0 -8
- package/dist/src/services/RestService.d.ts.map +0 -1
- package/dist/src/services/RestService.js +0 -67
- package/dist/src/services/RestService.js.map +0 -1
- package/dist/src/services/SocketService.d.ts +0 -13
- package/dist/src/services/SocketService.d.ts.map +0 -1
- package/dist/src/services/SocketService.js +0 -87
- package/dist/src/services/SocketService.js.map +0 -1
- package/dist/src/services/index.d.ts +0 -3
- package/dist/src/services/index.d.ts.map +0 -1
- package/dist/src/services/index.js +0 -19
- package/dist/src/services/index.js.map +0 -1
- package/dist/src/services/test/RestService.spec.d.ts +0 -2
- package/dist/src/services/test/RestService.spec.d.ts.map +0 -1
- package/dist/src/services/test/RestService.spec.js +0 -77
- package/dist/src/services/test/RestService.spec.js.map +0 -1
- package/dist/src/services/types/index.d.ts +0 -24
- package/dist/src/services/types/index.d.ts.map +0 -1
- package/dist/src/services/types/index.js +0 -10
- package/dist/src/services/types/index.js.map +0 -1
- package/dist/src/utils/index.d.ts +0 -6
- package/dist/src/utils/index.d.ts.map +0 -1
- package/dist/src/utils/index.js +0 -22
- package/dist/src/utils/index.js.map +0 -1
- package/dist/src/utils/retry.d.ts +0 -2
- package/dist/src/utils/retry.d.ts.map +0 -1
- package/dist/src/utils/retry.js +0 -29
- package/dist/src/utils/retry.js.map +0 -1
- package/dist/src/utils/sleep.d.ts +0 -2
- package/dist/src/utils/sleep.d.ts.map +0 -1
- package/dist/src/utils/sleep.js +0 -8
- package/dist/src/utils/sleep.js.map +0 -1
- package/dist/src/utils/test/validateDestinationAddress.spec.d.ts +0 -2
- package/dist/src/utils/test/validateDestinationAddress.spec.d.ts.map +0 -1
- package/dist/src/utils/test/validateDestinationAddress.spec.js +0 -135
- package/dist/src/utils/test/validateDestinationAddress.spec.js.map +0 -1
- package/dist/src/utils/validateChain.d.ts +0 -7
- package/dist/src/utils/validateChain.d.ts.map +0 -1
- package/dist/src/utils/validateChain.js +0 -52
- package/dist/src/utils/validateChain.js.map +0 -1
- package/dist/src/utils/validateDestinationAddress.d.ts +0 -4
- package/dist/src/utils/validateDestinationAddress.d.ts.map +0 -1
- package/dist/src/utils/validateDestinationAddress.js +0 -54
- package/dist/src/utils/validateDestinationAddress.js.map +0 -1
- package/dist/src/utils/wallet.d.ts +0 -9
- package/dist/src/utils/wallet.d.ts.map +0 -1
- package/dist/src/utils/wallet.js +0 -33
- package/dist/src/utils/wallet.js.map +0 -1
- package/dist/vitest.config.d.ts +0 -3
- package/dist/vitest.config.d.ts.map +0 -1
- package/dist/vitest.config.js +0 -12
- package/dist/vitest.config.js.map +0 -1
|
@@ -1,761 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.AxelarGMPRecoveryAPI = exports.RouteDir = exports.GMPErrorMap = void 0;
|
|
16
|
-
const types_1 = require("../types");
|
|
17
|
-
const AxelarRecoveryApi_1 = require("./AxelarRecoveryApi");
|
|
18
|
-
const EVMClient_1 = __importDefault(require("./client/EVMClient"));
|
|
19
|
-
const IAxelarExecutable_1 = __importDefault(require("../abi/IAxelarExecutable"));
|
|
20
|
-
const ethers_1 = require("ethers");
|
|
21
|
-
const contract_1 = require("./constants/contract");
|
|
22
|
-
const AxelarQueryAPI_1 = require("../AxelarQueryAPI");
|
|
23
|
-
const chain_1 = __importDefault(require("./constants/chain"));
|
|
24
|
-
const contractEventHelper_1 = require("./helpers/contractEventHelper");
|
|
25
|
-
const erc20Abi_json_1 = __importDefault(require("../abi/erc20Abi.json"));
|
|
26
|
-
const AxelarGateway_1 = require("../AxelarGateway");
|
|
27
|
-
const providerHelper_1 = require("./helpers/providerHelper");
|
|
28
|
-
const error_1 = require("./constants/error");
|
|
29
|
-
const helpers_1 = require("./helpers");
|
|
30
|
-
const utils_1 = require("../../utils");
|
|
31
|
-
const types_2 = require("@axelar-network/axelarjs-types/axelar/evm/v1beta1/types");
|
|
32
|
-
const utils_2 = require("ethers/lib/utils");
|
|
33
|
-
exports.GMPErrorMap = {
|
|
34
|
-
[AxelarRecoveryApi_1.GMPStatus.CANNOT_FETCH_STATUS]: types_1.ApproveGatewayError.FETCHING_STATUS_FAILED,
|
|
35
|
-
[AxelarRecoveryApi_1.GMPStatus.DEST_EXECUTED]: types_1.ApproveGatewayError.ALREADY_EXECUTED,
|
|
36
|
-
[AxelarRecoveryApi_1.GMPStatus.DEST_GATEWAY_APPROVED]: types_1.ApproveGatewayError.ALREADY_APPROVED,
|
|
37
|
-
};
|
|
38
|
-
var RouteDir;
|
|
39
|
-
(function (RouteDir) {
|
|
40
|
-
RouteDir["COSMOS_TO_EVM"] = "cosmos_to_evm";
|
|
41
|
-
RouteDir["EVM_TO_COSMOS"] = "evm_to_cosmos";
|
|
42
|
-
RouteDir["EVM_TO_EVM"] = "evm_to_evm";
|
|
43
|
-
})(RouteDir = exports.RouteDir || (exports.RouteDir = {}));
|
|
44
|
-
class AxelarGMPRecoveryAPI extends AxelarRecoveryApi_1.AxelarRecoveryApi {
|
|
45
|
-
constructor(config) {
|
|
46
|
-
super(config);
|
|
47
|
-
this.axelarQueryApi = new AxelarQueryAPI_1.AxelarQueryAPI({
|
|
48
|
-
environment: config.environment,
|
|
49
|
-
axelarRpcUrl: this.axelarRpcUrl,
|
|
50
|
-
axelarLcdUrl: this.axelarLcdUrl,
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
saveGMP(sourceTransactionHash, relayerAddress, transactionHash, error) {
|
|
54
|
-
const _super = Object.create(null, {
|
|
55
|
-
getAxelarGMPApiUrl: { get: () => super.getAxelarGMPApiUrl }
|
|
56
|
-
});
|
|
57
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
58
|
-
return yield this.execPost(_super.getAxelarGMPApiUrl, "", {
|
|
59
|
-
method: "saveGMP",
|
|
60
|
-
sourceTransactionHash,
|
|
61
|
-
transactionHash,
|
|
62
|
-
relayerAddress,
|
|
63
|
-
error,
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
getCidFromSrcTxHash(destChainId, txHash, eventIndex) {
|
|
68
|
-
return (0, helpers_1.getCommandId)(destChainId, txHash, eventIndex, this.environment, chain_1.default);
|
|
69
|
-
}
|
|
70
|
-
doesTxMeetConfirmHt(chain, txHash) {
|
|
71
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
72
|
-
const confirmations = yield this.getSigner(chain)
|
|
73
|
-
.provider.getTransactionReceipt(txHash)
|
|
74
|
-
.then((receipt) => receipt.confirmations);
|
|
75
|
-
return this.axelarQueryApi
|
|
76
|
-
.getConfirmationHeight(chain)
|
|
77
|
-
.then((minConfirmHeight) => minConfirmHeight <= confirmations)
|
|
78
|
-
.catch(() => undefined);
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
isEVMEventFailed(eventResponse) {
|
|
82
|
-
var _a;
|
|
83
|
-
if (!eventResponse)
|
|
84
|
-
return undefined;
|
|
85
|
-
return [types_2.Event_Status.STATUS_FAILED, types_2.Event_Status.STATUS_UNSPECIFIED].includes((_a = eventResponse.event) === null || _a === void 0 ? void 0 : _a.status);
|
|
86
|
-
}
|
|
87
|
-
isEVMEventConfirmed(eventResponse) {
|
|
88
|
-
var _a;
|
|
89
|
-
if (!eventResponse)
|
|
90
|
-
return undefined;
|
|
91
|
-
return ((_a = eventResponse.event) === null || _a === void 0 ? void 0 : _a.status) === types_2.Event_Status.STATUS_CONFIRMED;
|
|
92
|
-
}
|
|
93
|
-
isEVMEventCompleted(eventResponse) {
|
|
94
|
-
var _a;
|
|
95
|
-
if (!eventResponse)
|
|
96
|
-
return undefined;
|
|
97
|
-
return ((_a = eventResponse.event) === null || _a === void 0 ? void 0 : _a.status) === types_2.Event_Status.STATUS_COMPLETED;
|
|
98
|
-
}
|
|
99
|
-
getEvmEvent(srcChainId, destChainId, srcTxHash, evmWalletDetails) {
|
|
100
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
101
|
-
const eventIndex = yield this.getEventIndex(srcChainId, srcTxHash, evmWalletDetails)
|
|
102
|
-
.then((index) => index)
|
|
103
|
-
.catch(() => -1);
|
|
104
|
-
if (eventIndex === -1) {
|
|
105
|
-
return {
|
|
106
|
-
success: false,
|
|
107
|
-
errorMessage: `getEvmEvent(): could not find event index for ${srcTxHash}`,
|
|
108
|
-
commandId: "",
|
|
109
|
-
eventResponse: {},
|
|
110
|
-
infoLog: "",
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
const commandId = this.getCidFromSrcTxHash(destChainId, srcTxHash, eventIndex);
|
|
114
|
-
const eventResponse = yield (0, utils_1.retry)(() => this.axelarQueryApi.getEVMEvent(srcChainId, srcTxHash, eventIndex), 12, 10000);
|
|
115
|
-
if (!eventResponse || this.isEVMEventFailed(eventResponse)) {
|
|
116
|
-
const errorMessage = this.isEVMEventFailed(eventResponse)
|
|
117
|
-
? `getEvmEvent(): event on source chain is not successful for: ${srcTxHash}`
|
|
118
|
-
: `getEvmEvent(): could not determine status of event: ${srcTxHash}`;
|
|
119
|
-
return {
|
|
120
|
-
success: false,
|
|
121
|
-
errorMessage,
|
|
122
|
-
commandId,
|
|
123
|
-
eventResponse: {},
|
|
124
|
-
infoLog: `srcTxHash: ${srcTxHash}, generated commandId: ${commandId}`,
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
return {
|
|
128
|
-
success: true,
|
|
129
|
-
commandId,
|
|
130
|
-
eventResponse,
|
|
131
|
-
errorMessage: "",
|
|
132
|
-
infoLog: `${srcTxHash} correspondes to command ID: ${commandId}`,
|
|
133
|
-
};
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
findEventAndConfirmIfNeeded(srcChain, destChain, txHash, evmWalletDetails) {
|
|
137
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
138
|
-
if (this.debugMode)
|
|
139
|
-
console.debug(`confirmation: checking whether ${txHash} needs to be confirmed on Axelar`);
|
|
140
|
-
const evmEvent = yield this.getEvmEvent(srcChain, destChain, txHash, evmWalletDetails);
|
|
141
|
-
const { infoLog: getEvmEventInfoLog } = evmEvent;
|
|
142
|
-
if (this.debugMode)
|
|
143
|
-
console.debug(`confirmation: ${getEvmEventInfoLog}`);
|
|
144
|
-
if (this.isEVMEventCompleted(evmEvent.eventResponse) ||
|
|
145
|
-
this.isEVMEventConfirmed(evmEvent.eventResponse)) {
|
|
146
|
-
return {
|
|
147
|
-
success: true,
|
|
148
|
-
commandId: evmEvent.commandId,
|
|
149
|
-
eventResponse: evmEvent.eventResponse,
|
|
150
|
-
infoLogs: [
|
|
151
|
-
`confirmation: event for ${txHash} was already detected on the network and did not need to be confirmed`,
|
|
152
|
-
],
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
else {
|
|
156
|
-
const isConfirmFinalized = yield this.doesTxMeetConfirmHt(srcChain, txHash);
|
|
157
|
-
if (!isConfirmFinalized) {
|
|
158
|
-
const minConfirmLevel = yield this.axelarQueryApi.getConfirmationHeight(srcChain);
|
|
159
|
-
return {
|
|
160
|
-
success: false,
|
|
161
|
-
commandId: evmEvent.commandId,
|
|
162
|
-
eventResponse: evmEvent.eventResponse,
|
|
163
|
-
infoLogs: [],
|
|
164
|
-
errorMessage: `findEventAndConfirmIfNeeded(): ${txHash} is not confirmed on ${srcChain}. The minimum confirmation height is ${minConfirmLevel}`,
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
const confirmTx = yield this.confirmGatewayTx(txHash, srcChain).catch(() => undefined);
|
|
168
|
-
if (!confirmTx) {
|
|
169
|
-
return {
|
|
170
|
-
success: false,
|
|
171
|
-
commandId: evmEvent.commandId,
|
|
172
|
-
eventResponse: evmEvent.eventResponse,
|
|
173
|
-
infoLogs: [],
|
|
174
|
-
errorMessage: `findEventAndConfirmIfNeeded(): could not confirm transaction on Axelar`,
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
const updatedEvent = yield this.getEvmEvent(srcChain, destChain, txHash, evmWalletDetails);
|
|
178
|
-
if (this.isEVMEventCompleted(updatedEvent === null || updatedEvent === void 0 ? void 0 : updatedEvent.eventResponse)) {
|
|
179
|
-
return {
|
|
180
|
-
success: true,
|
|
181
|
-
commandId: updatedEvent.commandId,
|
|
182
|
-
eventResponse: updatedEvent.eventResponse,
|
|
183
|
-
infoLogs: [
|
|
184
|
-
`confirmation: successfully confirmed ${txHash} on Axelar; confirmed event was finalized`,
|
|
185
|
-
getEvmEventInfoLog,
|
|
186
|
-
],
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
else {
|
|
190
|
-
return {
|
|
191
|
-
success: false,
|
|
192
|
-
eventResponse: evmEvent.eventResponse,
|
|
193
|
-
commandId: updatedEvent.commandId,
|
|
194
|
-
errorMessage: `findEventAndConfirmIfNeeded(): could not confirm and finalize event successfully: ${txHash};. Your transaction may not have enough confirmations yet.`,
|
|
195
|
-
infoLogs: [
|
|
196
|
-
`confirmation: successfully confirmed ${txHash} on Axelar; confirmed event was unable to be finalized`,
|
|
197
|
-
getEvmEventInfoLog,
|
|
198
|
-
],
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
findBatchAndSignIfNeeded(commandId, destChainId) {
|
|
205
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
206
|
-
let signTxLog = "";
|
|
207
|
-
try {
|
|
208
|
-
const batchData = yield this.fetchBatchData(destChainId, commandId);
|
|
209
|
-
if (batchData) {
|
|
210
|
-
signTxLog = `signing: batch data exists so do not need to sign. commandId: ${commandId}, batchId: ${batchData.batch_id}`;
|
|
211
|
-
if (this.debugMode)
|
|
212
|
-
console.debug(signTxLog);
|
|
213
|
-
return {
|
|
214
|
-
success: true,
|
|
215
|
-
infoLogs: [signTxLog],
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
else {
|
|
219
|
-
const signCommandTx = yield this.signCommands(destChainId);
|
|
220
|
-
signTxLog = `signing: signed batch for commandId (${commandId}) in tx: ${signCommandTx.transactionHash}`;
|
|
221
|
-
if (this.debugMode)
|
|
222
|
-
console.debug(signTxLog);
|
|
223
|
-
return {
|
|
224
|
-
success: true,
|
|
225
|
-
signCommandTx,
|
|
226
|
-
infoLogs: [signTxLog],
|
|
227
|
-
};
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
catch (e) {
|
|
231
|
-
return {
|
|
232
|
-
success: false,
|
|
233
|
-
errorMessage: `findBatchAndSignIfNeeded(): issue retrieving and signing command data: ${commandId}`,
|
|
234
|
-
infoLogs: [signTxLog],
|
|
235
|
-
};
|
|
236
|
-
}
|
|
237
|
-
});
|
|
238
|
-
}
|
|
239
|
-
findBatchAndApproveGateway(commandId, destChainId, wallet) {
|
|
240
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
241
|
-
if (this.debugMode)
|
|
242
|
-
console.debug(`broadcasting: checking for command ID: ${commandId} to broadcast`);
|
|
243
|
-
return (0, utils_1.retry)(() => __awaiter(this, void 0, void 0, function* () {
|
|
244
|
-
const batchData = yield this.fetchBatchData(destChainId, commandId);
|
|
245
|
-
if (!batchData) {
|
|
246
|
-
return Promise.reject(`findBatchAndApproveGateway(): unable to retrieve batch data for ${commandId}`);
|
|
247
|
-
}
|
|
248
|
-
const commandData = batchData.command_ids.find((t) => t === commandId);
|
|
249
|
-
if (!commandData) {
|
|
250
|
-
return Promise.reject(`findBatchAndApproveGateway(): unable to retrieve command ID (${commandId}) in batch data`);
|
|
251
|
-
}
|
|
252
|
-
if (batchData.status === "BATCHED_COMMANDS_STATUS_SIGNING") {
|
|
253
|
-
return Promise.reject(`findBatchAndApproveGateway(): batch ID ${batchData.batch_id} signing in process`);
|
|
254
|
-
}
|
|
255
|
-
else if (batchData.status === "BATCHED_COMMANDS_STATUS_SIGNED") {
|
|
256
|
-
const approveTx = yield this.sendApproveTx(destChainId, batchData.execute_data, wallet);
|
|
257
|
-
return {
|
|
258
|
-
success: true,
|
|
259
|
-
approveTx,
|
|
260
|
-
infoLogs: [
|
|
261
|
-
`broadcasting: batch ID ${batchData.batch_id} broadcasted to ${destChainId}`,
|
|
262
|
-
],
|
|
263
|
-
};
|
|
264
|
-
}
|
|
265
|
-
else {
|
|
266
|
-
return Promise.reject(`findBatchAndApproveGateway(): batch ID ${batchData.batch_id} is in an unknown state for command data: ${commandId}`);
|
|
267
|
-
}
|
|
268
|
-
}), 3, 10).catch((error) => {
|
|
269
|
-
return {
|
|
270
|
-
success: false,
|
|
271
|
-
errorMessage: error.message || // error can be both a string or an object with a message property
|
|
272
|
-
error ||
|
|
273
|
-
`findBatchAndApproveGatewayIfNeeded(): issue retrieving and broadcasting command data: ${commandId}`,
|
|
274
|
-
infoLogs: [],
|
|
275
|
-
};
|
|
276
|
-
});
|
|
277
|
-
});
|
|
278
|
-
}
|
|
279
|
-
manualRelayToDestChain(txHash, evmWalletDetails, escapeAfterConfirm = true) {
|
|
280
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
281
|
-
const { callTx, status } = yield this.queryTransactionStatus(txHash);
|
|
282
|
-
/**first check if transaction is already executed */
|
|
283
|
-
if (exports.GMPErrorMap[status])
|
|
284
|
-
return {
|
|
285
|
-
success: false,
|
|
286
|
-
error: exports.GMPErrorMap[status],
|
|
287
|
-
};
|
|
288
|
-
const srcChain = callTx.chain;
|
|
289
|
-
const destChain = callTx.returnValues.destinationChain;
|
|
290
|
-
const srcChainInfo = yield this.getChainInfo(srcChain);
|
|
291
|
-
const destChainInfo = yield this.getChainInfo(destChain);
|
|
292
|
-
const routeDir = this.getRouteDir(srcChainInfo, destChainInfo);
|
|
293
|
-
const _evmWalletDetails = evmWalletDetails || { useWindowEthereum: true };
|
|
294
|
-
if (routeDir === RouteDir.COSMOS_TO_EVM) {
|
|
295
|
-
return this.recoverCosmosToEvmTx(txHash, _evmWalletDetails);
|
|
296
|
-
}
|
|
297
|
-
else if (routeDir === RouteDir.EVM_TO_COSMOS) {
|
|
298
|
-
return this.recoverEvmToCosmosTx(srcChain, txHash);
|
|
299
|
-
}
|
|
300
|
-
else {
|
|
301
|
-
return this.recoverEvmToEvmTx(srcChain, destChain, txHash, _evmWalletDetails, escapeAfterConfirm);
|
|
302
|
-
}
|
|
303
|
-
});
|
|
304
|
-
}
|
|
305
|
-
getRouteDir(srcChain, destChain) {
|
|
306
|
-
if (srcChain.module === "axelarnet" && destChain.module === "evm") {
|
|
307
|
-
return RouteDir.COSMOS_TO_EVM;
|
|
308
|
-
}
|
|
309
|
-
else if (srcChain.module === "evm" && destChain.module === "axelarnet") {
|
|
310
|
-
return RouteDir.EVM_TO_COSMOS;
|
|
311
|
-
}
|
|
312
|
-
else {
|
|
313
|
-
return RouteDir.EVM_TO_EVM;
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
recoverEvmToCosmosTx(srcChain, txHash) {
|
|
317
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
318
|
-
// Check if the tx is confirmed on the source chain
|
|
319
|
-
const isConfirmed = yield this.doesTxMeetConfirmHt(srcChain, txHash);
|
|
320
|
-
if (!isConfirmed) {
|
|
321
|
-
const minConfirmLevel = yield this.axelarQueryApi.getConfirmationHeight(srcChain);
|
|
322
|
-
return {
|
|
323
|
-
success: false,
|
|
324
|
-
error: `${txHash} is not confirmed on ${srcChain}. The minimum confirmation height is ${minConfirmLevel}`,
|
|
325
|
-
};
|
|
326
|
-
}
|
|
327
|
-
// ConfirmGatewayTx and check if it is successfully executed
|
|
328
|
-
const confirmTx = yield this.confirmGatewayTx(txHash, srcChain).catch(() => undefined);
|
|
329
|
-
if (!confirmTx) {
|
|
330
|
-
return {
|
|
331
|
-
success: false,
|
|
332
|
-
error: "Failed to send ConfirmGatewayTx to Axelar",
|
|
333
|
-
};
|
|
334
|
-
}
|
|
335
|
-
// Fetch all necessary data to send the route message tx
|
|
336
|
-
const payload = yield this.fetchGMPTransaction(txHash).then((data) => data.call.returnValues.payload);
|
|
337
|
-
const logIndex = yield this.getEventIndex(srcChain, txHash);
|
|
338
|
-
// Send the route message tx
|
|
339
|
-
const routeMessageTx = yield this.routeMessageRequest(txHash, payload, logIndex).catch(() => undefined);
|
|
340
|
-
// If the `success` flag is false, return the error response
|
|
341
|
-
if (!routeMessageTx) {
|
|
342
|
-
return {
|
|
343
|
-
success: false,
|
|
344
|
-
error: "Failed to send RouteMessage to Axelar",
|
|
345
|
-
};
|
|
346
|
-
}
|
|
347
|
-
// Return the success response
|
|
348
|
-
return {
|
|
349
|
-
success: true,
|
|
350
|
-
confirmTx,
|
|
351
|
-
routeMessageTx,
|
|
352
|
-
infoLogs: [
|
|
353
|
-
`Successfully sent ConfirmGatewayTx tx for given tx hash ${txHash}`,
|
|
354
|
-
`Successfully sent RouteMessage tx for given tx hash ${txHash}`,
|
|
355
|
-
],
|
|
356
|
-
};
|
|
357
|
-
});
|
|
358
|
-
}
|
|
359
|
-
recoverCosmosToEvmTx(txHash, evmWalletDetails) {
|
|
360
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
361
|
-
const txDetails = yield this.fetchGMPTransaction(txHash);
|
|
362
|
-
const { messageId, payload, destinationChain } = txDetails.call.returnValues;
|
|
363
|
-
const { command_id: commandId } = txDetails;
|
|
364
|
-
// Send RouteMessageTx
|
|
365
|
-
const routeMessageTx = yield this.routeMessageRequest(messageId, payload, -1).catch(() => undefined);
|
|
366
|
-
if (!routeMessageTx) {
|
|
367
|
-
return {
|
|
368
|
-
success: false,
|
|
369
|
-
error: "Failed to send RouteMessage to Axelar",
|
|
370
|
-
};
|
|
371
|
-
}
|
|
372
|
-
// Dispatch a SignCommand transaction and an Approve transaction to the Gateway contract.
|
|
373
|
-
const response = yield this.signAndApproveGateway(commandId, destinationChain, evmWalletDetails);
|
|
374
|
-
// If the response.success is false, we will return the error response
|
|
375
|
-
if (!response.success) {
|
|
376
|
-
return {
|
|
377
|
-
success: false,
|
|
378
|
-
error: response.error,
|
|
379
|
-
};
|
|
380
|
-
}
|
|
381
|
-
// Otherwise, we will return the success response
|
|
382
|
-
const { signCommandTx, infoLogs: signTxLogs } = response;
|
|
383
|
-
return {
|
|
384
|
-
success: true,
|
|
385
|
-
routeMessageTx,
|
|
386
|
-
signCommandTx,
|
|
387
|
-
infoLogs: [`Successfully sent RouteMessage tx for given ${txHash}`, ...signTxLogs],
|
|
388
|
-
};
|
|
389
|
-
});
|
|
390
|
-
}
|
|
391
|
-
recoverEvmToEvmTx(srcChain, destChain, txHash, evmWalletDetails, escapeAfterConfirm = true) {
|
|
392
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
393
|
-
try {
|
|
394
|
-
// ConfirmGatewayTx and check if it is successfully executed
|
|
395
|
-
const confirmTxRequest = yield this.findEventAndConfirmIfNeeded(srcChain, destChain, txHash, evmWalletDetails);
|
|
396
|
-
// If the `success` flag is false, we will return the error response
|
|
397
|
-
if (!(confirmTxRequest === null || confirmTxRequest === void 0 ? void 0 : confirmTxRequest.success)) {
|
|
398
|
-
return {
|
|
399
|
-
success: false,
|
|
400
|
-
error: confirmTxRequest.errorMessage || types_1.ApproveGatewayError.ERROR_BATCHED_COMMAND,
|
|
401
|
-
};
|
|
402
|
-
}
|
|
403
|
-
const { infoLogs: confirmTxLogs, commandId, confirmTx } = confirmTxRequest;
|
|
404
|
-
// If the `escapeAfterConfirm` flag is set to true, we will return the `confirmTx` and `infoLogs` immediately without signing the batch.
|
|
405
|
-
if (confirmTx && escapeAfterConfirm) {
|
|
406
|
-
return {
|
|
407
|
-
success: true,
|
|
408
|
-
confirmTx,
|
|
409
|
-
infoLogs: confirmTxLogs,
|
|
410
|
-
};
|
|
411
|
-
}
|
|
412
|
-
// Find the batch and sign it
|
|
413
|
-
const response = yield this.signAndApproveGateway(commandId, destChain, evmWalletDetails);
|
|
414
|
-
// If the response.success is false, we will return the error response
|
|
415
|
-
if (!response.success) {
|
|
416
|
-
return {
|
|
417
|
-
success: false,
|
|
418
|
-
error: response.error,
|
|
419
|
-
};
|
|
420
|
-
}
|
|
421
|
-
// Otherwise, we will return the success response
|
|
422
|
-
const { signCommandTx, approveTx, infoLogs: signTxLogs } = response;
|
|
423
|
-
return {
|
|
424
|
-
success: true,
|
|
425
|
-
confirmTx,
|
|
426
|
-
signCommandTx,
|
|
427
|
-
approveTx,
|
|
428
|
-
infoLogs: [...confirmTxLogs, ...signTxLogs],
|
|
429
|
-
};
|
|
430
|
-
// If more code is required here, you can add it below.
|
|
431
|
-
}
|
|
432
|
-
catch (e) {
|
|
433
|
-
return {
|
|
434
|
-
success: false,
|
|
435
|
-
error: e.message || types_1.ApproveGatewayError.CONFIRM_COMMAND_FAILED,
|
|
436
|
-
};
|
|
437
|
-
}
|
|
438
|
-
});
|
|
439
|
-
}
|
|
440
|
-
signAndApproveGateway(commandId, destChain, evmWalletDetails) {
|
|
441
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
442
|
-
try {
|
|
443
|
-
const signTxRequest = yield this.findBatchAndSignIfNeeded(commandId, destChain);
|
|
444
|
-
if (!(signTxRequest === null || signTxRequest === void 0 ? void 0 : signTxRequest.success)) {
|
|
445
|
-
return {
|
|
446
|
-
success: false,
|
|
447
|
-
error: signTxRequest.errorMessage || types_1.ApproveGatewayError.SIGN_COMMAND_FAILED,
|
|
448
|
-
};
|
|
449
|
-
}
|
|
450
|
-
const broadcastTxRequest = yield this.findBatchAndApproveGateway(commandId, destChain, evmWalletDetails);
|
|
451
|
-
if (!(broadcastTxRequest === null || broadcastTxRequest === void 0 ? void 0 : broadcastTxRequest.success)) {
|
|
452
|
-
return {
|
|
453
|
-
success: false,
|
|
454
|
-
error: broadcastTxRequest.errorMessage || types_1.ApproveGatewayError.ERROR_BROADCAST_EVENT,
|
|
455
|
-
};
|
|
456
|
-
}
|
|
457
|
-
return {
|
|
458
|
-
success: true,
|
|
459
|
-
signCommandTx: signTxRequest.signCommandTx,
|
|
460
|
-
approveTx: broadcastTxRequest.approveTx,
|
|
461
|
-
infoLogs: [...(signTxRequest.infoLogs || []), ...(broadcastTxRequest.infoLogs || [])],
|
|
462
|
-
};
|
|
463
|
-
}
|
|
464
|
-
catch (e) {
|
|
465
|
-
return {
|
|
466
|
-
success: false,
|
|
467
|
-
error: e.message || `Error signing and approving gateway for commandId: ${commandId}`,
|
|
468
|
-
};
|
|
469
|
-
}
|
|
470
|
-
});
|
|
471
|
-
}
|
|
472
|
-
/**
|
|
473
|
-
* Check if given transaction is already executed.
|
|
474
|
-
* @param txHash string - transaction hash
|
|
475
|
-
* @returns Promise<boolean> - true if transaction is already executed
|
|
476
|
-
*/
|
|
477
|
-
isExecuted(txHash) {
|
|
478
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
479
|
-
const txStatus = yield this.queryTransactionStatus(txHash).catch(() => undefined);
|
|
480
|
-
return (txStatus === null || txStatus === void 0 ? void 0 : txStatus.status) === AxelarRecoveryApi_1.GMPStatus.DEST_EXECUTED;
|
|
481
|
-
});
|
|
482
|
-
}
|
|
483
|
-
/**
|
|
484
|
-
* Check if given transaction is already confirmed.
|
|
485
|
-
* @param txHash string - transaction hash
|
|
486
|
-
* @returns Promise<boolean> - true if transaction is already confirmed
|
|
487
|
-
*/
|
|
488
|
-
isConfirmed(txHash) {
|
|
489
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
490
|
-
const txStatus = yield this.queryTransactionStatus(txHash).catch(() => undefined);
|
|
491
|
-
return [AxelarRecoveryApi_1.GMPStatus.SRC_GATEWAY_CONFIRMED, AxelarRecoveryApi_1.GMPStatus.DEST_GATEWAY_APPROVED].includes(this.parseGMPStatus(txStatus === null || txStatus === void 0 ? void 0 : txStatus.status));
|
|
492
|
-
});
|
|
493
|
-
}
|
|
494
|
-
/**
|
|
495
|
-
* Calculate the gas fee in native token for executing a transaction at the destination chain using the source chain's gas price.
|
|
496
|
-
* @param txHash string - transaction hash
|
|
497
|
-
* @param sourceChain EVMChain - source chain
|
|
498
|
-
* @param destinationChain EVMChain - destination chain
|
|
499
|
-
* @param gasTokenSymbol string - gas token symbol
|
|
500
|
-
* @param options QueryGasFeeOptions - options
|
|
501
|
-
* @returns Promise<string> - The gas fee to be paid at source chain
|
|
502
|
-
*/
|
|
503
|
-
calculateNativeGasFee(txHash, sourceChain, destinationChain, gasTokenSymbol, options) {
|
|
504
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
505
|
-
yield (0, utils_1.throwIfInvalidChainIds)([sourceChain, destinationChain], this.environment);
|
|
506
|
-
const provider = options.provider || (0, providerHelper_1.getDefaultProvider)(sourceChain, this.environment);
|
|
507
|
-
const receipt = yield provider.getTransactionReceipt(txHash);
|
|
508
|
-
const paidGasFee = (0, contractEventHelper_1.getNativeGasAmountFromTxReceipt)(receipt) || "0";
|
|
509
|
-
const hasTxBeenConfirmed = (yield this.isConfirmed(txHash)) || false;
|
|
510
|
-
options.shouldSubtractBaseFee = hasTxBeenConfirmed;
|
|
511
|
-
return this.subtractGasFee(sourceChain, destinationChain, gasTokenSymbol, paidGasFee, options);
|
|
512
|
-
});
|
|
513
|
-
}
|
|
514
|
-
/**
|
|
515
|
-
* Calculate the gas fee in an ERC-20 tokens for executing a transaction at the destination chain using the source chain's gas price.
|
|
516
|
-
* @param txHash string - transaction hash
|
|
517
|
-
* @param sourceChain EVMChain - source chain
|
|
518
|
-
* @param destinationChain EVMChain - destination chain
|
|
519
|
-
* @param gasTokenSymbol string - gas token symbol
|
|
520
|
-
* @param options QueryGasFeeOptions - options
|
|
521
|
-
* @returns Promise<string> - The gas fee to be paid at source chain
|
|
522
|
-
*/
|
|
523
|
-
calculateGasFee(txHash, sourceChain, destinationChain, gasTokenSymbol, options) {
|
|
524
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
525
|
-
yield (0, utils_1.throwIfInvalidChainIds)([sourceChain, destinationChain], this.environment);
|
|
526
|
-
const provider = options.provider || (0, providerHelper_1.getDefaultProvider)(sourceChain, this.environment);
|
|
527
|
-
const receipt = yield provider.getTransactionReceipt(txHash);
|
|
528
|
-
const paidGasFee = (0, contractEventHelper_1.getGasAmountFromTxReceipt)(receipt) || "0";
|
|
529
|
-
return this.subtractGasFee(sourceChain, destinationChain, gasTokenSymbol, paidGasFee, options);
|
|
530
|
-
});
|
|
531
|
-
}
|
|
532
|
-
getEventIndex(chain, txHash, evmWalletDetails) {
|
|
533
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
534
|
-
const signer = this.getSigner(chain, evmWalletDetails || { useWindowEthereum: true });
|
|
535
|
-
const receipt = yield signer.provider.getTransactionReceipt(txHash);
|
|
536
|
-
if (!receipt)
|
|
537
|
-
return -1;
|
|
538
|
-
const eventIndex = (0, contractEventHelper_1.getEventIndexFromTxReceipt)(receipt);
|
|
539
|
-
return eventIndex;
|
|
540
|
-
});
|
|
541
|
-
}
|
|
542
|
-
/**
|
|
543
|
-
* Pay native token as gas fee for the given transaction hash.
|
|
544
|
-
* If the transaction details is not valid, it will return an error with reason.
|
|
545
|
-
* @param chain - source chain
|
|
546
|
-
* @param txHash - transaction hash
|
|
547
|
-
* @param options - options
|
|
548
|
-
* @returns
|
|
549
|
-
*/
|
|
550
|
-
addNativeGas(chain, txHash, options) {
|
|
551
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
552
|
-
const evmWalletDetails = (options === null || options === void 0 ? void 0 : options.evmWalletDetails) || { useWindowEthereum: true };
|
|
553
|
-
const signer = this.getSigner(chain, evmWalletDetails);
|
|
554
|
-
const signerAddress = yield signer.getAddress();
|
|
555
|
-
const gasReceiverAddress = yield this.axelarQueryApi.getContractAddressFromConfig(chain, "gas_service");
|
|
556
|
-
const nativeGasTokenSymbol = contract_1.NATIVE_GAS_TOKEN_SYMBOL[chain];
|
|
557
|
-
const receipt = yield signer.provider.getTransactionReceipt(txHash);
|
|
558
|
-
if (!receipt)
|
|
559
|
-
return (0, error_1.InvalidTransactionError)(chain);
|
|
560
|
-
const destinationChain = (0, contractEventHelper_1.getDestinationChainFromTxReceipt)(receipt);
|
|
561
|
-
const logIndex = (0, contractEventHelper_1.getLogIndexFromTxReceipt)(receipt);
|
|
562
|
-
// Check if given txHash is valid
|
|
563
|
-
if (!destinationChain)
|
|
564
|
-
return (0, error_1.NotGMPTransactionError)();
|
|
565
|
-
// Check if the transaction status is already executed or not.
|
|
566
|
-
const _isExecuted = yield this.isExecuted(txHash);
|
|
567
|
-
if (_isExecuted)
|
|
568
|
-
return (0, error_1.AlreadyExecutedError)();
|
|
569
|
-
let gasFeeToAdd = options === null || options === void 0 ? void 0 : options.amount;
|
|
570
|
-
if (!gasFeeToAdd) {
|
|
571
|
-
gasFeeToAdd = yield this.calculateNativeGasFee(txHash, chain, destinationChain, nativeGasTokenSymbol, {
|
|
572
|
-
estimatedGas: options === null || options === void 0 ? void 0 : options.estimatedGasUsed,
|
|
573
|
-
gasMultipler: options === null || options === void 0 ? void 0 : options.gasMultipler,
|
|
574
|
-
provider: evmWalletDetails.provider,
|
|
575
|
-
}).catch(() => undefined);
|
|
576
|
-
}
|
|
577
|
-
// Check if gas price is queried successfully.
|
|
578
|
-
if (!gasFeeToAdd)
|
|
579
|
-
return (0, error_1.GasPriceAPIError)();
|
|
580
|
-
// Check if gas fee is not already sufficiently paid.
|
|
581
|
-
if (gasFeeToAdd === "0")
|
|
582
|
-
return (0, error_1.AlreadyPaidGasFeeError)();
|
|
583
|
-
const refundAddress = (options === null || options === void 0 ? void 0 : options.refundAddress) || signerAddress;
|
|
584
|
-
const contract = new ethers_1.ethers.Contract(gasReceiverAddress, [
|
|
585
|
-
"function addNativeGas(bytes32 txHash,uint256 logIndex,address refundAddress) external payable",
|
|
586
|
-
], signer);
|
|
587
|
-
return contract
|
|
588
|
-
.addNativeGas(txHash, logIndex, refundAddress, {
|
|
589
|
-
value: gasFeeToAdd,
|
|
590
|
-
})
|
|
591
|
-
.then((tx) => tx.wait())
|
|
592
|
-
.then((tx) => ({
|
|
593
|
-
success: true,
|
|
594
|
-
transaction: tx,
|
|
595
|
-
}))
|
|
596
|
-
.catch(error_1.ContractCallError);
|
|
597
|
-
});
|
|
598
|
-
}
|
|
599
|
-
/**
|
|
600
|
-
* Pay ERC20 token as gas fee for the given transaction hash.
|
|
601
|
-
* If the transaction details or `gasTokenAddress` is not valid, it will return an error with reason.
|
|
602
|
-
*
|
|
603
|
-
* @param chain EvmChain - The source chain of the transaction hash.
|
|
604
|
-
* @param txHash string - The transaction hash.
|
|
605
|
-
* @param gasTokenAddress string - The address of the ERC20 token to pay as gas fee.
|
|
606
|
-
* @param options AddGasOptions - The options to pay gas fee.
|
|
607
|
-
* @returns
|
|
608
|
-
*/
|
|
609
|
-
addGas(chain, txHash, gasTokenAddress, options) {
|
|
610
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
611
|
-
const evmWalletDetails = (options === null || options === void 0 ? void 0 : options.evmWalletDetails) || { useWindowEthereum: true };
|
|
612
|
-
const signer = this.getSigner(chain, evmWalletDetails);
|
|
613
|
-
const signerAddress = yield signer.getAddress();
|
|
614
|
-
const gasReceiverAddress = yield this.axelarQueryApi.getContractAddressFromConfig(chain, "gas_service");
|
|
615
|
-
const gasTokenContract = new ethers_1.ethers.Contract(gasTokenAddress, erc20Abi_json_1.default, signer.provider);
|
|
616
|
-
const gasTokenSymbol = yield gasTokenContract.symbol().catch(() => undefined);
|
|
617
|
-
// Check if given `gasTokenAddress` exists
|
|
618
|
-
if (!gasTokenSymbol)
|
|
619
|
-
return (0, error_1.InvalidGasTokenError)();
|
|
620
|
-
const axelarGateway = yield AxelarGateway_1.AxelarGateway.create(this.environment, chain, signer.provider);
|
|
621
|
-
const gatewayGasTokenAddress = yield axelarGateway.getTokenAddress(gasTokenSymbol);
|
|
622
|
-
// Check if given `gasTokenAddress` is supported by Axelar.
|
|
623
|
-
if (gatewayGasTokenAddress === ethers_1.ethers.constants.AddressZero)
|
|
624
|
-
return (0, error_1.UnsupportedGasTokenError)(gasTokenAddress);
|
|
625
|
-
const receipt = yield signer.provider.getTransactionReceipt(txHash);
|
|
626
|
-
// Check if transaction exists
|
|
627
|
-
if (!receipt)
|
|
628
|
-
return (0, error_1.InvalidTransactionError)(chain);
|
|
629
|
-
const destinationChain = (0, contractEventHelper_1.getDestinationChainFromTxReceipt)(receipt);
|
|
630
|
-
const logIndex = (0, contractEventHelper_1.getLogIndexFromTxReceipt)(receipt);
|
|
631
|
-
// Check if given txHash is valid
|
|
632
|
-
if (!destinationChain)
|
|
633
|
-
return (0, error_1.NotGMPTransactionError)();
|
|
634
|
-
// Check if the transaction status is already executed or not.
|
|
635
|
-
const _isExecuted = yield this.isExecuted(txHash);
|
|
636
|
-
if (_isExecuted)
|
|
637
|
-
return (0, error_1.AlreadyExecutedError)();
|
|
638
|
-
let gasFeeToAdd = options === null || options === void 0 ? void 0 : options.amount;
|
|
639
|
-
if (!gasFeeToAdd) {
|
|
640
|
-
gasFeeToAdd = yield this.calculateGasFee(txHash, chain, destinationChain, gasTokenSymbol, {
|
|
641
|
-
estimatedGas: options === null || options === void 0 ? void 0 : options.estimatedGasUsed,
|
|
642
|
-
provider: evmWalletDetails.provider,
|
|
643
|
-
}).catch(() => undefined);
|
|
644
|
-
}
|
|
645
|
-
// Check if gas price is queried successfully.
|
|
646
|
-
if (!gasFeeToAdd)
|
|
647
|
-
return (0, error_1.GasPriceAPIError)();
|
|
648
|
-
// Check if gas fee is not already sufficiently paid.
|
|
649
|
-
if (gasFeeToAdd === "0")
|
|
650
|
-
return (0, error_1.AlreadyPaidGasFeeError)();
|
|
651
|
-
const refundAddress = (options === null || options === void 0 ? void 0 : options.refundAddress) || signerAddress;
|
|
652
|
-
const contract = new ethers_1.ethers.Contract(gasReceiverAddress, new utils_2.Interface([
|
|
653
|
-
"function addGas(bytes32 txHash,uint256 txIndex,address gasToken,uint256 gasFeeAmount,address refundAddress) external",
|
|
654
|
-
]), signer);
|
|
655
|
-
return contract
|
|
656
|
-
.addGas(txHash, logIndex, gasTokenAddress, gasFeeToAdd, refundAddress)
|
|
657
|
-
.then((tx) => tx.wait())
|
|
658
|
-
.then((tx) => ({
|
|
659
|
-
success: true,
|
|
660
|
-
transaction: tx,
|
|
661
|
-
}))
|
|
662
|
-
.catch(error_1.ContractCallError);
|
|
663
|
-
});
|
|
664
|
-
}
|
|
665
|
-
/**
|
|
666
|
-
* Execute a transaction on the destination chain associated with given `srcTxHash`.
|
|
667
|
-
* @param srcTxHash - The transaction hash on the source chain.
|
|
668
|
-
* @param srcTxLogIndex - The log index of the transaction on the source chain.
|
|
669
|
-
* @param evmWalletDetails - The wallet details to use for executing the transaction.
|
|
670
|
-
* @returns The result of executing the transaction.
|
|
671
|
-
*/
|
|
672
|
-
execute(srcTxHash, srcTxLogIndex, evmWalletDetails) {
|
|
673
|
-
var _a;
|
|
674
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
675
|
-
const response = yield this.queryExecuteParams(srcTxHash, srcTxLogIndex).catch(() => undefined);
|
|
676
|
-
// Couldn't query the transaction details
|
|
677
|
-
if (!response)
|
|
678
|
-
return (0, error_1.GMPQueryError)();
|
|
679
|
-
// Already executed
|
|
680
|
-
if ((response === null || response === void 0 ? void 0 : response.status) === AxelarRecoveryApi_1.GMPStatus.DEST_EXECUTED)
|
|
681
|
-
return (0, error_1.AlreadyExecutedError)();
|
|
682
|
-
// Not Approved yet
|
|
683
|
-
if ((response === null || response === void 0 ? void 0 : response.status) !== AxelarRecoveryApi_1.GMPStatus.DEST_GATEWAY_APPROVED)
|
|
684
|
-
return (0, error_1.NotApprovedError)();
|
|
685
|
-
const executeParams = response.data;
|
|
686
|
-
const gasLimitBuffer = (evmWalletDetails === null || evmWalletDetails === void 0 ? void 0 : evmWalletDetails.gasLimitBuffer) || 0;
|
|
687
|
-
const { destinationChain, destinationContractAddress } = executeParams;
|
|
688
|
-
const signer = this.getSigner(destinationChain, evmWalletDetails);
|
|
689
|
-
const contract = new ethers_1.ethers.Contract(destinationContractAddress, IAxelarExecutable_1.default.abi, signer);
|
|
690
|
-
const txResult = yield (0, helpers_1.callExecute)(executeParams, contract, gasLimitBuffer)
|
|
691
|
-
.then((tx) => {
|
|
692
|
-
const { commandId, sourceChain, sourceAddress, payload, symbol, amount, isContractCallWithToken, } = executeParams;
|
|
693
|
-
const functionName = isContractCallWithToken ? "executeWithToken" : "execute";
|
|
694
|
-
return {
|
|
695
|
-
success: true,
|
|
696
|
-
transaction: tx,
|
|
697
|
-
data: {
|
|
698
|
-
functionName,
|
|
699
|
-
args: {
|
|
700
|
-
commandId,
|
|
701
|
-
sourceChain,
|
|
702
|
-
sourceAddress,
|
|
703
|
-
payload,
|
|
704
|
-
symbol,
|
|
705
|
-
amount,
|
|
706
|
-
},
|
|
707
|
-
},
|
|
708
|
-
};
|
|
709
|
-
})
|
|
710
|
-
.catch((e) => {
|
|
711
|
-
if (e.message === helpers_1.CALL_EXECUTE_ERROR.INSUFFICIENT_FUNDS) {
|
|
712
|
-
return (0, error_1.InsufficientFundsError)(executeParams);
|
|
713
|
-
}
|
|
714
|
-
else if (e.message === helpers_1.CALL_EXECUTE_ERROR.REVERT) {
|
|
715
|
-
return (0, error_1.ExecutionRevertedError)(executeParams);
|
|
716
|
-
}
|
|
717
|
-
else {
|
|
718
|
-
// should not happen
|
|
719
|
-
return (0, error_1.ContractCallError)(e);
|
|
720
|
-
}
|
|
721
|
-
});
|
|
722
|
-
// Submit execute data to axelarscan if the contract execution is success.
|
|
723
|
-
const signerAddress = yield signer.getAddress();
|
|
724
|
-
const executeTxHash = (_a = txResult.transaction) === null || _a === void 0 ? void 0 : _a.transactionHash;
|
|
725
|
-
if (executeTxHash) {
|
|
726
|
-
yield this.saveGMP(srcTxHash, signerAddress, executeTxHash).catch(() => undefined);
|
|
727
|
-
}
|
|
728
|
-
else {
|
|
729
|
-
yield this.saveGMP(srcTxHash, signerAddress, "", txResult.error).catch(() => undefined);
|
|
730
|
-
}
|
|
731
|
-
return txResult;
|
|
732
|
-
});
|
|
733
|
-
}
|
|
734
|
-
subtractGasFee(sourceChain, destinationChain, gasTokenSymbol, paidGasFee, options) {
|
|
735
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
736
|
-
const totalGasFee = yield this.axelarQueryApi.estimateGasFee(sourceChain, destinationChain, gasTokenSymbol, options.estimatedGas, options.gasMultipler, undefined, undefined);
|
|
737
|
-
let topupGasAmount = ethers_1.ethers.BigNumber.from(totalGasFee);
|
|
738
|
-
if (options.shouldSubtractBaseFee) {
|
|
739
|
-
const response = yield this.axelarQueryApi
|
|
740
|
-
.getNativeGasBaseFee(sourceChain, destinationChain, gasTokenSymbol)
|
|
741
|
-
.catch(() => undefined);
|
|
742
|
-
if (response && response.baseFee) {
|
|
743
|
-
topupGasAmount = topupGasAmount.sub(response.baseFee);
|
|
744
|
-
}
|
|
745
|
-
}
|
|
746
|
-
return topupGasAmount.gt(0) ? topupGasAmount.toString() : "0";
|
|
747
|
-
});
|
|
748
|
-
}
|
|
749
|
-
getSigner(chain, evmWalletDetails = { useWindowEthereum: true }) {
|
|
750
|
-
const { rpcMap, networkInfo } = chain_1.default[this.environment];
|
|
751
|
-
const evmClientConfig = {
|
|
752
|
-
rpcUrl: rpcMap[chain],
|
|
753
|
-
networkOptions: networkInfo[chain],
|
|
754
|
-
evmWalletDetails,
|
|
755
|
-
};
|
|
756
|
-
const evmClient = new EVMClient_1.default(evmClientConfig);
|
|
757
|
-
return evmClient.getSigner();
|
|
758
|
-
}
|
|
759
|
-
}
|
|
760
|
-
exports.AxelarGMPRecoveryAPI = AxelarGMPRecoveryAPI;
|
|
761
|
-
//# sourceMappingURL=AxelarGMPRecoveryAPI.js.map
|