@imtbl/sdk 0.36.5 → 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 +53 -53
- package/dist/checkout.d.ts +38 -22
- package/dist/checkout.js +109 -76
- 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 +112 -78
- package/dist/index.d.ts +43 -26
- package/dist/index.js +112 -78
- 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; },
|
|
@@ -35075,6 +35075,21 @@ var RoutingOutcomeType;
|
|
|
35075
35075
|
RoutingOutcomeType["NO_ROUTES_FOUND"] = "NO_ROUTES_FOUND";
|
|
35076
35076
|
RoutingOutcomeType["NO_ROUTE_OPTIONS"] = "NO_ROUTE_OPTIONS";
|
|
35077
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 = {}));
|
|
35078
35093
|
/**
|
|
35079
35094
|
* An enum representing the funding step types
|
|
35080
35095
|
* @enum {string}
|
|
@@ -35680,7 +35695,7 @@ const GAS_OVERRIDES = {
|
|
|
35680
35695
|
maxPriorityFeePerGas: ethers.BigNumber.from(101e9),
|
|
35681
35696
|
};
|
|
35682
35697
|
|
|
35683
|
-
const SDK_VERSION_MARKER = '0.
|
|
35698
|
+
const SDK_VERSION_MARKER = '0.37.0';
|
|
35684
35699
|
// This SDK version is replaced by the `yarn build` command ran on the root level
|
|
35685
35700
|
const globalPackageVersion = () => SDK_VERSION_MARKER;
|
|
35686
35701
|
|
|
@@ -36574,8 +36589,8 @@ const erc20ItemAggregator = (itemRequirements) => {
|
|
|
36574
36589
|
aggregatedItemRequirements.push(itemRequirement);
|
|
36575
36590
|
return;
|
|
36576
36591
|
}
|
|
36577
|
-
const {
|
|
36578
|
-
const key = `${
|
|
36592
|
+
const { tokenAddress, spenderAddress, amount } = itemRequirement;
|
|
36593
|
+
const key = `${tokenAddress}${spenderAddress}`;
|
|
36579
36594
|
const aggregateItem = aggregatedMap.get(key);
|
|
36580
36595
|
if (aggregateItem && aggregateItem.type === ItemType.ERC20) {
|
|
36581
36596
|
aggregateItem.amount = ethers.BigNumber.from(aggregateItem.amount).add(amount);
|
|
@@ -36641,10 +36656,10 @@ const hasERC20Allowances = async (provider, ownerAddress, itemRequirements) => {
|
|
|
36641
36656
|
for (const itemRequirement of itemRequirements) {
|
|
36642
36657
|
if (itemRequirement.type !== ItemType.ERC20)
|
|
36643
36658
|
continue;
|
|
36644
|
-
const {
|
|
36645
|
-
const key = `${
|
|
36659
|
+
const { tokenAddress, spenderAddress } = itemRequirement;
|
|
36660
|
+
const key = `${tokenAddress}${spenderAddress}`;
|
|
36646
36661
|
erc20s.set(key, itemRequirement);
|
|
36647
|
-
allowancePromises.set(key, getERC20Allowance(provider, ownerAddress,
|
|
36662
|
+
allowancePromises.set(key, getERC20Allowance(provider, ownerAddress, tokenAddress, spenderAddress));
|
|
36648
36663
|
}
|
|
36649
36664
|
const allowances = await Promise.all(allowancePromises.values());
|
|
36650
36665
|
const allowancePromiseIds = Array.from(allowancePromises.keys());
|
|
@@ -36663,8 +36678,8 @@ const hasERC20Allowances = async (provider, ownerAddress, itemRequirements) => {
|
|
|
36663
36678
|
continue;
|
|
36664
36679
|
}
|
|
36665
36680
|
sufficient = false; // Set sufficient false on the root of the return object when an ERC20 is insufficient
|
|
36666
|
-
const {
|
|
36667
|
-
const key = `${
|
|
36681
|
+
const { tokenAddress, spenderAddress } = itemRequirement;
|
|
36682
|
+
const key = `${tokenAddress}${spenderAddress}`;
|
|
36668
36683
|
const delta = itemRequirement.amount.sub(allowances[index]);
|
|
36669
36684
|
// Create maps for both the insufficient ERC20 data and the transaction promises using the same key so the results can be merged
|
|
36670
36685
|
insufficientERC20s.set(key, {
|
|
@@ -36674,7 +36689,7 @@ const hasERC20Allowances = async (provider, ownerAddress, itemRequirements) => {
|
|
|
36674
36689
|
itemRequirement,
|
|
36675
36690
|
approvalTransaction: undefined,
|
|
36676
36691
|
});
|
|
36677
|
-
transactionPromises.set(key, getERC20ApprovalTransaction(provider, ownerAddress,
|
|
36692
|
+
transactionPromises.set(key, getERC20ApprovalTransaction(provider, ownerAddress, tokenAddress, spenderAddress, delta));
|
|
36678
36693
|
}
|
|
36679
36694
|
// Resolves the approval transactions and merges them with the insufficient ERC20 data
|
|
36680
36695
|
const transactions = await Promise.all(transactionPromises.values());
|
|
@@ -36859,8 +36874,8 @@ const erc20BalanceAggregator = (itemRequirements) => {
|
|
|
36859
36874
|
aggregatedItemRequirements.push(itemRequirement);
|
|
36860
36875
|
return;
|
|
36861
36876
|
}
|
|
36862
|
-
const {
|
|
36863
|
-
const key = `${
|
|
36877
|
+
const { tokenAddress, amount } = itemRequirement;
|
|
36878
|
+
const key = `${tokenAddress}`;
|
|
36864
36879
|
const aggregateItem = aggregatedMap.get(key);
|
|
36865
36880
|
if (aggregateItem && aggregateItem.type === ItemType.ERC20) {
|
|
36866
36881
|
aggregateItem.amount = ethers.BigNumber.from(aggregateItem.amount).add(amount);
|
|
@@ -36893,14 +36908,21 @@ const balanceAggregator = (itemRequirements) => erc721BalanceAggregator(erc20Bal
|
|
|
36893
36908
|
/* eslint-disable arrow-body-style */
|
|
36894
36909
|
const getTokensFromRequirements = (itemRequirements) => itemRequirements
|
|
36895
36910
|
.map((itemRequirement) => {
|
|
36896
|
-
|
|
36897
|
-
|
|
36898
|
-
|
|
36899
|
-
|
|
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
|
+
};
|
|
36900
36925
|
}
|
|
36901
|
-
return {
|
|
36902
|
-
address: itemRequirement.contractAddress,
|
|
36903
|
-
};
|
|
36904
36926
|
});
|
|
36905
36927
|
/**
|
|
36906
36928
|
* Gets the balance requirement with delta for an ERC721 requirement.
|
|
@@ -36950,7 +36972,7 @@ const getTokenBalanceRequirement = (itemRequirement, balances) => {
|
|
|
36950
36972
|
// Get the requirements related balance
|
|
36951
36973
|
if (itemRequirement.type === ItemType.ERC20) {
|
|
36952
36974
|
itemBalanceResult = balances.find((balance) => {
|
|
36953
|
-
return balance.token?.address === itemRequirement.
|
|
36975
|
+
return balance.token?.address === itemRequirement.tokenAddress;
|
|
36954
36976
|
});
|
|
36955
36977
|
}
|
|
36956
36978
|
else if (itemRequirement.type === ItemType.NATIVE) {
|
|
@@ -37014,7 +37036,7 @@ const getTokenBalanceRequirement = (itemRequirement, balances) => {
|
|
|
37014
37036
|
token: {
|
|
37015
37037
|
name,
|
|
37016
37038
|
symbol,
|
|
37017
|
-
address: itemRequirement.
|
|
37039
|
+
address: itemRequirement.tokenAddress,
|
|
37018
37040
|
decimals,
|
|
37019
37041
|
},
|
|
37020
37042
|
};
|
|
@@ -37173,7 +37195,7 @@ const getGasItemRequirement = (gas, transactionOrGas) => {
|
|
|
37173
37195
|
return {
|
|
37174
37196
|
type: ItemType.ERC20,
|
|
37175
37197
|
amount: gas,
|
|
37176
|
-
|
|
37198
|
+
tokenAddress: transactionOrGas.gasToken.tokenAddress,
|
|
37177
37199
|
spenderAddress: '',
|
|
37178
37200
|
};
|
|
37179
37201
|
};
|
|
@@ -37396,36 +37418,37 @@ const quoteFetcher = async (config, chainId, walletAddress, requiredToken, swapp
|
|
|
37396
37418
|
}
|
|
37397
37419
|
};
|
|
37398
37420
|
|
|
37399
|
-
const constructFees$1 = (
|
|
37421
|
+
const constructFees$1 = (approvalGasFee, swapGasFee, swapFees) => {
|
|
37400
37422
|
let approvalGasFeeAmount = ethers.BigNumber.from(0);
|
|
37401
37423
|
let approvalGasFeeFormatted = '0';
|
|
37402
37424
|
let approvalToken;
|
|
37403
|
-
if (
|
|
37404
|
-
approvalGasFeeAmount =
|
|
37405
|
-
approvalGasFeeFormatted = ethers.utils.formatUnits(
|
|
37425
|
+
if (approvalGasFee) {
|
|
37426
|
+
approvalGasFeeAmount = approvalGasFee.value;
|
|
37427
|
+
approvalGasFeeFormatted = ethers.utils.formatUnits(approvalGasFee.value, approvalGasFee.token.decimals);
|
|
37406
37428
|
approvalToken = {
|
|
37407
|
-
name:
|
|
37408
|
-
symbol:
|
|
37409
|
-
address:
|
|
37410
|
-
decimals:
|
|
37429
|
+
name: approvalGasFee.token.name ?? '',
|
|
37430
|
+
symbol: approvalGasFee.token.symbol ?? '',
|
|
37431
|
+
address: approvalGasFee.token.address,
|
|
37432
|
+
decimals: approvalGasFee.token.decimals,
|
|
37411
37433
|
};
|
|
37412
37434
|
}
|
|
37413
37435
|
let swapGasFeeAmount = ethers.BigNumber.from(0);
|
|
37414
37436
|
let swapGasFeeFormatted = '0';
|
|
37415
37437
|
let swapGasToken;
|
|
37416
|
-
if (
|
|
37417
|
-
swapGasFeeAmount =
|
|
37418
|
-
swapGasFeeFormatted = ethers.utils.formatUnits(
|
|
37438
|
+
if (swapGasFee) {
|
|
37439
|
+
swapGasFeeAmount = swapGasFee.value;
|
|
37440
|
+
swapGasFeeFormatted = ethers.utils.formatUnits(swapGasFee.value, swapGasFee.token.decimals);
|
|
37419
37441
|
swapGasToken = {
|
|
37420
|
-
name:
|
|
37421
|
-
symbol:
|
|
37422
|
-
address:
|
|
37423
|
-
decimals:
|
|
37442
|
+
name: swapGasFee.token.name ?? '',
|
|
37443
|
+
symbol: swapGasFee.token.symbol ?? '',
|
|
37444
|
+
address: swapGasFee.token.address,
|
|
37445
|
+
decimals: swapGasFee.token.decimals,
|
|
37424
37446
|
};
|
|
37425
37447
|
}
|
|
37426
37448
|
const fees = [];
|
|
37427
37449
|
for (const swapFee of swapFees) {
|
|
37428
37450
|
fees.push({
|
|
37451
|
+
type: FeeType.SWAP_FEE,
|
|
37429
37452
|
amount: swapFee.amount.value,
|
|
37430
37453
|
formattedAmount: ethers.utils.formatUnits(swapFee.amount.value, swapFee.amount.token.decimals),
|
|
37431
37454
|
token: {
|
|
@@ -37437,12 +37460,14 @@ const constructFees$1 = (approvalGasFees, swapGasFees, swapFees) => {
|
|
|
37437
37460
|
});
|
|
37438
37461
|
}
|
|
37439
37462
|
return {
|
|
37440
|
-
|
|
37463
|
+
approvalGasFee: {
|
|
37464
|
+
type: FeeType.GAS,
|
|
37441
37465
|
amount: approvalGasFeeAmount,
|
|
37442
37466
|
formattedAmount: approvalGasFeeFormatted,
|
|
37443
37467
|
token: approvalToken,
|
|
37444
37468
|
},
|
|
37445
|
-
|
|
37469
|
+
swapGasFee: {
|
|
37470
|
+
type: FeeType.GAS,
|
|
37446
37471
|
amount: swapGasFeeAmount,
|
|
37447
37472
|
formattedAmount: swapGasFeeFormatted,
|
|
37448
37473
|
token: swapGasToken,
|
|
@@ -37527,7 +37552,7 @@ const checkUserCanCoverApprovalFees = (l2Balances, approval) => {
|
|
|
37527
37552
|
// The user has enough to cover approval gas fees
|
|
37528
37553
|
return { sufficient: true, approvalGasFee, approvalGasTokenAddress };
|
|
37529
37554
|
};
|
|
37530
|
-
const checkUserCanCoverSwapFees = (l2Balances, approvalFees,
|
|
37555
|
+
const checkUserCanCoverSwapFees = (l2Balances, approvalFees, swapGasFee, swapFees, tokenBeingSwapped) => {
|
|
37531
37556
|
// Set up a map of token addresses to amounts for each of the swap fees
|
|
37532
37557
|
const feeMap = new Map();
|
|
37533
37558
|
// Add the approval fee to list of fees
|
|
@@ -37535,13 +37560,13 @@ const checkUserCanCoverSwapFees = (l2Balances, approvalFees, swapGasFees, swapFe
|
|
|
37535
37560
|
feeMap.set(approvalFees.approvalGasTokenAddress, approvalFees.approvalGasFee);
|
|
37536
37561
|
}
|
|
37537
37562
|
// Add the swap gas fee to list of fees
|
|
37538
|
-
if (
|
|
37539
|
-
const fee = feeMap.get(
|
|
37563
|
+
if (swapGasFee) {
|
|
37564
|
+
const fee = feeMap.get(swapGasFee.token.address);
|
|
37540
37565
|
if (fee) {
|
|
37541
|
-
feeMap.set(
|
|
37566
|
+
feeMap.set(swapGasFee.token.address, fee.add(swapGasFee.value));
|
|
37542
37567
|
}
|
|
37543
37568
|
else {
|
|
37544
|
-
feeMap.set(
|
|
37569
|
+
feeMap.set(swapGasFee.token.address, swapGasFee.value);
|
|
37545
37570
|
}
|
|
37546
37571
|
}
|
|
37547
37572
|
// Add the token being swapped to list of fees to ensure the user can cover the fee + the token swap
|
|
@@ -37795,31 +37820,39 @@ const hasSufficientL1Eth = (tokenBalanceResult, totalFees) => {
|
|
|
37795
37820
|
const balance = getEthBalance(tokenBalanceResult);
|
|
37796
37821
|
return balance.gte(totalFees);
|
|
37797
37822
|
};
|
|
37798
|
-
const constructFees = (
|
|
37823
|
+
const constructFees = (bridgeGasFee, bridgeFee, imtblFee, approvalGasFee, token) => {
|
|
37799
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
|
+
}
|
|
37800
37842
|
return {
|
|
37801
|
-
|
|
37802
|
-
|
|
37803
|
-
|
|
37843
|
+
approvalGasFee: {
|
|
37844
|
+
type: FeeType.GAS,
|
|
37845
|
+
amount: approvalGasFee,
|
|
37846
|
+
formattedAmount: ethers.utils.formatUnits(approvalGasFee, DEFAULT_TOKEN_DECIMALS$1),
|
|
37804
37847
|
token,
|
|
37805
37848
|
},
|
|
37806
|
-
|
|
37807
|
-
|
|
37808
|
-
|
|
37849
|
+
bridgeGasFee: {
|
|
37850
|
+
type: FeeType.GAS,
|
|
37851
|
+
amount: bridgeGasFee,
|
|
37852
|
+
formattedAmount: ethers.utils.formatUnits(bridgeGasFee, DEFAULT_TOKEN_DECIMALS$1),
|
|
37809
37853
|
token,
|
|
37810
37854
|
},
|
|
37811
|
-
bridgeFees
|
|
37812
|
-
{
|
|
37813
|
-
amount: bridgeFee,
|
|
37814
|
-
formattedAmount: ethers.utils.formatUnits(bridgeFee, bridgeFeeDecimals),
|
|
37815
|
-
token,
|
|
37816
|
-
},
|
|
37817
|
-
{
|
|
37818
|
-
amount: imtblFee,
|
|
37819
|
-
formattedAmount: ethers.utils.formatUnits(imtblFee, bridgeFeeDecimals),
|
|
37820
|
-
token,
|
|
37821
|
-
},
|
|
37822
|
-
],
|
|
37855
|
+
bridgeFees,
|
|
37823
37856
|
};
|
|
37824
37857
|
};
|
|
37825
37858
|
const constructBridgeFundingRoute = (chainId, balance, bridgeRequirement, itemType, fees) => ({
|
|
@@ -38678,13 +38711,13 @@ const calculateFees = (orderFees, weiAmount, decimals = 18) => {
|
|
|
38678
38711
|
return calculateFeesResult;
|
|
38679
38712
|
};
|
|
38680
38713
|
|
|
38681
|
-
const getItemRequirement = (type,
|
|
38714
|
+
const getItemRequirement = (type, tokenAddress, amount, spenderAddress) => {
|
|
38682
38715
|
switch (type) {
|
|
38683
38716
|
case ItemType.ERC20:
|
|
38684
38717
|
return {
|
|
38685
38718
|
type,
|
|
38686
38719
|
amount,
|
|
38687
|
-
|
|
38720
|
+
tokenAddress,
|
|
38688
38721
|
spenderAddress,
|
|
38689
38722
|
};
|
|
38690
38723
|
case ItemType.NATIVE:
|
|
@@ -38907,7 +38940,7 @@ const getBuyToken = (buyToken, decimals = 18) => {
|
|
|
38907
38940
|
return {
|
|
38908
38941
|
type: ItemType.ERC20,
|
|
38909
38942
|
amount: bnAmount.toString(),
|
|
38910
|
-
contractAddress: buyToken.
|
|
38943
|
+
contractAddress: buyToken.tokenAddress,
|
|
38911
38944
|
};
|
|
38912
38945
|
};
|
|
38913
38946
|
const sell = async (config, provider, orders) => {
|
|
@@ -38921,7 +38954,7 @@ const sell = async (config, provider, orders) => {
|
|
|
38921
38954
|
let decimals = 18;
|
|
38922
38955
|
if (buyToken.type === ItemType.ERC20) {
|
|
38923
38956
|
// get this from the allowed list
|
|
38924
|
-
const buyTokenContract = new ethers.Contract(buyToken.
|
|
38957
|
+
const buyTokenContract = new ethers.Contract(buyToken.tokenAddress, JSON.stringify(ERC20ABI), provider);
|
|
38925
38958
|
decimals = await measureAsyncExecution(config, 'Time to get decimals of token contract for the buy token', buyTokenContract.decimals());
|
|
38926
38959
|
}
|
|
38927
38960
|
const buyTokenOrNative = getBuyToken(buyToken, decimals);
|
|
@@ -39073,8 +39106,8 @@ async function getItemRequirementsFromRequirements(provider, requirements) {
|
|
|
39073
39106
|
const decimalPromises = [];
|
|
39074
39107
|
requirements.forEach((itemRequirementParam) => {
|
|
39075
39108
|
if (itemRequirementParam.type === ItemType.ERC20) {
|
|
39076
|
-
const {
|
|
39077
|
-
decimalPromises.push(getTokenContract(
|
|
39109
|
+
const { tokenAddress } = itemRequirementParam;
|
|
39110
|
+
decimalPromises.push(getTokenContract(tokenAddress, ERC20ABI, provider).decimals());
|
|
39078
39111
|
}
|
|
39079
39112
|
});
|
|
39080
39113
|
const decimals = await Promise.all(decimalPromises);
|
|
@@ -39389,7 +39422,7 @@ class Checkout {
|
|
|
39389
39422
|
try {
|
|
39390
39423
|
itemRequirements = await getItemRequirementsFromRequirements(web3Provider, params.itemRequirements);
|
|
39391
39424
|
}
|
|
39392
|
-
catch {
|
|
39425
|
+
catch (error) {
|
|
39393
39426
|
throw new CheckoutError('Failed to map item requirements', CheckoutErrorType.ITEM_REQUIREMENTS_ERROR);
|
|
39394
39427
|
}
|
|
39395
39428
|
return await smartCheckout(this.config, web3Provider, itemRequirements, params.transactionOrGasAmount);
|
|
@@ -39470,6 +39503,7 @@ var checkout = /*#__PURE__*/Object.freeze({
|
|
|
39470
39503
|
get ConnectEventType () { return ConnectEventType; },
|
|
39471
39504
|
get ConnectTargetLayer () { return ConnectTargetLayer; },
|
|
39472
39505
|
get ExchangeType () { return ExchangeType; },
|
|
39506
|
+
get FeeType () { return FeeType; },
|
|
39473
39507
|
get FundingStepType () { return FundingStepType; },
|
|
39474
39508
|
get GasEstimateType () { return GasEstimateType; },
|
|
39475
39509
|
get GasTokenType () { return GasTokenType; },
|
package/dist/index.d.ts
CHANGED
|
@@ -16183,7 +16183,7 @@ interface CreateListingParams {
|
|
|
16183
16183
|
}
|
|
16184
16184
|
type ListListingsParams = Omit<Parameters<typeof OrdersService.prototype.listListings>[0], 'chainName'>;
|
|
16185
16185
|
type ListTradesParams = Omit<Parameters<typeof OrdersService.prototype.listTrades>[0], 'chainName'>;
|
|
16186
|
-
declare enum FeeType {
|
|
16186
|
+
declare enum FeeType$1 {
|
|
16187
16187
|
MAKER_ECOSYSTEM = "MAKER_ECOSYSTEM",
|
|
16188
16188
|
TAKER_ECOSYSTEM = "TAKER_ECOSYSTEM",
|
|
16189
16189
|
PROTOCOL = "PROTOCOL",
|
|
@@ -16194,7 +16194,7 @@ interface FeeValue {
|
|
|
16194
16194
|
amount: string;
|
|
16195
16195
|
}
|
|
16196
16196
|
interface Fee$1 extends FeeValue {
|
|
16197
|
-
type: FeeType;
|
|
16197
|
+
type: FeeType$1;
|
|
16198
16198
|
}
|
|
16199
16199
|
declare enum TransactionPurpose {
|
|
16200
16200
|
APPROVAL = "APPROVAL",
|
|
@@ -16463,8 +16463,6 @@ type orderbook_d_CancelOrdersOnChainResponse = CancelOrdersOnChainResponse;
|
|
|
16463
16463
|
type orderbook_d_CreateListingParams = CreateListingParams;
|
|
16464
16464
|
type orderbook_d_ERC20Item = ERC20Item;
|
|
16465
16465
|
type orderbook_d_ERC721Item = ERC721Item;
|
|
16466
|
-
type orderbook_d_FeeType = FeeType;
|
|
16467
|
-
declare const orderbook_d_FeeType: typeof FeeType;
|
|
16468
16466
|
type orderbook_d_FeeValue = FeeValue;
|
|
16469
16467
|
type orderbook_d_FulfillBulkOrdersInsufficientBalanceResponse = FulfillBulkOrdersInsufficientBalanceResponse;
|
|
16470
16468
|
type orderbook_d_FulfillBulkOrdersResponse = FulfillBulkOrdersResponse;
|
|
@@ -16507,7 +16505,7 @@ declare namespace orderbook_d {
|
|
|
16507
16505
|
orderbook_d_ERC20Item as ERC20Item,
|
|
16508
16506
|
orderbook_d_ERC721Item as ERC721Item,
|
|
16509
16507
|
Fee$1 as Fee,
|
|
16510
|
-
|
|
16508
|
+
FeeType$1 as FeeType,
|
|
16511
16509
|
orderbook_d_FeeValue as FeeValue,
|
|
16512
16510
|
orderbook_d_FulfillBulkOrdersInsufficientBalanceResponse as FulfillBulkOrdersInsufficientBalanceResponse,
|
|
16513
16511
|
orderbook_d_FulfillBulkOrdersResponse as FulfillBulkOrdersResponse,
|
|
@@ -16846,15 +16844,15 @@ type NativeBuyToken = {
|
|
|
16846
16844
|
* Represents a ERC20 buy token
|
|
16847
16845
|
* @property {ItemType} type
|
|
16848
16846
|
* @property {string} amount
|
|
16849
|
-
* @property {string}
|
|
16847
|
+
* @property {string} tokenAddress
|
|
16850
16848
|
*/
|
|
16851
16849
|
type ERC20BuyToken = {
|
|
16852
16850
|
/** The type indicate this is a ERC20 token. */
|
|
16853
16851
|
type: ItemType.ERC20;
|
|
16854
16852
|
/** The amount of native token. */
|
|
16855
16853
|
amount: string;
|
|
16856
|
-
/** The
|
|
16857
|
-
|
|
16854
|
+
/** The token address of the ERC20. */
|
|
16855
|
+
tokenAddress: string;
|
|
16858
16856
|
};
|
|
16859
16857
|
/**
|
|
16860
16858
|
* The SellToken type
|
|
@@ -16895,16 +16893,16 @@ type NativeItemRequirement = {
|
|
|
16895
16893
|
/**
|
|
16896
16894
|
* Represents an ERC20 item requirement for a transaction.
|
|
16897
16895
|
* @property {ItemType.ERC20} type
|
|
16896
|
+
* @property {string} tokenAddress
|
|
16898
16897
|
* @property {string} amount
|
|
16899
|
-
* @property {string} contractAddress
|
|
16900
16898
|
* @property {string} spenderAddress
|
|
16901
16899
|
*/
|
|
16902
16900
|
type ERC20ItemRequirement = {
|
|
16903
16901
|
/** The type to indicate this is a ERC20 item requirement. */
|
|
16904
16902
|
type: ItemType.ERC20;
|
|
16903
|
+
/** The token address of the ERC20. */
|
|
16904
|
+
tokenAddress: string;
|
|
16905
16905
|
/** The amount of the item. */
|
|
16906
|
-
contractAddress: string;
|
|
16907
|
-
/** The contract address of the ERC20. */
|
|
16908
16906
|
amount: string;
|
|
16909
16907
|
/** The contract address of the approver. */
|
|
16910
16908
|
spenderAddress: string;
|
|
@@ -16998,14 +16996,14 @@ type NativeGas = {
|
|
|
16998
16996
|
/**
|
|
16999
16997
|
* Represents an ERC20 gas token.
|
|
17000
16998
|
* @property {GasTokenType} type
|
|
17001
|
-
* @property {string}
|
|
16999
|
+
* @property {string} tokenAddress
|
|
17002
17000
|
* @property {BigNumber} limit
|
|
17003
17001
|
*/
|
|
17004
17002
|
type ERC20Gas = {
|
|
17005
17003
|
/** The type to indicate this is an ERC20 gas token. */
|
|
17006
17004
|
type: GasTokenType.ERC20;
|
|
17007
|
-
/** The
|
|
17008
|
-
|
|
17005
|
+
/** The token address of the ERC20. */
|
|
17006
|
+
tokenAddress: string;
|
|
17009
17007
|
/** The gas limit. */
|
|
17010
17008
|
limit: BigNumber;
|
|
17011
17009
|
};
|
|
@@ -17113,6 +17111,8 @@ type FundingRoute = {
|
|
|
17113
17111
|
* @property {TokenInfo | undefined} token
|
|
17114
17112
|
*/
|
|
17115
17113
|
type Fee = {
|
|
17114
|
+
/** The type of fee */
|
|
17115
|
+
type: FeeType;
|
|
17116
17116
|
/** The amount of the fee */
|
|
17117
17117
|
amount: BigNumber;
|
|
17118
17118
|
/** The formatted amount of the fee */
|
|
@@ -17120,6 +17120,20 @@ type Fee = {
|
|
|
17120
17120
|
/** The token info for the fee */
|
|
17121
17121
|
token?: TokenInfo;
|
|
17122
17122
|
};
|
|
17123
|
+
/**
|
|
17124
|
+
* An enum representing the funding step types
|
|
17125
|
+
* @enum {string}
|
|
17126
|
+
* @property {string} GAS - If the fee is a gas fee.
|
|
17127
|
+
* @property {string} BRIDGE_FEE - If the fee is a bridge fee.
|
|
17128
|
+
* @property {string} SWAP_FEE - If the fee is a swap fee.
|
|
17129
|
+
* @property {string} IMMUTABLE_FEE - If the fee is an immutable fee.
|
|
17130
|
+
*/
|
|
17131
|
+
declare enum FeeType {
|
|
17132
|
+
GAS = "GAS",
|
|
17133
|
+
BRIDGE_FEE = "BRIDGE_FEE",
|
|
17134
|
+
SWAP_FEE = "SWAP_FEE",
|
|
17135
|
+
IMMUTABLE_FEE = "IMMUTABLE_FEE"
|
|
17136
|
+
}
|
|
17123
17137
|
type FundingStep = BridgeFundingStep | SwapFundingStep | OnRampFundingStep;
|
|
17124
17138
|
/**
|
|
17125
17139
|
* Represents a bridge funding route
|
|
@@ -17140,15 +17154,15 @@ type BridgeFundingStep = {
|
|
|
17140
17154
|
};
|
|
17141
17155
|
/**
|
|
17142
17156
|
* Represents the fees for a bridge funding step
|
|
17143
|
-
* @property {Fee}
|
|
17144
|
-
* @property {Fee}
|
|
17157
|
+
* @property {Fee} approvalGasFee
|
|
17158
|
+
* @property {Fee} bridgeGasFee
|
|
17145
17159
|
* @property {Fee[]} bridgeFees
|
|
17146
17160
|
*/
|
|
17147
17161
|
type BridgeFees = {
|
|
17148
|
-
/** The approval gas
|
|
17149
|
-
|
|
17150
|
-
/** The bridge gas
|
|
17151
|
-
|
|
17162
|
+
/** The approval gas fee for the bridge */
|
|
17163
|
+
approvalGasFee: Fee;
|
|
17164
|
+
/** The bridge gas fee for the bridge */
|
|
17165
|
+
bridgeGasFee: Fee;
|
|
17152
17166
|
/** Additional bridge fees for the bridge */
|
|
17153
17167
|
bridgeFees: Fee[];
|
|
17154
17168
|
};
|
|
@@ -17171,15 +17185,15 @@ type SwapFundingStep = {
|
|
|
17171
17185
|
};
|
|
17172
17186
|
/**
|
|
17173
17187
|
* Represents the fees for a swap funding step
|
|
17174
|
-
* @property {Fee}
|
|
17175
|
-
* @property {Fee}
|
|
17188
|
+
* @property {Fee} approvalGasFee
|
|
17189
|
+
* @property {Fee} swapGasFee
|
|
17176
17190
|
* @property {Fee[]} swapFees
|
|
17177
17191
|
*/
|
|
17178
17192
|
type SwapFees = {
|
|
17179
|
-
/** The approval gas
|
|
17180
|
-
|
|
17181
|
-
/** The swap gas
|
|
17182
|
-
|
|
17193
|
+
/** The approval gas fee for the swap */
|
|
17194
|
+
approvalGasFee: Fee;
|
|
17195
|
+
/** The swap gas fee for the swap */
|
|
17196
|
+
swapGasFee: Fee;
|
|
17183
17197
|
/** Additional swap fees for the swap */
|
|
17184
17198
|
swapFees: Fee[];
|
|
17185
17199
|
};
|
|
@@ -19022,6 +19036,8 @@ declare const checkout_d_ExchangeType: typeof ExchangeType;
|
|
|
19022
19036
|
type checkout_d_Fee = Fee;
|
|
19023
19037
|
type checkout_d_FeePercentage = FeePercentage;
|
|
19024
19038
|
type checkout_d_FeeToken = FeeToken;
|
|
19039
|
+
type checkout_d_FeeType = FeeType;
|
|
19040
|
+
declare const checkout_d_FeeType: typeof FeeType;
|
|
19025
19041
|
type checkout_d_FiatRampParams = FiatRampParams;
|
|
19026
19042
|
type checkout_d_FulfillmentTransaction = FulfillmentTransaction;
|
|
19027
19043
|
type checkout_d_FundingItem = FundingItem;
|
|
@@ -19213,6 +19229,7 @@ declare namespace checkout_d {
|
|
|
19213
19229
|
checkout_d_Fee as Fee,
|
|
19214
19230
|
checkout_d_FeePercentage as FeePercentage,
|
|
19215
19231
|
checkout_d_FeeToken as FeeToken,
|
|
19232
|
+
checkout_d_FeeType as FeeType,
|
|
19216
19233
|
checkout_d_FiatRampParams as FiatRampParams,
|
|
19217
19234
|
checkout_d_FulfillmentTransaction as FulfillmentTransaction,
|
|
19218
19235
|
checkout_d_FundingItem as FundingItem,
|