@imtbl/sdk 0.36.4 → 0.37.0
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 +40 -24
- package/dist/checkout.js +463 -212
- package/dist/immutablex_client.js +1 -1
- package/dist/index.browser.js +12 -12
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +466 -214
- package/dist/index.d.ts +45 -28
- package/dist/index.js +466 -214
- 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.
|
|
4259
|
+
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.37.0' };
|
|
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.
|
|
4319
|
+
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.37.0',
|
|
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.
|
|
4758
|
+
sdkVersion: 'ts-immutable-sdk-0.37.0',
|
|
4759
4759
|
});
|
|
4760
4760
|
/**
|
|
4761
4761
|
* Sets `sdkVersion` at the time of build
|
|
@@ -12254,13 +12254,13 @@ var ProtocolData;
|
|
|
12254
12254
|
})(ProtocolData.order_type || (ProtocolData.order_type = {}));
|
|
12255
12255
|
})(ProtocolData || (ProtocolData = {}));
|
|
12256
12256
|
|
|
12257
|
-
var FeeType;
|
|
12257
|
+
var FeeType$1;
|
|
12258
12258
|
(function (FeeType) {
|
|
12259
12259
|
FeeType["MAKER_ECOSYSTEM"] = "MAKER_ECOSYSTEM";
|
|
12260
12260
|
FeeType["TAKER_ECOSYSTEM"] = "TAKER_ECOSYSTEM";
|
|
12261
12261
|
FeeType["PROTOCOL"] = "PROTOCOL";
|
|
12262
12262
|
FeeType["ROYALTY"] = "ROYALTY";
|
|
12263
|
-
})(FeeType || (FeeType = {}));
|
|
12263
|
+
})(FeeType$1 || (FeeType$1 = {}));
|
|
12264
12264
|
var TransactionPurpose;
|
|
12265
12265
|
(function (TransactionPurpose) {
|
|
12266
12266
|
TransactionPurpose["APPROVAL"] = "APPROVAL";
|
|
@@ -12822,7 +12822,7 @@ class ImmutableApiClient {
|
|
|
12822
12822
|
],
|
|
12823
12823
|
fees: makerFees.map((x) => ({
|
|
12824
12824
|
amount: x.amount,
|
|
12825
|
-
type: FeeType.MAKER_ECOSYSTEM,
|
|
12825
|
+
type: FeeType$1.MAKER_ECOSYSTEM,
|
|
12826
12826
|
recipient_address: x.recipientAddress,
|
|
12827
12827
|
})),
|
|
12828
12828
|
end_at: new Date(parseInt(`${orderComponents.endTime.toString()}000`, 10)).toISOString(),
|
|
@@ -13036,7 +13036,7 @@ class Orderbook {
|
|
|
13036
13036
|
order_id: listingId,
|
|
13037
13037
|
fees: takerFees.map((fee) => ({
|
|
13038
13038
|
amount: fee.amount,
|
|
13039
|
-
type: FeeType.TAKER_ECOSYSTEM,
|
|
13039
|
+
type: FeeType$1.TAKER_ECOSYSTEM,
|
|
13040
13040
|
recipient_address: fee.recipientAddress,
|
|
13041
13041
|
})),
|
|
13042
13042
|
},
|
|
@@ -13059,7 +13059,7 @@ class Orderbook {
|
|
|
13059
13059
|
order_id: listingRequest.listingId,
|
|
13060
13060
|
fees: listingRequest.takerFees.map((fee) => ({
|
|
13061
13061
|
amount: fee.amount,
|
|
13062
|
-
type: FeeType.TAKER_ECOSYSTEM,
|
|
13062
|
+
type: FeeType$1.TAKER_ECOSYSTEM,
|
|
13063
13063
|
recipient_address: fee.recipientAddress,
|
|
13064
13064
|
})),
|
|
13065
13065
|
})));
|
|
@@ -13190,7 +13190,7 @@ const constants = {
|
|
|
13190
13190
|
var orderbook = /*#__PURE__*/Object.freeze({
|
|
13191
13191
|
__proto__: null,
|
|
13192
13192
|
get ActionType () { return ActionType; },
|
|
13193
|
-
get FeeType () { return FeeType; },
|
|
13193
|
+
get FeeType () { return FeeType$1; },
|
|
13194
13194
|
get OrderStatusName () { return OrderStatusName; },
|
|
13195
13195
|
Orderbook: Orderbook,
|
|
13196
13196
|
get SignablePurpose () { return SignablePurpose; },
|
|
@@ -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',
|
|
@@ -34857,6 +35075,21 @@ var RoutingOutcomeType;
|
|
|
34857
35075
|
RoutingOutcomeType["NO_ROUTES_FOUND"] = "NO_ROUTES_FOUND";
|
|
34858
35076
|
RoutingOutcomeType["NO_ROUTE_OPTIONS"] = "NO_ROUTE_OPTIONS";
|
|
34859
35077
|
})(RoutingOutcomeType || (RoutingOutcomeType = {}));
|
|
35078
|
+
/**
|
|
35079
|
+
* An enum representing the funding step types
|
|
35080
|
+
* @enum {string}
|
|
35081
|
+
* @property {string} GAS - If the fee is a gas fee.
|
|
35082
|
+
* @property {string} BRIDGE_FEE - If the fee is a bridge fee.
|
|
35083
|
+
* @property {string} SWAP_FEE - If the fee is a swap fee.
|
|
35084
|
+
* @property {string} IMMUTABLE_FEE - If the fee is an immutable fee.
|
|
35085
|
+
*/
|
|
35086
|
+
var FeeType;
|
|
35087
|
+
(function (FeeType) {
|
|
35088
|
+
FeeType["GAS"] = "GAS";
|
|
35089
|
+
FeeType["BRIDGE_FEE"] = "BRIDGE_FEE";
|
|
35090
|
+
FeeType["SWAP_FEE"] = "SWAP_FEE";
|
|
35091
|
+
FeeType["IMMUTABLE_FEE"] = "IMMUTABLE_FEE";
|
|
35092
|
+
})(FeeType || (FeeType = {}));
|
|
34860
35093
|
/**
|
|
34861
35094
|
* An enum representing the funding step types
|
|
34862
35095
|
* @enum {string}
|
|
@@ -35462,7 +35695,7 @@ const GAS_OVERRIDES = {
|
|
|
35462
35695
|
maxPriorityFeePerGas: ethers.BigNumber.from(101e9),
|
|
35463
35696
|
};
|
|
35464
35697
|
|
|
35465
|
-
const SDK_VERSION_MARKER = '0.
|
|
35698
|
+
const SDK_VERSION_MARKER = '0.37.0';
|
|
35466
35699
|
// This SDK version is replaced by the `yarn build` command ran on the root level
|
|
35467
35700
|
const globalPackageVersion = () => SDK_VERSION_MARKER;
|
|
35468
35701
|
|
|
@@ -36356,8 +36589,8 @@ const erc20ItemAggregator = (itemRequirements) => {
|
|
|
36356
36589
|
aggregatedItemRequirements.push(itemRequirement);
|
|
36357
36590
|
return;
|
|
36358
36591
|
}
|
|
36359
|
-
const {
|
|
36360
|
-
const key = `${
|
|
36592
|
+
const { tokenAddress, spenderAddress, amount } = itemRequirement;
|
|
36593
|
+
const key = `${tokenAddress}${spenderAddress}`;
|
|
36361
36594
|
const aggregateItem = aggregatedMap.get(key);
|
|
36362
36595
|
if (aggregateItem && aggregateItem.type === ItemType.ERC20) {
|
|
36363
36596
|
aggregateItem.amount = ethers.BigNumber.from(aggregateItem.amount).add(amount);
|
|
@@ -36423,10 +36656,10 @@ const hasERC20Allowances = async (provider, ownerAddress, itemRequirements) => {
|
|
|
36423
36656
|
for (const itemRequirement of itemRequirements) {
|
|
36424
36657
|
if (itemRequirement.type !== ItemType.ERC20)
|
|
36425
36658
|
continue;
|
|
36426
|
-
const {
|
|
36427
|
-
const key = `${
|
|
36659
|
+
const { tokenAddress, spenderAddress } = itemRequirement;
|
|
36660
|
+
const key = `${tokenAddress}${spenderAddress}`;
|
|
36428
36661
|
erc20s.set(key, itemRequirement);
|
|
36429
|
-
allowancePromises.set(key, getERC20Allowance(provider, ownerAddress,
|
|
36662
|
+
allowancePromises.set(key, getERC20Allowance(provider, ownerAddress, tokenAddress, spenderAddress));
|
|
36430
36663
|
}
|
|
36431
36664
|
const allowances = await Promise.all(allowancePromises.values());
|
|
36432
36665
|
const allowancePromiseIds = Array.from(allowancePromises.keys());
|
|
@@ -36445,8 +36678,8 @@ const hasERC20Allowances = async (provider, ownerAddress, itemRequirements) => {
|
|
|
36445
36678
|
continue;
|
|
36446
36679
|
}
|
|
36447
36680
|
sufficient = false; // Set sufficient false on the root of the return object when an ERC20 is insufficient
|
|
36448
|
-
const {
|
|
36449
|
-
const key = `${
|
|
36681
|
+
const { tokenAddress, spenderAddress } = itemRequirement;
|
|
36682
|
+
const key = `${tokenAddress}${spenderAddress}`;
|
|
36450
36683
|
const delta = itemRequirement.amount.sub(allowances[index]);
|
|
36451
36684
|
// Create maps for both the insufficient ERC20 data and the transaction promises using the same key so the results can be merged
|
|
36452
36685
|
insufficientERC20s.set(key, {
|
|
@@ -36456,7 +36689,7 @@ const hasERC20Allowances = async (provider, ownerAddress, itemRequirements) => {
|
|
|
36456
36689
|
itemRequirement,
|
|
36457
36690
|
approvalTransaction: undefined,
|
|
36458
36691
|
});
|
|
36459
|
-
transactionPromises.set(key, getERC20ApprovalTransaction(provider, ownerAddress,
|
|
36692
|
+
transactionPromises.set(key, getERC20ApprovalTransaction(provider, ownerAddress, tokenAddress, spenderAddress, delta));
|
|
36460
36693
|
}
|
|
36461
36694
|
// Resolves the approval transactions and merges them with the insufficient ERC20 data
|
|
36462
36695
|
const transactions = await Promise.all(transactionPromises.values());
|
|
@@ -36641,8 +36874,8 @@ const erc20BalanceAggregator = (itemRequirements) => {
|
|
|
36641
36874
|
aggregatedItemRequirements.push(itemRequirement);
|
|
36642
36875
|
return;
|
|
36643
36876
|
}
|
|
36644
|
-
const {
|
|
36645
|
-
const key = `${
|
|
36877
|
+
const { tokenAddress, amount } = itemRequirement;
|
|
36878
|
+
const key = `${tokenAddress}`;
|
|
36646
36879
|
const aggregateItem = aggregatedMap.get(key);
|
|
36647
36880
|
if (aggregateItem && aggregateItem.type === ItemType.ERC20) {
|
|
36648
36881
|
aggregateItem.amount = ethers.BigNumber.from(aggregateItem.amount).add(amount);
|
|
@@ -36675,14 +36908,21 @@ const balanceAggregator = (itemRequirements) => erc721BalanceAggregator(erc20Bal
|
|
|
36675
36908
|
/* eslint-disable arrow-body-style */
|
|
36676
36909
|
const getTokensFromRequirements = (itemRequirements) => itemRequirements
|
|
36677
36910
|
.map((itemRequirement) => {
|
|
36678
|
-
|
|
36679
|
-
|
|
36680
|
-
|
|
36681
|
-
|
|
36911
|
+
switch (itemRequirement.type) {
|
|
36912
|
+
case ItemType.ERC20:
|
|
36913
|
+
return {
|
|
36914
|
+
address: itemRequirement.tokenAddress,
|
|
36915
|
+
};
|
|
36916
|
+
case ItemType.NATIVE:
|
|
36917
|
+
return {
|
|
36918
|
+
address: NATIVE,
|
|
36919
|
+
};
|
|
36920
|
+
case ItemType.ERC721:
|
|
36921
|
+
default:
|
|
36922
|
+
return {
|
|
36923
|
+
address: itemRequirement.contractAddress,
|
|
36924
|
+
};
|
|
36682
36925
|
}
|
|
36683
|
-
return {
|
|
36684
|
-
address: itemRequirement.contractAddress,
|
|
36685
|
-
};
|
|
36686
36926
|
});
|
|
36687
36927
|
/**
|
|
36688
36928
|
* Gets the balance requirement with delta for an ERC721 requirement.
|
|
@@ -36732,7 +36972,7 @@ const getTokenBalanceRequirement = (itemRequirement, balances) => {
|
|
|
36732
36972
|
// Get the requirements related balance
|
|
36733
36973
|
if (itemRequirement.type === ItemType.ERC20) {
|
|
36734
36974
|
itemBalanceResult = balances.find((balance) => {
|
|
36735
|
-
return balance.token?.address === itemRequirement.
|
|
36975
|
+
return balance.token?.address === itemRequirement.tokenAddress;
|
|
36736
36976
|
});
|
|
36737
36977
|
}
|
|
36738
36978
|
else if (itemRequirement.type === ItemType.NATIVE) {
|
|
@@ -36796,7 +37036,7 @@ const getTokenBalanceRequirement = (itemRequirement, balances) => {
|
|
|
36796
37036
|
token: {
|
|
36797
37037
|
name,
|
|
36798
37038
|
symbol,
|
|
36799
|
-
address: itemRequirement.
|
|
37039
|
+
address: itemRequirement.tokenAddress,
|
|
36800
37040
|
decimals,
|
|
36801
37041
|
},
|
|
36802
37042
|
};
|
|
@@ -36955,7 +37195,7 @@ const getGasItemRequirement = (gas, transactionOrGas) => {
|
|
|
36955
37195
|
return {
|
|
36956
37196
|
type: ItemType.ERC20,
|
|
36957
37197
|
amount: gas,
|
|
36958
|
-
|
|
37198
|
+
tokenAddress: transactionOrGas.gasToken.tokenAddress,
|
|
36959
37199
|
spenderAddress: '',
|
|
36960
37200
|
};
|
|
36961
37201
|
};
|
|
@@ -37178,36 +37418,37 @@ const quoteFetcher = async (config, chainId, walletAddress, requiredToken, swapp
|
|
|
37178
37418
|
}
|
|
37179
37419
|
};
|
|
37180
37420
|
|
|
37181
|
-
const constructFees$1 = (
|
|
37421
|
+
const constructFees$1 = (approvalGasFee, swapGasFee, swapFees) => {
|
|
37182
37422
|
let approvalGasFeeAmount = ethers.BigNumber.from(0);
|
|
37183
37423
|
let approvalGasFeeFormatted = '0';
|
|
37184
37424
|
let approvalToken;
|
|
37185
|
-
if (
|
|
37186
|
-
approvalGasFeeAmount =
|
|
37187
|
-
approvalGasFeeFormatted = ethers.utils.formatUnits(
|
|
37425
|
+
if (approvalGasFee) {
|
|
37426
|
+
approvalGasFeeAmount = approvalGasFee.value;
|
|
37427
|
+
approvalGasFeeFormatted = ethers.utils.formatUnits(approvalGasFee.value, approvalGasFee.token.decimals);
|
|
37188
37428
|
approvalToken = {
|
|
37189
|
-
name:
|
|
37190
|
-
symbol:
|
|
37191
|
-
address:
|
|
37192
|
-
decimals:
|
|
37429
|
+
name: approvalGasFee.token.name ?? '',
|
|
37430
|
+
symbol: approvalGasFee.token.symbol ?? '',
|
|
37431
|
+
address: approvalGasFee.token.address,
|
|
37432
|
+
decimals: approvalGasFee.token.decimals,
|
|
37193
37433
|
};
|
|
37194
37434
|
}
|
|
37195
37435
|
let swapGasFeeAmount = ethers.BigNumber.from(0);
|
|
37196
37436
|
let swapGasFeeFormatted = '0';
|
|
37197
37437
|
let swapGasToken;
|
|
37198
|
-
if (
|
|
37199
|
-
swapGasFeeAmount =
|
|
37200
|
-
swapGasFeeFormatted = ethers.utils.formatUnits(
|
|
37438
|
+
if (swapGasFee) {
|
|
37439
|
+
swapGasFeeAmount = swapGasFee.value;
|
|
37440
|
+
swapGasFeeFormatted = ethers.utils.formatUnits(swapGasFee.value, swapGasFee.token.decimals);
|
|
37201
37441
|
swapGasToken = {
|
|
37202
|
-
name:
|
|
37203
|
-
symbol:
|
|
37204
|
-
address:
|
|
37205
|
-
decimals:
|
|
37442
|
+
name: swapGasFee.token.name ?? '',
|
|
37443
|
+
symbol: swapGasFee.token.symbol ?? '',
|
|
37444
|
+
address: swapGasFee.token.address,
|
|
37445
|
+
decimals: swapGasFee.token.decimals,
|
|
37206
37446
|
};
|
|
37207
37447
|
}
|
|
37208
37448
|
const fees = [];
|
|
37209
37449
|
for (const swapFee of swapFees) {
|
|
37210
37450
|
fees.push({
|
|
37451
|
+
type: FeeType.SWAP_FEE,
|
|
37211
37452
|
amount: swapFee.amount.value,
|
|
37212
37453
|
formattedAmount: ethers.utils.formatUnits(swapFee.amount.value, swapFee.amount.token.decimals),
|
|
37213
37454
|
token: {
|
|
@@ -37219,12 +37460,14 @@ const constructFees$1 = (approvalGasFees, swapGasFees, swapFees) => {
|
|
|
37219
37460
|
});
|
|
37220
37461
|
}
|
|
37221
37462
|
return {
|
|
37222
|
-
|
|
37463
|
+
approvalGasFee: {
|
|
37464
|
+
type: FeeType.GAS,
|
|
37223
37465
|
amount: approvalGasFeeAmount,
|
|
37224
37466
|
formattedAmount: approvalGasFeeFormatted,
|
|
37225
37467
|
token: approvalToken,
|
|
37226
37468
|
},
|
|
37227
|
-
|
|
37469
|
+
swapGasFee: {
|
|
37470
|
+
type: FeeType.GAS,
|
|
37228
37471
|
amount: swapGasFeeAmount,
|
|
37229
37472
|
formattedAmount: swapGasFeeFormatted,
|
|
37230
37473
|
token: swapGasToken,
|
|
@@ -37309,7 +37552,7 @@ const checkUserCanCoverApprovalFees = (l2Balances, approval) => {
|
|
|
37309
37552
|
// The user has enough to cover approval gas fees
|
|
37310
37553
|
return { sufficient: true, approvalGasFee, approvalGasTokenAddress };
|
|
37311
37554
|
};
|
|
37312
|
-
const checkUserCanCoverSwapFees = (l2Balances, approvalFees,
|
|
37555
|
+
const checkUserCanCoverSwapFees = (l2Balances, approvalFees, swapGasFee, swapFees, tokenBeingSwapped) => {
|
|
37313
37556
|
// Set up a map of token addresses to amounts for each of the swap fees
|
|
37314
37557
|
const feeMap = new Map();
|
|
37315
37558
|
// Add the approval fee to list of fees
|
|
@@ -37317,13 +37560,13 @@ const checkUserCanCoverSwapFees = (l2Balances, approvalFees, swapGasFees, swapFe
|
|
|
37317
37560
|
feeMap.set(approvalFees.approvalGasTokenAddress, approvalFees.approvalGasFee);
|
|
37318
37561
|
}
|
|
37319
37562
|
// Add the swap gas fee to list of fees
|
|
37320
|
-
if (
|
|
37321
|
-
const fee = feeMap.get(
|
|
37563
|
+
if (swapGasFee) {
|
|
37564
|
+
const fee = feeMap.get(swapGasFee.token.address);
|
|
37322
37565
|
if (fee) {
|
|
37323
|
-
feeMap.set(
|
|
37566
|
+
feeMap.set(swapGasFee.token.address, fee.add(swapGasFee.value));
|
|
37324
37567
|
}
|
|
37325
37568
|
else {
|
|
37326
|
-
feeMap.set(
|
|
37569
|
+
feeMap.set(swapGasFee.token.address, swapGasFee.value);
|
|
37327
37570
|
}
|
|
37328
37571
|
}
|
|
37329
37572
|
// Add the token being swapped to list of fees to ensure the user can cover the fee + the token swap
|
|
@@ -37577,31 +37820,39 @@ const hasSufficientL1Eth = (tokenBalanceResult, totalFees) => {
|
|
|
37577
37820
|
const balance = getEthBalance(tokenBalanceResult);
|
|
37578
37821
|
return balance.gte(totalFees);
|
|
37579
37822
|
};
|
|
37580
|
-
const constructFees = (
|
|
37823
|
+
const constructFees = (bridgeGasFee, bridgeFee, imtblFee, approvalGasFee, token) => {
|
|
37581
37824
|
const bridgeFeeDecimals = token?.decimals ?? DEFAULT_TOKEN_DECIMALS$1;
|
|
37825
|
+
const bridgeFees = [];
|
|
37826
|
+
if (bridgeFee.gt(0)) {
|
|
37827
|
+
bridgeFees.push({
|
|
37828
|
+
type: FeeType.BRIDGE_FEE,
|
|
37829
|
+
amount: bridgeFee,
|
|
37830
|
+
formattedAmount: ethers.utils.formatUnits(bridgeFee, bridgeFeeDecimals),
|
|
37831
|
+
token,
|
|
37832
|
+
});
|
|
37833
|
+
}
|
|
37834
|
+
if (imtblFee.gt(0)) {
|
|
37835
|
+
bridgeFees.push({
|
|
37836
|
+
type: FeeType.IMMUTABLE_FEE,
|
|
37837
|
+
amount: imtblFee,
|
|
37838
|
+
formattedAmount: ethers.utils.formatUnits(imtblFee, bridgeFeeDecimals),
|
|
37839
|
+
token,
|
|
37840
|
+
});
|
|
37841
|
+
}
|
|
37582
37842
|
return {
|
|
37583
|
-
|
|
37584
|
-
|
|
37585
|
-
|
|
37843
|
+
approvalGasFee: {
|
|
37844
|
+
type: FeeType.GAS,
|
|
37845
|
+
amount: approvalGasFee,
|
|
37846
|
+
formattedAmount: ethers.utils.formatUnits(approvalGasFee, DEFAULT_TOKEN_DECIMALS$1),
|
|
37586
37847
|
token,
|
|
37587
37848
|
},
|
|
37588
|
-
|
|
37589
|
-
|
|
37590
|
-
|
|
37849
|
+
bridgeGasFee: {
|
|
37850
|
+
type: FeeType.GAS,
|
|
37851
|
+
amount: bridgeGasFee,
|
|
37852
|
+
formattedAmount: ethers.utils.formatUnits(bridgeGasFee, DEFAULT_TOKEN_DECIMALS$1),
|
|
37591
37853
|
token,
|
|
37592
37854
|
},
|
|
37593
|
-
bridgeFees
|
|
37594
|
-
{
|
|
37595
|
-
amount: bridgeFee,
|
|
37596
|
-
formattedAmount: ethers.utils.formatUnits(bridgeFee, bridgeFeeDecimals),
|
|
37597
|
-
token,
|
|
37598
|
-
},
|
|
37599
|
-
{
|
|
37600
|
-
amount: imtblFee,
|
|
37601
|
-
formattedAmount: ethers.utils.formatUnits(imtblFee, bridgeFeeDecimals),
|
|
37602
|
-
token,
|
|
37603
|
-
},
|
|
37604
|
-
],
|
|
37855
|
+
bridgeFees,
|
|
37605
37856
|
};
|
|
37606
37857
|
};
|
|
37607
37858
|
const constructBridgeFundingRoute = (chainId, balance, bridgeRequirement, itemType, fees) => ({
|
|
@@ -38460,13 +38711,13 @@ const calculateFees = (orderFees, weiAmount, decimals = 18) => {
|
|
|
38460
38711
|
return calculateFeesResult;
|
|
38461
38712
|
};
|
|
38462
38713
|
|
|
38463
|
-
const getItemRequirement = (type,
|
|
38714
|
+
const getItemRequirement = (type, tokenAddress, amount, spenderAddress) => {
|
|
38464
38715
|
switch (type) {
|
|
38465
38716
|
case ItemType.ERC20:
|
|
38466
38717
|
return {
|
|
38467
38718
|
type,
|
|
38468
38719
|
amount,
|
|
38469
|
-
|
|
38720
|
+
tokenAddress,
|
|
38470
38721
|
spenderAddress,
|
|
38471
38722
|
};
|
|
38472
38723
|
case ItemType.NATIVE:
|
|
@@ -38689,7 +38940,7 @@ const getBuyToken = (buyToken, decimals = 18) => {
|
|
|
38689
38940
|
return {
|
|
38690
38941
|
type: ItemType.ERC20,
|
|
38691
38942
|
amount: bnAmount.toString(),
|
|
38692
|
-
contractAddress: buyToken.
|
|
38943
|
+
contractAddress: buyToken.tokenAddress,
|
|
38693
38944
|
};
|
|
38694
38945
|
};
|
|
38695
38946
|
const sell = async (config, provider, orders) => {
|
|
@@ -38703,7 +38954,7 @@ const sell = async (config, provider, orders) => {
|
|
|
38703
38954
|
let decimals = 18;
|
|
38704
38955
|
if (buyToken.type === ItemType.ERC20) {
|
|
38705
38956
|
// get this from the allowed list
|
|
38706
|
-
const buyTokenContract = new ethers.Contract(buyToken.
|
|
38957
|
+
const buyTokenContract = new ethers.Contract(buyToken.tokenAddress, JSON.stringify(ERC20ABI), provider);
|
|
38707
38958
|
decimals = await measureAsyncExecution(config, 'Time to get decimals of token contract for the buy token', buyTokenContract.decimals());
|
|
38708
38959
|
}
|
|
38709
38960
|
const buyTokenOrNative = getBuyToken(buyToken, decimals);
|
|
@@ -38855,8 +39106,8 @@ async function getItemRequirementsFromRequirements(provider, requirements) {
|
|
|
38855
39106
|
const decimalPromises = [];
|
|
38856
39107
|
requirements.forEach((itemRequirementParam) => {
|
|
38857
39108
|
if (itemRequirementParam.type === ItemType.ERC20) {
|
|
38858
|
-
const {
|
|
38859
|
-
decimalPromises.push(getTokenContract(
|
|
39109
|
+
const { tokenAddress } = itemRequirementParam;
|
|
39110
|
+
decimalPromises.push(getTokenContract(tokenAddress, ERC20ABI, provider).decimals());
|
|
38860
39111
|
}
|
|
38861
39112
|
});
|
|
38862
39113
|
const decimals = await Promise.all(decimalPromises);
|
|
@@ -39171,7 +39422,7 @@ class Checkout {
|
|
|
39171
39422
|
try {
|
|
39172
39423
|
itemRequirements = await getItemRequirementsFromRequirements(web3Provider, params.itemRequirements);
|
|
39173
39424
|
}
|
|
39174
|
-
catch {
|
|
39425
|
+
catch (error) {
|
|
39175
39426
|
throw new CheckoutError('Failed to map item requirements', CheckoutErrorType.ITEM_REQUIREMENTS_ERROR);
|
|
39176
39427
|
}
|
|
39177
39428
|
return await smartCheckout(this.config, web3Provider, itemRequirements, params.transactionOrGasAmount);
|
|
@@ -39252,6 +39503,7 @@ var checkout = /*#__PURE__*/Object.freeze({
|
|
|
39252
39503
|
get ConnectEventType () { return ConnectEventType; },
|
|
39253
39504
|
get ConnectTargetLayer () { return ConnectTargetLayer; },
|
|
39254
39505
|
get ExchangeType () { return ExchangeType; },
|
|
39506
|
+
get FeeType () { return FeeType; },
|
|
39255
39507
|
get FundingStepType () { return FundingStepType; },
|
|
39256
39508
|
get GasEstimateType () { return GasEstimateType; },
|
|
39257
39509
|
get GasTokenType () { return GasTokenType; },
|