@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/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
|
|
@@ -26393,12 +26611,12 @@ var ChainId;
|
|
|
26393
26611
|
})(ChainId || (ChainId = {}));
|
|
26394
26612
|
/**
|
|
26395
26613
|
* Enum representing different chain names.
|
|
26396
|
-
* @enum {
|
|
26397
|
-
* @property {
|
|
26398
|
-
* @property {
|
|
26399
|
-
* @property {
|
|
26400
|
-
* @property {
|
|
26401
|
-
* @property {
|
|
26614
|
+
* @enum {string}
|
|
26615
|
+
* @property {string} IMTBL_ZKEVM_MAINNET - The chain name for IMTBL ZKEVM Mainnet.
|
|
26616
|
+
* @property {string} IMTBL_ZKEVM_TESTNET - The chain name for IMTBL ZKEVM Testnet.
|
|
26617
|
+
* @property {string} IMTBL_ZKEVM_DEVNET - The chain name for IMTBL ZKEVM Devnet.
|
|
26618
|
+
* @property {string} ETHEREUM - The chain name for Ethereum.
|
|
26619
|
+
* @property {string} SEPOLIA - The chain name for Sepolia.
|
|
26402
26620
|
*/
|
|
26403
26621
|
var ChainName;
|
|
26404
26622
|
(function (ChainName) {
|
|
@@ -26408,6 +26626,23 @@ var ChainName;
|
|
|
26408
26626
|
ChainName["IMTBL_ZKEVM_DEVNET"] = "Immutable zkEVM Dev";
|
|
26409
26627
|
ChainName["IMTBL_ZKEVM_MAINNET"] = "Immutable zkEVM";
|
|
26410
26628
|
})(ChainName || (ChainName = {}));
|
|
26629
|
+
/**
|
|
26630
|
+
* Enum representing different chain slugs.
|
|
26631
|
+
* @enum {string}
|
|
26632
|
+
* @property {string} IMTBL_ZKEVM_MAINNET - The chain slug for IMTBL ZKEVM Mainnet.
|
|
26633
|
+
* @property {string} IMTBL_ZKEVM_TESTNET - The chain slug for IMTBL ZKEVM Testnet.
|
|
26634
|
+
* @property {string} IMTBL_ZKEVM_DEVNET - The chain slug for IMTBL ZKEVM Devnet.
|
|
26635
|
+
* @property {string} ETHEREUM - The chain slug for Ethereum.
|
|
26636
|
+
* @property {string} SEPOLIA - The chain slug for Sepolia.
|
|
26637
|
+
*/
|
|
26638
|
+
var ChainSlug;
|
|
26639
|
+
(function (ChainSlug) {
|
|
26640
|
+
ChainSlug["ETHEREUM"] = "ethereum";
|
|
26641
|
+
ChainSlug["SEPOLIA"] = "sepolia";
|
|
26642
|
+
ChainSlug["IMTBL_ZKEVM_MAINNET"] = "imtbl-zkevm-mainnet";
|
|
26643
|
+
ChainSlug["IMTBL_ZKEVM_TESTNET"] = "imtbl-zkevm-testnet";
|
|
26644
|
+
ChainSlug["IMTBL_ZKEVM_DEVNET"] = "imtbl-zkevm-devnet";
|
|
26645
|
+
})(ChainSlug || (ChainSlug = {}));
|
|
26411
26646
|
|
|
26412
26647
|
var OnRampProvider;
|
|
26413
26648
|
(function (OnRampProvider) {
|
|
@@ -26572,6 +26807,7 @@ var CheckoutErrorType;
|
|
|
26572
26807
|
CheckoutErrorType["CONNECT_PROVIDER_ERROR"] = "CONNECT_PROVIDER_ERROR";
|
|
26573
26808
|
CheckoutErrorType["GET_BALANCE_ERROR"] = "GET_BALANCE_ERROR";
|
|
26574
26809
|
CheckoutErrorType["GET_INDEXER_BALANCE_ERROR"] = "GET_INDEXER_BALANCE_ERROR";
|
|
26810
|
+
CheckoutErrorType["GET_ERC20_INFO_ERROR"] = "GET_ERC20_INFO_ERROR";
|
|
26575
26811
|
CheckoutErrorType["GET_ERC20_BALANCE_ERROR"] = "GET_ERC20_BALANCE_ERROR";
|
|
26576
26812
|
CheckoutErrorType["GET_ERC721_BALANCE_ERROR"] = "GET_ERC721_BALANCE_ERROR";
|
|
26577
26813
|
CheckoutErrorType["GET_NETWORK_INFO_ERROR"] = "GET_NETWORK_INFO_ERROR";
|
|
@@ -27139,7 +27375,7 @@ const GAS_OVERRIDES = {
|
|
|
27139
27375
|
maxPriorityFeePerGas: BigNumber$1.from(101e9),
|
|
27140
27376
|
};
|
|
27141
27377
|
|
|
27142
|
-
const SDK_VERSION_MARKER = '0.36.
|
|
27378
|
+
const SDK_VERSION_MARKER = '0.36.5';
|
|
27143
27379
|
// This SDK version is replaced by the `yarn build` command ran on the root level
|
|
27144
27380
|
const globalPackageVersion = () => SDK_VERSION_MARKER;
|
|
27145
27381
|
|
|
@@ -27300,6 +27536,22 @@ const getTokenAllowList = async (config, { type = TokenFilterTypes.ALL, chainId,
|
|
|
27300
27536
|
};
|
|
27301
27537
|
};
|
|
27302
27538
|
const isNativeToken = (address) => !address || address.toLocaleLowerCase() === NATIVE;
|
|
27539
|
+
async function getERC20TokenInfo(web3Provider, tokenAddress) {
|
|
27540
|
+
return await withCheckoutError(async () => {
|
|
27541
|
+
const contract = new Contract$1(tokenAddress, JSON.stringify(ERC20ABI), web3Provider);
|
|
27542
|
+
const [name, symbol, decimals] = await Promise.all([
|
|
27543
|
+
contract.name(),
|
|
27544
|
+
contract.symbol(),
|
|
27545
|
+
contract.decimals(),
|
|
27546
|
+
]);
|
|
27547
|
+
return {
|
|
27548
|
+
name,
|
|
27549
|
+
symbol,
|
|
27550
|
+
decimals,
|
|
27551
|
+
address: tokenAddress,
|
|
27552
|
+
};
|
|
27553
|
+
}, { type: CheckoutErrorType.GET_ERC20_INFO_ERROR });
|
|
27554
|
+
}
|
|
27303
27555
|
|
|
27304
27556
|
const CACHE_DATA_TTL = 60; // seconds
|
|
27305
27557
|
/**
|
|
@@ -27470,20 +27722,18 @@ async function getERC20Balance(web3Provider, walletAddress, tokenAddress) {
|
|
|
27470
27722
|
return await withCheckoutError(async () => {
|
|
27471
27723
|
const contract = new Contract$1(tokenAddress, JSON.stringify(ERC20ABI), web3Provider);
|
|
27472
27724
|
return Promise.all([
|
|
27473
|
-
|
|
27474
|
-
contract.symbol(),
|
|
27725
|
+
getERC20TokenInfo(web3Provider, tokenAddress),
|
|
27475
27726
|
contract.balanceOf(walletAddress),
|
|
27476
|
-
contract.decimals(),
|
|
27477
27727
|
])
|
|
27478
|
-
.then(([
|
|
27479
|
-
const formattedBalance = utils$1.formatUnits(balance, decimals);
|
|
27728
|
+
.then(([tokenInfo, balance]) => {
|
|
27729
|
+
const formattedBalance = utils$1.formatUnits(balance, tokenInfo.decimals);
|
|
27480
27730
|
return {
|
|
27481
27731
|
balance,
|
|
27482
27732
|
formattedBalance,
|
|
27483
27733
|
token: {
|
|
27484
|
-
name,
|
|
27485
|
-
symbol,
|
|
27486
|
-
decimals,
|
|
27734
|
+
name: tokenInfo.name,
|
|
27735
|
+
symbol: tokenInfo.symbol,
|
|
27736
|
+
decimals: tokenInfo.decimals,
|
|
27487
27737
|
address: tokenAddress,
|
|
27488
27738
|
},
|
|
27489
27739
|
};
|
|
@@ -27583,6 +27833,9 @@ const getBalances = async (config, web3Provider, walletAddress, tokens) => {
|
|
|
27583
27833
|
const allBalancePromises = [];
|
|
27584
27834
|
tokens
|
|
27585
27835
|
.forEach((token) => {
|
|
27836
|
+
// For some reason isNativeToken always returns undefined.
|
|
27837
|
+
// We have spent way too much time figuring out why this is happening.
|
|
27838
|
+
// That we have given up -- keep it as it is for now.
|
|
27586
27839
|
if (!token.address || token.address.toLocaleLowerCase() === NATIVE) {
|
|
27587
27840
|
allBalancePromises.push(getBalance(config, web3Provider, walletAddress));
|
|
27588
27841
|
}
|
|
@@ -27591,13 +27844,25 @@ const getBalances = async (config, web3Provider, walletAddress, tokens) => {
|
|
|
27591
27844
|
}
|
|
27592
27845
|
});
|
|
27593
27846
|
const balanceResults = await Promise.allSettled(allBalancePromises);
|
|
27594
|
-
const balances = balanceResults.filter((result) => result.status === 'fulfilled').map((result) =>
|
|
27847
|
+
const balances = balanceResults.filter((result) => result.status === 'fulfilled').map((result) => {
|
|
27848
|
+
const resp = result;
|
|
27849
|
+
const { token } = resp.value;
|
|
27850
|
+
// For some reason isNativeToken always returns undefined.
|
|
27851
|
+
// We have spent way too much time figuring out why this is happening.
|
|
27852
|
+
// That we have given up -- keep it as it is for now.
|
|
27853
|
+
if (!token.address || token.address.toLocaleLowerCase() === NATIVE)
|
|
27854
|
+
resp.value.token.address = NATIVE;
|
|
27855
|
+
return resp.value;
|
|
27856
|
+
});
|
|
27595
27857
|
return { balances };
|
|
27596
27858
|
};
|
|
27597
27859
|
const getAllBalances = async (config, web3Provider, walletAddress, chainId) => {
|
|
27598
27860
|
if (!walletAddress && !web3Provider) {
|
|
27599
27861
|
throw new CheckoutError('both walletAddress and provider are missing. At least one must be provided.', CheckoutErrorType.MISSING_PARAMS);
|
|
27600
27862
|
}
|
|
27863
|
+
if (!config.networkMap.get(chainId)) {
|
|
27864
|
+
throw new CheckoutError(`chain ID ${chainId} not supported by the environment`, CheckoutErrorType.CHAIN_NOT_SUPPORTED_ERROR);
|
|
27865
|
+
}
|
|
27601
27866
|
const { tokens } = await getTokenAllowList(config, {
|
|
27602
27867
|
type: TokenFilterTypes.ALL,
|
|
27603
27868
|
chainId,
|
|
@@ -29179,11 +29444,11 @@ const getBridgeFeeEstimate = async (config, readOnlyProviders, fromChainId, toCh
|
|
|
29179
29444
|
const INDEXER_ETH_ROOT_CONTRACT_ADDRESS = '0x0000000000000000000000000000000000000eee';
|
|
29180
29445
|
const getIndexerChainName = (chainId) => {
|
|
29181
29446
|
if (chainId === ChainId.IMTBL_ZKEVM_MAINNET)
|
|
29182
|
-
return
|
|
29447
|
+
return ChainSlug.IMTBL_ZKEVM_MAINNET;
|
|
29183
29448
|
if (chainId === ChainId.IMTBL_ZKEVM_TESTNET)
|
|
29184
|
-
return
|
|
29449
|
+
return ChainSlug.IMTBL_ZKEVM_TESTNET;
|
|
29185
29450
|
if (chainId === ChainId.IMTBL_ZKEVM_DEVNET)
|
|
29186
|
-
return
|
|
29451
|
+
return ChainSlug.IMTBL_ZKEVM_DEVNET;
|
|
29187
29452
|
return '';
|
|
29188
29453
|
};
|
|
29189
29454
|
// Indexer ERC20 call does not support IMX so cannot get root chain mapping from this endpoint.
|
|
@@ -30629,6 +30894,8 @@ class Checkout {
|
|
|
30629
30894
|
*/
|
|
30630
30895
|
async widgets(init) {
|
|
30631
30896
|
const checkout = this;
|
|
30897
|
+
// Preload the configurations
|
|
30898
|
+
await checkout.config.remote.getConfig();
|
|
30632
30899
|
const factory = new Promise((resolve, reject) => {
|
|
30633
30900
|
function checkForWidgetsBundleLoaded() {
|
|
30634
30901
|
if (typeof ImmutableCheckoutWidgets !== 'undefined') {
|
|
@@ -30644,8 +30911,6 @@ class Checkout {
|
|
|
30644
30911
|
try {
|
|
30645
30912
|
const script = loadUnresolved(init.version);
|
|
30646
30913
|
if (script.loaded && typeof ImmutableCheckoutWidgets !== 'undefined') {
|
|
30647
|
-
// eslint-disable-next-line no-console
|
|
30648
|
-
console.warn('Checkout widgets script is already loaded');
|
|
30649
30914
|
resolve(new ImmutableCheckoutWidgets.WidgetsFactory(checkout, init.config));
|
|
30650
30915
|
}
|
|
30651
30916
|
else {
|
|
@@ -30699,6 +30964,15 @@ class Checkout {
|
|
|
30699
30964
|
const switchNetworkRes = await switchWalletNetwork(this.config, web3Provider, params.chainId);
|
|
30700
30965
|
return switchNetworkRes;
|
|
30701
30966
|
}
|
|
30967
|
+
/**
|
|
30968
|
+
* Retrieves the token information given the token address. This function makes RPC calls to
|
|
30969
|
+
* ERC20 contracts to fetch the main contract information (e.g. symbol).
|
|
30970
|
+
* @param {GetTokenInfoParams} params - The parameters for retrieving the token information.
|
|
30971
|
+
* @returns {Promise<TokenInfo>} - A promise that resolves to the token info request.
|
|
30972
|
+
*/
|
|
30973
|
+
async getTokenInfo(params) {
|
|
30974
|
+
return await getERC20TokenInfo(params.provider, params.tokenAddress);
|
|
30975
|
+
}
|
|
30702
30976
|
/**
|
|
30703
30977
|
* Retrieves the balance of a wallet address.
|
|
30704
30978
|
* @param {GetBalanceParams} params - The parameters for retrieving the balance.
|
|
@@ -30878,4 +31152,4 @@ class Checkout {
|
|
|
30878
31152
|
}
|
|
30879
31153
|
}
|
|
30880
31154
|
|
|
30881
|
-
export { BridgeEventType, ChainId, ChainName, Checkout, CheckoutConfiguration, CheckoutErrorType, CheckoutStatus, ConnectEventType, ConnectTargetLayer, ExchangeType, FundingStepType, GasEstimateType, GasTokenType, IMMUTABLE_API_BASE_URL, IMTBLWidgetEvents, ItemType, NetworkFilterTypes, OnRampEventType, OrchestrationEventType, ProviderEventType, RoutingOutcomeType, SaleEventType, SwapEventType, TokenFilterTypes, TransactionOrGasType, WalletEventType, WalletFilterTypes, WalletProviderName, WidgetTheme, WidgetType };
|
|
31155
|
+
export { BridgeEventType, ChainId, ChainName, ChainSlug, Checkout, CheckoutConfiguration, CheckoutErrorType, CheckoutStatus, ConnectEventType, ConnectTargetLayer, ExchangeType, FundingStepType, GasEstimateType, GasTokenType, IMMUTABLE_API_BASE_URL, IMTBLWidgetEvents, ItemType, NetworkFilterTypes, OnRampEventType, OrchestrationEventType, ProviderEventType, RoutingOutcomeType, SaleEventType, SwapEventType, TokenFilterTypes, TransactionOrGasType, WalletEventType, WalletFilterTypes, WalletProviderName, WidgetTheme, WidgetType };
|