@hypercerts-org/marketplace-sdk 0.4.0 → 0.4.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/index.esm.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import { Contract, ZeroAddress, AbiCoder, TypedDataEncoder, keccak256, solidityPackedKeccak256, ethers, getAddress, ZeroHash, MaxUint256 } from 'ethers';
2
2
  import { HypercertExchangeAbi, TransferManagerAbi, OrderValidatorV2AAbi, deployments, asDeployedChain as asDeployedChain$2 } from '@hypercerts-org/contracts';
3
3
  import { MerkleTree } from 'merkletreejs';
4
- import { keccak256 as keccak256$1 } from 'js-sha3';
5
4
  import { CONSTANTS } from '@hypercerts-org/sdk';
6
5
 
7
6
  var abiIERC721 = [
@@ -592,14 +591,6 @@ const cancelOrderNonces = (signer, address, nonces, overrides) => {
592
591
  callStatic: (additionalOverrides) => contract.cancelOrderNonces.staticCall(nonces, { ...overrides, ...additionalOverrides }),
593
592
  };
594
593
  };
595
- const cancelSubsetNonces = (signer, address, nonces, overrides) => {
596
- const contract = new Contract(address, HypercertExchangeAbi).connect(signer);
597
- return {
598
- call: (additionalOverrides) => contract.cancelSubsetNonces.send(nonces, { ...overrides, ...additionalOverrides }),
599
- estimateGas: (additionalOverrides) => contract.cancelSubsetNonces.estimateGas(nonces, { ...overrides, ...additionalOverrides }),
600
- callStatic: (additionalOverrides) => contract.cancelSubsetNonces.staticCall(nonces, { ...overrides, ...additionalOverrides }),
601
- };
602
- };
603
594
  const incrementBidAskNonces = (signer, address, bid, ask, overrides) => {
604
595
  const contract = new Contract(address, HypercertExchangeAbi).connect(signer);
605
596
  return {
@@ -612,7 +603,6 @@ const incrementBidAskNonces = (signer, address, bid, ask, overrides) => {
612
603
  var nonces = /*#__PURE__*/Object.freeze({
613
604
  __proto__: null,
614
605
  cancelOrderNonces: cancelOrderNonces,
615
- cancelSubsetNonces: cancelSubsetNonces,
616
606
  incrementBidAskNonces: incrementBidAskNonces,
617
607
  viewUserBidAskNonces: viewUserBidAskNonces
618
608
  });
@@ -638,30 +628,12 @@ const revokeApprovals = (signer, address, operators, overrides) => {
638
628
  callStatic: (additionalOverrides) => contract.revokeApprovals.staticCall(operators, { ...overrides, ...additionalOverrides }),
639
629
  };
640
630
  };
641
- const transferBatchItemsAcrossCollections = (signer, address, items, from, to, overrides) => {
642
- const contract = new Contract(address, TransferManagerAbi).connect(signer);
643
- return {
644
- call: (additionalOverrides) => contract.transferBatchItemsAcrossCollections.send(items, from, to, {
645
- ...overrides,
646
- ...additionalOverrides,
647
- }),
648
- estimateGas: (additionalOverrides) => contract.transferBatchItemsAcrossCollections.estimateGas(items, from, to, {
649
- ...overrides,
650
- ...additionalOverrides,
651
- }),
652
- callStatic: (additionalOverrides) => contract.transferBatchItemsAcrossCollections.staticCall(items, from, to, {
653
- ...overrides,
654
- ...additionalOverrides,
655
- }),
656
- };
657
- };
658
631
 
659
632
  var transferManager = /*#__PURE__*/Object.freeze({
660
633
  __proto__: null,
661
634
  grantApprovals: grantApprovals,
662
635
  hasUserApprovedOperator: hasUserApprovedOperator,
663
- revokeApprovals: revokeApprovals,
664
- transferBatchItemsAcrossCollections: transferBatchItemsAcrossCollections
636
+ revokeApprovals: revokeApprovals
665
637
  });
666
638
 
667
639
  const verifyMakerOrders = async (signerOrProvider, address, makerOrders, signatures, merkleTrees, overrides) => {
@@ -714,22 +686,13 @@ var CollectionType;
714
686
  CollectionType[CollectionType["ERC721"] = 0] = "ERC721";
715
687
  CollectionType[CollectionType["ERC1155"] = 1] = "ERC1155";
716
688
  CollectionType[CollectionType["HYPERCERT"] = 2] = "HYPERCERT";
717
- CollectionType[CollectionType["HYPERBOARD"] = 3] = "HYPERBOARD";
718
689
  })(CollectionType || (CollectionType = {}));
719
690
  /** List of trading strategies */
720
691
  var StrategyType;
721
692
  (function (StrategyType) {
722
693
  StrategyType[StrategyType["standard"] = 0] = "standard";
723
- StrategyType[StrategyType["collection"] = 10] = "collection";
724
- StrategyType[StrategyType["collectionWithMerkleTree"] = 2] = "collectionWithMerkleTree";
725
- StrategyType[StrategyType["dutchAuction"] = 4] = "dutchAuction";
726
- StrategyType[StrategyType["itemIdsRange"] = 5] = "itemIdsRange";
727
- StrategyType[StrategyType["hypercertCollectionOffer"] = 6] = "hypercertCollectionOffer";
728
- StrategyType[StrategyType["hypercertCollectionOfferWithProof"] = 7] = "hypercertCollectionOfferWithProof";
729
- StrategyType[StrategyType["hypercertCollectionOfferWithAllowlist"] = 8] = "hypercertCollectionOfferWithAllowlist";
730
- StrategyType[StrategyType["hypercertDutchAuction"] = 9] = "hypercertDutchAuction";
731
694
  StrategyType[StrategyType["hypercertFractionOffer"] = 1] = "hypercertFractionOffer";
732
- StrategyType[StrategyType["hypercertFractionOfferWithAllowlist"] = 11] = "hypercertFractionOfferWithAllowlist";
695
+ StrategyType[StrategyType["hypercertFractionOfferWithAllowlist"] = 2] = "hypercertFractionOfferWithAllowlist";
733
696
  })(StrategyType || (StrategyType = {}));
734
697
  /** Type for maker order */
735
698
  var QuoteType;
@@ -806,12 +769,9 @@ var OrderValidatorCode;
806
769
  * @returns Array of solidity types for encoding
807
770
  */
808
771
  const getMakerParamsTypes = (strategy) => {
809
- if (strategy === StrategyType.standard || strategy === StrategyType.collection) {
772
+ if (strategy === StrategyType.standard) {
810
773
  return [];
811
774
  }
812
- if (strategy === StrategyType.collectionWithMerkleTree) {
813
- return ["bytes32"]; // Merkle tree root
814
- }
815
775
  if (strategy === StrategyType.hypercertFractionOffer) {
816
776
  return ["uint256", "uint256", "uint256", "bool"]; // minUnitAmount, maxUnitAmount, minUnitsToKeep, sellLeftoverFraction
817
777
  }
@@ -829,12 +789,6 @@ const getTakerParamsTypes = (strategy) => {
829
789
  if (strategy === StrategyType.standard) {
830
790
  return [];
831
791
  }
832
- if (strategy === StrategyType.collection) {
833
- return ["uint256"]; // Item id
834
- }
835
- if (strategy === StrategyType.collectionWithMerkleTree) {
836
- return ["uint256", "bytes32[]"]; // Item id, merkle proof
837
- }
838
792
  if (strategy === StrategyType.hypercertFractionOffer) {
839
793
  return ["uint256", "uint256"]; // unitAmount, pricePerUnit
840
794
  }
@@ -7603,7 +7557,7 @@ class ApiClient {
7603
7557
  constructor(indexerEnvironment, baseUrl) {
7604
7558
  this.baseUrl = baseUrl;
7605
7559
  /**
7606
- * Fetches order nonce from api
7560
+ * Fetches order nonce from API
7607
7561
  * @param address Address
7608
7562
  * @param chainId Chain ID
7609
7563
  */
@@ -7622,7 +7576,7 @@ class ApiClient {
7622
7576
  .then((res) => res.data);
7623
7577
  };
7624
7578
  /**
7625
- * Registers order in api
7579
+ * Registers order in the marketplace API
7626
7580
  * @param order Order
7627
7581
  * @param signer Signer
7628
7582
  * @param signature Signature
@@ -7648,6 +7602,7 @@ class ApiClient {
7648
7602
  }).then((res) => this.handleResponse(res));
7649
7603
  };
7650
7604
  /**
7605
+ * @deprecated use GraphQL API instead
7651
7606
  * Fetch existing open orders from the marketplace API
7652
7607
  * @param signer address of the user that created the order
7653
7608
  * @param claimTokenIds a list of claimTokenIds - will return any order that is for one or more of these claimTokenIds
@@ -7658,7 +7613,8 @@ class ApiClient {
7658
7613
  return await getOrders({ signer, chainId: chainId ? BigInt(chainId) : undefined }, this._urqlClient);
7659
7614
  };
7660
7615
  /**
7661
- * Fetches orders from api by hypercert ID
7616
+ * @deprecated use the GraphQL API instead
7617
+ * Fetches orders from API by hypercert ID
7662
7618
  * @param hypercertId Hypercert ID
7663
7619
  * @param chainId Chain ID
7664
7620
  */
@@ -7723,10 +7679,10 @@ const ACCEPTED_ERROR_CODES = [
7723
7679
  class HypercertExchangeClient {
7724
7680
  /**
7725
7681
  * HypercertExchange protocol main class
7726
- * @param chainId Current app chain id
7682
+ * @param chainId Chain id for contract interactions
7727
7683
  * @param provider Ethers provider
7728
7684
  * @param signer Ethers signer
7729
- * @param overrides Override contract addresses or api endpoint used
7685
+ * @param overrides Override contract addresses or API endpoint used
7730
7686
  */
7731
7687
  constructor(chainId, provider, signer, overrides) {
7732
7688
  const deployment = CONSTANTS.DEPLOYMENTS[asDeployedChain$2(chainId)];
@@ -7776,7 +7732,7 @@ class HypercertExchangeClient {
7776
7732
  * @param CreateMakerInput
7777
7733
  * @returns the maker object, isTransferManagerApproved, and isTransferManagerApproved
7778
7734
  */
7779
- async createMakerAsk({ collection, strategyId, collectionType, subsetNonce, orderNonce, endTime, price, itemIds, amounts = [1], currency = ZeroAddress, startTime = Math.floor(Date.now() / 1000), additionalParameters = [], }) {
7735
+ async createMakerAsk({ collection, strategyId, collectionType, subsetNonce, orderNonce, endTime, price, itemIds, currency = ZeroAddress, startTime = Math.floor(Date.now() / 1000), additionalParameters = [], }) {
7780
7736
  const signer = this.getSigner();
7781
7737
  if (!this.isTimestampValid(startTime) || !this.isTimestampValid(endTime)) {
7782
7738
  throw new ErrorTimestamp();
@@ -7803,7 +7759,7 @@ class HypercertExchangeClient {
7803
7759
  endTime: endTime,
7804
7760
  price: price,
7805
7761
  itemIds: itemIds,
7806
- amounts: amounts,
7762
+ amounts: itemIds.map(_ => 1n),
7807
7763
  additionalParameters: encodeParams(additionalParameters, getMakerParamsTypes(strategyId)),
7808
7764
  };
7809
7765
  return {
@@ -7817,7 +7773,7 @@ class HypercertExchangeClient {
7817
7773
  * @param CreateMakerInput
7818
7774
  * @returns the maker object, isCurrencyApproved, and isBalanceSufficient
7819
7775
  */
7820
- async createMakerBid({ collection, strategyId, collectionType, subsetNonce, orderNonce, endTime, price, itemIds, amounts = [1], currency, startTime = Math.floor(Date.now() / 1000), additionalParameters = [], }) {
7776
+ async createMakerBid({ collection, strategyId, collectionType, subsetNonce, orderNonce, endTime, price, itemIds, currency, startTime = Math.floor(Date.now() / 1000), additionalParameters = [], }) {
7821
7777
  const signer = this.getSigner();
7822
7778
  if (!this.isTimestampValid(startTime) || !this.isTimestampValid(endTime)) {
7823
7779
  throw new ErrorTimestamp();
@@ -7847,7 +7803,7 @@ class HypercertExchangeClient {
7847
7803
  endTime: endTime,
7848
7804
  price: price,
7849
7805
  itemIds: itemIds,
7850
- amounts: amounts,
7806
+ amounts: itemIds.map(_ => 1n),
7851
7807
  additionalParameters: encodeParams(additionalParameters, getMakerParamsTypes(strategyId)),
7852
7808
  };
7853
7809
  return {
@@ -7856,36 +7812,6 @@ class HypercertExchangeClient {
7856
7812
  isBalanceSufficient: BigInt(balance) >= BigInt(price),
7857
7813
  };
7858
7814
  }
7859
- /**
7860
- * Create a maker bid for collection offer.
7861
- * @see this.createMakerBid
7862
- * @param orderInputs Order data
7863
- * @returns CreateMakerBidOutput
7864
- */
7865
- createMakerCollectionOffer(orderInputs) {
7866
- return this.createMakerBid({ ...orderInputs, strategyId: StrategyType.collection, itemIds: [] });
7867
- }
7868
- /**
7869
- * Create a maker bid for collection, with a list of item id that can be used for the taker order
7870
- * @see this.createMakerBid
7871
- * @param orderInputs Order data
7872
- * @returns CreateMakerBidOutput
7873
- */
7874
- async createMakerCollectionOfferWithProof(orderInputs) {
7875
- const { itemIds, ...otherInputs } = orderInputs;
7876
- const leaves = itemIds.map((itemId) => {
7877
- const hash = solidityPackedKeccak256(["uint256"], [itemId]);
7878
- return Buffer.from(hash.slice(2), "hex");
7879
- });
7880
- const tree = new MerkleTree(leaves, keccak256$1, { sortPairs: true });
7881
- const root = tree.getHexRoot();
7882
- return this.createMakerBid({
7883
- ...otherInputs,
7884
- strategyId: StrategyType.collectionWithMerkleTree,
7885
- additionalParameters: [root],
7886
- itemIds: [],
7887
- });
7888
- }
7889
7815
  /**
7890
7816
  * Create a taker ask ready to be executed against a maker bid
7891
7817
  * @param maker Maker order that will be used as counterparty for the taker
@@ -7899,53 +7825,6 @@ class HypercertExchangeClient {
7899
7825
  additionalParameters: encodeParams(additionalParameters, getTakerParamsTypes(maker.strategyId)),
7900
7826
  };
7901
7827
  }
7902
- /**
7903
- * Create a taker ask order for collection order.
7904
- * @see this.createTaker
7905
- * @see this.createMakerCollectionOffer
7906
- * @param maker Maker bid that will be used as counterparty for the taker
7907
- * @param itemId Token id to use as a counterparty for the collection order
7908
- * @param recipient Recipient address of the taker (if none, it will use the sender)
7909
- * @returns Taker object
7910
- */
7911
- createTakerCollectionOffer(maker, itemId, recipient) {
7912
- if (maker.quoteType !== QuoteType.Bid) {
7913
- throw new ErrorQuoteType();
7914
- }
7915
- if (maker.strategyId !== StrategyType.collection) {
7916
- throw new ErrorStrategyType();
7917
- }
7918
- return this.createTaker(maker, recipient, [itemId]);
7919
- }
7920
- /**
7921
- * Create a taker ask to fulfill a collection order (maker bid) created with a whitelist of item ids
7922
- * @see this.createTaker
7923
- * @see this.createMakerCollectionOfferWithMerkleTree
7924
- * @param maker Maker bid that will be used as counterparty for the taker
7925
- * @param itemId Token id to use as a counterparty for the collection order
7926
- * @param itemIds List of token ids used during the maker creation
7927
- * @param recipient Recipient address of the taker (if none, it will use the sender)
7928
- * @returns Taker object
7929
- */
7930
- createTakerCollectionOfferWithProof(maker, itemId, itemIds, recipient) {
7931
- if (maker.quoteType !== QuoteType.Bid) {
7932
- throw new ErrorQuoteType();
7933
- }
7934
- if (maker.strategyId !== StrategyType.collectionWithMerkleTree) {
7935
- throw new ErrorStrategyType();
7936
- }
7937
- const index = itemIds.findIndex((id) => BigInt(id) === BigInt(itemId));
7938
- if (index === -1) {
7939
- throw new ErrorItemId();
7940
- }
7941
- const leaves = itemIds.map((id) => {
7942
- const hash = solidityPackedKeccak256(["uint256"], [id]);
7943
- return Buffer.from(hash.slice(2), "hex");
7944
- });
7945
- const tree = new MerkleTree(leaves, keccak256$1, { sortPairs: true });
7946
- const proof = tree.getHexProof(leaves[index]);
7947
- return this.createTaker(maker, recipient, [itemId, proof]);
7948
- }
7949
7828
  /**
7950
7829
  * Sign a maker order using the signer provided in the constructor
7951
7830
  * @param maker Order to be signed by the user
@@ -7974,7 +7853,7 @@ class HypercertExchangeClient {
7974
7853
  * @param maker Maker order
7975
7854
  * @param taker Taker order
7976
7855
  * @param signature Signature of the maker order
7977
- * @param merkleTree If the maker has been signed with a merkle tree
7856
+ * @param merkleTree Optional merkle tree
7978
7857
  * @returns ContractMethods
7979
7858
  */
7980
7859
  executeOrder(maker, taker, signature, merkleTree = defaultMerkleTree, overrides) {
@@ -8017,7 +7896,7 @@ class HypercertExchangeClient {
8017
7896
  return incrementBidAskNonces(signer, this.addresses.EXCHANGE_V2, bid, ask, overrides);
8018
7897
  }
8019
7898
  /**
8020
- * Cancel a list of specific orders
7899
+ * Cancel a list of orders by nonce
8021
7900
  * @param nonces List of nonces to be cancelled
8022
7901
  * @returns ContractMethods
8023
7902
  */
@@ -8026,16 +7905,7 @@ class HypercertExchangeClient {
8026
7905
  return cancelOrderNonces(signer, this.addresses.EXCHANGE_V2, nonces, overrides);
8027
7906
  }
8028
7907
  /**
8029
- * Cancel a list of specific subset orders
8030
- * @param nonces List of nonces to be cancelled
8031
- * @returns ContractMethods
8032
- */
8033
- cancelSubsetOrders(nonces, overrides) {
8034
- const signer = this.getSigner();
8035
- return cancelSubsetNonces(signer, this.addresses.EXCHANGE_V2, nonces, overrides);
8036
- }
8037
- /**
8038
- * Approve all the items of a collection, to eventually be traded on HypercertExchange
7908
+ * Approve all the items of a collection, to eventually be traded on the Hypercert Exchange
8039
7909
  * The spender is the TransferManager.
8040
7910
  * @param collectionAddress Address of the collection to be approved.
8041
7911
  * @param approved true to approve, false to revoke the approval (default to true)
@@ -8047,7 +7917,7 @@ class HypercertExchangeClient {
8047
7917
  return setApprovalForAll(signer, collectionAddress, spenderAddress, approved, overrides);
8048
7918
  }
8049
7919
  /**
8050
- * Approve an ERC20 to be used as a currency on HypercertExchange.
7920
+ * Approve an ERC20 to be used as a currency on the Hypercert Exchange.
8051
7921
  * The spender is the HypercertExchangeProtocol contract.
8052
7922
  * @param tokenAddress Address of the ERC20 to approve
8053
7923
  * @param amount Amount to be approved (default to MaxUint256)
@@ -8088,17 +7958,6 @@ class HypercertExchangeClient {
8088
7958
  const signer = this.getSigner();
8089
7959
  return revokeApprovals(signer, this.addresses.TRANSFER_MANAGER_V2, operators, overrides);
8090
7960
  }
8091
- /**
8092
- * Transfer a list of items across different collections
8093
- * @param to Recipient address
8094
- * @param collectionItems Each object in the array represent a list of items for a specific collection
8095
- * @returns ContractMethods
8096
- */
8097
- async transferItemsAcrossCollection(to, collectionItems, overrides) {
8098
- const signer = this.getSigner();
8099
- const from = await signer.getAddress();
8100
- return transferBatchItemsAcrossCollections(signer, this.addresses.TRANSFER_MANAGER_V2, collectionItems, from, to, overrides);
8101
- }
8102
7961
  /**
8103
7962
  * Verify if a set of orders can be executed (i.e are valid)
8104
7963
  * @param makerOrders List of maker orders
@@ -8161,12 +8020,7 @@ class HypercertExchangeClient {
8161
8020
  }
8162
8021
  /**
8163
8022
  * Create a maker ask for a collection or singular offer of fractions
8164
- * @param itemIds Token IDs of the fractions to be sold
8165
- * @param price Price of the fractions in wei
8166
- * @param startTime Timestamp in seconds when the order becomes valid
8167
- * @param endTime Timestamp in seconds when the order becomes invalid
8168
- * @param currency Currency used to buy the fractions (default to WETH)
8169
- * @param additionalParameters Additional parameters used to support complex orders
8023
+ * @param CreateDirectFractionsSaleMakerAskInput
8170
8024
  */
8171
8025
  async createDirectFractionsSaleMakerAsk({ itemIds, price, startTime, endTime, currency, additionalParameters = [], }) {
8172
8026
  const address = await this.signer?.getAddress();
@@ -8181,7 +8035,6 @@ class HypercertExchangeClient {
8181
8035
  address,
8182
8036
  chainId,
8183
8037
  });
8184
- const amounts = Array.from({ length: itemIds.length }, () => 1);
8185
8038
  return this.createMakerAsk({
8186
8039
  // Defaults
8187
8040
  strategyId: StrategyType.standard,
@@ -8189,7 +8042,6 @@ class HypercertExchangeClient {
8189
8042
  collection: this.addresses.MINTER,
8190
8043
  subsetNonce: 0,
8191
8044
  currency,
8192
- amounts,
8193
8045
  orderNonce: nonce_counter.toString(),
8194
8046
  // User specified
8195
8047
  itemIds,
@@ -8200,17 +8052,8 @@ class HypercertExchangeClient {
8200
8052
  });
8201
8053
  }
8202
8054
  /**
8203
- * Create a maker ask to let the buyer decide how much of the fraction they want to buy
8204
- * @param itemIds Token IDs of the fractions to be sold
8205
- * @param price Price of one unit in wei
8206
- * @param startTime Timestamp in seconds when the order becomes valid
8207
- * @param endTime Timestamp in seconds when the order becomes invalid
8208
- * @param currency Currency used to buy the fractions (default to WETH)
8209
- * @param maxUnitAmount Maximum amount of units that can be bought in a single transaction
8210
- * @param minUnitAmount Minimum amount of units that can be bought in a single transaction
8211
- * @param minUnitsToKeep Minimum amount of units that the seller wants to keep
8212
- * @param sellLeftoverFraction Whether or not the seller wants to sell the leftover units
8213
- * @param root Merkle tree root (optional)
8055
+ * Create a maker ask to let the buyer decide how much of a fraction they want to buy
8056
+ * @param CreateFractionalSaleMakerInput
8214
8057
  */
8215
8058
  async createFractionalSaleMakerAsk({ itemIds, price, startTime, endTime, currency, maxUnitAmount, minUnitAmount, minUnitsToKeep, sellLeftoverFraction, root, }) {
8216
8059
  const address = await this.signer?.getAddress();
@@ -8228,7 +8071,7 @@ class HypercertExchangeClient {
8228
8071
  const amounts = Array.from({ length: itemIds.length }, () => 1);
8229
8072
  const sharedArgs = {
8230
8073
  // Defaults
8231
- collectionType: 2,
8074
+ collectionType: CollectionType.HYPERCERT,
8232
8075
  collection: this.addresses.MINTER,
8233
8076
  subsetNonce: 0,
8234
8077
  currency,
@@ -8254,7 +8097,7 @@ class HypercertExchangeClient {
8254
8097
  });
8255
8098
  }
8256
8099
  /**
8257
- * Create a taker bid for buying a fraction of an open fractional sale
8100
+ * Create a taker bid for buying part of a fraction
8258
8101
  * @param maker Maker order
8259
8102
  * @param recipient Recipient address of the taker (if none, it will use the sender)
8260
8103
  * @param unitAmount Amount of units to buy
@@ -8267,7 +8110,7 @@ class HypercertExchangeClient {
8267
8110
  };
8268
8111
  }
8269
8112
  /**
8270
- * Register the order with hypercerts marketplace API.
8113
+ * Register the order with the hypercerts marketplace API
8271
8114
  * @param order Maker order
8272
8115
  * @param signature Signature of the maker order
8273
8116
  */
@@ -8286,7 +8129,7 @@ class HypercertExchangeClient {
8286
8129
  });
8287
8130
  }
8288
8131
  /**
8289
- * Delete the order
8132
+ * Delete the order from the hypercerts marketplace API
8290
8133
  * @param orderId Order ID
8291
8134
  */
8292
8135
  async deleteOrder(orderId) {
package/dist/types.d.ts CHANGED
@@ -41,22 +41,13 @@ export interface ChainInfo {
41
41
  export declare enum CollectionType {
42
42
  ERC721 = 0,
43
43
  ERC1155 = 1,
44
- HYPERCERT = 2,
45
- HYPERBOARD = 3
44
+ HYPERCERT = 2
46
45
  }
47
46
  /** List of trading strategies */
48
47
  export declare enum StrategyType {
49
48
  standard = 0,
50
- collection = 10,
51
- collectionWithMerkleTree = 2,
52
- dutchAuction = 4,
53
- itemIdsRange = 5,
54
- hypercertCollectionOffer = 6,
55
- hypercertCollectionOfferWithProof = 7,
56
- hypercertCollectionOfferWithAllowlist = 8,
57
- hypercertDutchAuction = 9,
58
49
  hypercertFractionOffer = 1,
59
- hypercertFractionOfferWithAllowlist = 11
50
+ hypercertFractionOfferWithAllowlist = 2
60
51
  }
61
52
  /** Type for maker order */
62
53
  export declare enum QuoteType {
@@ -67,16 +58,6 @@ export declare enum QuoteType {
67
58
  export type SolidityType = "bool" | "address" | "uint8" | "uint16" | "uint112" | "uint256" | "uint256[]" | "bytes" | "bytes32" | "bytes32[]" | "string";
68
59
  /** EIP712 type data */
69
60
  export type EIP712TypedData = Record<string, Array<TypedDataField>>;
70
- /**
71
- * Item structure used for batch transfers
72
- * @see {@link https://github.com/LooksRare/contracts-exchange-v2/blob/8de425de2571a57112e9e67cf0c925439a83c9e3/contracts/interfaces/ITransferManager.sol#L16 TransferManager interface}
73
- */
74
- export interface BatchTransferItem {
75
- collection: string;
76
- collectionType: CollectionType;
77
- itemIds: BigNumberish[];
78
- amounts: BigNumberish[];
79
- }
80
61
  /** Return type for any on chain call */
81
62
  export interface ContractMethods {
82
63
  call: (additionalOverrides?: Overrides) => Promise<ContractTransactionResponse>;
@@ -106,25 +87,23 @@ export interface CreateMakerBidOutput {
106
87
  export interface CreateMakerInput {
107
88
  /** Collection address */
108
89
  collection: string;
109
- /** Strategy ID, 0: Standard, 1: Collection, etc*/
90
+ /** Strategy ID, 0: Sell entire fraction, 1: Sell part of a fraction, etc*/
110
91
  strategyId: StrategyType;
111
92
  /** Asset type, 0: ERC-721, 1:ERC-1155, etc */
112
93
  collectionType: CollectionType;
113
94
  /** Subset nonce used to group an arbitrary number of orders under the same nonce */
114
95
  subsetNonce: BigNumberish;
115
- /** Order nonce, get it from the HypercertExchange api */
96
+ /** Order nonce, get it from the HypercertExchange API */
116
97
  orderNonce: BigNumberish;
117
98
  /** Timestamp in seconds when the order becomes invalid */
118
99
  endTime: BigNumberish;
119
100
  /** Asset price in wei */
120
101
  price: BigNumberish;
121
102
  /**
122
- * List of items ids to be sold
103
+ * IDs of fractions to be sold
123
104
  * @defaultValue [1]
124
105
  */
125
106
  itemIds: BigNumberish[];
126
- /** Amount for each item ids (needs to have the same length as itemIds array) */
127
- amounts?: BigNumberish[];
128
107
  /**
129
108
  * Currency address
130
109
  * @defaultValue ETH
@@ -141,6 +120,33 @@ export interface CreateMakerInput {
141
120
  */
142
121
  additionalParameters?: any[];
143
122
  }
123
+ export type CreateDirectFractionsSaleMakerAskInput = Omit<CreateMakerInput, "strategyId" | "collectionType" | "collection" | "subsetNonce" | "orderNonce" | "amounts">;
124
+ export type CreateFractionalSaleMakerAskInput = Omit<CreateMakerInput, "strategyId" | "collectionType" | "collection" | "subsetNonce" | "orderNonce" | "amounts" | "additionalParameters" | "price"> & {
125
+ /**
126
+ * Price of one unit in wei
127
+ */
128
+ price: BigNumberish;
129
+ /**
130
+ * Minimum amount of units to sell per transaction.
131
+ */
132
+ minUnitAmount: BigNumberish;
133
+ /**
134
+ * Maximum amount of units to sell per transaction.
135
+ */
136
+ maxUnitAmount: BigNumberish;
137
+ /**
138
+ * Minimum amount of units to keep after all sales.
139
+ */
140
+ minUnitsToKeep: BigNumberish;
141
+ /**
142
+ * Whether to sell the leftover fraction, if any. This will override `minUnitsAmount` on the last sale if there are leftover units in the fraction.
143
+ */
144
+ sellLeftoverFraction: boolean;
145
+ /**
146
+ * Root of the allowlist tree for users that are allowed to buy parts of the fraction.
147
+ */
148
+ root?: string;
149
+ };
144
150
  export type CreateMakerCollectionOfferInput = Omit<CreateMakerInput, "strategyId" | "itemIds">;
145
151
  export type CreateMakerCollectionOfferWithProofInput = Omit<CreateMakerInput, "strategyId">;
146
152
  /** Maker object to be used in execute functions */
@@ -169,9 +175,9 @@ export interface Maker {
169
175
  endTime: BigNumberish;
170
176
  /** Minimum price to be received after the trade */
171
177
  price: BigNumberish;
172
- /** List of item IDS */
178
+ /** List of fraction IDS */
173
179
  itemIds: BigNumberish[];
174
- /** List of amount for each item ID (1 for ERC721) */
180
+ /** List of amount for sale for each fraction ID (will always be 1 for hypercert fractions as they are unique) */
175
181
  amounts: BigNumberish[];
176
182
  /** Additional parameters for complex orders */
177
183
  additionalParameters: BytesLike;
@@ -5,7 +5,7 @@ export declare class ApiClient {
5
5
  private readonly _urqlClient;
6
6
  constructor(indexerEnvironment: "test" | "production", baseUrl?: string | undefined);
7
7
  /**
8
- * Fetches order nonce from api
8
+ * Fetches order nonce from API
9
9
  * @param address Address
10
10
  * @param chainId Chain ID
11
11
  */
@@ -18,7 +18,7 @@ export declare class ApiClient {
18
18
  chain_id: number;
19
19
  }>;
20
20
  /**
21
- * Registers order in api
21
+ * Registers order in the marketplace API
22
22
  * @param order Order
23
23
  * @param signer Signer
24
24
  * @param signature Signature
@@ -35,6 +35,7 @@ export declare class ApiClient {
35
35
  success: boolean;
36
36
  }>;
37
37
  /**
38
+ * @deprecated use GraphQL API instead
38
39
  * Fetch existing open orders from the marketplace API
39
40
  * @param signer address of the user that created the order
40
41
  * @param claimTokenIds a list of claimTokenIds - will return any order that is for one or more of these claimTokenIds
@@ -93,7 +94,8 @@ export declare class ApiClient {
93
94
  id: string;
94
95
  }[] | null | undefined>;
95
96
  /**
96
- * Fetches orders from api by hypercert ID
97
+ * @deprecated use the GraphQL API instead
98
+ * Fetches orders from API by hypercert ID
97
99
  * @param hypercertId Hypercert ID
98
100
  * @param chainId Chain ID
99
101
  */
@@ -5,5 +5,4 @@ export declare const viewUserBidAskNonces: (signerOrProvider: Provider | Signer,
5
5
  askNonce: bigint;
6
6
  }>;
7
7
  export declare const cancelOrderNonces: (signer: Signer, address: string, nonces: BigNumberish[], overrides?: Overrides) => ContractMethods;
8
- export declare const cancelSubsetNonces: (signer: Signer, address: string, nonces: BigNumberish[], overrides?: Overrides) => ContractMethods;
9
8
  export declare const incrementBidAskNonces: (signer: Signer, address: string, bid: boolean, ask: boolean, overrides?: Overrides) => ContractMethods;
@@ -1,6 +1,5 @@
1
1
  import { Overrides, Provider, Signer } from "ethers";
2
- import { ContractMethods, BatchTransferItem } from "../../types";
2
+ import { ContractMethods } from "../../types";
3
3
  export declare const hasUserApprovedOperator: (signerOrProvider: Provider | Signer, address: string, user: string, operator: string, overrides?: Overrides) => Promise<boolean>;
4
4
  export declare const grantApprovals: (signer: Signer, address: string, operators: string[], overrides?: Overrides) => ContractMethods;
5
5
  export declare const revokeApprovals: (signer: Signer, address: string, operators: string[], overrides?: Overrides) => ContractMethods;
6
- export declare const transferBatchItemsAcrossCollections: (signer: Signer, address: string, items: BatchTransferItem[], from: string, to: string, overrides?: Overrides) => ContractMethods;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hypercerts-org/marketplace-sdk",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -29,7 +29,7 @@
29
29
  "dev": "rollup -c --bundleConfigAsCjs -w",
30
30
  "build:ts": "rollup -c --bundleConfigAsCjs",
31
31
  "build:sc": "hardhat compile",
32
- "build": "yarn build:sc && yarn build:ts",
32
+ "build": "pnpm run build:sc && pnpm run build:ts",
33
33
  "test": "nyc hardhat test",
34
34
  "doc": "typedoc --plugin typedoc-plugin-markdown --tsconfig tsconfig.build.json",
35
35
  "lint": "eslint --max-warnings 0 'src/**/*.{js,ts}'",
@@ -38,7 +38,7 @@
38
38
  "release": "release-it --only-version --set-upstream"
39
39
  },
40
40
  "lint-staged": {
41
- "*.{js,jsx,ts,tsx,json,yaml,yml}": "yarn format:write"
41
+ "*.{js,jsx,ts,tsx,json,yaml,yml}": "pnpm run format:write"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "ethers": "^6.6.2"
@@ -51,6 +51,7 @@
51
51
  "@istanbuljs/nyc-config-typescript": "^1.0.2",
52
52
  "@looksrare/contracts-exchange-v1": "^1.2.0",
53
53
  "@looksrare/contracts-exchange-v2": "^0.1.2",
54
+ "@looksrare/contracts-libs": "^3.5.1",
54
55
  "@nomicfoundation/hardhat-ethers": "^3.0.4",
55
56
  "@rollup/plugin-json": "^6.0.0",
56
57
  "@rollup/plugin-node-resolve": "^15.2.3",
@@ -86,8 +87,8 @@
86
87
  "source-map-support": "^0.5.21",
87
88
  "ts-node": "^10.9.1",
88
89
  "typechain": "^8.2.0",
89
- "typedoc": "^0.24.7",
90
- "typedoc-plugin-markdown": "^3.15.3",
90
+ "typedoc": "^0.27.4",
91
+ "typedoc-plugin-markdown": "^4.3.2",
91
92
  "typescript": "^5.3.3"
92
93
  },
93
94
  "dependencies": {
@@ -96,6 +97,7 @@
96
97
  "@urql/core": "^5.0.4",
97
98
  "ethers": "^6.6.2",
98
99
  "gql.tada": "^1.7.6",
100
+ "js-sha3": "^0.9.3",
99
101
  "merkletreejs": "^0.3.9"
100
102
  }
101
103
  }