@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/checkout_sdk.js
CHANGED
|
@@ -16186,6 +16186,13 @@ var ProtocolData;
|
|
|
16186
16186
|
})(ProtocolData.order_type || (ProtocolData.order_type = {}));
|
|
16187
16187
|
})(ProtocolData || (ProtocolData = {}));
|
|
16188
16188
|
|
|
16189
|
+
var FeeType;
|
|
16190
|
+
(function (FeeType) {
|
|
16191
|
+
FeeType["MAKER_MARKETPLACE"] = "MAKER_MARKETPLACE";
|
|
16192
|
+
FeeType["TAKER_MARKETPLACE"] = "TAKER_MARKETPLACE";
|
|
16193
|
+
FeeType["PROTOCOL"] = "PROTOCOL";
|
|
16194
|
+
FeeType["ROYALTY"] = "ROYALTY";
|
|
16195
|
+
})(FeeType || (FeeType = {}));
|
|
16189
16196
|
var TransactionPurpose;
|
|
16190
16197
|
(function (TransactionPurpose) {
|
|
16191
16198
|
TransactionPurpose["APPROVAL"] = "APPROVAL";
|
|
@@ -16548,7 +16555,11 @@ class ImmutableApiClient {
|
|
|
16548
16555
|
contract_address: orderComponents.consideration[0].token,
|
|
16549
16556
|
},
|
|
16550
16557
|
],
|
|
16551
|
-
fees: makerFee ? [
|
|
16558
|
+
fees: makerFee ? [{
|
|
16559
|
+
amount: makerFee.amount,
|
|
16560
|
+
fee_type: makerFee.type,
|
|
16561
|
+
recipient: makerFee.recipient,
|
|
16562
|
+
}] : [],
|
|
16552
16563
|
end_time: new Date(parseInt(`${orderComponents.endTime.toString()}000`, 10)).toISOString(),
|
|
16553
16564
|
protocol_data: {
|
|
16554
16565
|
order_type: ProtocolData.order_type.FULL_RESTRICTED,
|
|
@@ -16721,7 +16732,13 @@ class Orderbook {
|
|
|
16721
16732
|
const fulfillmentDataRes = await this.apiClient.fulfillmentData([
|
|
16722
16733
|
{
|
|
16723
16734
|
order_id: listingId,
|
|
16724
|
-
fee: takerFee
|
|
16735
|
+
fee: takerFee
|
|
16736
|
+
? {
|
|
16737
|
+
amount: takerFee.amount,
|
|
16738
|
+
fee_type: takerFee.type,
|
|
16739
|
+
recipient: takerFee.recipient,
|
|
16740
|
+
}
|
|
16741
|
+
: undefined,
|
|
16725
16742
|
},
|
|
16726
16743
|
]);
|
|
16727
16744
|
if (fulfillmentDataRes.result.length !== 1) {
|
|
@@ -17899,9 +17916,39 @@ async function $2e7bf45a7c9a9570$export$942c8de7174809fc(params, readOnlyProvide
|
|
|
17899
17916
|
|
|
17900
17917
|
|
|
17901
17918
|
|
|
17919
|
+
const $ddc6bcd0896481e5$export$2fbfa41a4de56a89 = (erc20allowances, erc721allowances)=>{
|
|
17920
|
+
const aggregatedAllowances = [];
|
|
17921
|
+
if (!erc20allowances.sufficient) {
|
|
17922
|
+
for (const allowance of erc20allowances.allowances)if (!allowance.sufficient) aggregatedAllowances.push(allowance);
|
|
17923
|
+
}
|
|
17924
|
+
if (!erc721allowances.sufficient) {
|
|
17925
|
+
for (const allowance of erc721allowances.allowances)if (!allowance.sufficient) aggregatedAllowances.push(allowance);
|
|
17926
|
+
}
|
|
17927
|
+
return aggregatedAllowances;
|
|
17928
|
+
};
|
|
17929
|
+
|
|
17930
|
+
|
|
17902
17931
|
|
|
17903
17932
|
|
|
17904
|
-
const $
|
|
17933
|
+
const $074f75878f618031$export$84f303391caa056f = (itemRequirements)=>{
|
|
17934
|
+
const aggregatedMap = new Map();
|
|
17935
|
+
const aggregatedItemRequirements = [];
|
|
17936
|
+
itemRequirements.forEach((itemRequirement)=>{
|
|
17937
|
+
const { type: type } = itemRequirement;
|
|
17938
|
+
if (type !== ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE) {
|
|
17939
|
+
aggregatedItemRequirements.push(itemRequirement);
|
|
17940
|
+
return;
|
|
17941
|
+
}
|
|
17942
|
+
const { amount: amount } = itemRequirement;
|
|
17943
|
+
const aggregateItem = aggregatedMap.get(type);
|
|
17944
|
+
if (aggregateItem && aggregateItem.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE) aggregateItem.amount = (BigNumber$1).from(aggregateItem.amount).add(amount);
|
|
17945
|
+
else aggregatedMap.set(type, {
|
|
17946
|
+
...itemRequirement
|
|
17947
|
+
});
|
|
17948
|
+
});
|
|
17949
|
+
return aggregatedItemRequirements.concat(Array.from(aggregatedMap.values()));
|
|
17950
|
+
};
|
|
17951
|
+
const $074f75878f618031$export$1ede6278abcdf1cb = (itemRequirements)=>{
|
|
17905
17952
|
const aggregatedMap = new Map();
|
|
17906
17953
|
const aggregatedItemRequirements = [];
|
|
17907
17954
|
itemRequirements.forEach((itemRequirement)=>{
|
|
@@ -17920,7 +17967,7 @@ const $2499eab4caa6dc71$export$1ede6278abcdf1cb = (itemRequirements)=>{
|
|
|
17920
17967
|
});
|
|
17921
17968
|
return aggregatedItemRequirements.concat(Array.from(aggregatedMap.values()));
|
|
17922
17969
|
};
|
|
17923
|
-
const $
|
|
17970
|
+
const $074f75878f618031$export$fa1f577106a81103 = (itemRequirements)=>{
|
|
17924
17971
|
const aggregatedMap = new Map();
|
|
17925
17972
|
const aggregatedItemRequirements = [];
|
|
17926
17973
|
itemRequirements.forEach((itemRequirement)=>{
|
|
@@ -17938,7 +17985,9 @@ const $2499eab4caa6dc71$export$fa1f577106a81103 = (itemRequirements)=>{
|
|
|
17938
17985
|
});
|
|
17939
17986
|
return aggregatedItemRequirements.concat(Array.from(aggregatedMap.values()));
|
|
17940
17987
|
};
|
|
17941
|
-
const $
|
|
17988
|
+
const $074f75878f618031$export$c804c9ade5c28607 = (itemRequirements)=>$074f75878f618031$export$fa1f577106a81103($074f75878f618031$export$1ede6278abcdf1cb($074f75878f618031$export$84f303391caa056f(itemRequirements)));
|
|
17989
|
+
|
|
17990
|
+
|
|
17942
17991
|
|
|
17943
17992
|
|
|
17944
17993
|
|
|
@@ -18167,17 +18216,81 @@ const $35c3fc7013888ba5$export$be546c525d418988 = async (provider, ownerAddress,
|
|
|
18167
18216
|
|
|
18168
18217
|
|
|
18169
18218
|
|
|
18219
|
+
|
|
18220
|
+
|
|
18221
|
+
|
|
18222
|
+
|
|
18223
|
+
const $7d1bfafb81e64d74$var$doesChainSupportEIP1559 = (feeData)=>!!feeData.maxFeePerGas && !!feeData.maxPriorityFeePerGas;
|
|
18224
|
+
const $7d1bfafb81e64d74$var$getGasPriceInWei = (feeData)=>{
|
|
18225
|
+
if ($7d1bfafb81e64d74$var$doesChainSupportEIP1559(feeData)) return (BigNumber$1).from(feeData.maxFeePerGas).add((BigNumber$1).from(feeData.maxPriorityFeePerGas));
|
|
18226
|
+
if (feeData.gasPrice) return (BigNumber$1).from(feeData.gasPrice);
|
|
18227
|
+
return undefined;
|
|
18228
|
+
};
|
|
18229
|
+
const $7d1bfafb81e64d74$export$e0580ae1f48db848 = async (provider, transaction)=>{
|
|
18230
|
+
try {
|
|
18231
|
+
return await provider.estimateGas(transaction);
|
|
18232
|
+
} catch (err) {
|
|
18233
|
+
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Failed to estimate gas for transaction", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).UNPREDICTABLE_GAS_LIMIT);
|
|
18234
|
+
}
|
|
18235
|
+
};
|
|
18236
|
+
const $7d1bfafb81e64d74$export$c5e1b13f11e2e27f = (gas, transactionOrGas)=>{
|
|
18237
|
+
if (transactionOrGas.type === ($4b58188d47aafe8d$export$65c64e46348ee3c1).TRANSACTION || transactionOrGas.gasToken.type === ($4b58188d47aafe8d$export$537fa3efd10ed435).NATIVE) return {
|
|
18238
|
+
type: ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE,
|
|
18239
|
+
amount: gas
|
|
18240
|
+
};
|
|
18241
|
+
return {
|
|
18242
|
+
type: ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20,
|
|
18243
|
+
amount: gas,
|
|
18244
|
+
contractAddress: transactionOrGas.gasToken.contractAddress,
|
|
18245
|
+
spenderAddress: ""
|
|
18246
|
+
};
|
|
18247
|
+
};
|
|
18248
|
+
const $7d1bfafb81e64d74$export$3a4140bd9e983e4e = async (provider, insufficientItems, transactionOrGas)=>{
|
|
18249
|
+
const estimateGasPromises = [];
|
|
18250
|
+
let totalGas = (BigNumber$1).from(0);
|
|
18251
|
+
// Get all the gas estimate promises for the approval transactions
|
|
18252
|
+
for (const item of insufficientItems){
|
|
18253
|
+
if (item.approvalTransaction === undefined) continue;
|
|
18254
|
+
estimateGasPromises.push($7d1bfafb81e64d74$export$e0580ae1f48db848(provider, item.approvalTransaction));
|
|
18255
|
+
}
|
|
18256
|
+
// If the transaction is a fulfilment transaction get the estimate gas promise
|
|
18257
|
+
// Otherwise use the gas amount with the limit to estimate the gas
|
|
18258
|
+
if (transactionOrGas.type === ($4b58188d47aafe8d$export$65c64e46348ee3c1).TRANSACTION) estimateGasPromises.push($7d1bfafb81e64d74$export$e0580ae1f48db848(provider, transactionOrGas.transaction));
|
|
18259
|
+
else {
|
|
18260
|
+
const feeData = await provider.getFeeData();
|
|
18261
|
+
const gasPrice = $7d1bfafb81e64d74$var$getGasPriceInWei(feeData);
|
|
18262
|
+
const gas = gasPrice?.mul(transactionOrGas.gasToken.limit);
|
|
18263
|
+
if (gas) totalGas = totalGas.add(gas);
|
|
18264
|
+
}
|
|
18265
|
+
// Get the gas estimates for all the transactions and calculate the total gas
|
|
18266
|
+
const gasEstimatePromises = await Promise.all(estimateGasPromises);
|
|
18267
|
+
gasEstimatePromises.forEach((gasEstimate)=>{
|
|
18268
|
+
totalGas = totalGas.add(gasEstimate);
|
|
18269
|
+
});
|
|
18270
|
+
if (totalGas.eq(0)) return null;
|
|
18271
|
+
return $7d1bfafb81e64d74$export$c5e1b13f11e2e27f(totalGas, transactionOrGas);
|
|
18272
|
+
};
|
|
18273
|
+
|
|
18274
|
+
|
|
18170
18275
|
const $0e7419077c373b24$export$9e073f9ada8c81e6 = async (provider, itemRequirements, transactionOrGasAmount)=>{
|
|
18171
18276
|
// eslint-disable-next-line no-console
|
|
18172
18277
|
console.log(provider, itemRequirements, transactionOrGasAmount);
|
|
18173
18278
|
const ownerAddress = await provider.getSigner().getAddress();
|
|
18174
|
-
|
|
18279
|
+
let aggregatedItems = ($074f75878f618031$export$c804c9ade5c28607)(itemRequirements);
|
|
18175
18280
|
const erc20Allowances = await ($fc8b338399d890f3$export$d93c00812189e36)(provider, ownerAddress, aggregatedItems);
|
|
18176
18281
|
const erc721Allowances = await ($35c3fc7013888ba5$export$be546c525d418988)(provider, ownerAddress, aggregatedItems);
|
|
18177
18282
|
// eslint-disable-next-line no-console
|
|
18178
18283
|
console.log("ERC20 Allowances", erc20Allowances);
|
|
18179
18284
|
// eslint-disable-next-line no-console
|
|
18180
18285
|
console.log("ERC721 Allowances", erc721Allowances);
|
|
18286
|
+
const aggregatedAllowances = ($ddc6bcd0896481e5$export$2fbfa41a4de56a89)(erc20Allowances, erc721Allowances);
|
|
18287
|
+
const gasItem = await ($7d1bfafb81e64d74$export$3a4140bd9e983e4e)(provider, aggregatedAllowances, transactionOrGasAmount);
|
|
18288
|
+
if (gasItem !== null) {
|
|
18289
|
+
aggregatedItems.push(gasItem);
|
|
18290
|
+
aggregatedItems = ($074f75878f618031$export$c804c9ade5c28607)(aggregatedItems);
|
|
18291
|
+
}
|
|
18292
|
+
// eslint-disable-next-line no-console
|
|
18293
|
+
console.log("Aggregated Items", aggregatedItems);
|
|
18181
18294
|
return {
|
|
18182
18295
|
sufficient: true,
|
|
18183
18296
|
transactionRequirements: [
|
package/dist/checkout_widgets.js
CHANGED
|
@@ -4,7 +4,7 @@ import { useEffect } from 'react';
|
|
|
4
4
|
function $parcel$export(e, n, v, s) {
|
|
5
5
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
6
6
|
}
|
|
7
|
-
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.13.1-alpha";
|
|
7
|
+
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.13.1-alpha.1";
|
|
8
8
|
const $d663162fd5a0853f$export$83bf90b30cdfd29f = ()=>false;
|
|
9
9
|
const $d663162fd5a0853f$export$1169f5475725171b = ()=>$d663162fd5a0853f$export$38a083d9fb5551ca;
|
|
10
10
|
|
|
@@ -16,7 +16,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
16
16
|
chainID,
|
|
17
17
|
coreContractAddress,
|
|
18
18
|
registrationContractAddress,
|
|
19
|
-
sdkVersion: 'ts-immutable-sdk-0.13.1-alpha',
|
|
19
|
+
sdkVersion: 'ts-immutable-sdk-0.13.1-alpha.1',
|
|
20
20
|
});
|
|
21
21
|
/**
|
|
22
22
|
* Sets `sdkVersion` at the time of build
|