@hypercerts-org/marketplace-sdk 0.0.24 → 0.1.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.
@@ -1,16 +1,16 @@
1
1
  import { BigNumberish, ContractTransactionResponse, Overrides, Provider, Signer, TypedDataDomain } from "ethers";
2
- import * as api from "./utils/api";
3
2
  import { Addresses, BatchTransferItem, ChainId, ContractMethods, CreateMakerAskOutput, CreateMakerBidOutput, CreateMakerCollectionOfferInput, CreateMakerCollectionOfferWithProofInput, CreateMakerInput, Maker, MerkleTree, OrderValidatorCode, SignMerkleTreeOrdersOutput, StrategyInfo, StrategyType, Taker } from "./types";
3
+ import { ApiClient } from "./utils/api";
4
4
  /**
5
- * LooksRare
6
- * This class provides helpers to interact with the LooksRare V2 contracts
5
+ * HypercertExchange
6
+ * This class provides helpers to interact with the HypercertExchange V2 contracts
7
7
  */
8
8
  export declare class HypercertExchangeClient {
9
9
  /** Current app chain ID */
10
10
  readonly chainId: ChainId;
11
- /** Mapping of LooksRare protocol addresses for the current chain */
11
+ /** Mapping of Hypercert protocol addresses for the current chain */
12
12
  readonly addresses: Addresses;
13
- readonly api: typeof api;
13
+ readonly api: ApiClient;
14
14
  /**
15
15
  * Ethers signer
16
16
  * @see {@link https://docs.ethers.org/v6/api/providers/#Signer Ethers signer doc}
@@ -22,13 +22,16 @@ export declare class HypercertExchangeClient {
22
22
  */
23
23
  readonly provider: Provider;
24
24
  /**
25
- * LooksRare protocol main class
25
+ * HypercertExchange protocol main class
26
26
  * @param chainId Current app chain id
27
27
  * @param provider Ethers provider
28
28
  * @param signer Ethers signer
29
- * @param override Overrides contract addresses for hardhat setup
29
+ * @param overrides Override contract addresses or api endpoint used
30
30
  */
31
- constructor(chainId: ChainId, provider: Provider, signer?: Signer, override?: Addresses);
31
+ constructor(chainId: ChainId, provider: Provider, signer?: Signer, overrides?: {
32
+ addresses: Addresses;
33
+ apiEndpoint?: string;
34
+ });
32
35
  /**
33
36
  * Return the signer it it's set, throw an exception otherwise
34
37
  * @returns Signer
@@ -135,9 +138,9 @@ export declare class HypercertExchangeClient {
135
138
  signature: string;
136
139
  merkleTree?: MerkleTree;
137
140
  }[], isAtomic: boolean, overrides?: Overrides): {
138
- call: (additionalOverrides?: any) => any;
139
- estimateGas: (additionalOverrides?: any) => any;
140
- callStatic: (additionalOverrides?: any) => any;
141
+ call: (additionalOverrides?: import("./typechain/common").PayableOverrides | undefined) => any;
142
+ estimateGas: (additionalOverrides?: import("./typechain/common").PayableOverrides | undefined) => any;
143
+ callStatic: (additionalOverrides?: import("./typechain/common").PayableOverrides | undefined) => any;
141
144
  };
142
145
  /**
143
146
  * Cancell all maker bid and/or ask orders for the current user
@@ -159,7 +162,7 @@ export declare class HypercertExchangeClient {
159
162
  */
160
163
  cancelSubsetOrders(nonces: BigNumberish[], overrides?: Overrides): ContractMethods;
161
164
  /**
162
- * Approve all the items of a collection, to eventually be traded on LooksRare
165
+ * Approve all the items of a collection, to eventually be traded on HypercertExchange
163
166
  * The spender is the TransferManager.
164
167
  * @param collectionAddress Address of the collection to be approved.
165
168
  * @param approved true to approve, false to revoke the approval (default to true)
@@ -167,8 +170,8 @@ export declare class HypercertExchangeClient {
167
170
  */
168
171
  approveAllCollectionItems(collectionAddress: string, approved?: boolean, overrides?: Overrides): Promise<ContractTransactionResponse>;
169
172
  /**
170
- * Approve an ERC20 to be used as a currency on LooksRare.
171
- * The spender is the LooksRareProtocol contract.
173
+ * Approve an ERC20 to be used as a currency on HypercertExchange.
174
+ * The spender is the HypercertExchangeProtocol contract.
172
175
  * @param tokenAddress Address of the ERC20 to approve
173
176
  * @param amount Amount to be approved (default to MaxUint256)
174
177
  * @returns ContractTransaction
package/dist/index.cjs.js CHANGED
@@ -4804,119 +4804,120 @@ const contractName = "LooksRareProtocol";
4804
4804
  */
4805
4805
  const version = 2;
4806
4806
 
4807
- const HYPERCERTS_MARKETPLACE_API_URL = "https://staging.hyperboards.org/api";
4807
+ const HYPERCERTS_MARKETPLACE_API_URL = "http://localhost:3000/api";
4808
4808
  const SUPABASE_HYPERCERTS_URL = "https://clagjjfinooizoqdkvqc.supabase.co";
4809
4809
  const SUPABASE_HYPERCERTS_ANON_KEY = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImNsYWdqamZpbm9vaXpvcWRrdnFjIiwicm9sZSI6ImFub24iLCJpYXQiOjE2NzY5NTAxNDAsImV4cCI6MTk5MjUyNjE0MH0.LOIW3NcYEfF7w893PS3Ne1VrntACE3OPeSRFkspvyqw";
4810
4810
  const supabaseHypercerts = supabaseJs.createClient(SUPABASE_HYPERCERTS_URL, SUPABASE_HYPERCERTS_ANON_KEY);
4811
- /**
4812
- * Fetches order nonce from api
4813
- * @param address Address
4814
- * @param chainId Chain ID
4815
- */
4816
- const fetchOrderNonce = async ({ address, chainId }) => {
4817
- return fetch(`${HYPERCERTS_MARKETPLACE_API_URL}/marketplace/order-nonce/`, {
4818
- method: "POST",
4819
- headers: {
4820
- "Content-Type": "application/json",
4821
- },
4822
- body: JSON.stringify({
4823
- address,
4824
- chainId,
4825
- }),
4826
- })
4827
- .then((res) => res.json())
4828
- .then((res) => res.data);
4829
- };
4830
- /**
4831
- * Registers order in api
4832
- * @param order Order
4833
- * @param signer Signer
4834
- * @param signature Signature
4835
- * @param quoteType Quote type
4836
- * @param chainId Chain ID
4837
- */
4838
- const registerOrder = async ({ order, signer, signature, quoteType, chainId, }) => {
4839
- const { globalNonce, ...orderWithoutGlobalNonce } = order;
4840
- return fetch(`${HYPERCERTS_MARKETPLACE_API_URL}/marketplace/order/`, {
4841
- method: "POST",
4842
- headers: {
4843
- "Content-Type": "application/json",
4844
- },
4845
- body: JSON.stringify({
4846
- ...orderWithoutGlobalNonce,
4847
- globalNonce: globalNonce.toString(10),
4848
- price: order.price.toString(10),
4849
- quoteType,
4850
- signer,
4851
- signature,
4852
- chainId,
4853
- }),
4854
- }).then((res) => res.json());
4855
- };
4856
- /**
4857
- * Fetches orders from api by hypercert ID
4858
- * @param hypercertId Hypercert ID
4859
- * @param chainId Chain ID
4860
- */
4861
- const fetchOrdersByHypercertId = async ({ hypercertId, chainId }) => {
4862
- const hypercertsClient = new sdk.HypercertClient({
4863
- chain: { id: chainId },
4864
- });
4865
- const fractions = await hypercertsClient.indexer.fractionsByClaim(hypercertId);
4866
- const tokenIds = fractions.claimTokens.map((fraction) => fraction.tokenID);
4867
- return supabaseHypercerts.from("marketplace-orders").select("*").containedBy("itemIds", tokenIds).throwOnError();
4868
- };
4869
- /**
4870
- * Fetch existing open orders from the marketplace API
4871
- * @param signer address of the user that created the order
4872
- * @param claimTokenIds a list of claimTokenIds - will return any order that is for one or more of these claimTokenIds
4873
- * @param chainId chain id for the order
4874
- * @param strategy strategy for the order
4875
- */
4876
- const fetchOrders = async ({ signer, claimTokenIds, chainId, strategy }) => {
4877
- let baseQuery = supabaseHypercerts.from("marketplace-orders").select("*");
4878
- if (signer) {
4879
- baseQuery.eq("signer", signer);
4880
- }
4881
- if (claimTokenIds) {
4882
- baseQuery = baseQuery.overlaps("itemIds", claimTokenIds);
4883
- }
4884
- if (chainId) {
4885
- baseQuery.eq("chainId", chainId);
4886
- }
4887
- if (strategy) {
4888
- baseQuery.eq("strategyId", strategy);
4811
+ class ApiClient {
4812
+ constructor(baseUrl) {
4813
+ this.baseUrl = baseUrl;
4814
+ /**
4815
+ * Fetches order nonce from api
4816
+ * @param address Address
4817
+ * @param chainId Chain ID
4818
+ */
4819
+ this.fetchOrderNonce = async ({ address, chainId }) => {
4820
+ return fetch(`${this.baseUrl}/marketplace/order-nonce/`, {
4821
+ method: "POST",
4822
+ headers: {
4823
+ "Content-Type": "application/json",
4824
+ },
4825
+ body: JSON.stringify({
4826
+ address,
4827
+ chainId,
4828
+ }),
4829
+ })
4830
+ .then((res) => res.json())
4831
+ .then((res) => res.data);
4832
+ };
4833
+ /**
4834
+ * Registers order in api
4835
+ * @param order Order
4836
+ * @param signer Signer
4837
+ * @param signature Signature
4838
+ * @param quoteType Quote type
4839
+ * @param chainId Chain ID
4840
+ */
4841
+ this.registerOrder = async ({ order, signer, signature, quoteType, chainId, }) => {
4842
+ const { globalNonce, ...orderWithoutGlobalNonce } = order;
4843
+ return fetch(`${this.baseUrl}/marketplace/order/`, {
4844
+ method: "POST",
4845
+ headers: {
4846
+ "Content-Type": "application/json",
4847
+ },
4848
+ body: JSON.stringify({
4849
+ ...orderWithoutGlobalNonce,
4850
+ globalNonce: globalNonce.toString(10),
4851
+ price: order.price.toString(10),
4852
+ quoteType,
4853
+ signer,
4854
+ signature,
4855
+ chainId,
4856
+ }),
4857
+ }).then((res) => res.json());
4858
+ };
4859
+ /**
4860
+ * Fetch existing open orders from the marketplace API
4861
+ * @param signer address of the user that created the order
4862
+ * @param claimTokenIds a list of claimTokenIds - will return any order that is for one or more of these claimTokenIds
4863
+ * @param chainId chain id for the order
4864
+ * @param strategy strategy for the order
4865
+ */
4866
+ this.fetchOrders = async ({ signer, claimTokenIds, chainId, strategy }) => {
4867
+ let baseQuery = supabaseHypercerts.from("marketplace-orders").select("*");
4868
+ if (signer) {
4869
+ baseQuery.eq("signer", signer);
4870
+ }
4871
+ if (claimTokenIds) {
4872
+ baseQuery = baseQuery.overlaps("itemIds", claimTokenIds);
4873
+ }
4874
+ if (chainId) {
4875
+ baseQuery.eq("chainId", chainId);
4876
+ }
4877
+ if (strategy) {
4878
+ baseQuery.eq("strategyId", strategy);
4879
+ }
4880
+ return baseQuery.throwOnError();
4881
+ };
4882
+ /**
4883
+ * Fetches orders from api by hypercert ID
4884
+ * @param hypercertId Hypercert ID
4885
+ * @param chainId Chain ID
4886
+ */
4887
+ this.fetchOrdersByHypercertId = async ({ hypercertId, chainId }) => {
4888
+ const hypercertsClient = new sdk.HypercertClient({
4889
+ chain: { id: chainId },
4890
+ });
4891
+ const fractions = await hypercertsClient.indexer.fractionsByClaim(hypercertId);
4892
+ const tokenIds = fractions.claimTokens.map((fraction) => fraction.tokenID);
4893
+ return supabaseHypercerts.from("marketplace-orders").select("*").containedBy("itemIds", tokenIds).throwOnError();
4894
+ };
4895
+ const url = baseUrl || HYPERCERTS_MARKETPLACE_API_URL;
4896
+ if (!url) {
4897
+ throw new Error("No API URL provided");
4898
+ }
4899
+ this._baseUrl = url;
4889
4900
  }
4890
- return baseQuery.throwOnError();
4891
- };
4892
-
4893
- var api = /*#__PURE__*/Object.freeze({
4894
- __proto__: null,
4895
- fetchOrderNonce: fetchOrderNonce,
4896
- fetchOrders: fetchOrders,
4897
- fetchOrdersByHypercertId: fetchOrdersByHypercertId,
4898
- registerOrder: registerOrder,
4899
- supabaseHypercerts: supabaseHypercerts
4900
- });
4901
+ }
4901
4902
 
4902
4903
  /**
4903
- * LooksRare
4904
- * This class provides helpers to interact with the LooksRare V2 contracts
4904
+ * HypercertExchange
4905
+ * This class provides helpers to interact with the HypercertExchange V2 contracts
4905
4906
  */
4906
4907
  class HypercertExchangeClient {
4907
4908
  /**
4908
- * LooksRare protocol main class
4909
+ * HypercertExchange protocol main class
4909
4910
  * @param chainId Current app chain id
4910
4911
  * @param provider Ethers provider
4911
4912
  * @param signer Ethers signer
4912
- * @param override Overrides contract addresses for hardhat setup
4913
+ * @param overrides Override contract addresses or api endpoint used
4913
4914
  */
4914
- constructor(chainId, provider, signer, override) {
4915
+ constructor(chainId, provider, signer, overrides) {
4915
4916
  this.chainId = chainId;
4916
- this.addresses = override ?? addressesByNetwork[this.chainId];
4917
+ this.addresses = overrides?.addresses ?? addressesByNetwork[this.chainId];
4917
4918
  this.signer = signer;
4918
4919
  this.provider = provider;
4919
- this.api = api;
4920
+ this.api = new ApiClient(overrides?.apiEndpoint);
4920
4921
  }
4921
4922
  /**
4922
4923
  * Return the signer it it's set, throw an exception otherwise
@@ -5209,7 +5210,7 @@ class HypercertExchangeClient {
5209
5210
  return cancelSubsetNonces(signer, this.addresses.EXCHANGE_V2, nonces, overrides);
5210
5211
  }
5211
5212
  /**
5212
- * Approve all the items of a collection, to eventually be traded on LooksRare
5213
+ * Approve all the items of a collection, to eventually be traded on HypercertExchange
5213
5214
  * The spender is the TransferManager.
5214
5215
  * @param collectionAddress Address of the collection to be approved.
5215
5216
  * @param approved true to approve, false to revoke the approval (default to true)
@@ -5221,8 +5222,8 @@ class HypercertExchangeClient {
5221
5222
  return setApprovalForAll(signer, collectionAddress, spenderAddress, approved, overrides);
5222
5223
  }
5223
5224
  /**
5224
- * Approve an ERC20 to be used as a currency on LooksRare.
5225
- * The spender is the LooksRareProtocol contract.
5225
+ * Approve an ERC20 to be used as a currency on HypercertExchange.
5226
+ * The spender is the HypercertExchangeProtocol contract.
5226
5227
  * @param tokenAddress Address of the ERC20 to approve
5227
5228
  * @param amount Amount to be approved (default to MaxUint256)
5228
5229
  * @returns ContractTransaction
@@ -5307,7 +5308,7 @@ class HypercertExchangeClient {
5307
5308
  throw new Error("No signer address could be determined");
5308
5309
  }
5309
5310
  const chainId = this.chainId;
5310
- const { nonce_counter } = await fetchOrderNonce({
5311
+ const { nonce_counter } = await this.api.fetchOrderNonce({
5311
5312
  address,
5312
5313
  chainId,
5313
5314
  });
@@ -5348,7 +5349,7 @@ class HypercertExchangeClient {
5348
5349
  throw new Error("No signer address could be determined");
5349
5350
  }
5350
5351
  const chainId = this.chainId;
5351
- const { nonce_counter } = await fetchOrderNonce({
5352
+ const { nonce_counter } = await this.api.fetchOrderNonce({
5352
5353
  address,
5353
5354
  chainId,
5354
5355
  });
@@ -5404,7 +5405,7 @@ class HypercertExchangeClient {
5404
5405
  throw new Error("No signer address could be determined");
5405
5406
  }
5406
5407
  const chainId = this.chainId;
5407
- return registerOrder({
5408
+ return this.api.registerOrder({
5408
5409
  order,
5409
5410
  signer: address,
5410
5411
  signature,
package/dist/index.d.ts CHANGED
@@ -23,12 +23,12 @@ declare const utils: {
23
23
  cancelOrderNonces: (signer: import("ethers").Signer, address: string, nonces: import("ethers").BigNumberish[], overrides?: import("ethers").Overrides | undefined) => import("./types").ContractMethods;
24
24
  cancelSubsetNonces: (signer: import("ethers").Signer, address: string, nonces: import("ethers").BigNumberish[], overrides?: import("ethers").Overrides | undefined) => import("./types").ContractMethods;
25
25
  incrementBidAskNonces: (signer: import("ethers").Signer, address: string, bid: boolean, ask: boolean, overrides?: import("ethers").Overrides | undefined) => import("./types").ContractMethods;
26
- executeTakerBid: (signer: import("ethers").Signer, address: string, taker: import("./types").Taker, maker: import("./types").Maker, makerSignature: string, merkleTree: import("./types").MerkleTree, overrides?: any) => import("./types").ContractMethods;
27
- executeTakerAsk: (signer: import("ethers").Signer, address: string, taker: import("./types").Taker, maker: import("./types").Maker, makerSignature: string, merkleTree: import("./types").MerkleTree, overrides?: any) => import("./types").ContractMethods;
28
- executeMultipleTakerBids: (signer: import("ethers").Signer, address: string, taker: import("./types").Taker[], maker: import("./types").Maker[], makerSignature: string[], isAtomic: boolean, merkleTree: import("./types").MerkleTree[], overrides?: any) => {
29
- call: (additionalOverrides?: any) => any;
30
- estimateGas: (additionalOverrides?: any) => any;
31
- callStatic: (additionalOverrides?: any) => any;
26
+ executeTakerBid: (signer: import("ethers").Signer, address: string, taker: import("./types").Taker, maker: import("./types").Maker, makerSignature: string, merkleTree: import("./types").MerkleTree, overrides?: import("./typechain/common").PayableOverrides | undefined) => import("./types").ContractMethods;
27
+ executeTakerAsk: (signer: import("ethers").Signer, address: string, taker: import("./types").Taker, maker: import("./types").Maker, makerSignature: string, merkleTree: import("./types").MerkleTree, overrides?: import("./typechain/common").PayableOverrides | undefined) => import("./types").ContractMethods;
28
+ executeMultipleTakerBids: (signer: import("ethers").Signer, address: string, taker: import("./types").Taker[], maker: import("./types").Maker[], makerSignature: string[], isAtomic: boolean, merkleTree: import("./types").MerkleTree[], overrides?: import("./typechain/common").PayableOverrides | undefined) => {
29
+ call: (additionalOverrides?: import("./typechain/common").PayableOverrides | undefined) => any;
30
+ estimateGas: (additionalOverrides?: import("./typechain/common").PayableOverrides | undefined) => any;
31
+ callStatic: (additionalOverrides?: import("./typechain/common").PayableOverrides | undefined) => any;
32
32
  };
33
33
  setApprovalForAll: (signer: import("ethers").Signer, collection: string, operator: string, approved: boolean, overrides?: import("ethers").Overrides | undefined) => Promise<import("ethers").ContractTransactionResponse>;
34
34
  isApprovedForAll: (signerOrProvider: import("ethers").Signer | import("ethers").Provider, collection: string, account: string, operator: string, overrides?: import("ethers").Overrides | undefined) => Promise<boolean>;
package/dist/index.esm.js CHANGED
@@ -4802,119 +4802,120 @@ const contractName = "LooksRareProtocol";
4802
4802
  */
4803
4803
  const version = 2;
4804
4804
 
4805
- const HYPERCERTS_MARKETPLACE_API_URL = "https://staging.hyperboards.org/api";
4805
+ const HYPERCERTS_MARKETPLACE_API_URL = "http://localhost:3000/api";
4806
4806
  const SUPABASE_HYPERCERTS_URL = "https://clagjjfinooizoqdkvqc.supabase.co";
4807
4807
  const SUPABASE_HYPERCERTS_ANON_KEY = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImNsYWdqamZpbm9vaXpvcWRrdnFjIiwicm9sZSI6ImFub24iLCJpYXQiOjE2NzY5NTAxNDAsImV4cCI6MTk5MjUyNjE0MH0.LOIW3NcYEfF7w893PS3Ne1VrntACE3OPeSRFkspvyqw";
4808
4808
  const supabaseHypercerts = createClient(SUPABASE_HYPERCERTS_URL, SUPABASE_HYPERCERTS_ANON_KEY);
4809
- /**
4810
- * Fetches order nonce from api
4811
- * @param address Address
4812
- * @param chainId Chain ID
4813
- */
4814
- const fetchOrderNonce = async ({ address, chainId }) => {
4815
- return fetch(`${HYPERCERTS_MARKETPLACE_API_URL}/marketplace/order-nonce/`, {
4816
- method: "POST",
4817
- headers: {
4818
- "Content-Type": "application/json",
4819
- },
4820
- body: JSON.stringify({
4821
- address,
4822
- chainId,
4823
- }),
4824
- })
4825
- .then((res) => res.json())
4826
- .then((res) => res.data);
4827
- };
4828
- /**
4829
- * Registers order in api
4830
- * @param order Order
4831
- * @param signer Signer
4832
- * @param signature Signature
4833
- * @param quoteType Quote type
4834
- * @param chainId Chain ID
4835
- */
4836
- const registerOrder = async ({ order, signer, signature, quoteType, chainId, }) => {
4837
- const { globalNonce, ...orderWithoutGlobalNonce } = order;
4838
- return fetch(`${HYPERCERTS_MARKETPLACE_API_URL}/marketplace/order/`, {
4839
- method: "POST",
4840
- headers: {
4841
- "Content-Type": "application/json",
4842
- },
4843
- body: JSON.stringify({
4844
- ...orderWithoutGlobalNonce,
4845
- globalNonce: globalNonce.toString(10),
4846
- price: order.price.toString(10),
4847
- quoteType,
4848
- signer,
4849
- signature,
4850
- chainId,
4851
- }),
4852
- }).then((res) => res.json());
4853
- };
4854
- /**
4855
- * Fetches orders from api by hypercert ID
4856
- * @param hypercertId Hypercert ID
4857
- * @param chainId Chain ID
4858
- */
4859
- const fetchOrdersByHypercertId = async ({ hypercertId, chainId }) => {
4860
- const hypercertsClient = new HypercertClient({
4861
- chain: { id: chainId },
4862
- });
4863
- const fractions = await hypercertsClient.indexer.fractionsByClaim(hypercertId);
4864
- const tokenIds = fractions.claimTokens.map((fraction) => fraction.tokenID);
4865
- return supabaseHypercerts.from("marketplace-orders").select("*").containedBy("itemIds", tokenIds).throwOnError();
4866
- };
4867
- /**
4868
- * Fetch existing open orders from the marketplace API
4869
- * @param signer address of the user that created the order
4870
- * @param claimTokenIds a list of claimTokenIds - will return any order that is for one or more of these claimTokenIds
4871
- * @param chainId chain id for the order
4872
- * @param strategy strategy for the order
4873
- */
4874
- const fetchOrders = async ({ signer, claimTokenIds, chainId, strategy }) => {
4875
- let baseQuery = supabaseHypercerts.from("marketplace-orders").select("*");
4876
- if (signer) {
4877
- baseQuery.eq("signer", signer);
4878
- }
4879
- if (claimTokenIds) {
4880
- baseQuery = baseQuery.overlaps("itemIds", claimTokenIds);
4881
- }
4882
- if (chainId) {
4883
- baseQuery.eq("chainId", chainId);
4884
- }
4885
- if (strategy) {
4886
- baseQuery.eq("strategyId", strategy);
4809
+ class ApiClient {
4810
+ constructor(baseUrl) {
4811
+ this.baseUrl = baseUrl;
4812
+ /**
4813
+ * Fetches order nonce from api
4814
+ * @param address Address
4815
+ * @param chainId Chain ID
4816
+ */
4817
+ this.fetchOrderNonce = async ({ address, chainId }) => {
4818
+ return fetch(`${this.baseUrl}/marketplace/order-nonce/`, {
4819
+ method: "POST",
4820
+ headers: {
4821
+ "Content-Type": "application/json",
4822
+ },
4823
+ body: JSON.stringify({
4824
+ address,
4825
+ chainId,
4826
+ }),
4827
+ })
4828
+ .then((res) => res.json())
4829
+ .then((res) => res.data);
4830
+ };
4831
+ /**
4832
+ * Registers order in api
4833
+ * @param order Order
4834
+ * @param signer Signer
4835
+ * @param signature Signature
4836
+ * @param quoteType Quote type
4837
+ * @param chainId Chain ID
4838
+ */
4839
+ this.registerOrder = async ({ order, signer, signature, quoteType, chainId, }) => {
4840
+ const { globalNonce, ...orderWithoutGlobalNonce } = order;
4841
+ return fetch(`${this.baseUrl}/marketplace/order/`, {
4842
+ method: "POST",
4843
+ headers: {
4844
+ "Content-Type": "application/json",
4845
+ },
4846
+ body: JSON.stringify({
4847
+ ...orderWithoutGlobalNonce,
4848
+ globalNonce: globalNonce.toString(10),
4849
+ price: order.price.toString(10),
4850
+ quoteType,
4851
+ signer,
4852
+ signature,
4853
+ chainId,
4854
+ }),
4855
+ }).then((res) => res.json());
4856
+ };
4857
+ /**
4858
+ * Fetch existing open orders from the marketplace API
4859
+ * @param signer address of the user that created the order
4860
+ * @param claimTokenIds a list of claimTokenIds - will return any order that is for one or more of these claimTokenIds
4861
+ * @param chainId chain id for the order
4862
+ * @param strategy strategy for the order
4863
+ */
4864
+ this.fetchOrders = async ({ signer, claimTokenIds, chainId, strategy }) => {
4865
+ let baseQuery = supabaseHypercerts.from("marketplace-orders").select("*");
4866
+ if (signer) {
4867
+ baseQuery.eq("signer", signer);
4868
+ }
4869
+ if (claimTokenIds) {
4870
+ baseQuery = baseQuery.overlaps("itemIds", claimTokenIds);
4871
+ }
4872
+ if (chainId) {
4873
+ baseQuery.eq("chainId", chainId);
4874
+ }
4875
+ if (strategy) {
4876
+ baseQuery.eq("strategyId", strategy);
4877
+ }
4878
+ return baseQuery.throwOnError();
4879
+ };
4880
+ /**
4881
+ * Fetches orders from api by hypercert ID
4882
+ * @param hypercertId Hypercert ID
4883
+ * @param chainId Chain ID
4884
+ */
4885
+ this.fetchOrdersByHypercertId = async ({ hypercertId, chainId }) => {
4886
+ const hypercertsClient = new HypercertClient({
4887
+ chain: { id: chainId },
4888
+ });
4889
+ const fractions = await hypercertsClient.indexer.fractionsByClaim(hypercertId);
4890
+ const tokenIds = fractions.claimTokens.map((fraction) => fraction.tokenID);
4891
+ return supabaseHypercerts.from("marketplace-orders").select("*").containedBy("itemIds", tokenIds).throwOnError();
4892
+ };
4893
+ const url = baseUrl || HYPERCERTS_MARKETPLACE_API_URL;
4894
+ if (!url) {
4895
+ throw new Error("No API URL provided");
4896
+ }
4897
+ this._baseUrl = url;
4887
4898
  }
4888
- return baseQuery.throwOnError();
4889
- };
4890
-
4891
- var api = /*#__PURE__*/Object.freeze({
4892
- __proto__: null,
4893
- fetchOrderNonce: fetchOrderNonce,
4894
- fetchOrders: fetchOrders,
4895
- fetchOrdersByHypercertId: fetchOrdersByHypercertId,
4896
- registerOrder: registerOrder,
4897
- supabaseHypercerts: supabaseHypercerts
4898
- });
4899
+ }
4899
4900
 
4900
4901
  /**
4901
- * LooksRare
4902
- * This class provides helpers to interact with the LooksRare V2 contracts
4902
+ * HypercertExchange
4903
+ * This class provides helpers to interact with the HypercertExchange V2 contracts
4903
4904
  */
4904
4905
  class HypercertExchangeClient {
4905
4906
  /**
4906
- * LooksRare protocol main class
4907
+ * HypercertExchange protocol main class
4907
4908
  * @param chainId Current app chain id
4908
4909
  * @param provider Ethers provider
4909
4910
  * @param signer Ethers signer
4910
- * @param override Overrides contract addresses for hardhat setup
4911
+ * @param overrides Override contract addresses or api endpoint used
4911
4912
  */
4912
- constructor(chainId, provider, signer, override) {
4913
+ constructor(chainId, provider, signer, overrides) {
4913
4914
  this.chainId = chainId;
4914
- this.addresses = override ?? addressesByNetwork[this.chainId];
4915
+ this.addresses = overrides?.addresses ?? addressesByNetwork[this.chainId];
4915
4916
  this.signer = signer;
4916
4917
  this.provider = provider;
4917
- this.api = api;
4918
+ this.api = new ApiClient(overrides?.apiEndpoint);
4918
4919
  }
4919
4920
  /**
4920
4921
  * Return the signer it it's set, throw an exception otherwise
@@ -5207,7 +5208,7 @@ class HypercertExchangeClient {
5207
5208
  return cancelSubsetNonces(signer, this.addresses.EXCHANGE_V2, nonces, overrides);
5208
5209
  }
5209
5210
  /**
5210
- * Approve all the items of a collection, to eventually be traded on LooksRare
5211
+ * Approve all the items of a collection, to eventually be traded on HypercertExchange
5211
5212
  * The spender is the TransferManager.
5212
5213
  * @param collectionAddress Address of the collection to be approved.
5213
5214
  * @param approved true to approve, false to revoke the approval (default to true)
@@ -5219,8 +5220,8 @@ class HypercertExchangeClient {
5219
5220
  return setApprovalForAll(signer, collectionAddress, spenderAddress, approved, overrides);
5220
5221
  }
5221
5222
  /**
5222
- * Approve an ERC20 to be used as a currency on LooksRare.
5223
- * The spender is the LooksRareProtocol contract.
5223
+ * Approve an ERC20 to be used as a currency on HypercertExchange.
5224
+ * The spender is the HypercertExchangeProtocol contract.
5224
5225
  * @param tokenAddress Address of the ERC20 to approve
5225
5226
  * @param amount Amount to be approved (default to MaxUint256)
5226
5227
  * @returns ContractTransaction
@@ -5305,7 +5306,7 @@ class HypercertExchangeClient {
5305
5306
  throw new Error("No signer address could be determined");
5306
5307
  }
5307
5308
  const chainId = this.chainId;
5308
- const { nonce_counter } = await fetchOrderNonce({
5309
+ const { nonce_counter } = await this.api.fetchOrderNonce({
5309
5310
  address,
5310
5311
  chainId,
5311
5312
  });
@@ -5346,7 +5347,7 @@ class HypercertExchangeClient {
5346
5347
  throw new Error("No signer address could be determined");
5347
5348
  }
5348
5349
  const chainId = this.chainId;
5349
- const { nonce_counter } = await fetchOrderNonce({
5350
+ const { nonce_counter } = await this.api.fetchOrderNonce({
5350
5351
  address,
5351
5352
  chainId,
5352
5353
  });
@@ -5402,7 +5403,7 @@ class HypercertExchangeClient {
5402
5403
  throw new Error("No signer address could be determined");
5403
5404
  }
5404
5405
  const chainId = this.chainId;
5405
- return registerOrder({
5406
+ return this.api.registerOrder({
5406
5407
  order,
5407
5408
  signer: address,
5408
5409
  signature,
package/dist/types.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { BigNumberish, BytesLike, Overrides, TypedDataField, ContractTransactionResponse } from "ethers";
2
2
  import { Eip712MakerMerkleTree } from "./utils/Eip712MakerMerkleTree";
3
- /** Addresses used to create a LooksRare instance */
3
+ /** Addresses used to create a HypercertExchange instance */
4
4
  export interface Addresses {
5
5
  EXCHANGE_V2: `0x${string}`;
6
6
  TRANSFER_MANAGER_V2: `0x${string}`;
@@ -13,7 +13,7 @@ export declare enum ChainId {
13
13
  SEPOLIA = 11155111,
14
14
  HARDHAT = 31337
15
15
  }
16
- /** ChainInfo data used to interact with LooksRare ecosystem */
16
+ /** ChainInfo data used to interact with HypercertExchange ecosystem */
17
17
  export interface ChainInfo {
18
18
  label: string;
19
19
  appUrl: string;
@@ -97,7 +97,7 @@ export interface CreateMakerInput {
97
97
  collectionType: CollectionType;
98
98
  /** Subset nonce used to group an arbitrary number of orders under the same nonce */
99
99
  subsetNonce: BigNumberish;
100
- /** Order nonce, get it from the LooksRare api */
100
+ /** Order nonce, get it from the HypercertExchange api */
101
101
  orderNonce: BigNumberish;
102
102
  /** Timestamp in seconds when the order becomes invalid */
103
103
  endTime: BigNumberish;
@@ -74,11 +74,6 @@ export declare const supabaseHypercerts: import("@supabase/supabase-js").Supabas
74
74
  created_at?: string | null | undefined;
75
75
  fractionCounter?: number | null | undefined;
76
76
  hidden?: boolean | undefined;
77
- /**
78
- * Fetches orders from api by hypercert ID
79
- * @param hypercertId Hypercert ID
80
- * @param chainId Chain ID
81
- */
82
77
  id?: number | undefined;
83
78
  };
84
79
  Update: {
@@ -90,7 +85,13 @@ export declare const supabaseHypercerts: import("@supabase/supabase-js").Supabas
90
85
  id?: number | undefined;
91
86
  };
92
87
  Relationships: [];
93
- };
88
+ }; /**
89
+ * Fetch existing open orders from the marketplace API
90
+ * @param signer address of the user that created the order
91
+ * @param claimTokenIds a list of claimTokenIds - will return any order that is for one or more of these claimTokenIds
92
+ * @param chainId chain id for the order
93
+ * @param strategy strategy for the order
94
+ */
94
95
  "allowlistCache-optimism": {
95
96
  Row: {
96
97
  address: string | null;
@@ -105,13 +106,7 @@ export declare const supabaseHypercerts: import("@supabase/supabase-js").Supabas
105
106
  claimId?: string | null | undefined;
106
107
  created_at?: string | null | undefined;
107
108
  fractionCounter?: number | null | undefined;
108
- hidden?: boolean | undefined; /**
109
- * Fetch existing open orders from the marketplace API
110
- * @param signer address of the user that created the order
111
- * @param claimTokenIds a list of claimTokenIds - will return any order that is for one or more of these claimTokenIds
112
- * @param chainId chain id for the order
113
- * @param strategy strategy for the order
114
- */
109
+ hidden?: boolean | undefined;
115
110
  id?: number | undefined;
116
111
  };
117
112
  Update: {
@@ -735,97 +730,102 @@ export declare const supabaseHypercerts: import("@supabase/supabase-js").Supabas
735
730
  Enums: {};
736
731
  CompositeTypes: {};
737
732
  }>;
738
- /**
739
- * Fetches order nonce from api
740
- * @param address Address
741
- * @param chainId Chain ID
742
- */
743
- export declare const fetchOrderNonce: ({ address, chainId }: {
744
- address: string;
745
- chainId: number;
746
- }) => Promise<{
747
- nonce_counter: number;
748
- address: string;
749
- chain_id: number;
750
- }>;
751
- /**
752
- * Registers order in api
753
- * @param order Order
754
- * @param signer Signer
755
- * @param signature Signature
756
- * @param quoteType Quote type
757
- * @param chainId Chain ID
758
- */
759
- export declare const registerOrder: ({ order, signer, signature, quoteType, chainId, }: {
760
- order: Maker;
761
- signer: string;
762
- signature: string;
763
- quoteType: QuoteType;
764
- chainId: number;
765
- }) => Promise<{
766
- success: boolean;
767
- }>;
768
- /**
769
- * Fetches orders from api by hypercert ID
770
- * @param hypercertId Hypercert ID
771
- * @param chainId Chain ID
772
- */
773
- export declare const fetchOrdersByHypercertId: ({ hypercertId, chainId }: {
774
- hypercertId: string;
775
- chainId: number;
776
- }) => Promise<import("@supabase/supabase-js").PostgrestSingleResponse<{
777
- additionalParameters: string;
778
- amounts: number[];
779
- chainId: number;
780
- collection: string;
781
- collectionType: number;
782
- createdAt: string;
783
- currency: string;
784
- endTime: number;
785
- globalNonce: string;
786
- id: string;
787
- itemIds: string[];
788
- orderNonce: string;
789
- price: string;
790
- quoteType: number;
791
- signature: string;
792
- signer: string;
793
- startTime: number;
794
- strategyId: number;
795
- subsetNonce: number;
796
- }[]>>;
733
+ export declare class ApiClient {
734
+ private readonly baseUrl?;
735
+ private _baseUrl;
736
+ constructor(baseUrl?: string | undefined);
737
+ /**
738
+ * Fetches order nonce from api
739
+ * @param address Address
740
+ * @param chainId Chain ID
741
+ */
742
+ fetchOrderNonce: ({ address, chainId }: {
743
+ address: string;
744
+ chainId: number;
745
+ }) => Promise<{
746
+ nonce_counter: number;
747
+ address: string;
748
+ chain_id: number;
749
+ }>;
750
+ /**
751
+ * Registers order in api
752
+ * @param order Order
753
+ * @param signer Signer
754
+ * @param signature Signature
755
+ * @param quoteType Quote type
756
+ * @param chainId Chain ID
757
+ */
758
+ registerOrder: ({ order, signer, signature, quoteType, chainId, }: {
759
+ order: Maker;
760
+ signer: string;
761
+ signature: string;
762
+ quoteType: QuoteType;
763
+ chainId: number;
764
+ }) => Promise<{
765
+ success: boolean;
766
+ }>;
767
+ /**
768
+ * Fetch existing open orders from the marketplace API
769
+ * @param signer address of the user that created the order
770
+ * @param claimTokenIds a list of claimTokenIds - will return any order that is for one or more of these claimTokenIds
771
+ * @param chainId chain id for the order
772
+ * @param strategy strategy for the order
773
+ */
774
+ fetchOrders: ({ signer, claimTokenIds, chainId, strategy }: Partial<FetchOrderArgs>) => Promise<import("@supabase/supabase-js").PostgrestSingleResponse<{
775
+ additionalParameters: string;
776
+ amounts: number[];
777
+ chainId: number;
778
+ collection: string;
779
+ collectionType: number;
780
+ createdAt: string;
781
+ currency: string;
782
+ endTime: number;
783
+ globalNonce: string;
784
+ id: string;
785
+ itemIds: string[];
786
+ orderNonce: string;
787
+ price: string;
788
+ quoteType: number;
789
+ signature: string;
790
+ signer: string;
791
+ startTime: number;
792
+ strategyId: number;
793
+ subsetNonce: number;
794
+ }[]>>;
795
+ /**
796
+ * Fetches orders from api by hypercert ID
797
+ * @param hypercertId Hypercert ID
798
+ * @param chainId Chain ID
799
+ */
800
+ fetchOrdersByHypercertId: ({ hypercertId, chainId }: {
801
+ hypercertId: string;
802
+ chainId: number;
803
+ }) => Promise<import("@supabase/supabase-js").PostgrestSingleResponse<{
804
+ additionalParameters: string;
805
+ amounts: number[];
806
+ chainId: number;
807
+ collection: string;
808
+ collectionType: number;
809
+ createdAt: string;
810
+ currency: string;
811
+ endTime: number;
812
+ globalNonce: string;
813
+ id: string;
814
+ itemIds: string[];
815
+ orderNonce: string;
816
+ price: string;
817
+ quoteType: number;
818
+ signature: string;
819
+ signer: string;
820
+ startTime: number;
821
+ strategyId: number;
822
+ subsetNonce: number;
823
+ }[]>>;
824
+ }
797
825
  interface FetchOrderArgs {
798
826
  signer: `0x${string}`;
799
827
  claimTokenIds: string[];
800
828
  chainId: number;
801
829
  strategy: StrategyType;
802
830
  }
803
- /**
804
- * Fetch existing open orders from the marketplace API
805
- * @param signer address of the user that created the order
806
- * @param claimTokenIds a list of claimTokenIds - will return any order that is for one or more of these claimTokenIds
807
- * @param chainId chain id for the order
808
- * @param strategy strategy for the order
809
- */
810
- export declare const fetchOrders: ({ signer, claimTokenIds, chainId, strategy }: Partial<FetchOrderArgs>) => Promise<import("@supabase/supabase-js").PostgrestSingleResponse<{
811
- additionalParameters: string;
812
- amounts: number[];
813
- chainId: number;
814
- collection: string;
815
- collectionType: number;
816
- createdAt: string;
817
- currency: string;
818
- endTime: number;
819
- globalNonce: string;
820
- id: string;
821
- itemIds: string[];
822
- orderNonce: string;
823
- price: string;
824
- quoteType: number;
825
- signature: string;
826
- signer: string;
827
- startTime: number;
828
- strategyId: number;
829
- subsetNonce: number;
830
- }[]>>;
831
831
  export {};
@@ -1,9 +1,10 @@
1
1
  import { Signer } from "ethers";
2
2
  import { Maker, MerkleTree, Taker, ContractMethods } from "../../types";
3
- export declare const executeTakerBid: (signer: Signer, address: string, taker: Taker, maker: Maker, makerSignature: string, merkleTree: MerkleTree, overrides?: any) => ContractMethods;
4
- export declare const executeTakerAsk: (signer: Signer, address: string, taker: Taker, maker: Maker, makerSignature: string, merkleTree: MerkleTree, overrides?: any) => ContractMethods;
5
- export declare const executeMultipleTakerBids: (signer: Signer, address: string, taker: Taker[], maker: Maker[], makerSignature: string[], isAtomic: boolean, merkleTree: MerkleTree[], overrides?: any) => {
6
- call: (additionalOverrides?: any) => any;
7
- estimateGas: (additionalOverrides?: any) => any;
8
- callStatic: (additionalOverrides?: any) => any;
3
+ import { PayableOverrides } from "../../typechain/common";
4
+ export declare const executeTakerBid: (signer: Signer, address: string, taker: Taker, maker: Maker, makerSignature: string, merkleTree: MerkleTree, overrides?: PayableOverrides) => ContractMethods;
5
+ export declare const executeTakerAsk: (signer: Signer, address: string, taker: Taker, maker: Maker, makerSignature: string, merkleTree: MerkleTree, overrides?: PayableOverrides) => ContractMethods;
6
+ export declare const executeMultipleTakerBids: (signer: Signer, address: string, taker: Taker[], maker: Maker[], makerSignature: string[], isAtomic: boolean, merkleTree: MerkleTree[], overrides?: PayableOverrides) => {
7
+ call: (additionalOverrides?: PayableOverrides) => any;
8
+ estimateGas: (additionalOverrides?: PayableOverrides) => any;
9
+ callStatic: (additionalOverrides?: PayableOverrides) => any;
9
10
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hypercerts-org/marketplace-sdk",
3
- "version": "0.0.24",
3
+ "version": "0.1.1",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -13,7 +13,7 @@
13
13
  "registry": "https://registry.npmjs.org"
14
14
  },
15
15
  "keywords": [
16
- "looksrare"
16
+ "hypercertexchange"
17
17
  ],
18
18
  "homepage": "https://hypercerts.org/",
19
19
  "bugs": "https://github.com/hypercerts-org/hypercerts/issues",