@imtbl/sdk 0.36.4 → 0.36.5
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/dist/blockchain_data.js +1 -1
- package/dist/browser/checkout/sdk.js +6 -6
- package/dist/browser/checkout/widgets.js +57 -57
- package/dist/checkout.d.ts +2 -2
- package/dist/checkout.js +356 -138
- package/dist/immutablex_client.js +1 -1
- package/dist/index.browser.js +5 -5
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +358 -140
- package/dist/index.d.ts +2 -2
- package/dist/index.js +358 -140
- package/dist/passport.js +2 -2
- package/package.json +1 -1
package/dist/checkout.d.ts
CHANGED
|
@@ -11618,10 +11618,10 @@ type ImxAddressConfig = {
|
|
|
11618
11618
|
};
|
|
11619
11619
|
/**
|
|
11620
11620
|
* A type representing the telemetry configurations.
|
|
11621
|
-
* @property {string}
|
|
11621
|
+
* @property {string} segmentPublishableKey
|
|
11622
11622
|
*/
|
|
11623
11623
|
type TelemetryConfig = {
|
|
11624
|
-
|
|
11624
|
+
segmentPublishableKey: string;
|
|
11625
11625
|
};
|
|
11626
11626
|
/**
|
|
11627
11627
|
* A type representing the required information to estimate gas for a transaction.
|
package/dist/checkout.js
CHANGED
|
@@ -3234,105 +3234,6 @@ axios.default = axios;
|
|
|
3234
3234
|
// this module should only have a default export
|
|
3235
3235
|
var axios$1 = axios;
|
|
3236
3236
|
|
|
3237
|
-
/* eslint-disable @typescript-eslint/naming-convention */
|
|
3238
|
-
/**
|
|
3239
|
-
* @constant {string} ETH_SEPOLIA_CHAIN_ID - The chain ID for the Ethereum Sepolia testnet (EIP-155 compatible format).
|
|
3240
|
-
*/
|
|
3241
|
-
const ETH_SEPOLIA_CHAIN_ID = '11155111';
|
|
3242
|
-
/**
|
|
3243
|
-
* @constant {string} ETH_MAINNET_CHAIN_ID - The chain ID for the Ethereum mainnet (EIP-155 compatible format).
|
|
3244
|
-
*/
|
|
3245
|
-
const ETH_MAINNET_CHAIN_ID = '1';
|
|
3246
|
-
/**
|
|
3247
|
-
* @constant {string} ZKEVM_DEVNET_CHAIN_ID - The chain ID for the zkEVM devnet (EIP-155 compatible format).
|
|
3248
|
-
*/
|
|
3249
|
-
const ZKEVM_DEVNET_CHAIN_ID = '15003';
|
|
3250
|
-
/**
|
|
3251
|
-
* @constant {string} ZKEVM_TESTNET_CHAIN_ID - The chain ID for the zkEVM testnet (EIP-155 compatible format).
|
|
3252
|
-
*/
|
|
3253
|
-
const ZKEVM_TESTNET_CHAIN_ID = '13473';
|
|
3254
|
-
/**
|
|
3255
|
-
* @constant {string} ZKEVM_MAINNET_CHAIN_ID - The chain ID for the zkEVM mainnet (EIP-155 compatible format).
|
|
3256
|
-
*/
|
|
3257
|
-
const ZKEVM_MAINNET_CHAIN_ID = '13371'; // @TODO confirm this is still correct
|
|
3258
|
-
/**
|
|
3259
|
-
* @constant {BridgeInstance} ETH_SEPOLIA_TO_ZKEVM_DEVNET - A bridge instance configuration for bridging between
|
|
3260
|
-
* the Ethereum Sepolia testnet and the zkEVM devnet.
|
|
3261
|
-
*/
|
|
3262
|
-
const ETH_SEPOLIA_TO_ZKEVM_DEVNET = {
|
|
3263
|
-
rootChainID: ETH_SEPOLIA_CHAIN_ID,
|
|
3264
|
-
childChainID: ZKEVM_DEVNET_CHAIN_ID,
|
|
3265
|
-
};
|
|
3266
|
-
/**
|
|
3267
|
-
* @constant {BridgeInstance} ETH_SEPOLIA_TO_ZKEVM_TESTNET - A bridge instance configuration for bridging
|
|
3268
|
-
* between the Ethereum Sepolia testnet and the zkEVM testnet.
|
|
3269
|
-
*/
|
|
3270
|
-
const ETH_SEPOLIA_TO_ZKEVM_TESTNET = {
|
|
3271
|
-
rootChainID: ETH_SEPOLIA_CHAIN_ID,
|
|
3272
|
-
childChainID: ZKEVM_TESTNET_CHAIN_ID,
|
|
3273
|
-
};
|
|
3274
|
-
/**
|
|
3275
|
-
* @constant {BridgeInstance} ETH_MAINNET_TO_ZKEVM_MAINNET - A bridge instance configuration for bridging
|
|
3276
|
-
* between the Ethereum mainnet and the zkEVM mainnet.
|
|
3277
|
-
*/
|
|
3278
|
-
const ETH_MAINNET_TO_ZKEVM_MAINNET = {
|
|
3279
|
-
rootChainID: ETH_MAINNET_CHAIN_ID,
|
|
3280
|
-
childChainID: ZKEVM_MAINNET_CHAIN_ID,
|
|
3281
|
-
};
|
|
3282
|
-
/**
|
|
3283
|
-
* @typedef {Object} axelarAPIEndpoints - API endpoints for the testnet & mainnet Axelar environment configurations
|
|
3284
|
-
*/
|
|
3285
|
-
const axelarAPIEndpoints = {
|
|
3286
|
-
testnet: 'https://testnet.api.gmp.axelarscan.io',
|
|
3287
|
-
mainnet: 'https://api.gmp.axelarscan.io',
|
|
3288
|
-
devnet: '',
|
|
3289
|
-
};
|
|
3290
|
-
/**
|
|
3291
|
-
* @typedef {Object} axelarChains
|
|
3292
|
-
* @property {AxelarChainDetails} [chainId] - Mapping of the ChainId to the Axelar chain id string and symbol.
|
|
3293
|
-
*/
|
|
3294
|
-
const axelarChains = {
|
|
3295
|
-
11155111: {
|
|
3296
|
-
id: 'ethereum-sepolia',
|
|
3297
|
-
symbol: 'ETH',
|
|
3298
|
-
},
|
|
3299
|
-
1: {
|
|
3300
|
-
id: 'ethereum',
|
|
3301
|
-
symbol: 'ETH',
|
|
3302
|
-
},
|
|
3303
|
-
15003: {
|
|
3304
|
-
id: 'immutable',
|
|
3305
|
-
symbol: 'IMX',
|
|
3306
|
-
},
|
|
3307
|
-
13473: {
|
|
3308
|
-
id: 'immutable',
|
|
3309
|
-
symbol: 'IMX',
|
|
3310
|
-
},
|
|
3311
|
-
13371: {
|
|
3312
|
-
id: 'immutable',
|
|
3313
|
-
symbol: 'IMX',
|
|
3314
|
-
}, // immutable zkevm mainnet
|
|
3315
|
-
};
|
|
3316
|
-
/**
|
|
3317
|
-
* @typedef {Object} bridgeMethods
|
|
3318
|
-
* @property {string} deposit - The set of contract methods for depositing.
|
|
3319
|
-
* @property {string} withdraw - The set of contract methods for withdrawing.
|
|
3320
|
-
*/
|
|
3321
|
-
const bridgeMethods = {
|
|
3322
|
-
deposit: {
|
|
3323
|
-
token: 'deposit',
|
|
3324
|
-
tokenTo: 'depositTo',
|
|
3325
|
-
native: 'depositETH',
|
|
3326
|
-
nativeTo: 'depositToETH',
|
|
3327
|
-
},
|
|
3328
|
-
withdraw: {
|
|
3329
|
-
token: 'withdraw',
|
|
3330
|
-
tokenTo: 'withdrawTo',
|
|
3331
|
-
native: 'withdrawIMX',
|
|
3332
|
-
nativeTo: 'withdrawIMXTo',
|
|
3333
|
-
},
|
|
3334
|
-
};
|
|
3335
|
-
|
|
3336
3237
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
3337
3238
|
|
|
3338
3239
|
function getDefaultExportFromCjs (x) {
|
|
@@ -12519,6 +12420,105 @@ function parseUnits(value, unitName) {
|
|
|
12519
12420
|
return parseFixed(value, (unitName != null) ? unitName : 18);
|
|
12520
12421
|
}
|
|
12521
12422
|
|
|
12423
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
12424
|
+
/**
|
|
12425
|
+
* @constant {string} ETH_SEPOLIA_CHAIN_ID - The chain ID for the Ethereum Sepolia testnet (EIP-155 compatible format).
|
|
12426
|
+
*/
|
|
12427
|
+
const ETH_SEPOLIA_CHAIN_ID = '11155111';
|
|
12428
|
+
/**
|
|
12429
|
+
* @constant {string} ETH_MAINNET_CHAIN_ID - The chain ID for the Ethereum mainnet (EIP-155 compatible format).
|
|
12430
|
+
*/
|
|
12431
|
+
const ETH_MAINNET_CHAIN_ID = '1';
|
|
12432
|
+
/**
|
|
12433
|
+
* @constant {string} ZKEVM_DEVNET_CHAIN_ID - The chain ID for the zkEVM devnet (EIP-155 compatible format).
|
|
12434
|
+
*/
|
|
12435
|
+
const ZKEVM_DEVNET_CHAIN_ID = '15003';
|
|
12436
|
+
/**
|
|
12437
|
+
* @constant {string} ZKEVM_TESTNET_CHAIN_ID - The chain ID for the zkEVM testnet (EIP-155 compatible format).
|
|
12438
|
+
*/
|
|
12439
|
+
const ZKEVM_TESTNET_CHAIN_ID = '13473';
|
|
12440
|
+
/**
|
|
12441
|
+
* @constant {string} ZKEVM_MAINNET_CHAIN_ID - The chain ID for the zkEVM mainnet (EIP-155 compatible format).
|
|
12442
|
+
*/
|
|
12443
|
+
const ZKEVM_MAINNET_CHAIN_ID = '13371'; // @TODO confirm this is still correct
|
|
12444
|
+
/**
|
|
12445
|
+
* @constant {BridgeInstance} ETH_SEPOLIA_TO_ZKEVM_DEVNET - A bridge instance configuration for bridging between
|
|
12446
|
+
* the Ethereum Sepolia testnet and the zkEVM devnet.
|
|
12447
|
+
*/
|
|
12448
|
+
const ETH_SEPOLIA_TO_ZKEVM_DEVNET = {
|
|
12449
|
+
rootChainID: ETH_SEPOLIA_CHAIN_ID,
|
|
12450
|
+
childChainID: ZKEVM_DEVNET_CHAIN_ID,
|
|
12451
|
+
};
|
|
12452
|
+
/**
|
|
12453
|
+
* @constant {BridgeInstance} ETH_SEPOLIA_TO_ZKEVM_TESTNET - A bridge instance configuration for bridging
|
|
12454
|
+
* between the Ethereum Sepolia testnet and the zkEVM testnet.
|
|
12455
|
+
*/
|
|
12456
|
+
const ETH_SEPOLIA_TO_ZKEVM_TESTNET = {
|
|
12457
|
+
rootChainID: ETH_SEPOLIA_CHAIN_ID,
|
|
12458
|
+
childChainID: ZKEVM_TESTNET_CHAIN_ID,
|
|
12459
|
+
};
|
|
12460
|
+
/**
|
|
12461
|
+
* @constant {BridgeInstance} ETH_MAINNET_TO_ZKEVM_MAINNET - A bridge instance configuration for bridging
|
|
12462
|
+
* between the Ethereum mainnet and the zkEVM mainnet.
|
|
12463
|
+
*/
|
|
12464
|
+
const ETH_MAINNET_TO_ZKEVM_MAINNET = {
|
|
12465
|
+
rootChainID: ETH_MAINNET_CHAIN_ID,
|
|
12466
|
+
childChainID: ZKEVM_MAINNET_CHAIN_ID,
|
|
12467
|
+
};
|
|
12468
|
+
/**
|
|
12469
|
+
* @typedef {Object} axelarAPIEndpoints - API endpoints for the testnet & mainnet Axelar environment configurations
|
|
12470
|
+
*/
|
|
12471
|
+
const axelarAPIEndpoints = {
|
|
12472
|
+
testnet: 'https://testnet.api.gmp.axelarscan.io',
|
|
12473
|
+
mainnet: 'https://api.gmp.axelarscan.io',
|
|
12474
|
+
devnet: '',
|
|
12475
|
+
};
|
|
12476
|
+
/**
|
|
12477
|
+
* @typedef {Object} axelarChains
|
|
12478
|
+
* @property {AxelarChainDetails} [chainId] - Mapping of the ChainId to the Axelar chain id string and symbol.
|
|
12479
|
+
*/
|
|
12480
|
+
const axelarChains = {
|
|
12481
|
+
11155111: {
|
|
12482
|
+
id: 'ethereum-sepolia',
|
|
12483
|
+
symbol: 'ETH',
|
|
12484
|
+
},
|
|
12485
|
+
1: {
|
|
12486
|
+
id: 'ethereum',
|
|
12487
|
+
symbol: 'ETH',
|
|
12488
|
+
},
|
|
12489
|
+
15003: {
|
|
12490
|
+
id: 'immutable',
|
|
12491
|
+
symbol: 'IMX',
|
|
12492
|
+
},
|
|
12493
|
+
13473: {
|
|
12494
|
+
id: 'immutable',
|
|
12495
|
+
symbol: 'IMX',
|
|
12496
|
+
},
|
|
12497
|
+
13371: {
|
|
12498
|
+
id: 'immutable',
|
|
12499
|
+
symbol: 'IMX',
|
|
12500
|
+
}, // immutable zkevm mainnet
|
|
12501
|
+
};
|
|
12502
|
+
/**
|
|
12503
|
+
* @typedef {Object} bridgeMethods
|
|
12504
|
+
* @property {string} deposit - The set of contract methods for depositing.
|
|
12505
|
+
* @property {string} withdraw - The set of contract methods for withdrawing.
|
|
12506
|
+
*/
|
|
12507
|
+
const bridgeMethods = {
|
|
12508
|
+
deposit: {
|
|
12509
|
+
token: 'deposit',
|
|
12510
|
+
tokenTo: 'depositTo',
|
|
12511
|
+
native: 'depositETH',
|
|
12512
|
+
nativeTo: 'depositToETH',
|
|
12513
|
+
},
|
|
12514
|
+
withdraw: {
|
|
12515
|
+
token: 'withdraw',
|
|
12516
|
+
tokenTo: 'withdrawTo',
|
|
12517
|
+
native: 'withdrawIMX',
|
|
12518
|
+
nativeTo: 'withdrawIMXTo',
|
|
12519
|
+
},
|
|
12520
|
+
};
|
|
12521
|
+
|
|
12522
12522
|
const ROOT_ERC20_BRIDGE_FLOW_RATE = [
|
|
12523
12523
|
{
|
|
12524
12524
|
inputs: [
|
|
@@ -14779,6 +14779,7 @@ var BridgeErrorType;
|
|
|
14779
14779
|
BridgeErrorType["AXELAR_CHAIN_NOT_FOUND"] = "AXELAR_CHAIN_NOT_FOUND";
|
|
14780
14780
|
BridgeErrorType["AXELAR_GAS_ESTIMATE_FAILED"] = "AXELAR_GAS_ESTIMATE_FAILED";
|
|
14781
14781
|
BridgeErrorType["INVALID_RECIPIENT"] = "INVALID_RECIPIENT";
|
|
14782
|
+
BridgeErrorType["FLOW_RATE_ERROR"] = "FLOW_RATE_ERROR";
|
|
14782
14783
|
})(BridgeErrorType || (BridgeErrorType = {}));
|
|
14783
14784
|
/**
|
|
14784
14785
|
* Represents a custom error for bridge operations.
|
|
@@ -16091,16 +16092,17 @@ var BridgeFeeActions;
|
|
|
16091
16092
|
*/
|
|
16092
16093
|
var BridgeMethodsGasLimit;
|
|
16093
16094
|
(function (BridgeMethodsGasLimit) {
|
|
16094
|
-
BridgeMethodsGasLimit[BridgeMethodsGasLimit["DEPOSIT_SOURCE"] =
|
|
16095
|
-
BridgeMethodsGasLimit[BridgeMethodsGasLimit["DEPOSIT_DESTINATION"] =
|
|
16096
|
-
BridgeMethodsGasLimit[BridgeMethodsGasLimit["WITHDRAW_SOURCE"] =
|
|
16097
|
-
BridgeMethodsGasLimit[BridgeMethodsGasLimit["WITHDRAW_DESTINATION"] =
|
|
16098
|
-
BridgeMethodsGasLimit[BridgeMethodsGasLimit["MAP_TOKEN_SOURCE"] =
|
|
16099
|
-
BridgeMethodsGasLimit[BridgeMethodsGasLimit["MAP_TOKEN_DESTINATION"] =
|
|
16095
|
+
BridgeMethodsGasLimit[BridgeMethodsGasLimit["DEPOSIT_SOURCE"] = 200000] = "DEPOSIT_SOURCE";
|
|
16096
|
+
BridgeMethodsGasLimit[BridgeMethodsGasLimit["DEPOSIT_DESTINATION"] = 200000] = "DEPOSIT_DESTINATION";
|
|
16097
|
+
BridgeMethodsGasLimit[BridgeMethodsGasLimit["WITHDRAW_SOURCE"] = 200000] = "WITHDRAW_SOURCE";
|
|
16098
|
+
BridgeMethodsGasLimit[BridgeMethodsGasLimit["WITHDRAW_DESTINATION"] = 250000] = "WITHDRAW_DESTINATION";
|
|
16099
|
+
BridgeMethodsGasLimit[BridgeMethodsGasLimit["MAP_TOKEN_SOURCE"] = 200000] = "MAP_TOKEN_SOURCE";
|
|
16100
|
+
BridgeMethodsGasLimit[BridgeMethodsGasLimit["MAP_TOKEN_DESTINATION"] = 200000] = "MAP_TOKEN_DESTINATION";
|
|
16100
16101
|
BridgeMethodsGasLimit[BridgeMethodsGasLimit["FINALISE_WITHDRAWAL"] = 200000] = "FINALISE_WITHDRAWAL";
|
|
16101
16102
|
})(BridgeMethodsGasLimit || (BridgeMethodsGasLimit = {}));
|
|
16102
16103
|
var StatusResponse;
|
|
16103
16104
|
(function (StatusResponse) {
|
|
16105
|
+
StatusResponse["PENDING"] = "PENDING";
|
|
16104
16106
|
StatusResponse["PROCESSING"] = "PROCESSING";
|
|
16105
16107
|
StatusResponse["COMPLETE"] = "COMPLETE";
|
|
16106
16108
|
StatusResponse["RETRY"] = "RETRY";
|
|
@@ -16109,6 +16111,109 @@ var StatusResponse;
|
|
|
16109
16111
|
StatusResponse["FLOW_RATE_CONTROLLED"] = "FLOW_RATE_CONTROLLED";
|
|
16110
16112
|
})(StatusResponse || (StatusResponse = {}));
|
|
16111
16113
|
|
|
16114
|
+
var GMPStatus;
|
|
16115
|
+
(function (GMPStatus) {
|
|
16116
|
+
GMPStatus["SRC_GATEWAY_CALLED"] = "source_gateway_called";
|
|
16117
|
+
GMPStatus["DEST_GATEWAY_APPROVED"] = "destination_gateway_approved";
|
|
16118
|
+
GMPStatus["DEST_EXECUTED"] = "destination_executed";
|
|
16119
|
+
GMPStatus["EXPRESS_EXECUTED"] = "express_executed";
|
|
16120
|
+
GMPStatus["DEST_EXECUTE_ERROR"] = "error";
|
|
16121
|
+
GMPStatus["DEST_EXECUTING"] = "executing";
|
|
16122
|
+
GMPStatus["APPROVING"] = "approving";
|
|
16123
|
+
GMPStatus["FORECALLED"] = "forecalled";
|
|
16124
|
+
GMPStatus["FORECALLED_WITHOUT_GAS_PAID"] = "forecalled_without_gas_paid";
|
|
16125
|
+
GMPStatus["NOT_EXECUTED"] = "not_executed";
|
|
16126
|
+
GMPStatus["NOT_EXECUTED_WITHOUT_GAS_PAID"] = "not_executed_without_gas_paid";
|
|
16127
|
+
GMPStatus["INSUFFICIENT_FEE"] = "insufficient_fee";
|
|
16128
|
+
GMPStatus["UNKNOWN_ERROR"] = "unknown_error";
|
|
16129
|
+
GMPStatus["CANNOT_FETCH_STATUS"] = "cannot_fetch_status";
|
|
16130
|
+
GMPStatus["SRC_GATEWAY_CONFIRMED"] = "confirmed";
|
|
16131
|
+
})(GMPStatus || (GMPStatus = {}));
|
|
16132
|
+
var GasPaidStatus;
|
|
16133
|
+
(function (GasPaidStatus) {
|
|
16134
|
+
GasPaidStatus["GAS_UNPAID"] = "gas_unpaid";
|
|
16135
|
+
GasPaidStatus["GAS_PAID"] = "gas_paid";
|
|
16136
|
+
GasPaidStatus["GAS_PAID_NOT_ENOUGH_GAS"] = "gas_paid_not_enough_gas";
|
|
16137
|
+
GasPaidStatus["GAS_PAID_ENOUGH_GAS"] = "gas_paid_enough_gas";
|
|
16138
|
+
})(GasPaidStatus || (GasPaidStatus = {}));
|
|
16139
|
+
|
|
16140
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
16141
|
+
const parseGMPStatus = (response) => {
|
|
16142
|
+
const { error, status } = response;
|
|
16143
|
+
if (status === 'error' && error)
|
|
16144
|
+
return GMPStatus.DEST_EXECUTE_ERROR;
|
|
16145
|
+
if (status === 'executed')
|
|
16146
|
+
return GMPStatus.DEST_EXECUTED;
|
|
16147
|
+
if (status === 'approved')
|
|
16148
|
+
return GMPStatus.DEST_GATEWAY_APPROVED;
|
|
16149
|
+
if (status === 'called')
|
|
16150
|
+
return GMPStatus.SRC_GATEWAY_CALLED;
|
|
16151
|
+
if (status === 'executing')
|
|
16152
|
+
return GMPStatus.DEST_EXECUTING;
|
|
16153
|
+
return status;
|
|
16154
|
+
};
|
|
16155
|
+
const parseGMPError = (response) => {
|
|
16156
|
+
if (response.error) {
|
|
16157
|
+
return {
|
|
16158
|
+
message: response.error.error.message,
|
|
16159
|
+
txHash: response.error.error.transactionHash,
|
|
16160
|
+
chain: response.error.chain,
|
|
16161
|
+
};
|
|
16162
|
+
}
|
|
16163
|
+
if (response.is_insufficient_fee) {
|
|
16164
|
+
return {
|
|
16165
|
+
message: 'Insufficient fee',
|
|
16166
|
+
txHash: response.call.transaction.hash,
|
|
16167
|
+
chain: response.call.chain,
|
|
16168
|
+
};
|
|
16169
|
+
}
|
|
16170
|
+
return undefined;
|
|
16171
|
+
};
|
|
16172
|
+
const execGet = async (base, params) => fetch(`${base}?${new URLSearchParams(params).toString()}`, {
|
|
16173
|
+
method: 'GET',
|
|
16174
|
+
headers: { 'Content-Type': 'application/json' },
|
|
16175
|
+
cache: 'no-store',
|
|
16176
|
+
})
|
|
16177
|
+
.then((res) => res.json())
|
|
16178
|
+
.then((res) => res.data);
|
|
16179
|
+
const fetchGMPTransaction = async (axelarGMPApiUrl, txHash, txLogIndex) => execGet(axelarGMPApiUrl, {
|
|
16180
|
+
method: 'searchGMP',
|
|
16181
|
+
txHash,
|
|
16182
|
+
txLogIndex,
|
|
16183
|
+
})
|
|
16184
|
+
.then((data) => data.find((gmpTx) => gmpTx.id.indexOf(txHash) > -1 || gmpTx.call.transactionHash.indexOf(txHash) > -1))
|
|
16185
|
+
.catch(() => undefined);
|
|
16186
|
+
const queryTransactionStatus = async (axelarGMPApiUrl, txHash, txLogIndex) => {
|
|
16187
|
+
const txDetails = await fetchGMPTransaction(axelarGMPApiUrl, txHash, txLogIndex);
|
|
16188
|
+
if (!txDetails)
|
|
16189
|
+
return { status: GMPStatus.CANNOT_FETCH_STATUS };
|
|
16190
|
+
const { call, gas_status, gas_paid, executed, express_executed, approved, callback, } = txDetails;
|
|
16191
|
+
const gasPaidInfo = {
|
|
16192
|
+
status: gas_status,
|
|
16193
|
+
details: gas_paid,
|
|
16194
|
+
};
|
|
16195
|
+
// Note: Currently, the GMP API doesn't always return the `total` field in the `time_spent` object
|
|
16196
|
+
// This is a temporary fix to ensure that the `total` field is always present
|
|
16197
|
+
// TODO: Remove this once the API is fixed
|
|
16198
|
+
const timeSpent = txDetails.time_spent;
|
|
16199
|
+
if (timeSpent) {
|
|
16200
|
+
timeSpent.total = timeSpent.total
|
|
16201
|
+
|| Object.values(timeSpent).reduce((accumulator, value) => accumulator + value, 0);
|
|
16202
|
+
}
|
|
16203
|
+
return {
|
|
16204
|
+
status: parseGMPStatus(txDetails),
|
|
16205
|
+
error: parseGMPError(txDetails),
|
|
16206
|
+
timeSpent,
|
|
16207
|
+
gasPaidInfo,
|
|
16208
|
+
callTx: call,
|
|
16209
|
+
executed,
|
|
16210
|
+
expressExecuted: express_executed,
|
|
16211
|
+
approved,
|
|
16212
|
+
callback,
|
|
16213
|
+
};
|
|
16214
|
+
};
|
|
16215
|
+
|
|
16216
|
+
/* eslint-disable no-console */
|
|
16112
16217
|
/* eslint-disable class-methods-use-this */
|
|
16113
16218
|
/**
|
|
16114
16219
|
* Represents a token bridge, which manages asset transfers between two chains.
|
|
@@ -16300,6 +16405,7 @@ class TokenBridge {
|
|
|
16300
16405
|
to: req.token,
|
|
16301
16406
|
value: 0,
|
|
16302
16407
|
from: req.senderAddress,
|
|
16408
|
+
chainId: parseInt(req.sourceChainId, 10),
|
|
16303
16409
|
};
|
|
16304
16410
|
return {
|
|
16305
16411
|
contractToApprove: sourceBridgeAddress,
|
|
@@ -16445,6 +16551,7 @@ class TokenBridge {
|
|
|
16445
16551
|
data,
|
|
16446
16552
|
to: contractAddress,
|
|
16447
16553
|
value: amount.add(fees.bridgeFee).toString(),
|
|
16554
|
+
chainId: parseInt(sourceChainId, 10),
|
|
16448
16555
|
},
|
|
16449
16556
|
};
|
|
16450
16557
|
}
|
|
@@ -16464,6 +16571,7 @@ class TokenBridge {
|
|
|
16464
16571
|
data,
|
|
16465
16572
|
to: contractAddress,
|
|
16466
16573
|
value: fees.bridgeFee.toString(),
|
|
16574
|
+
chainId: parseInt(sourceChainId, 10),
|
|
16467
16575
|
},
|
|
16468
16576
|
};
|
|
16469
16577
|
}
|
|
@@ -16512,6 +16620,21 @@ class TokenBridge {
|
|
|
16512
16620
|
throw new BridgeError(`Childchain provider chainID ${childNetwork.chainId} does not match expected chainID ${this.config.bridgeInstance.childChainID}. ${errMessage}`, BridgeErrorType.UNSUPPORTED_ERROR);
|
|
16513
16621
|
}
|
|
16514
16622
|
}
|
|
16623
|
+
getAxelarEndpoint(source) {
|
|
16624
|
+
let axelarAPIEndpoint;
|
|
16625
|
+
if (source === ETH_MAINNET_TO_ZKEVM_MAINNET.rootChainID
|
|
16626
|
+
|| source === ETH_MAINNET_TO_ZKEVM_MAINNET.childChainID) {
|
|
16627
|
+
axelarAPIEndpoint = axelarAPIEndpoints.mainnet;
|
|
16628
|
+
}
|
|
16629
|
+
else if (source === ETH_SEPOLIA_TO_ZKEVM_TESTNET.rootChainID
|
|
16630
|
+
|| source === ETH_SEPOLIA_TO_ZKEVM_TESTNET.childChainID) {
|
|
16631
|
+
axelarAPIEndpoint = axelarAPIEndpoints.testnet;
|
|
16632
|
+
}
|
|
16633
|
+
else {
|
|
16634
|
+
axelarAPIEndpoint = axelarAPIEndpoints.devnet;
|
|
16635
|
+
}
|
|
16636
|
+
return axelarAPIEndpoint;
|
|
16637
|
+
}
|
|
16515
16638
|
/**
|
|
16516
16639
|
* Calculate the gas amount for a transaction using axelarjs-sdk.
|
|
16517
16640
|
* @param {*} source - The source chainId.
|
|
@@ -16530,18 +16653,7 @@ class TokenBridge {
|
|
|
16530
16653
|
if (!destinationAxelar) {
|
|
16531
16654
|
throw new BridgeError(`Destination chainID ${destination} can not be matched to an Axelar chain.`, BridgeErrorType.AXELAR_CHAIN_NOT_FOUND);
|
|
16532
16655
|
}
|
|
16533
|
-
|
|
16534
|
-
if (source === ETH_MAINNET_TO_ZKEVM_MAINNET.rootChainID
|
|
16535
|
-
|| source === ETH_MAINNET_TO_ZKEVM_MAINNET.childChainID) {
|
|
16536
|
-
axelarApiEndpoint = axelarAPIEndpoints.mainnet;
|
|
16537
|
-
}
|
|
16538
|
-
else if (source === ETH_SEPOLIA_TO_ZKEVM_TESTNET.rootChainID
|
|
16539
|
-
|| source === ETH_SEPOLIA_TO_ZKEVM_TESTNET.childChainID) {
|
|
16540
|
-
axelarApiEndpoint = axelarAPIEndpoints.testnet;
|
|
16541
|
-
}
|
|
16542
|
-
else {
|
|
16543
|
-
axelarApiEndpoint = axelarAPIEndpoints.devnet;
|
|
16544
|
-
}
|
|
16656
|
+
const axelarAPIEndpoint = this.getAxelarEndpoint(source);
|
|
16545
16657
|
let axiosResponse;
|
|
16546
16658
|
const estimateGasReq = {
|
|
16547
16659
|
method: 'estimateGasFee',
|
|
@@ -16552,7 +16664,7 @@ class TokenBridge {
|
|
|
16552
16664
|
gasMultiplier,
|
|
16553
16665
|
};
|
|
16554
16666
|
try {
|
|
16555
|
-
axiosResponse = await axios$1.post(
|
|
16667
|
+
axiosResponse = await axios$1.post(axelarAPIEndpoint, estimateGasReq);
|
|
16556
16668
|
}
|
|
16557
16669
|
catch (error) {
|
|
16558
16670
|
axiosResponse = error.response;
|
|
@@ -16569,30 +16681,136 @@ class TokenBridge {
|
|
|
16569
16681
|
throw new BridgeError(`Estimating Axelar Gas failed with the reason: ${err}`, BridgeErrorType.AXELAR_GAS_ESTIMATE_FAILED);
|
|
16570
16682
|
}
|
|
16571
16683
|
}
|
|
16572
|
-
// STUBBED ENDPOINTS FOR PHASE 2 -------------------------------------------
|
|
16573
16684
|
/**
|
|
16574
16685
|
* Queries the status of a bridge transaction.
|
|
16575
16686
|
*
|
|
16576
|
-
* @param {
|
|
16577
|
-
* @returns {Promise<
|
|
16687
|
+
* @param {TxStatusRequest} req - The request object containing an array of transactions to query.
|
|
16688
|
+
* @returns {Promise<TxStatusResponse>} - A promise that resolves to an array of transaction statuses.
|
|
16578
16689
|
* @throws {BridgeError} - If an error occurs during the query, a BridgeError will be thrown with a specific error type.
|
|
16579
|
-
* @dev this SDK method is currently stubbed
|
|
16580
16690
|
*/
|
|
16581
16691
|
async getTransactionStatus(req) {
|
|
16582
|
-
|
|
16583
|
-
|
|
16584
|
-
|
|
16585
|
-
return {
|
|
16586
|
-
transactions: [{
|
|
16587
|
-
transactionHash: '0x1234....',
|
|
16588
|
-
status: StatusResponse.COMPLETE,
|
|
16589
|
-
data: 'stubbed data',
|
|
16590
|
-
}, {
|
|
16591
|
-
transactionHash: '0xABCD....',
|
|
16592
|
-
status: StatusResponse.PROCESSING,
|
|
16593
|
-
data: 'stubbed data',
|
|
16594
|
-
}],
|
|
16692
|
+
const axelarAPIEndpoint = this.getAxelarEndpoint(req.sourceChainId);
|
|
16693
|
+
const txStatusResponse = {
|
|
16694
|
+
transactions: [],
|
|
16595
16695
|
};
|
|
16696
|
+
const abiCoder = new AbiCoder();
|
|
16697
|
+
const statusPromises = [];
|
|
16698
|
+
for (const transaction of req.transactions) {
|
|
16699
|
+
statusPromises.push(queryTransactionStatus(axelarAPIEndpoint, transaction.txHash));
|
|
16700
|
+
}
|
|
16701
|
+
let statusResponses;
|
|
16702
|
+
try {
|
|
16703
|
+
statusResponses = await Promise.all(statusPromises);
|
|
16704
|
+
}
|
|
16705
|
+
catch (err) {
|
|
16706
|
+
throw new BridgeError(`Failed to fetch the Axelar Status with the reason: ${err}`, BridgeErrorType.AXELAR_GAS_ESTIMATE_FAILED);
|
|
16707
|
+
}
|
|
16708
|
+
const unpaidGasStatus = [GasPaidStatus.GAS_UNPAID, GasPaidStatus.GAS_PAID_NOT_ENOUGH_GAS];
|
|
16709
|
+
const isWithdraw = [
|
|
16710
|
+
ZKEVM_DEVNET_CHAIN_ID,
|
|
16711
|
+
ZKEVM_TESTNET_CHAIN_ID,
|
|
16712
|
+
ZKEVM_MAINNET_CHAIN_ID
|
|
16713
|
+
].includes(req.sourceChainId);
|
|
16714
|
+
let rootBridge;
|
|
16715
|
+
if (isWithdraw) {
|
|
16716
|
+
rootBridge = await withBridgeError(async () => {
|
|
16717
|
+
const contract = new Contract(this.config.bridgeContracts.rootERC20BridgeFlowRate, ROOT_ERC20_BRIDGE_FLOW_RATE, this.config.rootProvider);
|
|
16718
|
+
return contract;
|
|
16719
|
+
}, BridgeErrorType.INTERNAL_ERROR);
|
|
16720
|
+
}
|
|
16721
|
+
const flowRatePromises = [];
|
|
16722
|
+
const flowRatePromisesReceivers = [];
|
|
16723
|
+
for (let i = 0, l = statusResponses.length; i < l; i++) {
|
|
16724
|
+
let metaStatus;
|
|
16725
|
+
// consolidate axelar statuses to our own simplified metaStatus
|
|
16726
|
+
switch (statusResponses[i].status) {
|
|
16727
|
+
case GMPStatus.CANNOT_FETCH_STATUS:
|
|
16728
|
+
metaStatus = StatusResponse.PENDING;
|
|
16729
|
+
break;
|
|
16730
|
+
case GMPStatus.SRC_GATEWAY_CALLED:
|
|
16731
|
+
case GMPStatus.DEST_GATEWAY_APPROVED:
|
|
16732
|
+
case GMPStatus.DEST_EXECUTING:
|
|
16733
|
+
case GMPStatus.SRC_GATEWAY_CONFIRMED:
|
|
16734
|
+
case GMPStatus.APPROVING:
|
|
16735
|
+
metaStatus = StatusResponse.PROCESSING;
|
|
16736
|
+
break;
|
|
16737
|
+
case GMPStatus.NOT_EXECUTED:
|
|
16738
|
+
metaStatus = StatusResponse.RETRY;
|
|
16739
|
+
break;
|
|
16740
|
+
case GMPStatus.NOT_EXECUTED_WITHOUT_GAS_PAID:
|
|
16741
|
+
case GMPStatus.INSUFFICIENT_FEE:
|
|
16742
|
+
metaStatus = StatusResponse.NOT_ENOUGH_GAS;
|
|
16743
|
+
break;
|
|
16744
|
+
case GMPStatus.DEST_EXECUTED:
|
|
16745
|
+
metaStatus = StatusResponse.COMPLETE;
|
|
16746
|
+
break;
|
|
16747
|
+
default:
|
|
16748
|
+
metaStatus = StatusResponse.ERROR;
|
|
16749
|
+
}
|
|
16750
|
+
if (statusResponses[i].gasPaidInfo) {
|
|
16751
|
+
if (unpaidGasStatus.includes(statusResponses[i].gasPaidInfo.status)) {
|
|
16752
|
+
metaStatus = StatusResponse.NOT_ENOUGH_GAS;
|
|
16753
|
+
}
|
|
16754
|
+
}
|
|
16755
|
+
let txItem = {
|
|
16756
|
+
txHash: req.transactions[i].txHash,
|
|
16757
|
+
status: metaStatus,
|
|
16758
|
+
data: {
|
|
16759
|
+
gmpResponse: statusResponses[i].status,
|
|
16760
|
+
},
|
|
16761
|
+
};
|
|
16762
|
+
let decodedData;
|
|
16763
|
+
if (statusResponses[i]?.callTx?.returnValues?.payload) {
|
|
16764
|
+
decodedData = abiCoder.decode(['bytes32', 'address', 'address', 'address', 'uint256'], statusResponses[i].callTx.returnValues.payload);
|
|
16765
|
+
txItem = {
|
|
16766
|
+
...txItem,
|
|
16767
|
+
token: decodedData[1],
|
|
16768
|
+
sender: decodedData[2],
|
|
16769
|
+
receiver: decodedData[3],
|
|
16770
|
+
amount: decodedData[4],
|
|
16771
|
+
};
|
|
16772
|
+
}
|
|
16773
|
+
let flowRatePromiseIndex;
|
|
16774
|
+
if (metaStatus === StatusResponse.COMPLETE
|
|
16775
|
+
&& isWithdraw && txItem.receiver) {
|
|
16776
|
+
// consolidate the calls we have to make to the flow rate by receiver
|
|
16777
|
+
if (!flowRatePromisesReceivers.includes(txItem.receiver)) {
|
|
16778
|
+
flowRatePromises.push(rootBridge.getPendingWithdrawals(txItem.receiver, [0]));
|
|
16779
|
+
flowRatePromisesReceivers.push(txItem.receiver);
|
|
16780
|
+
flowRatePromiseIndex = flowRatePromisesReceivers.length - 1;
|
|
16781
|
+
}
|
|
16782
|
+
else {
|
|
16783
|
+
flowRatePromiseIndex = flowRatePromisesReceivers.findIndex((el) => el === txItem.receiver);
|
|
16784
|
+
}
|
|
16785
|
+
txItem.data.flowRatePromiseIndex = flowRatePromiseIndex;
|
|
16786
|
+
}
|
|
16787
|
+
txStatusResponse.transactions.push(txItem);
|
|
16788
|
+
} // for
|
|
16789
|
+
let flowRateResponses = [];
|
|
16790
|
+
if (flowRatePromises.length > 0) {
|
|
16791
|
+
try {
|
|
16792
|
+
flowRateResponses = await Promise.all(flowRatePromises);
|
|
16793
|
+
}
|
|
16794
|
+
catch (err) {
|
|
16795
|
+
throw new BridgeError(`Failed to fetch the Flow Rate statuses with the reason: ${err}`, BridgeErrorType.FLOW_RATE_ERROR);
|
|
16796
|
+
}
|
|
16797
|
+
}
|
|
16798
|
+
for (const txStatusRes of txStatusResponse.transactions) {
|
|
16799
|
+
if (txStatusRes.data.flowRatePromiseIndex !== -1 && flowRateResponses[txStatusRes.data.flowRatePromiseIndex]) {
|
|
16800
|
+
const flowRatedTx = flowRateResponses[txStatusRes.data.flowRatePromiseIndex].find((el) => (el.amount.toString() === txStatusRes.amount.toString()
|
|
16801
|
+
&& el.token === txStatusRes.token
|
|
16802
|
+
&& el.withdrawer === txStatusRes.sender));
|
|
16803
|
+
if (flowRatedTx) {
|
|
16804
|
+
txStatusRes.status = StatusResponse.FLOW_RATE_CONTROLLED;
|
|
16805
|
+
txStatusRes.data = {
|
|
16806
|
+
timestamp: flowRatedTx.timestamp.toString(),
|
|
16807
|
+
};
|
|
16808
|
+
}
|
|
16809
|
+
}
|
|
16810
|
+
delete txStatusRes.data.flowRatePromiseIndex;
|
|
16811
|
+
}
|
|
16812
|
+
// Return the tx status response
|
|
16813
|
+
return txStatusResponse;
|
|
16596
16814
|
}
|
|
16597
16815
|
/**
|
|
16598
16816
|
* Queries for the information about which tokens are flowrated and how long the delay is.
|
|
@@ -16731,7 +16949,7 @@ const CONTRACTS_FOR_BRIDGE = new Map()
|
|
|
16731
16949
|
.set(ETH_SEPOLIA_TO_ZKEVM_TESTNET, {
|
|
16732
16950
|
rootERC20BridgeFlowRate: '0x0D3C59c779Fd552C27b23F723E80246c840100F5',
|
|
16733
16951
|
childERC20Bridge: '0x0D3C59c779Fd552C27b23F723E80246c840100F5',
|
|
16734
|
-
wrappedIMX: '
|
|
16952
|
+
wrappedIMX: '0x1CcCa691501174B4A623CeDA58cC8f1a76dc3439',
|
|
16735
16953
|
})
|
|
16736
16954
|
.set(ETH_MAINNET_TO_ZKEVM_MAINNET, {
|
|
16737
16955
|
rootERC20BridgeFlowRate: '0x0',
|
|
@@ -25833,7 +26051,7 @@ class APIError extends Error {
|
|
|
25833
26051
|
|
|
25834
26052
|
/* eslint-disable implicit-arrow-linebreak */
|
|
25835
26053
|
const defaultHeaders = {
|
|
25836
|
-
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.36.
|
|
26054
|
+
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.36.5',
|
|
25837
26055
|
};
|
|
25838
26056
|
/**
|
|
25839
26057
|
* createAPIConfiguration to create a custom Configuration
|
|
@@ -27157,7 +27375,7 @@ const GAS_OVERRIDES = {
|
|
|
27157
27375
|
maxPriorityFeePerGas: BigNumber$1.from(101e9),
|
|
27158
27376
|
};
|
|
27159
27377
|
|
|
27160
|
-
const SDK_VERSION_MARKER = '0.36.
|
|
27378
|
+
const SDK_VERSION_MARKER = '0.36.5';
|
|
27161
27379
|
// This SDK version is replaced by the `yarn build` command ran on the root level
|
|
27162
27380
|
const globalPackageVersion = () => SDK_VERSION_MARKER;
|
|
27163
27381
|
|
|
@@ -17,7 +17,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
17
17
|
chainID,
|
|
18
18
|
coreContractAddress,
|
|
19
19
|
registrationContractAddress,
|
|
20
|
-
sdkVersion: 'ts-immutable-sdk-0.36.
|
|
20
|
+
sdkVersion: 'ts-immutable-sdk-0.36.5',
|
|
21
21
|
});
|
|
22
22
|
/**
|
|
23
23
|
* Sets `sdkVersion` at the time of build
|