@imtbl/sdk 0.14.0-alpha.1 → 0.15.0-alpha

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/index.cjs CHANGED
@@ -2420,7 +2420,7 @@ class MultiRollupApiClients {
2420
2420
  }
2421
2421
 
2422
2422
  // eslint-disable-next-line @typescript-eslint/naming-convention
2423
- const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.14.0-alpha.1' };
2423
+ const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.15.0-alpha' };
2424
2424
  const createConfig = ({ basePath, headers, }) => {
2425
2425
  if (!basePath.trim()) {
2426
2426
  throw Error('basePath can not be empty');
@@ -2480,7 +2480,7 @@ class APIError extends Error {
2480
2480
 
2481
2481
  /* eslint-disable implicit-arrow-linebreak */
2482
2482
  const defaultHeaders = {
2483
- sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.14.0-alpha.1',
2483
+ sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.15.0-alpha',
2484
2484
  };
2485
2485
  /**
2486
2486
  * createAPIConfiguration to create a custom Configuration
@@ -2752,7 +2752,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
2752
2752
  chainID,
2753
2753
  coreContractAddress,
2754
2754
  registrationContractAddress,
2755
- sdkVersion: 'ts-immutable-sdk-0.14.0-alpha.1',
2755
+ sdkVersion: 'ts-immutable-sdk-0.15.0-alpha',
2756
2756
  });
2757
2757
  /**
2758
2758
  * Sets `sdkVersion` at the time of build
@@ -9528,6 +9528,67 @@ var ActionType;
9528
9528
  ActionType["SIGNABLE"] = "SIGNABLE";
9529
9529
  })(ActionType || (ActionType = {}));
9530
9530
 
9531
+ function mapFromOpenApiOrder(order) {
9532
+ const buyItems = order.buy.map((item) => {
9533
+ if (item.item_type === 'ERC20') {
9534
+ return {
9535
+ type: 'ERC20',
9536
+ contractAddress: item.contract_address,
9537
+ amount: item.start_amount,
9538
+ };
9539
+ }
9540
+ if (item.item_type === 'NATIVE') {
9541
+ return {
9542
+ type: 'NATIVE',
9543
+ amount: item.start_amount,
9544
+ };
9545
+ }
9546
+ throw new Error('Buy items must be either ERC20 or NATIVE');
9547
+ });
9548
+ const sellItems = order.sell.map((item) => {
9549
+ if (item.item_type === 'ERC721') {
9550
+ return {
9551
+ type: 'ERC721',
9552
+ contractAddress: item.contract_address,
9553
+ tokenId: item.token_id,
9554
+ };
9555
+ }
9556
+ throw new Error('Sell items must ERC721');
9557
+ });
9558
+ return {
9559
+ id: order.id,
9560
+ accountAddress: order.account_address,
9561
+ buy: buyItems,
9562
+ sell: sellItems,
9563
+ fees: order.fees.map((fee) => ({
9564
+ amount: fee.amount,
9565
+ recipient: fee.recipient,
9566
+ type: fee.fee_type,
9567
+ })),
9568
+ chain: order.chain,
9569
+ createTime: order.create_time,
9570
+ endTime: order.end_time,
9571
+ protocolData: {
9572
+ counter: order.protocol_data.counter,
9573
+ orderType: order.protocol_data.order_type,
9574
+ seaportAddress: order.protocol_data.seaport_address,
9575
+ seaportVersion: order.protocol_data.seaport_version,
9576
+ zoneAddress: order.protocol_data.zone_address,
9577
+ },
9578
+ salt: order.salt,
9579
+ signature: order.signature,
9580
+ startTime: order.start_time,
9581
+ status: order.status,
9582
+ updateTime: order.update_time,
9583
+ };
9584
+ }
9585
+ function mapFromOpenApiPage(page) {
9586
+ return {
9587
+ nextCursor: page.next_cursor,
9588
+ previousCursor: page.previous_cursor,
9589
+ };
9590
+ }
9591
+
9531
9592
  /* eslint-disable */
9532
9593
  // TODO: Resolve these from seaport-js.
9533
9594
  // There is some bundling issue that is preventing this from working
@@ -9757,7 +9818,17 @@ class Seaport {
9757
9818
  buildTransaction: prepareTransaction(fulfilOrderAction.transactionMethods),
9758
9819
  purpose: TransactionPurpose.FULFILL_ORDER,
9759
9820
  });
9760
- return { actions: fulfillmentActions };
9821
+ // Expirtaion bytes in SIP7 extra data [21:29]
9822
+ // In hex string -> [21 * 2 + 2 (0x) : 29 * 2]
9823
+ // In JS slice (start, end_inclusive), (44,60)
9824
+ // 8 bytes uint64 epoch time in seconds
9825
+ const expirationHex = extraData.slice(44, 60);
9826
+ const expirationInSeconds = parseInt(expirationHex, 16);
9827
+ return {
9828
+ actions: fulfillmentActions,
9829
+ expiration: (new Date(expirationInSeconds * 1000)).toISOString(),
9830
+ order: mapFromOpenApiOrder(order),
9831
+ };
9761
9832
  }
9762
9833
  async cancelOrder(order, account) {
9763
9834
  const { orderComponents } = this.mapImmutableOrderToSeaportOrderComponents(order);
@@ -9875,11 +9946,11 @@ class ImmutableApiClient {
9875
9946
  contract_address: orderComponents.consideration[0].token,
9876
9947
  },
9877
9948
  ],
9878
- fees: makerFee ? [{
9879
- amount: makerFee.amount,
9880
- fee_type: FeeType.MAKER_MARKETPLACE,
9881
- recipient: makerFee.recipient,
9882
- }] : [],
9949
+ fee: makerFee ? {
9950
+ amount: makerFee.amount,
9951
+ fee_type: FeeType.MAKER_MARKETPLACE,
9952
+ recipient: makerFee.recipient,
9953
+ } : undefined,
9883
9954
  end_time: new Date(parseInt(`${orderComponents.endTime.toString()}000`, 10)).toISOString(),
9884
9955
  protocol_data: {
9885
9956
  order_type: ProtocolData.order_type.FULL_RESTRICTED,
@@ -9946,67 +10017,6 @@ function getOrderbookConfig(environment) {
9946
10017
  }
9947
10018
  }
9948
10019
 
9949
- function mapFromOpenApiOrder(order) {
9950
- const buyItems = order.buy.map((item) => {
9951
- if (item.item_type === 'ERC20') {
9952
- return {
9953
- type: 'ERC20',
9954
- contractAddress: item.contract_address,
9955
- amount: item.start_amount,
9956
- };
9957
- }
9958
- if (item.item_type === 'NATIVE') {
9959
- return {
9960
- type: 'NATIVE',
9961
- amount: item.start_amount,
9962
- };
9963
- }
9964
- throw new Error('Buy items must be either ERC20 or NATIVE');
9965
- });
9966
- const sellItems = order.sell.map((item) => {
9967
- if (item.item_type === 'ERC721') {
9968
- return {
9969
- type: 'ERC721',
9970
- contractAddress: item.contract_address,
9971
- tokenId: item.token_id,
9972
- };
9973
- }
9974
- throw new Error('Sell items must ERC721');
9975
- });
9976
- return {
9977
- id: order.id,
9978
- accountAddress: order.account_address,
9979
- buy: buyItems,
9980
- sell: sellItems,
9981
- fees: order.fees.map((fee) => ({
9982
- amount: fee.amount,
9983
- recipient: fee.recipient,
9984
- type: fee.fee_type,
9985
- })),
9986
- chain: order.chain,
9987
- createTime: order.create_time,
9988
- endTime: order.end_time,
9989
- protocolData: {
9990
- counter: order.protocol_data.counter,
9991
- orderType: order.protocol_data.order_type,
9992
- seaportAddress: order.protocol_data.seaport_address,
9993
- seaportVersion: order.protocol_data.seaport_version,
9994
- zoneAddress: order.protocol_data.zone_address,
9995
- },
9996
- salt: order.salt,
9997
- signature: order.signature,
9998
- startTime: order.start_time,
9999
- status: order.status,
10000
- updateTime: order.update_time,
10001
- };
10002
- }
10003
- function mapFromOpenApiPage(page) {
10004
- return {
10005
- nextCursor: page.next_cursor,
10006
- previousCursor: page.previous_cursor,
10007
- };
10008
- }
10009
-
10010
10020
  class SeaportLibFactory {
10011
10021
  defaultSeaportContractAddress;
10012
10022
  provider;
@@ -26939,6 +26949,8 @@ const $e768639828688ca3$export$44dde05038008549 = {
26939
26949
 
26940
26950
 
26941
26951
  const $d85ad1457a3f1a83$export$7d3a9eeba384fa59 = "development";
26952
+ const $d85ad1457a3f1a83$export$b80040cb173ba6e9 = "0x0000000000000000000000000000000000001010";
26953
+ const $d85ad1457a3f1a83$export$903389470ba9433c = 18;
26942
26954
  const $d85ad1457a3f1a83$export$161d4a74df65fc08 = {
26943
26955
  [$d85ad1457a3f1a83$export$7d3a9eeba384fa59]: "https://checkout-api.dev.immutable.com",
26944
26956
  [(Environment$1).SANDBOX]: "https://checkout-api.sandbox.immutable.com",
@@ -27221,6 +27233,25 @@ const $d85ad1457a3f1a83$export$8b8be7a2a654f23e = [
27221
27233
  payable: false,
27222
27234
  stateMutability: "view",
27223
27235
  type: "function"
27236
+ },
27237
+ {
27238
+ inputs: [
27239
+ {
27240
+ internalType: "uint256",
27241
+ name: "tokenId",
27242
+ type: "uint256"
27243
+ }
27244
+ ],
27245
+ name: "ownerOf",
27246
+ outputs: [
27247
+ {
27248
+ internalType: "address",
27249
+ name: "",
27250
+ type: "address"
27251
+ }
27252
+ ],
27253
+ stateMutability: "view",
27254
+ type: "function"
27224
27255
  }
27225
27256
  ];
27226
27257
 
@@ -27262,6 +27293,7 @@ var $4b58188d47aafe8d$export$5d3b0ad129b9b98e;
27262
27293
  CheckoutErrorType["CONNECT_PROVIDER_ERROR"] = "CONNECT_PROVIDER_ERROR";
27263
27294
  CheckoutErrorType["GET_BALANCE_ERROR"] = "GET_BALANCE_ERROR";
27264
27295
  CheckoutErrorType["GET_ERC20_BALANCE_ERROR"] = "GET_ERC20_BALANCE_ERROR";
27296
+ CheckoutErrorType["GET_ERC721_BALANCE_ERROR"] = "GET_ERC721_BALANCE_ERROR";
27265
27297
  CheckoutErrorType["GET_NETWORK_INFO_ERROR"] = "GET_NETWORK_INFO_ERROR";
27266
27298
  CheckoutErrorType["METAMASK_PROVIDER_ERROR"] = "METAMASK_PROVIDER_ERROR";
27267
27299
  CheckoutErrorType["CHAIN_NOT_SUPPORTED_ERROR"] = "CHAIN_NOT_SUPPORTED_ERROR";
@@ -27273,6 +27305,7 @@ var $4b58188d47aafe8d$export$5d3b0ad129b9b98e;
27273
27305
  CheckoutErrorType["UNPREDICTABLE_GAS_LIMIT"] = "UNPREDICTABLE_GAS_LIMIT";
27274
27306
  CheckoutErrorType["INVALID_GAS_ESTIMATE_TYPE"] = "INVALID_GAS_ESTIMATE_TYPE";
27275
27307
  CheckoutErrorType["UNSUPPORTED_TOKEN_TYPE_ERROR"] = "UNSUPPORTED_TOKEN_TYPE_ERROR";
27308
+ CheckoutErrorType["UNSUPPORTED_BALANCE_REQUIREMENT_ERROR"] = "UNSUPPORTED_BALANCE_REQUIREMENT_ERROR";
27276
27309
  CheckoutErrorType["GET_ORDER_LISTING_ERROR"] = "GET_ORDER_LISTING_ERROR";
27277
27310
  CheckoutErrorType["SWITCH_NETWORK_UNSUPPORTED"] = "SWITCH_NETWORK_UNSUPPORTED";
27278
27311
  CheckoutErrorType["GET_ERC20_ALLOWANCE_ERROR"] = "GET_ERC20_ALLOWANCE_ERROR";
@@ -27494,39 +27527,48 @@ const $1564e43dde50bb61$export$df96cd8d56be0ab1 = async (config, web3Provider, w
27494
27527
  async function $1564e43dde50bb61$export$60e0fe116a0e6ed0(web3Provider, walletAddress, contractAddress) {
27495
27528
  return await ($a8bc256d81a5e2c1$export$bacc563de539c6c3)(async ()=>{
27496
27529
  const contract = new (ethers.Contract)(contractAddress, JSON.stringify(($d85ad1457a3f1a83$export$db5daa1b5156ccfe)), web3Provider);
27497
- const name = await contract.name();
27498
- const symbol = await contract.symbol();
27499
- const balance = await contract.balanceOf(walletAddress);
27500
- const decimals = await contract.decimals();
27501
- const formattedBalance = (ethers.utils).formatUnits(balance, decimals);
27502
- return {
27503
- balance: balance,
27504
- formattedBalance: formattedBalance,
27505
- token: {
27506
- name: name,
27507
- symbol: symbol,
27508
- decimals: decimals,
27509
- address: contractAddress
27510
- }
27511
- };
27530
+ return Promise.all([
27531
+ contract.name(),
27532
+ contract.symbol(),
27533
+ contract.balanceOf(walletAddress),
27534
+ contract.decimals()
27535
+ ]).then(([name, symbol, balance, decimals])=>{
27536
+ const formattedBalance = (ethers.utils).formatUnits(balance, decimals);
27537
+ return {
27538
+ balance: balance,
27539
+ formattedBalance: formattedBalance,
27540
+ token: {
27541
+ name: name,
27542
+ symbol: symbol,
27543
+ decimals: decimals,
27544
+ address: contractAddress
27545
+ }
27546
+ };
27547
+ });
27512
27548
  }, {
27513
27549
  type: ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_ERC20_BALANCE_ERROR
27514
27550
  });
27515
27551
  }
27516
- const $1564e43dde50bb61$export$fee49741664a4d7e = async (config, web3Provider, walletAddress, chainId)=>{
27517
- const tokenList = await ($efe60cea83bfc4e8$export$473cec51305fdae8)(config, {
27518
- type: ($08d5ddc39acd6833$export$fd9b17d87f4121d2).ALL,
27519
- chainId: chainId
27520
- });
27552
+ const $1564e43dde50bb61$export$a3238cee431627c6 = async (config, web3Provider, walletAddress, tokens)=>{
27521
27553
  const allBalancePromises = [];
27522
- allBalancePromises.push($1564e43dde50bb61$export$df96cd8d56be0ab1(config, web3Provider, walletAddress));
27523
- tokenList.tokens.forEach((token)=>token.address && allBalancePromises.push($1564e43dde50bb61$export$60e0fe116a0e6ed0(web3Provider, walletAddress, token.address)));
27554
+ tokens.forEach((token)=>{
27555
+ // Check for NATIVE token
27556
+ if (!token.address || token.address === ($d85ad1457a3f1a83$export$b80040cb173ba6e9)) allBalancePromises.push($1564e43dde50bb61$export$df96cd8d56be0ab1(config, web3Provider, walletAddress));
27557
+ else allBalancePromises.push($1564e43dde50bb61$export$60e0fe116a0e6ed0(web3Provider, walletAddress, token.address));
27558
+ });
27524
27559
  const balanceResults = await Promise.allSettled(allBalancePromises);
27525
- const getBalanceResults = balanceResults.filter((result)=>result.status === "fulfilled").map((fulfilledResult)=>fulfilledResult.value);
27560
+ const balances = balanceResults.filter((result)=>result.status === "fulfilled").map((fulfilledResult)=>fulfilledResult.value);
27526
27561
  return {
27527
- balances: getBalanceResults
27562
+ balances: balances
27528
27563
  };
27529
27564
  };
27565
+ const $1564e43dde50bb61$export$fee49741664a4d7e = async (config, web3Provider, walletAddress, chainId)=>{
27566
+ const { tokens: tokens } = await ($efe60cea83bfc4e8$export$473cec51305fdae8)(config, {
27567
+ type: ($08d5ddc39acd6833$export$fd9b17d87f4121d2).ALL,
27568
+ chainId: chainId
27569
+ });
27570
+ return await $1564e43dde50bb61$export$a3238cee431627c6(config, web3Provider, walletAddress, tokens);
27571
+ };
27530
27572
 
27531
27573
 
27532
27574
 
@@ -28275,6 +28317,278 @@ const $35c3fc7013888ba5$export$be546c525d418988 = async (provider, ownerAddress,
28275
28317
 
28276
28318
 
28277
28319
 
28320
+ /* eslint-disable arrow-body-style */
28321
+
28322
+
28323
+
28324
+
28325
+
28326
+ const $aa6caea9a60d18c7$export$f4d35754ad350071 = (itemRequirements)=>{
28327
+ const aggregatedMap = new Map();
28328
+ const aggregatedItemRequirements = [];
28329
+ itemRequirements.forEach((itemRequirement)=>{
28330
+ const { type: type } = itemRequirement;
28331
+ if (type !== ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE) {
28332
+ aggregatedItemRequirements.push(itemRequirement);
28333
+ return;
28334
+ }
28335
+ const { amount: amount } = itemRequirement;
28336
+ const aggregateItem = aggregatedMap.get(type);
28337
+ if (aggregateItem && aggregateItem.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE) aggregateItem.amount = (ethers.BigNumber).from(aggregateItem.amount).add(amount);
28338
+ else aggregatedMap.set(type, {
28339
+ ...itemRequirement
28340
+ });
28341
+ });
28342
+ return aggregatedItemRequirements.concat(Array.from(aggregatedMap.values()));
28343
+ };
28344
+ const $aa6caea9a60d18c7$export$b8de545554d50911 = (itemRequirements)=>{
28345
+ const aggregatedMap = new Map();
28346
+ const aggregatedItemRequirements = [];
28347
+ itemRequirements.forEach((itemRequirement)=>{
28348
+ const { type: type } = itemRequirement;
28349
+ if (type !== ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20) {
28350
+ aggregatedItemRequirements.push(itemRequirement);
28351
+ return;
28352
+ }
28353
+ const { contractAddress: contractAddress, amount: amount } = itemRequirement;
28354
+ const key = `${contractAddress}`;
28355
+ const aggregateItem = aggregatedMap.get(key);
28356
+ if (aggregateItem && aggregateItem.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20) aggregateItem.amount = (ethers.BigNumber).from(aggregateItem.amount).add(amount);
28357
+ else aggregatedMap.set(key, {
28358
+ ...itemRequirement
28359
+ });
28360
+ });
28361
+ return aggregatedItemRequirements.concat(Array.from(aggregatedMap.values()));
28362
+ };
28363
+ const $aa6caea9a60d18c7$export$74fbc29ef48b4f31 = (itemRequirements)=>{
28364
+ const aggregatedMap = new Map();
28365
+ const aggregatedItemRequirements = [];
28366
+ itemRequirements.forEach((itemRequirement)=>{
28367
+ const { type: type } = itemRequirement;
28368
+ if (type !== ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC721) {
28369
+ aggregatedItemRequirements.push(itemRequirement);
28370
+ return;
28371
+ }
28372
+ const { contractAddress: contractAddress, id: id } = itemRequirement;
28373
+ const key = `${contractAddress}${id}`;
28374
+ const aggregateItem = aggregatedMap.get(key);
28375
+ if (!aggregateItem) aggregatedMap.set(key, {
28376
+ ...itemRequirement
28377
+ });
28378
+ });
28379
+ return aggregatedItemRequirements.concat(Array.from(aggregatedMap.values()));
28380
+ };
28381
+ const $aa6caea9a60d18c7$export$f96d1c819a615a64 = (itemRequirements)=>$aa6caea9a60d18c7$export$74fbc29ef48b4f31($aa6caea9a60d18c7$export$b8de545554d50911($aa6caea9a60d18c7$export$f4d35754ad350071(itemRequirements)));
28382
+
28383
+
28384
+ /* eslint-disable arrow-body-style */
28385
+
28386
+ const $73d2282a108cc7e2$export$ed7929b58bab85da = (itemRequirements)=>itemRequirements.map((itemRequirement)=>{
28387
+ if (itemRequirement.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE) return {
28388
+ name: "IMX",
28389
+ symbol: "IMX",
28390
+ address: ($d85ad1457a3f1a83$export$b80040cb173ba6e9)
28391
+ };
28392
+ return {
28393
+ name: itemRequirement.type,
28394
+ address: itemRequirement.contractAddress
28395
+ };
28396
+ });
28397
+ const $73d2282a108cc7e2$export$9b757e40b19984c3 = (itemRequirement, balances)=>{
28398
+ const requiredBalance = (ethers.BigNumber).from(1);
28399
+ // Find the requirements related balance
28400
+ const itemBalanceResult = balances.find((balance)=>{
28401
+ const balanceERC721Result = balance;
28402
+ return balanceERC721Result.contractAddress === itemRequirement.contractAddress && balanceERC721Result.id === itemRequirement.id;
28403
+ });
28404
+ // Calculate the balance delta
28405
+ const sufficient = requiredBalance.isNegative() || requiredBalance.isZero() || (itemBalanceResult?.balance.gte(requiredBalance) ?? false);
28406
+ const delta = requiredBalance.sub(itemBalanceResult?.balance ?? (ethers.BigNumber).from(0));
28407
+ let erc721BalanceResult = itemBalanceResult;
28408
+ if (!erc721BalanceResult) erc721BalanceResult = {
28409
+ balance: (ethers.BigNumber).from(0),
28410
+ formattedBalance: "0",
28411
+ contractAddress: itemRequirement.contractAddress,
28412
+ id: itemRequirement.id
28413
+ };
28414
+ return {
28415
+ sufficient: sufficient,
28416
+ type: itemRequirement.type,
28417
+ delta: {
28418
+ balance: delta,
28419
+ formattedBalance: delta.toString()
28420
+ },
28421
+ current: erc721BalanceResult,
28422
+ required: {
28423
+ ...erc721BalanceResult,
28424
+ balance: (ethers.BigNumber).from(1),
28425
+ formattedBalance: "1"
28426
+ }
28427
+ };
28428
+ };
28429
+ const $73d2282a108cc7e2$export$6ab9757fda54db7e = (itemRequirement, balances)=>{
28430
+ let itemBalanceResult;
28431
+ // Get the requirements related balance
28432
+ if (itemRequirement.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20) itemBalanceResult = balances.find((balance)=>{
28433
+ return balance.token?.address === itemRequirement.contractAddress;
28434
+ });
28435
+ else if (itemRequirement.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE) itemBalanceResult = balances.find((balance)=>{
28436
+ return !("address" in balance.token) || balance.token?.address === ($d85ad1457a3f1a83$export$b80040cb173ba6e9);
28437
+ });
28438
+ // Calculate the balance delta
28439
+ const requiredBalance = itemRequirement.amount;
28440
+ const sufficient = requiredBalance.isNegative() || requiredBalance.isZero() || (itemBalanceResult?.balance.gte(requiredBalance) ?? false);
28441
+ const delta = requiredBalance.sub(itemBalanceResult?.balance ?? (ethers.BigNumber).from(0));
28442
+ let decimals = ($d85ad1457a3f1a83$export$903389470ba9433c);
28443
+ if (itemBalanceResult) decimals = itemBalanceResult.token?.decimals ?? ($d85ad1457a3f1a83$export$903389470ba9433c);
28444
+ let tokenBalanceResult = itemBalanceResult;
28445
+ if (itemRequirement.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE) {
28446
+ // No token balance so mark as zero native
28447
+ if (!tokenBalanceResult) tokenBalanceResult = {
28448
+ balance: (ethers.BigNumber).from(0),
28449
+ formattedBalance: "0",
28450
+ token: {
28451
+ name: "IMX",
28452
+ symbol: "IMX",
28453
+ decimals: ($d85ad1457a3f1a83$export$903389470ba9433c),
28454
+ address: ($d85ad1457a3f1a83$export$b80040cb173ba6e9)
28455
+ }
28456
+ };
28457
+ return {
28458
+ sufficient: sufficient,
28459
+ type: ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE,
28460
+ delta: {
28461
+ balance: delta,
28462
+ formattedBalance: (ethers.utils).formatUnits(delta, decimals)
28463
+ },
28464
+ current: tokenBalanceResult,
28465
+ required: {
28466
+ ...tokenBalanceResult,
28467
+ balance: (ethers.BigNumber).from(itemRequirement.amount),
28468
+ formattedBalance: (ethers.utils).formatUnits(itemRequirement.amount, decimals)
28469
+ }
28470
+ };
28471
+ }
28472
+ // No token balance so mark as zero
28473
+ if (!tokenBalanceResult) tokenBalanceResult = {
28474
+ balance: (ethers.BigNumber).from(0),
28475
+ formattedBalance: "0",
28476
+ token: {
28477
+ address: itemRequirement.contractAddress
28478
+ }
28479
+ };
28480
+ return {
28481
+ sufficient: sufficient,
28482
+ type: ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20,
28483
+ delta: {
28484
+ balance: delta,
28485
+ formattedBalance: (ethers.utils).formatUnits(delta, decimals)
28486
+ },
28487
+ current: tokenBalanceResult,
28488
+ required: {
28489
+ ...tokenBalanceResult,
28490
+ balance: (ethers.BigNumber).from(itemRequirement.amount),
28491
+ formattedBalance: (ethers.utils).formatUnits(itemRequirement.amount, decimals)
28492
+ }
28493
+ };
28494
+ };
28495
+
28496
+
28497
+ /**
28498
+ * Gets the balances for all NATIVE and ERC20 balance requirements.
28499
+ */ const $beb896e098e41faf$var$getTokenBalances = async (config, provider, ownerAddress, itemRequirements)=>{
28500
+ let tokenBalances = [];
28501
+ try {
28502
+ const tokenList = (0, $73d2282a108cc7e2$export$ed7929b58bab85da)(itemRequirements);
28503
+ const { balances: balances } = await (0, $1564e43dde50bb61$export$a3238cee431627c6)(config, provider, ownerAddress, tokenList);
28504
+ tokenBalances = [
28505
+ ...balances.map((balance)=>balance)
28506
+ ];
28507
+ } catch (error) {
28508
+ throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Failed to get balances", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_BALANCE_ERROR);
28509
+ }
28510
+ return tokenBalances;
28511
+ };
28512
+ /**
28513
+ * Gets the balances for all ERC721 balance requirements.
28514
+ */ const $beb896e098e41faf$var$getERC721Balances = async (provider, ownerAddress, itemRequirements)=>{
28515
+ const erc721Balances = [];
28516
+ // Setup maps to be able to link data back to the associated promises
28517
+ const erc721s = new Map();
28518
+ const erc721OwnershipPromises = new Map();
28519
+ itemRequirements.filter((itemRequirement)=>itemRequirement.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC721).forEach((itemRequirement)=>{
28520
+ const erc721Requirement = itemRequirement;
28521
+ const contract = new (ethers.Contract)(erc721Requirement.contractAddress, JSON.stringify(($d85ad1457a3f1a83$export$8b8be7a2a654f23e)), provider);
28522
+ erc721s.set(erc721Requirement.contractAddress, itemRequirement);
28523
+ erc721OwnershipPromises.set(erc721Requirement.contractAddress, contract.ownerOf(erc721Requirement.id));
28524
+ });
28525
+ try {
28526
+ // Convert ERC721 ownership into a balance result
28527
+ const erc721Owners = await Promise.all(erc721OwnershipPromises.values());
28528
+ const erc721OwnersPromiseIds = Array.from(erc721OwnershipPromises.keys());
28529
+ erc721Owners.forEach((erc721OwnerAddress, index)=>{
28530
+ const itemRequirement = erc721s.get(erc721OwnersPromiseIds[index]);
28531
+ let itemCount = 0;
28532
+ if (itemRequirement && ownerAddress === erc721OwnerAddress) itemCount = 1;
28533
+ erc721Balances.push({
28534
+ balance: (0, ethers.BigNumber).from(itemCount),
28535
+ formattedBalance: itemCount.toString(),
28536
+ contractAddress: itemRequirement.contractAddress,
28537
+ id: itemRequirement.id
28538
+ });
28539
+ });
28540
+ } catch (error) {
28541
+ throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Failed to get ERC721 balances", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_ERC721_BALANCE_ERROR);
28542
+ }
28543
+ return erc721Balances;
28544
+ };
28545
+ const $beb896e098e41faf$export$ddfc885f43c3cb6e = async (config, provider, ownerAddress, itemRequirements)=>{
28546
+ const aggregatedItems = ($aa6caea9a60d18c7$export$f96d1c819a615a64)(itemRequirements);
28547
+ if (aggregatedItems.filter((itemRequirement)=>{
28548
+ return itemRequirement.type !== ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC721 && itemRequirement.type !== ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20 && itemRequirement.type !== ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE;
28549
+ }).length > 0) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Unsupported item requirement balance check", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).UNSUPPORTED_BALANCE_REQUIREMENT_ERROR);
28550
+ // Get all ERC20 and NATIVE balances
28551
+ const currentBalances = [];
28552
+ const tokenItemRequirements = aggregatedItems.filter((itemRequirement)=>itemRequirement.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20 || itemRequirement.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE);
28553
+ if (tokenItemRequirements.length > 0) currentBalances.push($beb896e098e41faf$var$getTokenBalances(config, provider, ownerAddress, aggregatedItems));
28554
+ // Get all ERC721 balances
28555
+ const erc721ItemRequirements = aggregatedItems.filter((itemRequirement)=>itemRequirement.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC721);
28556
+ if (erc721ItemRequirements.length > 0) currentBalances.push($beb896e098e41faf$var$getERC721Balances(provider, ownerAddress, aggregatedItems));
28557
+ // Wait for all balances and calculate the requirements
28558
+ const balanceRequirements = await Promise.all(currentBalances).then((balances)=>{
28559
+ const requirements = [];
28560
+ if (balances.length > 1 || tokenItemRequirements.length > 0) {
28561
+ const tokenBalances = balances[0];
28562
+ tokenItemRequirements.forEach((tokenItemRequirement)=>{
28563
+ requirements.push(($73d2282a108cc7e2$export$6ab9757fda54db7e)(tokenItemRequirement, tokenBalances));
28564
+ });
28565
+ if (erc721ItemRequirements.length > 0) {
28566
+ const erc721Balances = balances[1];
28567
+ erc721ItemRequirements.forEach((erc721ItemRequirement)=>{
28568
+ requirements.push(($73d2282a108cc7e2$export$9b757e40b19984c3)(erc721ItemRequirement, erc721Balances));
28569
+ });
28570
+ }
28571
+ } else if (erc721ItemRequirements.length > 0) {
28572
+ // Only erc721
28573
+ const erc721Balances = balances[0];
28574
+ erc721ItemRequirements.forEach((erc721ItemRequirement)=>{
28575
+ requirements.push(($73d2282a108cc7e2$export$9b757e40b19984c3)(erc721ItemRequirement, erc721Balances));
28576
+ });
28577
+ }
28578
+ return requirements;
28579
+ });
28580
+ const sufficient = balanceRequirements.reduce((acc, balanceRequirement)=>{
28581
+ return acc && balanceRequirement.sufficient;
28582
+ }, true);
28583
+ return {
28584
+ sufficient: sufficient,
28585
+ itemRequirements: balanceRequirements
28586
+ };
28587
+ };
28588
+
28589
+
28590
+
28591
+
28278
28592
 
28279
28593
 
28280
28594
 
@@ -28331,7 +28645,7 @@ const $7d1bfafb81e64d74$export$3a4140bd9e983e4e = async (provider, insufficientI
28331
28645
  };
28332
28646
 
28333
28647
 
28334
- const $0e7419077c373b24$export$9e073f9ada8c81e6 = async (provider, itemRequirements, transactionOrGasAmount)=>{
28648
+ const $0e7419077c373b24$export$9e073f9ada8c81e6 = async (config, provider, itemRequirements, transactionOrGasAmount)=>{
28335
28649
  // eslint-disable-next-line no-console
28336
28650
  console.log(provider, itemRequirements, transactionOrGasAmount);
28337
28651
  const ownerAddress = await provider.getSigner().getAddress();
@@ -28350,6 +28664,9 @@ const $0e7419077c373b24$export$9e073f9ada8c81e6 = async (provider, itemRequireme
28350
28664
  }
28351
28665
  // eslint-disable-next-line no-console
28352
28666
  console.log("Aggregated Items", aggregatedItems);
28667
+ const balanceRequirements = await ($beb896e098e41faf$export$ddfc885f43c3cb6e)(config, provider, ownerAddress, aggregatedItems);
28668
+ // eslint-disable-next-line no-console
28669
+ console.log("Balance Requirements", balanceRequirements);
28353
28670
  return {
28354
28671
  sufficient: true,
28355
28672
  transactionRequirements: [
@@ -28470,7 +28787,7 @@ const $64863c39386de592$export$7f8e2b98eca5a7f0 = async (config, provider, order
28470
28787
  const itemRequirements = [
28471
28788
  $64863c39386de592$export$4249179755829904(type, contractAddress, amount, spenderAddress)
28472
28789
  ];
28473
- await ($0e7419077c373b24$export$9e073f9ada8c81e6)(provider, itemRequirements, $64863c39386de592$export$8f2ff92ab8657f0b(gasLimit, unsignedTransaction));
28790
+ await ($0e7419077c373b24$export$9e073f9ada8c81e6)(config, provider, itemRequirements, $64863c39386de592$export$8f2ff92ab8657f0b(gasLimit, unsignedTransaction));
28474
28791
  return {
28475
28792
  itemRequirements: itemRequirements,
28476
28793
  gasToken: {
@@ -28639,7 +28956,7 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
28639
28956
  // eslint-disable-next-line no-console
28640
28957
  console.warn("This endpoint is currently under construction.");
28641
28958
  const web3Provider = await $bb88265fe45a0393$export$9e1fd9cc88c637a0(this.config, params.provider);
28642
- await $0e7419077c373b24$export$9e073f9ada8c81e6(web3Provider, params.itemRequirements, params.transactionOrGasAmount);
28959
+ await $0e7419077c373b24$export$9e073f9ada8c81e6(this.config, web3Provider, params.itemRequirements, params.transactionOrGasAmount);
28643
28960
  }
28644
28961
  /**
28645
28962
  * Checks if the given object is a Web3 provider.
@@ -28678,7 +28995,7 @@ var checkout_sdk = /*#__PURE__*/Object.freeze({
28678
28995
  function $parcel$export(e, n, v, s) {
28679
28996
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
28680
28997
  }
28681
- const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.14.0-alpha.1";
28998
+ const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.15.0-alpha";
28682
28999
  const $d663162fd5a0853f$export$83bf90b30cdfd29f = ()=>false;
28683
29000
  const $d663162fd5a0853f$export$1169f5475725171b = ()=>$d663162fd5a0853f$export$38a083d9fb5551ca;
28684
29001
 
package/dist/index.d.ts CHANGED
@@ -13276,7 +13276,10 @@ type CreateListingRequestBody = {
13276
13276
  * Buy item for listing should either be NATIVE or ERC20 item
13277
13277
  */
13278
13278
  buy: Array<Item>;
13279
- fees: Array<Fee$1>;
13279
+ /**
13280
+ * The maker marketplace fee
13281
+ */
13282
+ fee?: Fee$1;
13280
13283
  /**
13281
13284
  * Time after which the Order is considered expired
13282
13285
  */
@@ -13566,6 +13569,12 @@ interface SignableAction {
13566
13569
  type Action = TransactionAction | SignableAction;
13567
13570
  interface FulfillOrderResponse {
13568
13571
  actions: Action[];
13572
+ /**
13573
+ * User MUST submit the fulfillment transaction before the expiration
13574
+ * Submitting after the expiration will result in a on chain revert
13575
+ */
13576
+ expiration: string;
13577
+ order: Order;
13569
13578
  }
13570
13579
  interface CancelOrderResponse {
13571
13580
  unsignedCancelOrderTransaction: PopulatedTransaction;
@@ -14391,6 +14400,7 @@ declare enum CheckoutErrorType {
14391
14400
  CONNECT_PROVIDER_ERROR = "CONNECT_PROVIDER_ERROR",
14392
14401
  GET_BALANCE_ERROR = "GET_BALANCE_ERROR",
14393
14402
  GET_ERC20_BALANCE_ERROR = "GET_ERC20_BALANCE_ERROR",
14403
+ GET_ERC721_BALANCE_ERROR = "GET_ERC721_BALANCE_ERROR",
14394
14404
  GET_NETWORK_INFO_ERROR = "GET_NETWORK_INFO_ERROR",
14395
14405
  METAMASK_PROVIDER_ERROR = "METAMASK_PROVIDER_ERROR",
14396
14406
  CHAIN_NOT_SUPPORTED_ERROR = "CHAIN_NOT_SUPPORTED_ERROR",
@@ -14402,6 +14412,7 @@ declare enum CheckoutErrorType {
14402
14412
  UNPREDICTABLE_GAS_LIMIT = "UNPREDICTABLE_GAS_LIMIT",
14403
14413
  INVALID_GAS_ESTIMATE_TYPE = "INVALID_GAS_ESTIMATE_TYPE",
14404
14414
  UNSUPPORTED_TOKEN_TYPE_ERROR = "UNSUPPORTED_TOKEN_TYPE_ERROR",
14415
+ UNSUPPORTED_BALANCE_REQUIREMENT_ERROR = "UNSUPPORTED_BALANCE_REQUIREMENT_ERROR",
14405
14416
  GET_ORDER_LISTING_ERROR = "GET_ORDER_LISTING_ERROR",
14406
14417
  SWITCH_NETWORK_UNSUPPORTED = "SWITCH_NETWORK_UNSUPPORTED",
14407
14418
  GET_ERC20_ALLOWANCE_ERROR = "GET_ERC20_ALLOWANCE_ERROR",