@imtbl/sdk 0.36.3 → 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 +58 -58
- package/dist/checkout.d.ts +50 -7
- package/dist/checkout.js +433 -159
- package/dist/immutablex_client.js +1 -1
- package/dist/index.browser.js +10 -10
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +435 -160
- package/dist/index.d.ts +54 -6
- package/dist/index.js +435 -160
- package/dist/passport.js +2 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4256,7 +4256,7 @@ class MultiRollupApiClients {
|
|
|
4256
4256
|
}
|
|
4257
4257
|
|
|
4258
4258
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
4259
|
-
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.36.
|
|
4259
|
+
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.36.5' };
|
|
4260
4260
|
const createConfig = ({ basePath, headers, }) => {
|
|
4261
4261
|
if (!basePath.trim()) {
|
|
4262
4262
|
throw Error('basePath can not be empty');
|
|
@@ -4316,7 +4316,7 @@ class APIError extends Error {
|
|
|
4316
4316
|
|
|
4317
4317
|
/* eslint-disable implicit-arrow-linebreak */
|
|
4318
4318
|
const defaultHeaders = {
|
|
4319
|
-
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.36.
|
|
4319
|
+
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.36.5',
|
|
4320
4320
|
};
|
|
4321
4321
|
/**
|
|
4322
4322
|
* createAPIConfiguration to create a custom Configuration
|
|
@@ -4755,7 +4755,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
4755
4755
|
chainID,
|
|
4756
4756
|
coreContractAddress,
|
|
4757
4757
|
registrationContractAddress,
|
|
4758
|
-
sdkVersion: 'ts-immutable-sdk-0.36.
|
|
4758
|
+
sdkVersion: 'ts-immutable-sdk-0.36.5',
|
|
4759
4759
|
});
|
|
4760
4760
|
/**
|
|
4761
4761
|
* Sets `sdkVersion` at the time of build
|
|
@@ -17490,105 +17490,6 @@ axios.default = axios;
|
|
|
17490
17490
|
// this module should only have a default export
|
|
17491
17491
|
var axios$1 = axios;
|
|
17492
17492
|
|
|
17493
|
-
/* eslint-disable @typescript-eslint/naming-convention */
|
|
17494
|
-
/**
|
|
17495
|
-
* @constant {string} ETH_SEPOLIA_CHAIN_ID - The chain ID for the Ethereum Sepolia testnet (EIP-155 compatible format).
|
|
17496
|
-
*/
|
|
17497
|
-
const ETH_SEPOLIA_CHAIN_ID = '11155111';
|
|
17498
|
-
/**
|
|
17499
|
-
* @constant {string} ETH_MAINNET_CHAIN_ID - The chain ID for the Ethereum mainnet (EIP-155 compatible format).
|
|
17500
|
-
*/
|
|
17501
|
-
const ETH_MAINNET_CHAIN_ID = '1';
|
|
17502
|
-
/**
|
|
17503
|
-
* @constant {string} ZKEVM_DEVNET_CHAIN_ID - The chain ID for the zkEVM devnet (EIP-155 compatible format).
|
|
17504
|
-
*/
|
|
17505
|
-
const ZKEVM_DEVNET_CHAIN_ID = '15003';
|
|
17506
|
-
/**
|
|
17507
|
-
* @constant {string} ZKEVM_TESTNET_CHAIN_ID - The chain ID for the zkEVM testnet (EIP-155 compatible format).
|
|
17508
|
-
*/
|
|
17509
|
-
const ZKEVM_TESTNET_CHAIN_ID = '13473';
|
|
17510
|
-
/**
|
|
17511
|
-
* @constant {string} ZKEVM_MAINNET_CHAIN_ID - The chain ID for the zkEVM mainnet (EIP-155 compatible format).
|
|
17512
|
-
*/
|
|
17513
|
-
const ZKEVM_MAINNET_CHAIN_ID = '13371'; // @TODO confirm this is still correct
|
|
17514
|
-
/**
|
|
17515
|
-
* @constant {BridgeInstance} ETH_SEPOLIA_TO_ZKEVM_DEVNET - A bridge instance configuration for bridging between
|
|
17516
|
-
* the Ethereum Sepolia testnet and the zkEVM devnet.
|
|
17517
|
-
*/
|
|
17518
|
-
const ETH_SEPOLIA_TO_ZKEVM_DEVNET = {
|
|
17519
|
-
rootChainID: ETH_SEPOLIA_CHAIN_ID,
|
|
17520
|
-
childChainID: ZKEVM_DEVNET_CHAIN_ID,
|
|
17521
|
-
};
|
|
17522
|
-
/**
|
|
17523
|
-
* @constant {BridgeInstance} ETH_SEPOLIA_TO_ZKEVM_TESTNET - A bridge instance configuration for bridging
|
|
17524
|
-
* between the Ethereum Sepolia testnet and the zkEVM testnet.
|
|
17525
|
-
*/
|
|
17526
|
-
const ETH_SEPOLIA_TO_ZKEVM_TESTNET = {
|
|
17527
|
-
rootChainID: ETH_SEPOLIA_CHAIN_ID,
|
|
17528
|
-
childChainID: ZKEVM_TESTNET_CHAIN_ID,
|
|
17529
|
-
};
|
|
17530
|
-
/**
|
|
17531
|
-
* @constant {BridgeInstance} ETH_MAINNET_TO_ZKEVM_MAINNET - A bridge instance configuration for bridging
|
|
17532
|
-
* between the Ethereum mainnet and the zkEVM mainnet.
|
|
17533
|
-
*/
|
|
17534
|
-
const ETH_MAINNET_TO_ZKEVM_MAINNET = {
|
|
17535
|
-
rootChainID: ETH_MAINNET_CHAIN_ID,
|
|
17536
|
-
childChainID: ZKEVM_MAINNET_CHAIN_ID,
|
|
17537
|
-
};
|
|
17538
|
-
/**
|
|
17539
|
-
* @typedef {Object} axelarAPIEndpoints - API endpoints for the testnet & mainnet Axelar environment configurations
|
|
17540
|
-
*/
|
|
17541
|
-
const axelarAPIEndpoints = {
|
|
17542
|
-
testnet: 'https://testnet.api.gmp.axelarscan.io',
|
|
17543
|
-
mainnet: 'https://api.gmp.axelarscan.io',
|
|
17544
|
-
devnet: '',
|
|
17545
|
-
};
|
|
17546
|
-
/**
|
|
17547
|
-
* @typedef {Object} axelarChains
|
|
17548
|
-
* @property {AxelarChainDetails} [chainId] - Mapping of the ChainId to the Axelar chain id string and symbol.
|
|
17549
|
-
*/
|
|
17550
|
-
const axelarChains = {
|
|
17551
|
-
11155111: {
|
|
17552
|
-
id: 'ethereum-sepolia',
|
|
17553
|
-
symbol: 'ETH',
|
|
17554
|
-
},
|
|
17555
|
-
1: {
|
|
17556
|
-
id: 'ethereum',
|
|
17557
|
-
symbol: 'ETH',
|
|
17558
|
-
},
|
|
17559
|
-
15003: {
|
|
17560
|
-
id: 'immutable',
|
|
17561
|
-
symbol: 'IMX',
|
|
17562
|
-
},
|
|
17563
|
-
13473: {
|
|
17564
|
-
id: 'immutable',
|
|
17565
|
-
symbol: 'IMX',
|
|
17566
|
-
},
|
|
17567
|
-
13371: {
|
|
17568
|
-
id: 'immutable',
|
|
17569
|
-
symbol: 'IMX',
|
|
17570
|
-
}, // immutable zkevm mainnet
|
|
17571
|
-
};
|
|
17572
|
-
/**
|
|
17573
|
-
* @typedef {Object} bridgeMethods
|
|
17574
|
-
* @property {string} deposit - The set of contract methods for depositing.
|
|
17575
|
-
* @property {string} withdraw - The set of contract methods for withdrawing.
|
|
17576
|
-
*/
|
|
17577
|
-
const bridgeMethods = {
|
|
17578
|
-
deposit: {
|
|
17579
|
-
token: 'deposit',
|
|
17580
|
-
tokenTo: 'depositTo',
|
|
17581
|
-
native: 'depositETH',
|
|
17582
|
-
nativeTo: 'depositToETH',
|
|
17583
|
-
},
|
|
17584
|
-
withdraw: {
|
|
17585
|
-
token: 'withdraw',
|
|
17586
|
-
tokenTo: 'withdrawTo',
|
|
17587
|
-
native: 'withdrawIMX',
|
|
17588
|
-
nativeTo: 'withdrawIMXTo',
|
|
17589
|
-
},
|
|
17590
|
-
};
|
|
17591
|
-
|
|
17592
17493
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
17593
17494
|
|
|
17594
17495
|
function getDefaultExportFromCjs (x) {
|
|
@@ -26775,6 +26676,105 @@ function parseUnits(value, unitName) {
|
|
|
26775
26676
|
return parseFixed(value, (unitName != null) ? unitName : 18);
|
|
26776
26677
|
}
|
|
26777
26678
|
|
|
26679
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
26680
|
+
/**
|
|
26681
|
+
* @constant {string} ETH_SEPOLIA_CHAIN_ID - The chain ID for the Ethereum Sepolia testnet (EIP-155 compatible format).
|
|
26682
|
+
*/
|
|
26683
|
+
const ETH_SEPOLIA_CHAIN_ID = '11155111';
|
|
26684
|
+
/**
|
|
26685
|
+
* @constant {string} ETH_MAINNET_CHAIN_ID - The chain ID for the Ethereum mainnet (EIP-155 compatible format).
|
|
26686
|
+
*/
|
|
26687
|
+
const ETH_MAINNET_CHAIN_ID = '1';
|
|
26688
|
+
/**
|
|
26689
|
+
* @constant {string} ZKEVM_DEVNET_CHAIN_ID - The chain ID for the zkEVM devnet (EIP-155 compatible format).
|
|
26690
|
+
*/
|
|
26691
|
+
const ZKEVM_DEVNET_CHAIN_ID = '15003';
|
|
26692
|
+
/**
|
|
26693
|
+
* @constant {string} ZKEVM_TESTNET_CHAIN_ID - The chain ID for the zkEVM testnet (EIP-155 compatible format).
|
|
26694
|
+
*/
|
|
26695
|
+
const ZKEVM_TESTNET_CHAIN_ID = '13473';
|
|
26696
|
+
/**
|
|
26697
|
+
* @constant {string} ZKEVM_MAINNET_CHAIN_ID - The chain ID for the zkEVM mainnet (EIP-155 compatible format).
|
|
26698
|
+
*/
|
|
26699
|
+
const ZKEVM_MAINNET_CHAIN_ID = '13371'; // @TODO confirm this is still correct
|
|
26700
|
+
/**
|
|
26701
|
+
* @constant {BridgeInstance} ETH_SEPOLIA_TO_ZKEVM_DEVNET - A bridge instance configuration for bridging between
|
|
26702
|
+
* the Ethereum Sepolia testnet and the zkEVM devnet.
|
|
26703
|
+
*/
|
|
26704
|
+
const ETH_SEPOLIA_TO_ZKEVM_DEVNET = {
|
|
26705
|
+
rootChainID: ETH_SEPOLIA_CHAIN_ID,
|
|
26706
|
+
childChainID: ZKEVM_DEVNET_CHAIN_ID,
|
|
26707
|
+
};
|
|
26708
|
+
/**
|
|
26709
|
+
* @constant {BridgeInstance} ETH_SEPOLIA_TO_ZKEVM_TESTNET - A bridge instance configuration for bridging
|
|
26710
|
+
* between the Ethereum Sepolia testnet and the zkEVM testnet.
|
|
26711
|
+
*/
|
|
26712
|
+
const ETH_SEPOLIA_TO_ZKEVM_TESTNET = {
|
|
26713
|
+
rootChainID: ETH_SEPOLIA_CHAIN_ID,
|
|
26714
|
+
childChainID: ZKEVM_TESTNET_CHAIN_ID,
|
|
26715
|
+
};
|
|
26716
|
+
/**
|
|
26717
|
+
* @constant {BridgeInstance} ETH_MAINNET_TO_ZKEVM_MAINNET - A bridge instance configuration for bridging
|
|
26718
|
+
* between the Ethereum mainnet and the zkEVM mainnet.
|
|
26719
|
+
*/
|
|
26720
|
+
const ETH_MAINNET_TO_ZKEVM_MAINNET = {
|
|
26721
|
+
rootChainID: ETH_MAINNET_CHAIN_ID,
|
|
26722
|
+
childChainID: ZKEVM_MAINNET_CHAIN_ID,
|
|
26723
|
+
};
|
|
26724
|
+
/**
|
|
26725
|
+
* @typedef {Object} axelarAPIEndpoints - API endpoints for the testnet & mainnet Axelar environment configurations
|
|
26726
|
+
*/
|
|
26727
|
+
const axelarAPIEndpoints = {
|
|
26728
|
+
testnet: 'https://testnet.api.gmp.axelarscan.io',
|
|
26729
|
+
mainnet: 'https://api.gmp.axelarscan.io',
|
|
26730
|
+
devnet: '',
|
|
26731
|
+
};
|
|
26732
|
+
/**
|
|
26733
|
+
* @typedef {Object} axelarChains
|
|
26734
|
+
* @property {AxelarChainDetails} [chainId] - Mapping of the ChainId to the Axelar chain id string and symbol.
|
|
26735
|
+
*/
|
|
26736
|
+
const axelarChains = {
|
|
26737
|
+
11155111: {
|
|
26738
|
+
id: 'ethereum-sepolia',
|
|
26739
|
+
symbol: 'ETH',
|
|
26740
|
+
},
|
|
26741
|
+
1: {
|
|
26742
|
+
id: 'ethereum',
|
|
26743
|
+
symbol: 'ETH',
|
|
26744
|
+
},
|
|
26745
|
+
15003: {
|
|
26746
|
+
id: 'immutable',
|
|
26747
|
+
symbol: 'IMX',
|
|
26748
|
+
},
|
|
26749
|
+
13473: {
|
|
26750
|
+
id: 'immutable',
|
|
26751
|
+
symbol: 'IMX',
|
|
26752
|
+
},
|
|
26753
|
+
13371: {
|
|
26754
|
+
id: 'immutable',
|
|
26755
|
+
symbol: 'IMX',
|
|
26756
|
+
}, // immutable zkevm mainnet
|
|
26757
|
+
};
|
|
26758
|
+
/**
|
|
26759
|
+
* @typedef {Object} bridgeMethods
|
|
26760
|
+
* @property {string} deposit - The set of contract methods for depositing.
|
|
26761
|
+
* @property {string} withdraw - The set of contract methods for withdrawing.
|
|
26762
|
+
*/
|
|
26763
|
+
const bridgeMethods = {
|
|
26764
|
+
deposit: {
|
|
26765
|
+
token: 'deposit',
|
|
26766
|
+
tokenTo: 'depositTo',
|
|
26767
|
+
native: 'depositETH',
|
|
26768
|
+
nativeTo: 'depositToETH',
|
|
26769
|
+
},
|
|
26770
|
+
withdraw: {
|
|
26771
|
+
token: 'withdraw',
|
|
26772
|
+
tokenTo: 'withdrawTo',
|
|
26773
|
+
native: 'withdrawIMX',
|
|
26774
|
+
nativeTo: 'withdrawIMXTo',
|
|
26775
|
+
},
|
|
26776
|
+
};
|
|
26777
|
+
|
|
26778
26778
|
const ROOT_ERC20_BRIDGE_FLOW_RATE = [
|
|
26779
26779
|
{
|
|
26780
26780
|
inputs: [
|
|
@@ -29035,6 +29035,7 @@ var BridgeErrorType;
|
|
|
29035
29035
|
BridgeErrorType["AXELAR_CHAIN_NOT_FOUND"] = "AXELAR_CHAIN_NOT_FOUND";
|
|
29036
29036
|
BridgeErrorType["AXELAR_GAS_ESTIMATE_FAILED"] = "AXELAR_GAS_ESTIMATE_FAILED";
|
|
29037
29037
|
BridgeErrorType["INVALID_RECIPIENT"] = "INVALID_RECIPIENT";
|
|
29038
|
+
BridgeErrorType["FLOW_RATE_ERROR"] = "FLOW_RATE_ERROR";
|
|
29038
29039
|
})(BridgeErrorType || (BridgeErrorType = {}));
|
|
29039
29040
|
/**
|
|
29040
29041
|
* Represents a custom error for bridge operations.
|
|
@@ -30347,16 +30348,17 @@ var BridgeFeeActions;
|
|
|
30347
30348
|
*/
|
|
30348
30349
|
var BridgeMethodsGasLimit;
|
|
30349
30350
|
(function (BridgeMethodsGasLimit) {
|
|
30350
|
-
BridgeMethodsGasLimit[BridgeMethodsGasLimit["DEPOSIT_SOURCE"] =
|
|
30351
|
-
BridgeMethodsGasLimit[BridgeMethodsGasLimit["DEPOSIT_DESTINATION"] =
|
|
30352
|
-
BridgeMethodsGasLimit[BridgeMethodsGasLimit["WITHDRAW_SOURCE"] =
|
|
30353
|
-
BridgeMethodsGasLimit[BridgeMethodsGasLimit["WITHDRAW_DESTINATION"] =
|
|
30354
|
-
BridgeMethodsGasLimit[BridgeMethodsGasLimit["MAP_TOKEN_SOURCE"] =
|
|
30355
|
-
BridgeMethodsGasLimit[BridgeMethodsGasLimit["MAP_TOKEN_DESTINATION"] =
|
|
30351
|
+
BridgeMethodsGasLimit[BridgeMethodsGasLimit["DEPOSIT_SOURCE"] = 200000] = "DEPOSIT_SOURCE";
|
|
30352
|
+
BridgeMethodsGasLimit[BridgeMethodsGasLimit["DEPOSIT_DESTINATION"] = 200000] = "DEPOSIT_DESTINATION";
|
|
30353
|
+
BridgeMethodsGasLimit[BridgeMethodsGasLimit["WITHDRAW_SOURCE"] = 200000] = "WITHDRAW_SOURCE";
|
|
30354
|
+
BridgeMethodsGasLimit[BridgeMethodsGasLimit["WITHDRAW_DESTINATION"] = 250000] = "WITHDRAW_DESTINATION";
|
|
30355
|
+
BridgeMethodsGasLimit[BridgeMethodsGasLimit["MAP_TOKEN_SOURCE"] = 200000] = "MAP_TOKEN_SOURCE";
|
|
30356
|
+
BridgeMethodsGasLimit[BridgeMethodsGasLimit["MAP_TOKEN_DESTINATION"] = 200000] = "MAP_TOKEN_DESTINATION";
|
|
30356
30357
|
BridgeMethodsGasLimit[BridgeMethodsGasLimit["FINALISE_WITHDRAWAL"] = 200000] = "FINALISE_WITHDRAWAL";
|
|
30357
30358
|
})(BridgeMethodsGasLimit || (BridgeMethodsGasLimit = {}));
|
|
30358
30359
|
var StatusResponse;
|
|
30359
30360
|
(function (StatusResponse) {
|
|
30361
|
+
StatusResponse["PENDING"] = "PENDING";
|
|
30360
30362
|
StatusResponse["PROCESSING"] = "PROCESSING";
|
|
30361
30363
|
StatusResponse["COMPLETE"] = "COMPLETE";
|
|
30362
30364
|
StatusResponse["RETRY"] = "RETRY";
|
|
@@ -30365,6 +30367,109 @@ var StatusResponse;
|
|
|
30365
30367
|
StatusResponse["FLOW_RATE_CONTROLLED"] = "FLOW_RATE_CONTROLLED";
|
|
30366
30368
|
})(StatusResponse || (StatusResponse = {}));
|
|
30367
30369
|
|
|
30370
|
+
var GMPStatus;
|
|
30371
|
+
(function (GMPStatus) {
|
|
30372
|
+
GMPStatus["SRC_GATEWAY_CALLED"] = "source_gateway_called";
|
|
30373
|
+
GMPStatus["DEST_GATEWAY_APPROVED"] = "destination_gateway_approved";
|
|
30374
|
+
GMPStatus["DEST_EXECUTED"] = "destination_executed";
|
|
30375
|
+
GMPStatus["EXPRESS_EXECUTED"] = "express_executed";
|
|
30376
|
+
GMPStatus["DEST_EXECUTE_ERROR"] = "error";
|
|
30377
|
+
GMPStatus["DEST_EXECUTING"] = "executing";
|
|
30378
|
+
GMPStatus["APPROVING"] = "approving";
|
|
30379
|
+
GMPStatus["FORECALLED"] = "forecalled";
|
|
30380
|
+
GMPStatus["FORECALLED_WITHOUT_GAS_PAID"] = "forecalled_without_gas_paid";
|
|
30381
|
+
GMPStatus["NOT_EXECUTED"] = "not_executed";
|
|
30382
|
+
GMPStatus["NOT_EXECUTED_WITHOUT_GAS_PAID"] = "not_executed_without_gas_paid";
|
|
30383
|
+
GMPStatus["INSUFFICIENT_FEE"] = "insufficient_fee";
|
|
30384
|
+
GMPStatus["UNKNOWN_ERROR"] = "unknown_error";
|
|
30385
|
+
GMPStatus["CANNOT_FETCH_STATUS"] = "cannot_fetch_status";
|
|
30386
|
+
GMPStatus["SRC_GATEWAY_CONFIRMED"] = "confirmed";
|
|
30387
|
+
})(GMPStatus || (GMPStatus = {}));
|
|
30388
|
+
var GasPaidStatus;
|
|
30389
|
+
(function (GasPaidStatus) {
|
|
30390
|
+
GasPaidStatus["GAS_UNPAID"] = "gas_unpaid";
|
|
30391
|
+
GasPaidStatus["GAS_PAID"] = "gas_paid";
|
|
30392
|
+
GasPaidStatus["GAS_PAID_NOT_ENOUGH_GAS"] = "gas_paid_not_enough_gas";
|
|
30393
|
+
GasPaidStatus["GAS_PAID_ENOUGH_GAS"] = "gas_paid_enough_gas";
|
|
30394
|
+
})(GasPaidStatus || (GasPaidStatus = {}));
|
|
30395
|
+
|
|
30396
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
30397
|
+
const parseGMPStatus = (response) => {
|
|
30398
|
+
const { error, status } = response;
|
|
30399
|
+
if (status === 'error' && error)
|
|
30400
|
+
return GMPStatus.DEST_EXECUTE_ERROR;
|
|
30401
|
+
if (status === 'executed')
|
|
30402
|
+
return GMPStatus.DEST_EXECUTED;
|
|
30403
|
+
if (status === 'approved')
|
|
30404
|
+
return GMPStatus.DEST_GATEWAY_APPROVED;
|
|
30405
|
+
if (status === 'called')
|
|
30406
|
+
return GMPStatus.SRC_GATEWAY_CALLED;
|
|
30407
|
+
if (status === 'executing')
|
|
30408
|
+
return GMPStatus.DEST_EXECUTING;
|
|
30409
|
+
return status;
|
|
30410
|
+
};
|
|
30411
|
+
const parseGMPError = (response) => {
|
|
30412
|
+
if (response.error) {
|
|
30413
|
+
return {
|
|
30414
|
+
message: response.error.error.message,
|
|
30415
|
+
txHash: response.error.error.transactionHash,
|
|
30416
|
+
chain: response.error.chain,
|
|
30417
|
+
};
|
|
30418
|
+
}
|
|
30419
|
+
if (response.is_insufficient_fee) {
|
|
30420
|
+
return {
|
|
30421
|
+
message: 'Insufficient fee',
|
|
30422
|
+
txHash: response.call.transaction.hash,
|
|
30423
|
+
chain: response.call.chain,
|
|
30424
|
+
};
|
|
30425
|
+
}
|
|
30426
|
+
return undefined;
|
|
30427
|
+
};
|
|
30428
|
+
const execGet = async (base, params) => fetch(`${base}?${new URLSearchParams(params).toString()}`, {
|
|
30429
|
+
method: 'GET',
|
|
30430
|
+
headers: { 'Content-Type': 'application/json' },
|
|
30431
|
+
cache: 'no-store',
|
|
30432
|
+
})
|
|
30433
|
+
.then((res) => res.json())
|
|
30434
|
+
.then((res) => res.data);
|
|
30435
|
+
const fetchGMPTransaction = async (axelarGMPApiUrl, txHash, txLogIndex) => execGet(axelarGMPApiUrl, {
|
|
30436
|
+
method: 'searchGMP',
|
|
30437
|
+
txHash,
|
|
30438
|
+
txLogIndex,
|
|
30439
|
+
})
|
|
30440
|
+
.then((data) => data.find((gmpTx) => gmpTx.id.indexOf(txHash) > -1 || gmpTx.call.transactionHash.indexOf(txHash) > -1))
|
|
30441
|
+
.catch(() => undefined);
|
|
30442
|
+
const queryTransactionStatus = async (axelarGMPApiUrl, txHash, txLogIndex) => {
|
|
30443
|
+
const txDetails = await fetchGMPTransaction(axelarGMPApiUrl, txHash, txLogIndex);
|
|
30444
|
+
if (!txDetails)
|
|
30445
|
+
return { status: GMPStatus.CANNOT_FETCH_STATUS };
|
|
30446
|
+
const { call, gas_status, gas_paid, executed, express_executed, approved, callback, } = txDetails;
|
|
30447
|
+
const gasPaidInfo = {
|
|
30448
|
+
status: gas_status,
|
|
30449
|
+
details: gas_paid,
|
|
30450
|
+
};
|
|
30451
|
+
// Note: Currently, the GMP API doesn't always return the `total` field in the `time_spent` object
|
|
30452
|
+
// This is a temporary fix to ensure that the `total` field is always present
|
|
30453
|
+
// TODO: Remove this once the API is fixed
|
|
30454
|
+
const timeSpent = txDetails.time_spent;
|
|
30455
|
+
if (timeSpent) {
|
|
30456
|
+
timeSpent.total = timeSpent.total
|
|
30457
|
+
|| Object.values(timeSpent).reduce((accumulator, value) => accumulator + value, 0);
|
|
30458
|
+
}
|
|
30459
|
+
return {
|
|
30460
|
+
status: parseGMPStatus(txDetails),
|
|
30461
|
+
error: parseGMPError(txDetails),
|
|
30462
|
+
timeSpent,
|
|
30463
|
+
gasPaidInfo,
|
|
30464
|
+
callTx: call,
|
|
30465
|
+
executed,
|
|
30466
|
+
expressExecuted: express_executed,
|
|
30467
|
+
approved,
|
|
30468
|
+
callback,
|
|
30469
|
+
};
|
|
30470
|
+
};
|
|
30471
|
+
|
|
30472
|
+
/* eslint-disable no-console */
|
|
30368
30473
|
/* eslint-disable class-methods-use-this */
|
|
30369
30474
|
/**
|
|
30370
30475
|
* Represents a token bridge, which manages asset transfers between two chains.
|
|
@@ -30556,6 +30661,7 @@ class TokenBridge {
|
|
|
30556
30661
|
to: req.token,
|
|
30557
30662
|
value: 0,
|
|
30558
30663
|
from: req.senderAddress,
|
|
30664
|
+
chainId: parseInt(req.sourceChainId, 10),
|
|
30559
30665
|
};
|
|
30560
30666
|
return {
|
|
30561
30667
|
contractToApprove: sourceBridgeAddress,
|
|
@@ -30701,6 +30807,7 @@ class TokenBridge {
|
|
|
30701
30807
|
data,
|
|
30702
30808
|
to: contractAddress,
|
|
30703
30809
|
value: amount.add(fees.bridgeFee).toString(),
|
|
30810
|
+
chainId: parseInt(sourceChainId, 10),
|
|
30704
30811
|
},
|
|
30705
30812
|
};
|
|
30706
30813
|
}
|
|
@@ -30720,6 +30827,7 @@ class TokenBridge {
|
|
|
30720
30827
|
data,
|
|
30721
30828
|
to: contractAddress,
|
|
30722
30829
|
value: fees.bridgeFee.toString(),
|
|
30830
|
+
chainId: parseInt(sourceChainId, 10),
|
|
30723
30831
|
},
|
|
30724
30832
|
};
|
|
30725
30833
|
}
|
|
@@ -30768,6 +30876,21 @@ class TokenBridge {
|
|
|
30768
30876
|
throw new BridgeError(`Childchain provider chainID ${childNetwork.chainId} does not match expected chainID ${this.config.bridgeInstance.childChainID}. ${errMessage}`, BridgeErrorType.UNSUPPORTED_ERROR);
|
|
30769
30877
|
}
|
|
30770
30878
|
}
|
|
30879
|
+
getAxelarEndpoint(source) {
|
|
30880
|
+
let axelarAPIEndpoint;
|
|
30881
|
+
if (source === ETH_MAINNET_TO_ZKEVM_MAINNET.rootChainID
|
|
30882
|
+
|| source === ETH_MAINNET_TO_ZKEVM_MAINNET.childChainID) {
|
|
30883
|
+
axelarAPIEndpoint = axelarAPIEndpoints.mainnet;
|
|
30884
|
+
}
|
|
30885
|
+
else if (source === ETH_SEPOLIA_TO_ZKEVM_TESTNET.rootChainID
|
|
30886
|
+
|| source === ETH_SEPOLIA_TO_ZKEVM_TESTNET.childChainID) {
|
|
30887
|
+
axelarAPIEndpoint = axelarAPIEndpoints.testnet;
|
|
30888
|
+
}
|
|
30889
|
+
else {
|
|
30890
|
+
axelarAPIEndpoint = axelarAPIEndpoints.devnet;
|
|
30891
|
+
}
|
|
30892
|
+
return axelarAPIEndpoint;
|
|
30893
|
+
}
|
|
30771
30894
|
/**
|
|
30772
30895
|
* Calculate the gas amount for a transaction using axelarjs-sdk.
|
|
30773
30896
|
* @param {*} source - The source chainId.
|
|
@@ -30786,18 +30909,7 @@ class TokenBridge {
|
|
|
30786
30909
|
if (!destinationAxelar) {
|
|
30787
30910
|
throw new BridgeError(`Destination chainID ${destination} can not be matched to an Axelar chain.`, BridgeErrorType.AXELAR_CHAIN_NOT_FOUND);
|
|
30788
30911
|
}
|
|
30789
|
-
|
|
30790
|
-
if (source === ETH_MAINNET_TO_ZKEVM_MAINNET.rootChainID
|
|
30791
|
-
|| source === ETH_MAINNET_TO_ZKEVM_MAINNET.childChainID) {
|
|
30792
|
-
axelarApiEndpoint = axelarAPIEndpoints.mainnet;
|
|
30793
|
-
}
|
|
30794
|
-
else if (source === ETH_SEPOLIA_TO_ZKEVM_TESTNET.rootChainID
|
|
30795
|
-
|| source === ETH_SEPOLIA_TO_ZKEVM_TESTNET.childChainID) {
|
|
30796
|
-
axelarApiEndpoint = axelarAPIEndpoints.testnet;
|
|
30797
|
-
}
|
|
30798
|
-
else {
|
|
30799
|
-
axelarApiEndpoint = axelarAPIEndpoints.devnet;
|
|
30800
|
-
}
|
|
30912
|
+
const axelarAPIEndpoint = this.getAxelarEndpoint(source);
|
|
30801
30913
|
let axiosResponse;
|
|
30802
30914
|
const estimateGasReq = {
|
|
30803
30915
|
method: 'estimateGasFee',
|
|
@@ -30808,7 +30920,7 @@ class TokenBridge {
|
|
|
30808
30920
|
gasMultiplier,
|
|
30809
30921
|
};
|
|
30810
30922
|
try {
|
|
30811
|
-
axiosResponse = await axios$1.post(
|
|
30923
|
+
axiosResponse = await axios$1.post(axelarAPIEndpoint, estimateGasReq);
|
|
30812
30924
|
}
|
|
30813
30925
|
catch (error) {
|
|
30814
30926
|
axiosResponse = error.response;
|
|
@@ -30825,30 +30937,136 @@ class TokenBridge {
|
|
|
30825
30937
|
throw new BridgeError(`Estimating Axelar Gas failed with the reason: ${err}`, BridgeErrorType.AXELAR_GAS_ESTIMATE_FAILED);
|
|
30826
30938
|
}
|
|
30827
30939
|
}
|
|
30828
|
-
// STUBBED ENDPOINTS FOR PHASE 2 -------------------------------------------
|
|
30829
30940
|
/**
|
|
30830
30941
|
* Queries the status of a bridge transaction.
|
|
30831
30942
|
*
|
|
30832
|
-
* @param {
|
|
30833
|
-
* @returns {Promise<
|
|
30943
|
+
* @param {TxStatusRequest} req - The request object containing an array of transactions to query.
|
|
30944
|
+
* @returns {Promise<TxStatusResponse>} - A promise that resolves to an array of transaction statuses.
|
|
30834
30945
|
* @throws {BridgeError} - If an error occurs during the query, a BridgeError will be thrown with a specific error type.
|
|
30835
|
-
* @dev this SDK method is currently stubbed
|
|
30836
30946
|
*/
|
|
30837
30947
|
async getTransactionStatus(req) {
|
|
30838
|
-
|
|
30839
|
-
|
|
30840
|
-
|
|
30841
|
-
return {
|
|
30842
|
-
transactions: [{
|
|
30843
|
-
transactionHash: '0x1234....',
|
|
30844
|
-
status: StatusResponse.COMPLETE,
|
|
30845
|
-
data: 'stubbed data',
|
|
30846
|
-
}, {
|
|
30847
|
-
transactionHash: '0xABCD....',
|
|
30848
|
-
status: StatusResponse.PROCESSING,
|
|
30849
|
-
data: 'stubbed data',
|
|
30850
|
-
}],
|
|
30948
|
+
const axelarAPIEndpoint = this.getAxelarEndpoint(req.sourceChainId);
|
|
30949
|
+
const txStatusResponse = {
|
|
30950
|
+
transactions: [],
|
|
30851
30951
|
};
|
|
30952
|
+
const abiCoder = new AbiCoder();
|
|
30953
|
+
const statusPromises = [];
|
|
30954
|
+
for (const transaction of req.transactions) {
|
|
30955
|
+
statusPromises.push(queryTransactionStatus(axelarAPIEndpoint, transaction.txHash));
|
|
30956
|
+
}
|
|
30957
|
+
let statusResponses;
|
|
30958
|
+
try {
|
|
30959
|
+
statusResponses = await Promise.all(statusPromises);
|
|
30960
|
+
}
|
|
30961
|
+
catch (err) {
|
|
30962
|
+
throw new BridgeError(`Failed to fetch the Axelar Status with the reason: ${err}`, BridgeErrorType.AXELAR_GAS_ESTIMATE_FAILED);
|
|
30963
|
+
}
|
|
30964
|
+
const unpaidGasStatus = [GasPaidStatus.GAS_UNPAID, GasPaidStatus.GAS_PAID_NOT_ENOUGH_GAS];
|
|
30965
|
+
const isWithdraw = [
|
|
30966
|
+
ZKEVM_DEVNET_CHAIN_ID,
|
|
30967
|
+
ZKEVM_TESTNET_CHAIN_ID,
|
|
30968
|
+
ZKEVM_MAINNET_CHAIN_ID
|
|
30969
|
+
].includes(req.sourceChainId);
|
|
30970
|
+
let rootBridge;
|
|
30971
|
+
if (isWithdraw) {
|
|
30972
|
+
rootBridge = await withBridgeError(async () => {
|
|
30973
|
+
const contract = new Contract(this.config.bridgeContracts.rootERC20BridgeFlowRate, ROOT_ERC20_BRIDGE_FLOW_RATE, this.config.rootProvider);
|
|
30974
|
+
return contract;
|
|
30975
|
+
}, BridgeErrorType.INTERNAL_ERROR);
|
|
30976
|
+
}
|
|
30977
|
+
const flowRatePromises = [];
|
|
30978
|
+
const flowRatePromisesReceivers = [];
|
|
30979
|
+
for (let i = 0, l = statusResponses.length; i < l; i++) {
|
|
30980
|
+
let metaStatus;
|
|
30981
|
+
// consolidate axelar statuses to our own simplified metaStatus
|
|
30982
|
+
switch (statusResponses[i].status) {
|
|
30983
|
+
case GMPStatus.CANNOT_FETCH_STATUS:
|
|
30984
|
+
metaStatus = StatusResponse.PENDING;
|
|
30985
|
+
break;
|
|
30986
|
+
case GMPStatus.SRC_GATEWAY_CALLED:
|
|
30987
|
+
case GMPStatus.DEST_GATEWAY_APPROVED:
|
|
30988
|
+
case GMPStatus.DEST_EXECUTING:
|
|
30989
|
+
case GMPStatus.SRC_GATEWAY_CONFIRMED:
|
|
30990
|
+
case GMPStatus.APPROVING:
|
|
30991
|
+
metaStatus = StatusResponse.PROCESSING;
|
|
30992
|
+
break;
|
|
30993
|
+
case GMPStatus.NOT_EXECUTED:
|
|
30994
|
+
metaStatus = StatusResponse.RETRY;
|
|
30995
|
+
break;
|
|
30996
|
+
case GMPStatus.NOT_EXECUTED_WITHOUT_GAS_PAID:
|
|
30997
|
+
case GMPStatus.INSUFFICIENT_FEE:
|
|
30998
|
+
metaStatus = StatusResponse.NOT_ENOUGH_GAS;
|
|
30999
|
+
break;
|
|
31000
|
+
case GMPStatus.DEST_EXECUTED:
|
|
31001
|
+
metaStatus = StatusResponse.COMPLETE;
|
|
31002
|
+
break;
|
|
31003
|
+
default:
|
|
31004
|
+
metaStatus = StatusResponse.ERROR;
|
|
31005
|
+
}
|
|
31006
|
+
if (statusResponses[i].gasPaidInfo) {
|
|
31007
|
+
if (unpaidGasStatus.includes(statusResponses[i].gasPaidInfo.status)) {
|
|
31008
|
+
metaStatus = StatusResponse.NOT_ENOUGH_GAS;
|
|
31009
|
+
}
|
|
31010
|
+
}
|
|
31011
|
+
let txItem = {
|
|
31012
|
+
txHash: req.transactions[i].txHash,
|
|
31013
|
+
status: metaStatus,
|
|
31014
|
+
data: {
|
|
31015
|
+
gmpResponse: statusResponses[i].status,
|
|
31016
|
+
},
|
|
31017
|
+
};
|
|
31018
|
+
let decodedData;
|
|
31019
|
+
if (statusResponses[i]?.callTx?.returnValues?.payload) {
|
|
31020
|
+
decodedData = abiCoder.decode(['bytes32', 'address', 'address', 'address', 'uint256'], statusResponses[i].callTx.returnValues.payload);
|
|
31021
|
+
txItem = {
|
|
31022
|
+
...txItem,
|
|
31023
|
+
token: decodedData[1],
|
|
31024
|
+
sender: decodedData[2],
|
|
31025
|
+
receiver: decodedData[3],
|
|
31026
|
+
amount: decodedData[4],
|
|
31027
|
+
};
|
|
31028
|
+
}
|
|
31029
|
+
let flowRatePromiseIndex;
|
|
31030
|
+
if (metaStatus === StatusResponse.COMPLETE
|
|
31031
|
+
&& isWithdraw && txItem.receiver) {
|
|
31032
|
+
// consolidate the calls we have to make to the flow rate by receiver
|
|
31033
|
+
if (!flowRatePromisesReceivers.includes(txItem.receiver)) {
|
|
31034
|
+
flowRatePromises.push(rootBridge.getPendingWithdrawals(txItem.receiver, [0]));
|
|
31035
|
+
flowRatePromisesReceivers.push(txItem.receiver);
|
|
31036
|
+
flowRatePromiseIndex = flowRatePromisesReceivers.length - 1;
|
|
31037
|
+
}
|
|
31038
|
+
else {
|
|
31039
|
+
flowRatePromiseIndex = flowRatePromisesReceivers.findIndex((el) => el === txItem.receiver);
|
|
31040
|
+
}
|
|
31041
|
+
txItem.data.flowRatePromiseIndex = flowRatePromiseIndex;
|
|
31042
|
+
}
|
|
31043
|
+
txStatusResponse.transactions.push(txItem);
|
|
31044
|
+
} // for
|
|
31045
|
+
let flowRateResponses = [];
|
|
31046
|
+
if (flowRatePromises.length > 0) {
|
|
31047
|
+
try {
|
|
31048
|
+
flowRateResponses = await Promise.all(flowRatePromises);
|
|
31049
|
+
}
|
|
31050
|
+
catch (err) {
|
|
31051
|
+
throw new BridgeError(`Failed to fetch the Flow Rate statuses with the reason: ${err}`, BridgeErrorType.FLOW_RATE_ERROR);
|
|
31052
|
+
}
|
|
31053
|
+
}
|
|
31054
|
+
for (const txStatusRes of txStatusResponse.transactions) {
|
|
31055
|
+
if (txStatusRes.data.flowRatePromiseIndex !== -1 && flowRateResponses[txStatusRes.data.flowRatePromiseIndex]) {
|
|
31056
|
+
const flowRatedTx = flowRateResponses[txStatusRes.data.flowRatePromiseIndex].find((el) => (el.amount.toString() === txStatusRes.amount.toString()
|
|
31057
|
+
&& el.token === txStatusRes.token
|
|
31058
|
+
&& el.withdrawer === txStatusRes.sender));
|
|
31059
|
+
if (flowRatedTx) {
|
|
31060
|
+
txStatusRes.status = StatusResponse.FLOW_RATE_CONTROLLED;
|
|
31061
|
+
txStatusRes.data = {
|
|
31062
|
+
timestamp: flowRatedTx.timestamp.toString(),
|
|
31063
|
+
};
|
|
31064
|
+
}
|
|
31065
|
+
}
|
|
31066
|
+
delete txStatusRes.data.flowRatePromiseIndex;
|
|
31067
|
+
}
|
|
31068
|
+
// Return the tx status response
|
|
31069
|
+
return txStatusResponse;
|
|
30852
31070
|
}
|
|
30853
31071
|
/**
|
|
30854
31072
|
* Queries for the information about which tokens are flowrated and how long the delay is.
|
|
@@ -30987,7 +31205,7 @@ const CONTRACTS_FOR_BRIDGE = new Map()
|
|
|
30987
31205
|
.set(ETH_SEPOLIA_TO_ZKEVM_TESTNET, {
|
|
30988
31206
|
rootERC20BridgeFlowRate: '0x0D3C59c779Fd552C27b23F723E80246c840100F5',
|
|
30989
31207
|
childERC20Bridge: '0x0D3C59c779Fd552C27b23F723E80246c840100F5',
|
|
30990
|
-
wrappedIMX: '
|
|
31208
|
+
wrappedIMX: '0x1CcCa691501174B4A623CeDA58cC8f1a76dc3439',
|
|
30991
31209
|
})
|
|
30992
31210
|
.set(ETH_MAINNET_TO_ZKEVM_MAINNET, {
|
|
30993
31211
|
rootERC20BridgeFlowRate: '0x0',
|
|
@@ -34698,12 +34916,12 @@ var ChainId;
|
|
|
34698
34916
|
})(ChainId || (ChainId = {}));
|
|
34699
34917
|
/**
|
|
34700
34918
|
* Enum representing different chain names.
|
|
34701
|
-
* @enum {
|
|
34702
|
-
* @property {
|
|
34703
|
-
* @property {
|
|
34704
|
-
* @property {
|
|
34705
|
-
* @property {
|
|
34706
|
-
* @property {
|
|
34919
|
+
* @enum {string}
|
|
34920
|
+
* @property {string} IMTBL_ZKEVM_MAINNET - The chain name for IMTBL ZKEVM Mainnet.
|
|
34921
|
+
* @property {string} IMTBL_ZKEVM_TESTNET - The chain name for IMTBL ZKEVM Testnet.
|
|
34922
|
+
* @property {string} IMTBL_ZKEVM_DEVNET - The chain name for IMTBL ZKEVM Devnet.
|
|
34923
|
+
* @property {string} ETHEREUM - The chain name for Ethereum.
|
|
34924
|
+
* @property {string} SEPOLIA - The chain name for Sepolia.
|
|
34707
34925
|
*/
|
|
34708
34926
|
var ChainName;
|
|
34709
34927
|
(function (ChainName) {
|
|
@@ -34713,6 +34931,23 @@ var ChainName;
|
|
|
34713
34931
|
ChainName["IMTBL_ZKEVM_DEVNET"] = "Immutable zkEVM Dev";
|
|
34714
34932
|
ChainName["IMTBL_ZKEVM_MAINNET"] = "Immutable zkEVM";
|
|
34715
34933
|
})(ChainName || (ChainName = {}));
|
|
34934
|
+
/**
|
|
34935
|
+
* Enum representing different chain slugs.
|
|
34936
|
+
* @enum {string}
|
|
34937
|
+
* @property {string} IMTBL_ZKEVM_MAINNET - The chain slug for IMTBL ZKEVM Mainnet.
|
|
34938
|
+
* @property {string} IMTBL_ZKEVM_TESTNET - The chain slug for IMTBL ZKEVM Testnet.
|
|
34939
|
+
* @property {string} IMTBL_ZKEVM_DEVNET - The chain slug for IMTBL ZKEVM Devnet.
|
|
34940
|
+
* @property {string} ETHEREUM - The chain slug for Ethereum.
|
|
34941
|
+
* @property {string} SEPOLIA - The chain slug for Sepolia.
|
|
34942
|
+
*/
|
|
34943
|
+
var ChainSlug;
|
|
34944
|
+
(function (ChainSlug) {
|
|
34945
|
+
ChainSlug["ETHEREUM"] = "ethereum";
|
|
34946
|
+
ChainSlug["SEPOLIA"] = "sepolia";
|
|
34947
|
+
ChainSlug["IMTBL_ZKEVM_MAINNET"] = "imtbl-zkevm-mainnet";
|
|
34948
|
+
ChainSlug["IMTBL_ZKEVM_TESTNET"] = "imtbl-zkevm-testnet";
|
|
34949
|
+
ChainSlug["IMTBL_ZKEVM_DEVNET"] = "imtbl-zkevm-devnet";
|
|
34950
|
+
})(ChainSlug || (ChainSlug = {}));
|
|
34716
34951
|
|
|
34717
34952
|
var OnRampProvider;
|
|
34718
34953
|
(function (OnRampProvider) {
|
|
@@ -34877,6 +35112,7 @@ var CheckoutErrorType;
|
|
|
34877
35112
|
CheckoutErrorType["CONNECT_PROVIDER_ERROR"] = "CONNECT_PROVIDER_ERROR";
|
|
34878
35113
|
CheckoutErrorType["GET_BALANCE_ERROR"] = "GET_BALANCE_ERROR";
|
|
34879
35114
|
CheckoutErrorType["GET_INDEXER_BALANCE_ERROR"] = "GET_INDEXER_BALANCE_ERROR";
|
|
35115
|
+
CheckoutErrorType["GET_ERC20_INFO_ERROR"] = "GET_ERC20_INFO_ERROR";
|
|
34880
35116
|
CheckoutErrorType["GET_ERC20_BALANCE_ERROR"] = "GET_ERC20_BALANCE_ERROR";
|
|
34881
35117
|
CheckoutErrorType["GET_ERC721_BALANCE_ERROR"] = "GET_ERC721_BALANCE_ERROR";
|
|
34882
35118
|
CheckoutErrorType["GET_NETWORK_INFO_ERROR"] = "GET_NETWORK_INFO_ERROR";
|
|
@@ -35444,7 +35680,7 @@ const GAS_OVERRIDES = {
|
|
|
35444
35680
|
maxPriorityFeePerGas: ethers.BigNumber.from(101e9),
|
|
35445
35681
|
};
|
|
35446
35682
|
|
|
35447
|
-
const SDK_VERSION_MARKER = '0.36.
|
|
35683
|
+
const SDK_VERSION_MARKER = '0.36.5';
|
|
35448
35684
|
// This SDK version is replaced by the `yarn build` command ran on the root level
|
|
35449
35685
|
const globalPackageVersion = () => SDK_VERSION_MARKER;
|
|
35450
35686
|
|
|
@@ -35605,6 +35841,22 @@ const getTokenAllowList = async (config, { type = TokenFilterTypes.ALL, chainId,
|
|
|
35605
35841
|
};
|
|
35606
35842
|
};
|
|
35607
35843
|
const isNativeToken = (address) => !address || address.toLocaleLowerCase() === NATIVE;
|
|
35844
|
+
async function getERC20TokenInfo(web3Provider, tokenAddress) {
|
|
35845
|
+
return await withCheckoutError(async () => {
|
|
35846
|
+
const contract = new ethers.Contract(tokenAddress, JSON.stringify(ERC20ABI), web3Provider);
|
|
35847
|
+
const [name, symbol, decimals] = await Promise.all([
|
|
35848
|
+
contract.name(),
|
|
35849
|
+
contract.symbol(),
|
|
35850
|
+
contract.decimals(),
|
|
35851
|
+
]);
|
|
35852
|
+
return {
|
|
35853
|
+
name,
|
|
35854
|
+
symbol,
|
|
35855
|
+
decimals,
|
|
35856
|
+
address: tokenAddress,
|
|
35857
|
+
};
|
|
35858
|
+
}, { type: CheckoutErrorType.GET_ERC20_INFO_ERROR });
|
|
35859
|
+
}
|
|
35608
35860
|
|
|
35609
35861
|
const CACHE_DATA_TTL = 60; // seconds
|
|
35610
35862
|
/**
|
|
@@ -35775,20 +36027,18 @@ async function getERC20Balance(web3Provider, walletAddress, tokenAddress) {
|
|
|
35775
36027
|
return await withCheckoutError(async () => {
|
|
35776
36028
|
const contract = new ethers.Contract(tokenAddress, JSON.stringify(ERC20ABI), web3Provider);
|
|
35777
36029
|
return Promise.all([
|
|
35778
|
-
|
|
35779
|
-
contract.symbol(),
|
|
36030
|
+
getERC20TokenInfo(web3Provider, tokenAddress),
|
|
35780
36031
|
contract.balanceOf(walletAddress),
|
|
35781
|
-
contract.decimals(),
|
|
35782
36032
|
])
|
|
35783
|
-
.then(([
|
|
35784
|
-
const formattedBalance = ethers.utils.formatUnits(balance, decimals);
|
|
36033
|
+
.then(([tokenInfo, balance]) => {
|
|
36034
|
+
const formattedBalance = ethers.utils.formatUnits(balance, tokenInfo.decimals);
|
|
35785
36035
|
return {
|
|
35786
36036
|
balance,
|
|
35787
36037
|
formattedBalance,
|
|
35788
36038
|
token: {
|
|
35789
|
-
name,
|
|
35790
|
-
symbol,
|
|
35791
|
-
decimals,
|
|
36039
|
+
name: tokenInfo.name,
|
|
36040
|
+
symbol: tokenInfo.symbol,
|
|
36041
|
+
decimals: tokenInfo.decimals,
|
|
35792
36042
|
address: tokenAddress,
|
|
35793
36043
|
},
|
|
35794
36044
|
};
|
|
@@ -35888,6 +36138,9 @@ const getBalances = async (config, web3Provider, walletAddress, tokens) => {
|
|
|
35888
36138
|
const allBalancePromises = [];
|
|
35889
36139
|
tokens
|
|
35890
36140
|
.forEach((token) => {
|
|
36141
|
+
// For some reason isNativeToken always returns undefined.
|
|
36142
|
+
// We have spent way too much time figuring out why this is happening.
|
|
36143
|
+
// That we have given up -- keep it as it is for now.
|
|
35891
36144
|
if (!token.address || token.address.toLocaleLowerCase() === NATIVE) {
|
|
35892
36145
|
allBalancePromises.push(getBalance(config, web3Provider, walletAddress));
|
|
35893
36146
|
}
|
|
@@ -35896,13 +36149,25 @@ const getBalances = async (config, web3Provider, walletAddress, tokens) => {
|
|
|
35896
36149
|
}
|
|
35897
36150
|
});
|
|
35898
36151
|
const balanceResults = await Promise.allSettled(allBalancePromises);
|
|
35899
|
-
const balances = balanceResults.filter((result) => result.status === 'fulfilled').map((result) =>
|
|
36152
|
+
const balances = balanceResults.filter((result) => result.status === 'fulfilled').map((result) => {
|
|
36153
|
+
const resp = result;
|
|
36154
|
+
const { token } = resp.value;
|
|
36155
|
+
// For some reason isNativeToken always returns undefined.
|
|
36156
|
+
// We have spent way too much time figuring out why this is happening.
|
|
36157
|
+
// That we have given up -- keep it as it is for now.
|
|
36158
|
+
if (!token.address || token.address.toLocaleLowerCase() === NATIVE)
|
|
36159
|
+
resp.value.token.address = NATIVE;
|
|
36160
|
+
return resp.value;
|
|
36161
|
+
});
|
|
35900
36162
|
return { balances };
|
|
35901
36163
|
};
|
|
35902
36164
|
const getAllBalances = async (config, web3Provider, walletAddress, chainId) => {
|
|
35903
36165
|
if (!walletAddress && !web3Provider) {
|
|
35904
36166
|
throw new CheckoutError('both walletAddress and provider are missing. At least one must be provided.', CheckoutErrorType.MISSING_PARAMS);
|
|
35905
36167
|
}
|
|
36168
|
+
if (!config.networkMap.get(chainId)) {
|
|
36169
|
+
throw new CheckoutError(`chain ID ${chainId} not supported by the environment`, CheckoutErrorType.CHAIN_NOT_SUPPORTED_ERROR);
|
|
36170
|
+
}
|
|
35906
36171
|
const { tokens } = await getTokenAllowList(config, {
|
|
35907
36172
|
type: TokenFilterTypes.ALL,
|
|
35908
36173
|
chainId,
|
|
@@ -37484,11 +37749,11 @@ const getBridgeFeeEstimate = async (config, readOnlyProviders, fromChainId, toCh
|
|
|
37484
37749
|
const INDEXER_ETH_ROOT_CONTRACT_ADDRESS = '0x0000000000000000000000000000000000000eee';
|
|
37485
37750
|
const getIndexerChainName = (chainId) => {
|
|
37486
37751
|
if (chainId === ChainId.IMTBL_ZKEVM_MAINNET)
|
|
37487
|
-
return
|
|
37752
|
+
return ChainSlug.IMTBL_ZKEVM_MAINNET;
|
|
37488
37753
|
if (chainId === ChainId.IMTBL_ZKEVM_TESTNET)
|
|
37489
|
-
return
|
|
37754
|
+
return ChainSlug.IMTBL_ZKEVM_TESTNET;
|
|
37490
37755
|
if (chainId === ChainId.IMTBL_ZKEVM_DEVNET)
|
|
37491
|
-
return
|
|
37756
|
+
return ChainSlug.IMTBL_ZKEVM_DEVNET;
|
|
37492
37757
|
return '';
|
|
37493
37758
|
};
|
|
37494
37759
|
// Indexer ERC20 call does not support IMX so cannot get root chain mapping from this endpoint.
|
|
@@ -38934,6 +39199,8 @@ class Checkout {
|
|
|
38934
39199
|
*/
|
|
38935
39200
|
async widgets(init) {
|
|
38936
39201
|
const checkout = this;
|
|
39202
|
+
// Preload the configurations
|
|
39203
|
+
await checkout.config.remote.getConfig();
|
|
38937
39204
|
const factory = new Promise((resolve, reject) => {
|
|
38938
39205
|
function checkForWidgetsBundleLoaded() {
|
|
38939
39206
|
if (typeof ImmutableCheckoutWidgets !== 'undefined') {
|
|
@@ -38949,8 +39216,6 @@ class Checkout {
|
|
|
38949
39216
|
try {
|
|
38950
39217
|
const script = loadUnresolved(init.version);
|
|
38951
39218
|
if (script.loaded && typeof ImmutableCheckoutWidgets !== 'undefined') {
|
|
38952
|
-
// eslint-disable-next-line no-console
|
|
38953
|
-
console.warn('Checkout widgets script is already loaded');
|
|
38954
39219
|
resolve(new ImmutableCheckoutWidgets.WidgetsFactory(checkout, init.config));
|
|
38955
39220
|
}
|
|
38956
39221
|
else {
|
|
@@ -39004,6 +39269,15 @@ class Checkout {
|
|
|
39004
39269
|
const switchNetworkRes = await switchWalletNetwork(this.config, web3Provider, params.chainId);
|
|
39005
39270
|
return switchNetworkRes;
|
|
39006
39271
|
}
|
|
39272
|
+
/**
|
|
39273
|
+
* Retrieves the token information given the token address. This function makes RPC calls to
|
|
39274
|
+
* ERC20 contracts to fetch the main contract information (e.g. symbol).
|
|
39275
|
+
* @param {GetTokenInfoParams} params - The parameters for retrieving the token information.
|
|
39276
|
+
* @returns {Promise<TokenInfo>} - A promise that resolves to the token info request.
|
|
39277
|
+
*/
|
|
39278
|
+
async getTokenInfo(params) {
|
|
39279
|
+
return await getERC20TokenInfo(params.provider, params.tokenAddress);
|
|
39280
|
+
}
|
|
39007
39281
|
/**
|
|
39008
39282
|
* Retrieves the balance of a wallet address.
|
|
39009
39283
|
* @param {GetBalanceParams} params - The parameters for retrieving the balance.
|
|
@@ -39188,6 +39462,7 @@ var checkout = /*#__PURE__*/Object.freeze({
|
|
|
39188
39462
|
get BridgeEventType () { return BridgeEventType; },
|
|
39189
39463
|
get ChainId () { return ChainId; },
|
|
39190
39464
|
get ChainName () { return ChainName; },
|
|
39465
|
+
get ChainSlug () { return ChainSlug; },
|
|
39191
39466
|
Checkout: Checkout,
|
|
39192
39467
|
CheckoutConfiguration: CheckoutConfiguration,
|
|
39193
39468
|
get CheckoutErrorType () { return CheckoutErrorType; },
|