@imtbl/sdk 0.14.0-alpha.1 → 0.14.0-alpha.2
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.d.ts +2 -0
- package/dist/checkout_sdk.js +406 -89
- package/dist/checkout_widgets.js +1 -1
- package/dist/immutablex_client.js +1 -1
- package/dist/index.browser.js +7 -7
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +410 -93
- package/dist/index.d.ts +8 -0
- package/dist/index.js +410 -93
- package/dist/orderbook.d.ts +6 -0
- package/dist/orderbook.js +72 -62
- 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.14.0-alpha.
|
|
2401
|
+
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.14.0-alpha.2' };
|
|
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.14.0-alpha.
|
|
2461
|
+
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.14.0-alpha.2',
|
|
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.14.0-alpha.
|
|
2733
|
+
sdkVersion: 'ts-immutable-sdk-0.14.0-alpha.2',
|
|
2734
2734
|
});
|
|
2735
2735
|
/**
|
|
2736
2736
|
* Sets `sdkVersion` at the time of build
|
|
@@ -9506,6 +9506,67 @@ var ActionType;
|
|
|
9506
9506
|
ActionType["SIGNABLE"] = "SIGNABLE";
|
|
9507
9507
|
})(ActionType || (ActionType = {}));
|
|
9508
9508
|
|
|
9509
|
+
function mapFromOpenApiOrder(order) {
|
|
9510
|
+
const buyItems = order.buy.map((item) => {
|
|
9511
|
+
if (item.item_type === 'ERC20') {
|
|
9512
|
+
return {
|
|
9513
|
+
type: 'ERC20',
|
|
9514
|
+
contractAddress: item.contract_address,
|
|
9515
|
+
amount: item.start_amount,
|
|
9516
|
+
};
|
|
9517
|
+
}
|
|
9518
|
+
if (item.item_type === 'NATIVE') {
|
|
9519
|
+
return {
|
|
9520
|
+
type: 'NATIVE',
|
|
9521
|
+
amount: item.start_amount,
|
|
9522
|
+
};
|
|
9523
|
+
}
|
|
9524
|
+
throw new Error('Buy items must be either ERC20 or NATIVE');
|
|
9525
|
+
});
|
|
9526
|
+
const sellItems = order.sell.map((item) => {
|
|
9527
|
+
if (item.item_type === 'ERC721') {
|
|
9528
|
+
return {
|
|
9529
|
+
type: 'ERC721',
|
|
9530
|
+
contractAddress: item.contract_address,
|
|
9531
|
+
tokenId: item.token_id,
|
|
9532
|
+
};
|
|
9533
|
+
}
|
|
9534
|
+
throw new Error('Sell items must ERC721');
|
|
9535
|
+
});
|
|
9536
|
+
return {
|
|
9537
|
+
id: order.id,
|
|
9538
|
+
accountAddress: order.account_address,
|
|
9539
|
+
buy: buyItems,
|
|
9540
|
+
sell: sellItems,
|
|
9541
|
+
fees: order.fees.map((fee) => ({
|
|
9542
|
+
amount: fee.amount,
|
|
9543
|
+
recipient: fee.recipient,
|
|
9544
|
+
type: fee.fee_type,
|
|
9545
|
+
})),
|
|
9546
|
+
chain: order.chain,
|
|
9547
|
+
createTime: order.create_time,
|
|
9548
|
+
endTime: order.end_time,
|
|
9549
|
+
protocolData: {
|
|
9550
|
+
counter: order.protocol_data.counter,
|
|
9551
|
+
orderType: order.protocol_data.order_type,
|
|
9552
|
+
seaportAddress: order.protocol_data.seaport_address,
|
|
9553
|
+
seaportVersion: order.protocol_data.seaport_version,
|
|
9554
|
+
zoneAddress: order.protocol_data.zone_address,
|
|
9555
|
+
},
|
|
9556
|
+
salt: order.salt,
|
|
9557
|
+
signature: order.signature,
|
|
9558
|
+
startTime: order.start_time,
|
|
9559
|
+
status: order.status,
|
|
9560
|
+
updateTime: order.update_time,
|
|
9561
|
+
};
|
|
9562
|
+
}
|
|
9563
|
+
function mapFromOpenApiPage(page) {
|
|
9564
|
+
return {
|
|
9565
|
+
nextCursor: page.next_cursor,
|
|
9566
|
+
previousCursor: page.previous_cursor,
|
|
9567
|
+
};
|
|
9568
|
+
}
|
|
9569
|
+
|
|
9509
9570
|
/* eslint-disable */
|
|
9510
9571
|
// TODO: Resolve these from seaport-js.
|
|
9511
9572
|
// There is some bundling issue that is preventing this from working
|
|
@@ -9735,7 +9796,17 @@ class Seaport {
|
|
|
9735
9796
|
buildTransaction: prepareTransaction(fulfilOrderAction.transactionMethods),
|
|
9736
9797
|
purpose: TransactionPurpose.FULFILL_ORDER,
|
|
9737
9798
|
});
|
|
9738
|
-
|
|
9799
|
+
// Expirtaion bytes in SIP7 extra data [21:29]
|
|
9800
|
+
// In hex string -> [21 * 2 + 2 (0x) : 29 * 2]
|
|
9801
|
+
// In JS slice (start, end_inclusive), (44,60)
|
|
9802
|
+
// 8 bytes uint64 epoch time in seconds
|
|
9803
|
+
const expirationHex = extraData.slice(44, 60);
|
|
9804
|
+
const expirationInSeconds = parseInt(expirationHex, 16);
|
|
9805
|
+
return {
|
|
9806
|
+
actions: fulfillmentActions,
|
|
9807
|
+
expiration: (new Date(expirationInSeconds * 1000)).toISOString(),
|
|
9808
|
+
order: mapFromOpenApiOrder(order),
|
|
9809
|
+
};
|
|
9739
9810
|
}
|
|
9740
9811
|
async cancelOrder(order, account) {
|
|
9741
9812
|
const { orderComponents } = this.mapImmutableOrderToSeaportOrderComponents(order);
|
|
@@ -9924,67 +9995,6 @@ function getOrderbookConfig(environment) {
|
|
|
9924
9995
|
}
|
|
9925
9996
|
}
|
|
9926
9997
|
|
|
9927
|
-
function mapFromOpenApiOrder(order) {
|
|
9928
|
-
const buyItems = order.buy.map((item) => {
|
|
9929
|
-
if (item.item_type === 'ERC20') {
|
|
9930
|
-
return {
|
|
9931
|
-
type: 'ERC20',
|
|
9932
|
-
contractAddress: item.contract_address,
|
|
9933
|
-
amount: item.start_amount,
|
|
9934
|
-
};
|
|
9935
|
-
}
|
|
9936
|
-
if (item.item_type === 'NATIVE') {
|
|
9937
|
-
return {
|
|
9938
|
-
type: 'NATIVE',
|
|
9939
|
-
amount: item.start_amount,
|
|
9940
|
-
};
|
|
9941
|
-
}
|
|
9942
|
-
throw new Error('Buy items must be either ERC20 or NATIVE');
|
|
9943
|
-
});
|
|
9944
|
-
const sellItems = order.sell.map((item) => {
|
|
9945
|
-
if (item.item_type === 'ERC721') {
|
|
9946
|
-
return {
|
|
9947
|
-
type: 'ERC721',
|
|
9948
|
-
contractAddress: item.contract_address,
|
|
9949
|
-
tokenId: item.token_id,
|
|
9950
|
-
};
|
|
9951
|
-
}
|
|
9952
|
-
throw new Error('Sell items must ERC721');
|
|
9953
|
-
});
|
|
9954
|
-
return {
|
|
9955
|
-
id: order.id,
|
|
9956
|
-
accountAddress: order.account_address,
|
|
9957
|
-
buy: buyItems,
|
|
9958
|
-
sell: sellItems,
|
|
9959
|
-
fees: order.fees.map((fee) => ({
|
|
9960
|
-
amount: fee.amount,
|
|
9961
|
-
recipient: fee.recipient,
|
|
9962
|
-
type: fee.fee_type,
|
|
9963
|
-
})),
|
|
9964
|
-
chain: order.chain,
|
|
9965
|
-
createTime: order.create_time,
|
|
9966
|
-
endTime: order.end_time,
|
|
9967
|
-
protocolData: {
|
|
9968
|
-
counter: order.protocol_data.counter,
|
|
9969
|
-
orderType: order.protocol_data.order_type,
|
|
9970
|
-
seaportAddress: order.protocol_data.seaport_address,
|
|
9971
|
-
seaportVersion: order.protocol_data.seaport_version,
|
|
9972
|
-
zoneAddress: order.protocol_data.zone_address,
|
|
9973
|
-
},
|
|
9974
|
-
salt: order.salt,
|
|
9975
|
-
signature: order.signature,
|
|
9976
|
-
startTime: order.start_time,
|
|
9977
|
-
status: order.status,
|
|
9978
|
-
updateTime: order.update_time,
|
|
9979
|
-
};
|
|
9980
|
-
}
|
|
9981
|
-
function mapFromOpenApiPage(page) {
|
|
9982
|
-
return {
|
|
9983
|
-
nextCursor: page.next_cursor,
|
|
9984
|
-
previousCursor: page.previous_cursor,
|
|
9985
|
-
};
|
|
9986
|
-
}
|
|
9987
|
-
|
|
9988
9998
|
class SeaportLibFactory {
|
|
9989
9999
|
defaultSeaportContractAddress;
|
|
9990
10000
|
provider;
|
|
@@ -26917,6 +26927,8 @@ const $e768639828688ca3$export$44dde05038008549 = {
|
|
|
26917
26927
|
|
|
26918
26928
|
|
|
26919
26929
|
const $d85ad1457a3f1a83$export$7d3a9eeba384fa59 = "development";
|
|
26930
|
+
const $d85ad1457a3f1a83$export$b80040cb173ba6e9 = "0x0000000000000000000000000000000000001010";
|
|
26931
|
+
const $d85ad1457a3f1a83$export$903389470ba9433c = 18;
|
|
26920
26932
|
const $d85ad1457a3f1a83$export$161d4a74df65fc08 = {
|
|
26921
26933
|
[$d85ad1457a3f1a83$export$7d3a9eeba384fa59]: "https://checkout-api.dev.immutable.com",
|
|
26922
26934
|
[(Environment$1).SANDBOX]: "https://checkout-api.sandbox.immutable.com",
|
|
@@ -27199,6 +27211,25 @@ const $d85ad1457a3f1a83$export$8b8be7a2a654f23e = [
|
|
|
27199
27211
|
payable: false,
|
|
27200
27212
|
stateMutability: "view",
|
|
27201
27213
|
type: "function"
|
|
27214
|
+
},
|
|
27215
|
+
{
|
|
27216
|
+
inputs: [
|
|
27217
|
+
{
|
|
27218
|
+
internalType: "uint256",
|
|
27219
|
+
name: "tokenId",
|
|
27220
|
+
type: "uint256"
|
|
27221
|
+
}
|
|
27222
|
+
],
|
|
27223
|
+
name: "ownerOf",
|
|
27224
|
+
outputs: [
|
|
27225
|
+
{
|
|
27226
|
+
internalType: "address",
|
|
27227
|
+
name: "",
|
|
27228
|
+
type: "address"
|
|
27229
|
+
}
|
|
27230
|
+
],
|
|
27231
|
+
stateMutability: "view",
|
|
27232
|
+
type: "function"
|
|
27202
27233
|
}
|
|
27203
27234
|
];
|
|
27204
27235
|
|
|
@@ -27240,6 +27271,7 @@ var $4b58188d47aafe8d$export$5d3b0ad129b9b98e;
|
|
|
27240
27271
|
CheckoutErrorType["CONNECT_PROVIDER_ERROR"] = "CONNECT_PROVIDER_ERROR";
|
|
27241
27272
|
CheckoutErrorType["GET_BALANCE_ERROR"] = "GET_BALANCE_ERROR";
|
|
27242
27273
|
CheckoutErrorType["GET_ERC20_BALANCE_ERROR"] = "GET_ERC20_BALANCE_ERROR";
|
|
27274
|
+
CheckoutErrorType["GET_ERC721_BALANCE_ERROR"] = "GET_ERC721_BALANCE_ERROR";
|
|
27243
27275
|
CheckoutErrorType["GET_NETWORK_INFO_ERROR"] = "GET_NETWORK_INFO_ERROR";
|
|
27244
27276
|
CheckoutErrorType["METAMASK_PROVIDER_ERROR"] = "METAMASK_PROVIDER_ERROR";
|
|
27245
27277
|
CheckoutErrorType["CHAIN_NOT_SUPPORTED_ERROR"] = "CHAIN_NOT_SUPPORTED_ERROR";
|
|
@@ -27251,6 +27283,7 @@ var $4b58188d47aafe8d$export$5d3b0ad129b9b98e;
|
|
|
27251
27283
|
CheckoutErrorType["UNPREDICTABLE_GAS_LIMIT"] = "UNPREDICTABLE_GAS_LIMIT";
|
|
27252
27284
|
CheckoutErrorType["INVALID_GAS_ESTIMATE_TYPE"] = "INVALID_GAS_ESTIMATE_TYPE";
|
|
27253
27285
|
CheckoutErrorType["UNSUPPORTED_TOKEN_TYPE_ERROR"] = "UNSUPPORTED_TOKEN_TYPE_ERROR";
|
|
27286
|
+
CheckoutErrorType["UNSUPPORTED_BALANCE_REQUIREMENT_ERROR"] = "UNSUPPORTED_BALANCE_REQUIREMENT_ERROR";
|
|
27254
27287
|
CheckoutErrorType["GET_ORDER_LISTING_ERROR"] = "GET_ORDER_LISTING_ERROR";
|
|
27255
27288
|
CheckoutErrorType["SWITCH_NETWORK_UNSUPPORTED"] = "SWITCH_NETWORK_UNSUPPORTED";
|
|
27256
27289
|
CheckoutErrorType["GET_ERC20_ALLOWANCE_ERROR"] = "GET_ERC20_ALLOWANCE_ERROR";
|
|
@@ -27472,39 +27505,48 @@ const $1564e43dde50bb61$export$df96cd8d56be0ab1 = async (config, web3Provider, w
|
|
|
27472
27505
|
async function $1564e43dde50bb61$export$60e0fe116a0e6ed0(web3Provider, walletAddress, contractAddress) {
|
|
27473
27506
|
return await ($a8bc256d81a5e2c1$export$bacc563de539c6c3)(async ()=>{
|
|
27474
27507
|
const contract = new (Contract$1)(contractAddress, JSON.stringify(($d85ad1457a3f1a83$export$db5daa1b5156ccfe)), web3Provider);
|
|
27475
|
-
|
|
27476
|
-
|
|
27477
|
-
|
|
27478
|
-
|
|
27479
|
-
|
|
27480
|
-
|
|
27481
|
-
|
|
27482
|
-
|
|
27483
|
-
|
|
27484
|
-
|
|
27485
|
-
|
|
27486
|
-
|
|
27487
|
-
|
|
27488
|
-
|
|
27489
|
-
|
|
27508
|
+
return Promise.all([
|
|
27509
|
+
contract.name(),
|
|
27510
|
+
contract.symbol(),
|
|
27511
|
+
contract.balanceOf(walletAddress),
|
|
27512
|
+
contract.decimals()
|
|
27513
|
+
]).then(([name, symbol, balance, decimals])=>{
|
|
27514
|
+
const formattedBalance = (utils$1).formatUnits(balance, decimals);
|
|
27515
|
+
return {
|
|
27516
|
+
balance: balance,
|
|
27517
|
+
formattedBalance: formattedBalance,
|
|
27518
|
+
token: {
|
|
27519
|
+
name: name,
|
|
27520
|
+
symbol: symbol,
|
|
27521
|
+
decimals: decimals,
|
|
27522
|
+
address: contractAddress
|
|
27523
|
+
}
|
|
27524
|
+
};
|
|
27525
|
+
});
|
|
27490
27526
|
}, {
|
|
27491
27527
|
type: ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_ERC20_BALANCE_ERROR
|
|
27492
27528
|
});
|
|
27493
27529
|
}
|
|
27494
|
-
const $1564e43dde50bb61$export$
|
|
27495
|
-
const tokenList = await ($efe60cea83bfc4e8$export$473cec51305fdae8)(config, {
|
|
27496
|
-
type: ($08d5ddc39acd6833$export$fd9b17d87f4121d2).ALL,
|
|
27497
|
-
chainId: chainId
|
|
27498
|
-
});
|
|
27530
|
+
const $1564e43dde50bb61$export$a3238cee431627c6 = async (config, web3Provider, walletAddress, tokens)=>{
|
|
27499
27531
|
const allBalancePromises = [];
|
|
27500
|
-
|
|
27501
|
-
|
|
27532
|
+
tokens.forEach((token)=>{
|
|
27533
|
+
// Check for NATIVE token
|
|
27534
|
+
if (!token.address || token.address === ($d85ad1457a3f1a83$export$b80040cb173ba6e9)) allBalancePromises.push($1564e43dde50bb61$export$df96cd8d56be0ab1(config, web3Provider, walletAddress));
|
|
27535
|
+
else allBalancePromises.push($1564e43dde50bb61$export$60e0fe116a0e6ed0(web3Provider, walletAddress, token.address));
|
|
27536
|
+
});
|
|
27502
27537
|
const balanceResults = await Promise.allSettled(allBalancePromises);
|
|
27503
|
-
const
|
|
27538
|
+
const balances = balanceResults.filter((result)=>result.status === "fulfilled").map((fulfilledResult)=>fulfilledResult.value);
|
|
27504
27539
|
return {
|
|
27505
|
-
balances:
|
|
27540
|
+
balances: balances
|
|
27506
27541
|
};
|
|
27507
27542
|
};
|
|
27543
|
+
const $1564e43dde50bb61$export$fee49741664a4d7e = async (config, web3Provider, walletAddress, chainId)=>{
|
|
27544
|
+
const { tokens: tokens } = await ($efe60cea83bfc4e8$export$473cec51305fdae8)(config, {
|
|
27545
|
+
type: ($08d5ddc39acd6833$export$fd9b17d87f4121d2).ALL,
|
|
27546
|
+
chainId: chainId
|
|
27547
|
+
});
|
|
27548
|
+
return await $1564e43dde50bb61$export$a3238cee431627c6(config, web3Provider, walletAddress, tokens);
|
|
27549
|
+
};
|
|
27508
27550
|
|
|
27509
27551
|
|
|
27510
27552
|
|
|
@@ -28253,6 +28295,278 @@ const $35c3fc7013888ba5$export$be546c525d418988 = async (provider, ownerAddress,
|
|
|
28253
28295
|
|
|
28254
28296
|
|
|
28255
28297
|
|
|
28298
|
+
/* eslint-disable arrow-body-style */
|
|
28299
|
+
|
|
28300
|
+
|
|
28301
|
+
|
|
28302
|
+
|
|
28303
|
+
|
|
28304
|
+
const $aa6caea9a60d18c7$export$f4d35754ad350071 = (itemRequirements)=>{
|
|
28305
|
+
const aggregatedMap = new Map();
|
|
28306
|
+
const aggregatedItemRequirements = [];
|
|
28307
|
+
itemRequirements.forEach((itemRequirement)=>{
|
|
28308
|
+
const { type: type } = itemRequirement;
|
|
28309
|
+
if (type !== ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE) {
|
|
28310
|
+
aggregatedItemRequirements.push(itemRequirement);
|
|
28311
|
+
return;
|
|
28312
|
+
}
|
|
28313
|
+
const { amount: amount } = itemRequirement;
|
|
28314
|
+
const aggregateItem = aggregatedMap.get(type);
|
|
28315
|
+
if (aggregateItem && aggregateItem.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE) aggregateItem.amount = (BigNumber$1).from(aggregateItem.amount).add(amount);
|
|
28316
|
+
else aggregatedMap.set(type, {
|
|
28317
|
+
...itemRequirement
|
|
28318
|
+
});
|
|
28319
|
+
});
|
|
28320
|
+
return aggregatedItemRequirements.concat(Array.from(aggregatedMap.values()));
|
|
28321
|
+
};
|
|
28322
|
+
const $aa6caea9a60d18c7$export$b8de545554d50911 = (itemRequirements)=>{
|
|
28323
|
+
const aggregatedMap = new Map();
|
|
28324
|
+
const aggregatedItemRequirements = [];
|
|
28325
|
+
itemRequirements.forEach((itemRequirement)=>{
|
|
28326
|
+
const { type: type } = itemRequirement;
|
|
28327
|
+
if (type !== ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20) {
|
|
28328
|
+
aggregatedItemRequirements.push(itemRequirement);
|
|
28329
|
+
return;
|
|
28330
|
+
}
|
|
28331
|
+
const { contractAddress: contractAddress, amount: amount } = itemRequirement;
|
|
28332
|
+
const key = `${contractAddress}`;
|
|
28333
|
+
const aggregateItem = aggregatedMap.get(key);
|
|
28334
|
+
if (aggregateItem && aggregateItem.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20) aggregateItem.amount = (BigNumber$1).from(aggregateItem.amount).add(amount);
|
|
28335
|
+
else aggregatedMap.set(key, {
|
|
28336
|
+
...itemRequirement
|
|
28337
|
+
});
|
|
28338
|
+
});
|
|
28339
|
+
return aggregatedItemRequirements.concat(Array.from(aggregatedMap.values()));
|
|
28340
|
+
};
|
|
28341
|
+
const $aa6caea9a60d18c7$export$74fbc29ef48b4f31 = (itemRequirements)=>{
|
|
28342
|
+
const aggregatedMap = new Map();
|
|
28343
|
+
const aggregatedItemRequirements = [];
|
|
28344
|
+
itemRequirements.forEach((itemRequirement)=>{
|
|
28345
|
+
const { type: type } = itemRequirement;
|
|
28346
|
+
if (type !== ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC721) {
|
|
28347
|
+
aggregatedItemRequirements.push(itemRequirement);
|
|
28348
|
+
return;
|
|
28349
|
+
}
|
|
28350
|
+
const { contractAddress: contractAddress, id: id } = itemRequirement;
|
|
28351
|
+
const key = `${contractAddress}${id}`;
|
|
28352
|
+
const aggregateItem = aggregatedMap.get(key);
|
|
28353
|
+
if (!aggregateItem) aggregatedMap.set(key, {
|
|
28354
|
+
...itemRequirement
|
|
28355
|
+
});
|
|
28356
|
+
});
|
|
28357
|
+
return aggregatedItemRequirements.concat(Array.from(aggregatedMap.values()));
|
|
28358
|
+
};
|
|
28359
|
+
const $aa6caea9a60d18c7$export$f96d1c819a615a64 = (itemRequirements)=>$aa6caea9a60d18c7$export$74fbc29ef48b4f31($aa6caea9a60d18c7$export$b8de545554d50911($aa6caea9a60d18c7$export$f4d35754ad350071(itemRequirements)));
|
|
28360
|
+
|
|
28361
|
+
|
|
28362
|
+
/* eslint-disable arrow-body-style */
|
|
28363
|
+
|
|
28364
|
+
const $73d2282a108cc7e2$export$ed7929b58bab85da = (itemRequirements)=>itemRequirements.map((itemRequirement)=>{
|
|
28365
|
+
if (itemRequirement.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE) return {
|
|
28366
|
+
name: "IMX",
|
|
28367
|
+
symbol: "IMX",
|
|
28368
|
+
address: ($d85ad1457a3f1a83$export$b80040cb173ba6e9)
|
|
28369
|
+
};
|
|
28370
|
+
return {
|
|
28371
|
+
name: itemRequirement.type,
|
|
28372
|
+
address: itemRequirement.contractAddress
|
|
28373
|
+
};
|
|
28374
|
+
});
|
|
28375
|
+
const $73d2282a108cc7e2$export$9b757e40b19984c3 = (itemRequirement, balances)=>{
|
|
28376
|
+
const requiredBalance = (BigNumber$1).from(1);
|
|
28377
|
+
// Find the requirements related balance
|
|
28378
|
+
const itemBalanceResult = balances.find((balance)=>{
|
|
28379
|
+
const balanceERC721Result = balance;
|
|
28380
|
+
return balanceERC721Result.contractAddress === itemRequirement.contractAddress && balanceERC721Result.id === itemRequirement.id;
|
|
28381
|
+
});
|
|
28382
|
+
// Calculate the balance delta
|
|
28383
|
+
const sufficient = requiredBalance.isNegative() || requiredBalance.isZero() || (itemBalanceResult?.balance.gte(requiredBalance) ?? false);
|
|
28384
|
+
const delta = requiredBalance.sub(itemBalanceResult?.balance ?? (BigNumber$1).from(0));
|
|
28385
|
+
let erc721BalanceResult = itemBalanceResult;
|
|
28386
|
+
if (!erc721BalanceResult) erc721BalanceResult = {
|
|
28387
|
+
balance: (BigNumber$1).from(0),
|
|
28388
|
+
formattedBalance: "0",
|
|
28389
|
+
contractAddress: itemRequirement.contractAddress,
|
|
28390
|
+
id: itemRequirement.id
|
|
28391
|
+
};
|
|
28392
|
+
return {
|
|
28393
|
+
sufficient: sufficient,
|
|
28394
|
+
type: itemRequirement.type,
|
|
28395
|
+
delta: {
|
|
28396
|
+
balance: delta,
|
|
28397
|
+
formattedBalance: delta.toString()
|
|
28398
|
+
},
|
|
28399
|
+
current: erc721BalanceResult,
|
|
28400
|
+
required: {
|
|
28401
|
+
...erc721BalanceResult,
|
|
28402
|
+
balance: (BigNumber$1).from(1),
|
|
28403
|
+
formattedBalance: "1"
|
|
28404
|
+
}
|
|
28405
|
+
};
|
|
28406
|
+
};
|
|
28407
|
+
const $73d2282a108cc7e2$export$6ab9757fda54db7e = (itemRequirement, balances)=>{
|
|
28408
|
+
let itemBalanceResult;
|
|
28409
|
+
// Get the requirements related balance
|
|
28410
|
+
if (itemRequirement.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20) itemBalanceResult = balances.find((balance)=>{
|
|
28411
|
+
return balance.token?.address === itemRequirement.contractAddress;
|
|
28412
|
+
});
|
|
28413
|
+
else if (itemRequirement.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE) itemBalanceResult = balances.find((balance)=>{
|
|
28414
|
+
return !("address" in balance.token) || balance.token?.address === ($d85ad1457a3f1a83$export$b80040cb173ba6e9);
|
|
28415
|
+
});
|
|
28416
|
+
// Calculate the balance delta
|
|
28417
|
+
const requiredBalance = itemRequirement.amount;
|
|
28418
|
+
const sufficient = requiredBalance.isNegative() || requiredBalance.isZero() || (itemBalanceResult?.balance.gte(requiredBalance) ?? false);
|
|
28419
|
+
const delta = requiredBalance.sub(itemBalanceResult?.balance ?? (BigNumber$1).from(0));
|
|
28420
|
+
let decimals = ($d85ad1457a3f1a83$export$903389470ba9433c);
|
|
28421
|
+
if (itemBalanceResult) decimals = itemBalanceResult.token?.decimals ?? ($d85ad1457a3f1a83$export$903389470ba9433c);
|
|
28422
|
+
let tokenBalanceResult = itemBalanceResult;
|
|
28423
|
+
if (itemRequirement.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE) {
|
|
28424
|
+
// No token balance so mark as zero native
|
|
28425
|
+
if (!tokenBalanceResult) tokenBalanceResult = {
|
|
28426
|
+
balance: (BigNumber$1).from(0),
|
|
28427
|
+
formattedBalance: "0",
|
|
28428
|
+
token: {
|
|
28429
|
+
name: "IMX",
|
|
28430
|
+
symbol: "IMX",
|
|
28431
|
+
decimals: ($d85ad1457a3f1a83$export$903389470ba9433c),
|
|
28432
|
+
address: ($d85ad1457a3f1a83$export$b80040cb173ba6e9)
|
|
28433
|
+
}
|
|
28434
|
+
};
|
|
28435
|
+
return {
|
|
28436
|
+
sufficient: sufficient,
|
|
28437
|
+
type: ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE,
|
|
28438
|
+
delta: {
|
|
28439
|
+
balance: delta,
|
|
28440
|
+
formattedBalance: (utils$1).formatUnits(delta, decimals)
|
|
28441
|
+
},
|
|
28442
|
+
current: tokenBalanceResult,
|
|
28443
|
+
required: {
|
|
28444
|
+
...tokenBalanceResult,
|
|
28445
|
+
balance: (BigNumber$1).from(itemRequirement.amount),
|
|
28446
|
+
formattedBalance: (utils$1).formatUnits(itemRequirement.amount, decimals)
|
|
28447
|
+
}
|
|
28448
|
+
};
|
|
28449
|
+
}
|
|
28450
|
+
// No token balance so mark as zero
|
|
28451
|
+
if (!tokenBalanceResult) tokenBalanceResult = {
|
|
28452
|
+
balance: (BigNumber$1).from(0),
|
|
28453
|
+
formattedBalance: "0",
|
|
28454
|
+
token: {
|
|
28455
|
+
address: itemRequirement.contractAddress
|
|
28456
|
+
}
|
|
28457
|
+
};
|
|
28458
|
+
return {
|
|
28459
|
+
sufficient: sufficient,
|
|
28460
|
+
type: ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20,
|
|
28461
|
+
delta: {
|
|
28462
|
+
balance: delta,
|
|
28463
|
+
formattedBalance: (utils$1).formatUnits(delta, decimals)
|
|
28464
|
+
},
|
|
28465
|
+
current: tokenBalanceResult,
|
|
28466
|
+
required: {
|
|
28467
|
+
...tokenBalanceResult,
|
|
28468
|
+
balance: (BigNumber$1).from(itemRequirement.amount),
|
|
28469
|
+
formattedBalance: (utils$1).formatUnits(itemRequirement.amount, decimals)
|
|
28470
|
+
}
|
|
28471
|
+
};
|
|
28472
|
+
};
|
|
28473
|
+
|
|
28474
|
+
|
|
28475
|
+
/**
|
|
28476
|
+
* Gets the balances for all NATIVE and ERC20 balance requirements.
|
|
28477
|
+
*/ const $beb896e098e41faf$var$getTokenBalances = async (config, provider, ownerAddress, itemRequirements)=>{
|
|
28478
|
+
let tokenBalances = [];
|
|
28479
|
+
try {
|
|
28480
|
+
const tokenList = (0, $73d2282a108cc7e2$export$ed7929b58bab85da)(itemRequirements);
|
|
28481
|
+
const { balances: balances } = await (0, $1564e43dde50bb61$export$a3238cee431627c6)(config, provider, ownerAddress, tokenList);
|
|
28482
|
+
tokenBalances = [
|
|
28483
|
+
...balances.map((balance)=>balance)
|
|
28484
|
+
];
|
|
28485
|
+
} catch (error) {
|
|
28486
|
+
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Failed to get balances", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_BALANCE_ERROR);
|
|
28487
|
+
}
|
|
28488
|
+
return tokenBalances;
|
|
28489
|
+
};
|
|
28490
|
+
/**
|
|
28491
|
+
* Gets the balances for all ERC721 balance requirements.
|
|
28492
|
+
*/ const $beb896e098e41faf$var$getERC721Balances = async (provider, ownerAddress, itemRequirements)=>{
|
|
28493
|
+
const erc721Balances = [];
|
|
28494
|
+
// Setup maps to be able to link data back to the associated promises
|
|
28495
|
+
const erc721s = new Map();
|
|
28496
|
+
const erc721OwnershipPromises = new Map();
|
|
28497
|
+
itemRequirements.filter((itemRequirement)=>itemRequirement.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC721).forEach((itemRequirement)=>{
|
|
28498
|
+
const erc721Requirement = itemRequirement;
|
|
28499
|
+
const contract = new (Contract$1)(erc721Requirement.contractAddress, JSON.stringify(($d85ad1457a3f1a83$export$8b8be7a2a654f23e)), provider);
|
|
28500
|
+
erc721s.set(erc721Requirement.contractAddress, itemRequirement);
|
|
28501
|
+
erc721OwnershipPromises.set(erc721Requirement.contractAddress, contract.ownerOf(erc721Requirement.id));
|
|
28502
|
+
});
|
|
28503
|
+
try {
|
|
28504
|
+
// Convert ERC721 ownership into a balance result
|
|
28505
|
+
const erc721Owners = await Promise.all(erc721OwnershipPromises.values());
|
|
28506
|
+
const erc721OwnersPromiseIds = Array.from(erc721OwnershipPromises.keys());
|
|
28507
|
+
erc721Owners.forEach((erc721OwnerAddress, index)=>{
|
|
28508
|
+
const itemRequirement = erc721s.get(erc721OwnersPromiseIds[index]);
|
|
28509
|
+
let itemCount = 0;
|
|
28510
|
+
if (itemRequirement && ownerAddress === erc721OwnerAddress) itemCount = 1;
|
|
28511
|
+
erc721Balances.push({
|
|
28512
|
+
balance: (0, BigNumber$1).from(itemCount),
|
|
28513
|
+
formattedBalance: itemCount.toString(),
|
|
28514
|
+
contractAddress: itemRequirement.contractAddress,
|
|
28515
|
+
id: itemRequirement.id
|
|
28516
|
+
});
|
|
28517
|
+
});
|
|
28518
|
+
} catch (error) {
|
|
28519
|
+
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Failed to get ERC721 balances", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_ERC721_BALANCE_ERROR);
|
|
28520
|
+
}
|
|
28521
|
+
return erc721Balances;
|
|
28522
|
+
};
|
|
28523
|
+
const $beb896e098e41faf$export$ddfc885f43c3cb6e = async (config, provider, ownerAddress, itemRequirements)=>{
|
|
28524
|
+
const aggregatedItems = ($aa6caea9a60d18c7$export$f96d1c819a615a64)(itemRequirements);
|
|
28525
|
+
if (aggregatedItems.filter((itemRequirement)=>{
|
|
28526
|
+
return itemRequirement.type !== ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC721 && itemRequirement.type !== ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20 && itemRequirement.type !== ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE;
|
|
28527
|
+
}).length > 0) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Unsupported item requirement balance check", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).UNSUPPORTED_BALANCE_REQUIREMENT_ERROR);
|
|
28528
|
+
// Get all ERC20 and NATIVE balances
|
|
28529
|
+
const currentBalances = [];
|
|
28530
|
+
const tokenItemRequirements = aggregatedItems.filter((itemRequirement)=>itemRequirement.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20 || itemRequirement.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE);
|
|
28531
|
+
if (tokenItemRequirements.length > 0) currentBalances.push($beb896e098e41faf$var$getTokenBalances(config, provider, ownerAddress, aggregatedItems));
|
|
28532
|
+
// Get all ERC721 balances
|
|
28533
|
+
const erc721ItemRequirements = aggregatedItems.filter((itemRequirement)=>itemRequirement.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC721);
|
|
28534
|
+
if (erc721ItemRequirements.length > 0) currentBalances.push($beb896e098e41faf$var$getERC721Balances(provider, ownerAddress, aggregatedItems));
|
|
28535
|
+
// Wait for all balances and calculate the requirements
|
|
28536
|
+
const balanceRequirements = await Promise.all(currentBalances).then((balances)=>{
|
|
28537
|
+
const requirements = [];
|
|
28538
|
+
if (balances.length > 1 || tokenItemRequirements.length > 0) {
|
|
28539
|
+
const tokenBalances = balances[0];
|
|
28540
|
+
tokenItemRequirements.forEach((tokenItemRequirement)=>{
|
|
28541
|
+
requirements.push(($73d2282a108cc7e2$export$6ab9757fda54db7e)(tokenItemRequirement, tokenBalances));
|
|
28542
|
+
});
|
|
28543
|
+
if (erc721ItemRequirements.length > 0) {
|
|
28544
|
+
const erc721Balances = balances[1];
|
|
28545
|
+
erc721ItemRequirements.forEach((erc721ItemRequirement)=>{
|
|
28546
|
+
requirements.push(($73d2282a108cc7e2$export$9b757e40b19984c3)(erc721ItemRequirement, erc721Balances));
|
|
28547
|
+
});
|
|
28548
|
+
}
|
|
28549
|
+
} else if (erc721ItemRequirements.length > 0) {
|
|
28550
|
+
// Only erc721
|
|
28551
|
+
const erc721Balances = balances[0];
|
|
28552
|
+
erc721ItemRequirements.forEach((erc721ItemRequirement)=>{
|
|
28553
|
+
requirements.push(($73d2282a108cc7e2$export$9b757e40b19984c3)(erc721ItemRequirement, erc721Balances));
|
|
28554
|
+
});
|
|
28555
|
+
}
|
|
28556
|
+
return requirements;
|
|
28557
|
+
});
|
|
28558
|
+
const sufficient = balanceRequirements.reduce((acc, balanceRequirement)=>{
|
|
28559
|
+
return acc && balanceRequirement.sufficient;
|
|
28560
|
+
}, true);
|
|
28561
|
+
return {
|
|
28562
|
+
sufficient: sufficient,
|
|
28563
|
+
itemRequirements: balanceRequirements
|
|
28564
|
+
};
|
|
28565
|
+
};
|
|
28566
|
+
|
|
28567
|
+
|
|
28568
|
+
|
|
28569
|
+
|
|
28256
28570
|
|
|
28257
28571
|
|
|
28258
28572
|
|
|
@@ -28309,7 +28623,7 @@ const $7d1bfafb81e64d74$export$3a4140bd9e983e4e = async (provider, insufficientI
|
|
|
28309
28623
|
};
|
|
28310
28624
|
|
|
28311
28625
|
|
|
28312
|
-
const $0e7419077c373b24$export$9e073f9ada8c81e6 = async (provider, itemRequirements, transactionOrGasAmount)=>{
|
|
28626
|
+
const $0e7419077c373b24$export$9e073f9ada8c81e6 = async (config, provider, itemRequirements, transactionOrGasAmount)=>{
|
|
28313
28627
|
// eslint-disable-next-line no-console
|
|
28314
28628
|
console.log(provider, itemRequirements, transactionOrGasAmount);
|
|
28315
28629
|
const ownerAddress = await provider.getSigner().getAddress();
|
|
@@ -28328,6 +28642,9 @@ const $0e7419077c373b24$export$9e073f9ada8c81e6 = async (provider, itemRequireme
|
|
|
28328
28642
|
}
|
|
28329
28643
|
// eslint-disable-next-line no-console
|
|
28330
28644
|
console.log("Aggregated Items", aggregatedItems);
|
|
28645
|
+
const balanceRequirements = await ($beb896e098e41faf$export$ddfc885f43c3cb6e)(config, provider, ownerAddress, aggregatedItems);
|
|
28646
|
+
// eslint-disable-next-line no-console
|
|
28647
|
+
console.log("Balance Requirements", balanceRequirements);
|
|
28331
28648
|
return {
|
|
28332
28649
|
sufficient: true,
|
|
28333
28650
|
transactionRequirements: [
|
|
@@ -28448,7 +28765,7 @@ const $64863c39386de592$export$7f8e2b98eca5a7f0 = async (config, provider, order
|
|
|
28448
28765
|
const itemRequirements = [
|
|
28449
28766
|
$64863c39386de592$export$4249179755829904(type, contractAddress, amount, spenderAddress)
|
|
28450
28767
|
];
|
|
28451
|
-
await ($0e7419077c373b24$export$9e073f9ada8c81e6)(provider, itemRequirements, $64863c39386de592$export$8f2ff92ab8657f0b(gasLimit, unsignedTransaction));
|
|
28768
|
+
await ($0e7419077c373b24$export$9e073f9ada8c81e6)(config, provider, itemRequirements, $64863c39386de592$export$8f2ff92ab8657f0b(gasLimit, unsignedTransaction));
|
|
28452
28769
|
return {
|
|
28453
28770
|
itemRequirements: itemRequirements,
|
|
28454
28771
|
gasToken: {
|
|
@@ -28617,7 +28934,7 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
|
|
|
28617
28934
|
// eslint-disable-next-line no-console
|
|
28618
28935
|
console.warn("This endpoint is currently under construction.");
|
|
28619
28936
|
const web3Provider = await $bb88265fe45a0393$export$9e1fd9cc88c637a0(this.config, params.provider);
|
|
28620
|
-
await $0e7419077c373b24$export$9e073f9ada8c81e6(web3Provider, params.itemRequirements, params.transactionOrGasAmount);
|
|
28937
|
+
await $0e7419077c373b24$export$9e073f9ada8c81e6(this.config, web3Provider, params.itemRequirements, params.transactionOrGasAmount);
|
|
28621
28938
|
}
|
|
28622
28939
|
/**
|
|
28623
28940
|
* Checks if the given object is a Web3 provider.
|
|
@@ -28656,7 +28973,7 @@ var checkout_sdk = /*#__PURE__*/Object.freeze({
|
|
|
28656
28973
|
function $parcel$export(e, n, v, s) {
|
|
28657
28974
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
28658
28975
|
}
|
|
28659
|
-
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.14.0-alpha.
|
|
28976
|
+
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.14.0-alpha.2";
|
|
28660
28977
|
const $d663162fd5a0853f$export$83bf90b30cdfd29f = ()=>false;
|
|
28661
28978
|
const $d663162fd5a0853f$export$1169f5475725171b = ()=>$d663162fd5a0853f$export$38a083d9fb5551ca;
|
|
28662
28979
|
|
package/dist/orderbook.d.ts
CHANGED
|
@@ -1101,6 +1101,12 @@ interface SignableAction {
|
|
|
1101
1101
|
type Action = TransactionAction | SignableAction;
|
|
1102
1102
|
interface FulfillOrderResponse {
|
|
1103
1103
|
actions: Action[];
|
|
1104
|
+
/**
|
|
1105
|
+
* User MUST submit the fulfillment transaction before the expiration
|
|
1106
|
+
* Submitting after the expiration will result in a on chain revert
|
|
1107
|
+
*/
|
|
1108
|
+
expiration: string;
|
|
1109
|
+
order: Order;
|
|
1104
1110
|
}
|
|
1105
1111
|
interface CancelOrderResponse {
|
|
1106
1112
|
unsignedCancelOrderTransaction: PopulatedTransaction;
|