@imtbl/sdk 0.13.1-alpha → 0.13.1-alpha.1
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.js +2 -2
- package/dist/checkout_sdk.js +119 -6
- package/dist/checkout_widgets.js +1 -1
- package/dist/immutablex_client.js +1 -1
- package/dist/index.browser.js +8 -8
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +125 -10
- package/dist/index.d.ts +509 -91
- package/dist/index.js +125 -10
- package/dist/orderbook.d.ts +963 -71
- package/dist/orderbook.js +20 -3
- package/dist/passport.js +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2398,7 +2398,7 @@ class MultiRollupApiClients {
|
|
|
2398
2398
|
}
|
|
2399
2399
|
|
|
2400
2400
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
2401
|
-
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.13.1-alpha' };
|
|
2401
|
+
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.13.1-alpha.1' };
|
|
2402
2402
|
const createConfig = ({ basePath, headers, }) => {
|
|
2403
2403
|
if (!basePath.trim()) {
|
|
2404
2404
|
throw Error('basePath can not be empty');
|
|
@@ -2458,7 +2458,7 @@ class APIError extends Error {
|
|
|
2458
2458
|
|
|
2459
2459
|
/* eslint-disable implicit-arrow-linebreak */
|
|
2460
2460
|
const defaultHeaders = {
|
|
2461
|
-
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.13.1-alpha',
|
|
2461
|
+
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.13.1-alpha.1',
|
|
2462
2462
|
};
|
|
2463
2463
|
/**
|
|
2464
2464
|
* createAPIConfiguration to create a custom Configuration
|
|
@@ -2730,7 +2730,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
2730
2730
|
chainID,
|
|
2731
2731
|
coreContractAddress,
|
|
2732
2732
|
registrationContractAddress,
|
|
2733
|
-
sdkVersion: 'ts-immutable-sdk-0.13.1-alpha',
|
|
2733
|
+
sdkVersion: 'ts-immutable-sdk-0.13.1-alpha.1',
|
|
2734
2734
|
});
|
|
2735
2735
|
/**
|
|
2736
2736
|
* Sets `sdkVersion` at the time of build
|
|
@@ -9484,6 +9484,13 @@ var ProtocolData;
|
|
|
9484
9484
|
})(ProtocolData.order_type || (ProtocolData.order_type = {}));
|
|
9485
9485
|
})(ProtocolData || (ProtocolData = {}));
|
|
9486
9486
|
|
|
9487
|
+
var FeeType;
|
|
9488
|
+
(function (FeeType) {
|
|
9489
|
+
FeeType["MAKER_MARKETPLACE"] = "MAKER_MARKETPLACE";
|
|
9490
|
+
FeeType["TAKER_MARKETPLACE"] = "TAKER_MARKETPLACE";
|
|
9491
|
+
FeeType["PROTOCOL"] = "PROTOCOL";
|
|
9492
|
+
FeeType["ROYALTY"] = "ROYALTY";
|
|
9493
|
+
})(FeeType || (FeeType = {}));
|
|
9487
9494
|
var TransactionPurpose;
|
|
9488
9495
|
(function (TransactionPurpose) {
|
|
9489
9496
|
TransactionPurpose["APPROVAL"] = "APPROVAL";
|
|
@@ -9846,7 +9853,11 @@ class ImmutableApiClient {
|
|
|
9846
9853
|
contract_address: orderComponents.consideration[0].token,
|
|
9847
9854
|
},
|
|
9848
9855
|
],
|
|
9849
|
-
fees: makerFee ? [
|
|
9856
|
+
fees: makerFee ? [{
|
|
9857
|
+
amount: makerFee.amount,
|
|
9858
|
+
fee_type: makerFee.type,
|
|
9859
|
+
recipient: makerFee.recipient,
|
|
9860
|
+
}] : [],
|
|
9850
9861
|
end_time: new Date(parseInt(`${orderComponents.endTime.toString()}000`, 10)).toISOString(),
|
|
9851
9862
|
protocol_data: {
|
|
9852
9863
|
order_type: ProtocolData.order_type.FULL_RESTRICTED,
|
|
@@ -10019,7 +10030,13 @@ class Orderbook {
|
|
|
10019
10030
|
const fulfillmentDataRes = await this.apiClient.fulfillmentData([
|
|
10020
10031
|
{
|
|
10021
10032
|
order_id: listingId,
|
|
10022
|
-
fee: takerFee
|
|
10033
|
+
fee: takerFee
|
|
10034
|
+
? {
|
|
10035
|
+
amount: takerFee.amount,
|
|
10036
|
+
fee_type: takerFee.type,
|
|
10037
|
+
recipient: takerFee.recipient,
|
|
10038
|
+
}
|
|
10039
|
+
: undefined,
|
|
10023
10040
|
},
|
|
10024
10041
|
]);
|
|
10025
10042
|
if (fulfillmentDataRes.result.length !== 1) {
|
|
@@ -10065,6 +10082,8 @@ const constants = {
|
|
|
10065
10082
|
var orderbook = /*#__PURE__*/Object.freeze({
|
|
10066
10083
|
__proto__: null,
|
|
10067
10084
|
get ActionType () { return ActionType; },
|
|
10085
|
+
get FeeType () { return FeeType; },
|
|
10086
|
+
get OrderStatus () { return OrderStatus; },
|
|
10068
10087
|
Orderbook: Orderbook,
|
|
10069
10088
|
get SignablePurpose () { return SignablePurpose; },
|
|
10070
10089
|
get TransactionPurpose () { return TransactionPurpose; },
|
|
@@ -27886,9 +27905,39 @@ async function $2e7bf45a7c9a9570$export$942c8de7174809fc(params, readOnlyProvide
|
|
|
27886
27905
|
|
|
27887
27906
|
|
|
27888
27907
|
|
|
27908
|
+
const $ddc6bcd0896481e5$export$2fbfa41a4de56a89 = (erc20allowances, erc721allowances)=>{
|
|
27909
|
+
const aggregatedAllowances = [];
|
|
27910
|
+
if (!erc20allowances.sufficient) {
|
|
27911
|
+
for (const allowance of erc20allowances.allowances)if (!allowance.sufficient) aggregatedAllowances.push(allowance);
|
|
27912
|
+
}
|
|
27913
|
+
if (!erc721allowances.sufficient) {
|
|
27914
|
+
for (const allowance of erc721allowances.allowances)if (!allowance.sufficient) aggregatedAllowances.push(allowance);
|
|
27915
|
+
}
|
|
27916
|
+
return aggregatedAllowances;
|
|
27917
|
+
};
|
|
27918
|
+
|
|
27919
|
+
|
|
27889
27920
|
|
|
27890
27921
|
|
|
27891
|
-
const $
|
|
27922
|
+
const $074f75878f618031$export$84f303391caa056f = (itemRequirements)=>{
|
|
27923
|
+
const aggregatedMap = new Map();
|
|
27924
|
+
const aggregatedItemRequirements = [];
|
|
27925
|
+
itemRequirements.forEach((itemRequirement)=>{
|
|
27926
|
+
const { type: type } = itemRequirement;
|
|
27927
|
+
if (type !== ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE) {
|
|
27928
|
+
aggregatedItemRequirements.push(itemRequirement);
|
|
27929
|
+
return;
|
|
27930
|
+
}
|
|
27931
|
+
const { amount: amount } = itemRequirement;
|
|
27932
|
+
const aggregateItem = aggregatedMap.get(type);
|
|
27933
|
+
if (aggregateItem && aggregateItem.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE) aggregateItem.amount = (BigNumber$1).from(aggregateItem.amount).add(amount);
|
|
27934
|
+
else aggregatedMap.set(type, {
|
|
27935
|
+
...itemRequirement
|
|
27936
|
+
});
|
|
27937
|
+
});
|
|
27938
|
+
return aggregatedItemRequirements.concat(Array.from(aggregatedMap.values()));
|
|
27939
|
+
};
|
|
27940
|
+
const $074f75878f618031$export$1ede6278abcdf1cb = (itemRequirements)=>{
|
|
27892
27941
|
const aggregatedMap = new Map();
|
|
27893
27942
|
const aggregatedItemRequirements = [];
|
|
27894
27943
|
itemRequirements.forEach((itemRequirement)=>{
|
|
@@ -27907,7 +27956,7 @@ const $2499eab4caa6dc71$export$1ede6278abcdf1cb = (itemRequirements)=>{
|
|
|
27907
27956
|
});
|
|
27908
27957
|
return aggregatedItemRequirements.concat(Array.from(aggregatedMap.values()));
|
|
27909
27958
|
};
|
|
27910
|
-
const $
|
|
27959
|
+
const $074f75878f618031$export$fa1f577106a81103 = (itemRequirements)=>{
|
|
27911
27960
|
const aggregatedMap = new Map();
|
|
27912
27961
|
const aggregatedItemRequirements = [];
|
|
27913
27962
|
itemRequirements.forEach((itemRequirement)=>{
|
|
@@ -27925,7 +27974,9 @@ const $2499eab4caa6dc71$export$fa1f577106a81103 = (itemRequirements)=>{
|
|
|
27925
27974
|
});
|
|
27926
27975
|
return aggregatedItemRequirements.concat(Array.from(aggregatedMap.values()));
|
|
27927
27976
|
};
|
|
27928
|
-
const $
|
|
27977
|
+
const $074f75878f618031$export$c804c9ade5c28607 = (itemRequirements)=>$074f75878f618031$export$fa1f577106a81103($074f75878f618031$export$1ede6278abcdf1cb($074f75878f618031$export$84f303391caa056f(itemRequirements)));
|
|
27978
|
+
|
|
27979
|
+
|
|
27929
27980
|
|
|
27930
27981
|
|
|
27931
27982
|
|
|
@@ -28154,17 +28205,81 @@ const $35c3fc7013888ba5$export$be546c525d418988 = async (provider, ownerAddress,
|
|
|
28154
28205
|
|
|
28155
28206
|
|
|
28156
28207
|
|
|
28208
|
+
|
|
28209
|
+
|
|
28210
|
+
|
|
28211
|
+
|
|
28212
|
+
const $7d1bfafb81e64d74$var$doesChainSupportEIP1559 = (feeData)=>!!feeData.maxFeePerGas && !!feeData.maxPriorityFeePerGas;
|
|
28213
|
+
const $7d1bfafb81e64d74$var$getGasPriceInWei = (feeData)=>{
|
|
28214
|
+
if ($7d1bfafb81e64d74$var$doesChainSupportEIP1559(feeData)) return (BigNumber$1).from(feeData.maxFeePerGas).add((BigNumber$1).from(feeData.maxPriorityFeePerGas));
|
|
28215
|
+
if (feeData.gasPrice) return (BigNumber$1).from(feeData.gasPrice);
|
|
28216
|
+
return undefined;
|
|
28217
|
+
};
|
|
28218
|
+
const $7d1bfafb81e64d74$export$e0580ae1f48db848 = async (provider, transaction)=>{
|
|
28219
|
+
try {
|
|
28220
|
+
return await provider.estimateGas(transaction);
|
|
28221
|
+
} catch (err) {
|
|
28222
|
+
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Failed to estimate gas for transaction", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).UNPREDICTABLE_GAS_LIMIT);
|
|
28223
|
+
}
|
|
28224
|
+
};
|
|
28225
|
+
const $7d1bfafb81e64d74$export$c5e1b13f11e2e27f = (gas, transactionOrGas)=>{
|
|
28226
|
+
if (transactionOrGas.type === ($4b58188d47aafe8d$export$65c64e46348ee3c1).TRANSACTION || transactionOrGas.gasToken.type === ($4b58188d47aafe8d$export$537fa3efd10ed435).NATIVE) return {
|
|
28227
|
+
type: ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE,
|
|
28228
|
+
amount: gas
|
|
28229
|
+
};
|
|
28230
|
+
return {
|
|
28231
|
+
type: ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20,
|
|
28232
|
+
amount: gas,
|
|
28233
|
+
contractAddress: transactionOrGas.gasToken.contractAddress,
|
|
28234
|
+
spenderAddress: ""
|
|
28235
|
+
};
|
|
28236
|
+
};
|
|
28237
|
+
const $7d1bfafb81e64d74$export$3a4140bd9e983e4e = async (provider, insufficientItems, transactionOrGas)=>{
|
|
28238
|
+
const estimateGasPromises = [];
|
|
28239
|
+
let totalGas = (BigNumber$1).from(0);
|
|
28240
|
+
// Get all the gas estimate promises for the approval transactions
|
|
28241
|
+
for (const item of insufficientItems){
|
|
28242
|
+
if (item.approvalTransaction === undefined) continue;
|
|
28243
|
+
estimateGasPromises.push($7d1bfafb81e64d74$export$e0580ae1f48db848(provider, item.approvalTransaction));
|
|
28244
|
+
}
|
|
28245
|
+
// If the transaction is a fulfilment transaction get the estimate gas promise
|
|
28246
|
+
// Otherwise use the gas amount with the limit to estimate the gas
|
|
28247
|
+
if (transactionOrGas.type === ($4b58188d47aafe8d$export$65c64e46348ee3c1).TRANSACTION) estimateGasPromises.push($7d1bfafb81e64d74$export$e0580ae1f48db848(provider, transactionOrGas.transaction));
|
|
28248
|
+
else {
|
|
28249
|
+
const feeData = await provider.getFeeData();
|
|
28250
|
+
const gasPrice = $7d1bfafb81e64d74$var$getGasPriceInWei(feeData);
|
|
28251
|
+
const gas = gasPrice?.mul(transactionOrGas.gasToken.limit);
|
|
28252
|
+
if (gas) totalGas = totalGas.add(gas);
|
|
28253
|
+
}
|
|
28254
|
+
// Get the gas estimates for all the transactions and calculate the total gas
|
|
28255
|
+
const gasEstimatePromises = await Promise.all(estimateGasPromises);
|
|
28256
|
+
gasEstimatePromises.forEach((gasEstimate)=>{
|
|
28257
|
+
totalGas = totalGas.add(gasEstimate);
|
|
28258
|
+
});
|
|
28259
|
+
if (totalGas.eq(0)) return null;
|
|
28260
|
+
return $7d1bfafb81e64d74$export$c5e1b13f11e2e27f(totalGas, transactionOrGas);
|
|
28261
|
+
};
|
|
28262
|
+
|
|
28263
|
+
|
|
28157
28264
|
const $0e7419077c373b24$export$9e073f9ada8c81e6 = async (provider, itemRequirements, transactionOrGasAmount)=>{
|
|
28158
28265
|
// eslint-disable-next-line no-console
|
|
28159
28266
|
console.log(provider, itemRequirements, transactionOrGasAmount);
|
|
28160
28267
|
const ownerAddress = await provider.getSigner().getAddress();
|
|
28161
|
-
|
|
28268
|
+
let aggregatedItems = ($074f75878f618031$export$c804c9ade5c28607)(itemRequirements);
|
|
28162
28269
|
const erc20Allowances = await ($fc8b338399d890f3$export$d93c00812189e36)(provider, ownerAddress, aggregatedItems);
|
|
28163
28270
|
const erc721Allowances = await ($35c3fc7013888ba5$export$be546c525d418988)(provider, ownerAddress, aggregatedItems);
|
|
28164
28271
|
// eslint-disable-next-line no-console
|
|
28165
28272
|
console.log("ERC20 Allowances", erc20Allowances);
|
|
28166
28273
|
// eslint-disable-next-line no-console
|
|
28167
28274
|
console.log("ERC721 Allowances", erc721Allowances);
|
|
28275
|
+
const aggregatedAllowances = ($ddc6bcd0896481e5$export$2fbfa41a4de56a89)(erc20Allowances, erc721Allowances);
|
|
28276
|
+
const gasItem = await ($7d1bfafb81e64d74$export$3a4140bd9e983e4e)(provider, aggregatedAllowances, transactionOrGasAmount);
|
|
28277
|
+
if (gasItem !== null) {
|
|
28278
|
+
aggregatedItems.push(gasItem);
|
|
28279
|
+
aggregatedItems = ($074f75878f618031$export$c804c9ade5c28607)(aggregatedItems);
|
|
28280
|
+
}
|
|
28281
|
+
// eslint-disable-next-line no-console
|
|
28282
|
+
console.log("Aggregated Items", aggregatedItems);
|
|
28168
28283
|
return {
|
|
28169
28284
|
sufficient: true,
|
|
28170
28285
|
transactionRequirements: [
|
|
@@ -28493,7 +28608,7 @@ var checkout_sdk = /*#__PURE__*/Object.freeze({
|
|
|
28493
28608
|
function $parcel$export(e, n, v, s) {
|
|
28494
28609
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
28495
28610
|
}
|
|
28496
|
-
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.13.1-alpha";
|
|
28611
|
+
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.13.1-alpha.1";
|
|
28497
28612
|
const $d663162fd5a0853f$export$83bf90b30cdfd29f = ()=>false;
|
|
28498
28613
|
const $d663162fd5a0853f$export$1169f5475725171b = ()=>$d663162fd5a0853f$export$38a083d9fb5551ca;
|
|
28499
28614
|
|