@hypercerts-org/marketplace-sdk 0.0.16 → 0.0.17

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,14 +1,16 @@
1
1
  import { BigNumberish, ContractTransactionResponse, Overrides, TypedDataDomain, Provider, Signer } from "ethers";
2
+ import * as api from "./utils/api";
2
3
  import { Addresses, Maker, Taker, ChainId, CreateMakerInput, CreateMakerAskOutput, CreateMakerBidOutput, CreateMakerCollectionOfferInput, CreateMakerCollectionOfferWithProofInput, MerkleTree, ContractMethods, OrderValidatorCode, BatchTransferItem, SignMerkleTreeOrdersOutput, StrategyType, StrategyInfo } from "./types";
3
4
  /**
4
5
  * LooksRare
5
6
  * This class provides helpers to interact with the LooksRare V2 contracts
6
7
  */
7
- export declare class LooksRare {
8
+ export declare class HypercertExchangeClient {
8
9
  /** Current app chain ID */
9
10
  readonly chainId: ChainId;
10
11
  /** Mapping of LooksRare protocol addresses for the current chain */
11
12
  readonly addresses: Addresses;
13
+ readonly api: typeof api;
12
14
  /**
13
15
  * Ethers signer
14
16
  * @see {@link https://docs.ethers.org/v6/api/providers/#Signer Ethers signer doc}
@@ -136,11 +138,6 @@ export declare class LooksRare {
136
138
  merkleTree?: MerkleTree;
137
139
  }[], isAtomic: boolean, overrides?: Overrides): {
138
140
  call: (additionalOverrides?: import("./typechain/common").PayableOverrides | undefined) => any;
139
- /**
140
- * Validate a timestamp format (seconds)
141
- * @param timestamp
142
- * @returns boolean
143
- */
144
141
  estimateGas: (additionalOverrides?: import("./typechain/common").PayableOverrides | undefined) => any;
145
142
  callStatic: (additionalOverrides?: import("./typechain/common").PayableOverrides | undefined) => any;
146
143
  };
@@ -220,4 +217,24 @@ export declare class LooksRare {
220
217
  * @returns StrategyInfo
221
218
  */
222
219
  strategyInfo(strategyId: StrategyType, overrides?: Overrides): Promise<StrategyInfo>;
220
+ /**
221
+ * Create a maker ask for a collection or singular offer of fractions
222
+ * @param itemIds Token IDs of the fractions to be sold
223
+ * @param price Price of the fractions in wei
224
+ * @param startTime Timestamp in seconds when the order becomes valid
225
+ * @param endTime Timestamp in seconds when the order becomes invalid
226
+ * @param additionalParameters Additional parameters used to support complex orders
227
+ */
228
+ createDirectFractionsSaleMakerAsk({ itemIds, price, startTime, endTime, additionalParameters, }: Omit<CreateMakerInput, "strategyId" | "collectionType" | "collection" | "subsetNonce" | "orderNonce" | "amounts" | "currency">): Promise<CreateMakerAskOutput>;
229
+ /**
230
+ * Register the order with hypercerts marketplace API.
231
+ * @param order Maker order
232
+ * @param signature Signature of the maker order
233
+ */
234
+ registerOrder({ order, signature }: {
235
+ order: Maker;
236
+ signature: string;
237
+ }): Promise<{
238
+ success: boolean;
239
+ }>;
223
240
  }
package/dist/index.cjs.js CHANGED
@@ -3,9 +3,9 @@
3
3
  var ethers = require('ethers');
4
4
  var contracts = require('@hypercerts-org/contracts');
5
5
  var merkletreejs = require('merkletreejs');
6
- var supabaseJs = require('@supabase/supabase-js');
7
6
  var sdk = require('@hypercerts-org/sdk');
8
7
  var jsSha3 = require('js-sha3');
8
+ var supabaseJs = require('@supabase/supabase-js');
9
9
 
10
10
  var abiIERC721 = [
11
11
  {
@@ -688,6 +688,7 @@ var strategies = /*#__PURE__*/Object.freeze({
688
688
  exports.ChainId = void 0;
689
689
  (function (ChainId) {
690
690
  ChainId[ChainId["SEPOLIA"] = 11155111] = "SEPOLIA";
691
+ ChainId[ChainId["HARDHAT"] = 31337] = "HARDHAT";
691
692
  })(exports.ChainId || (exports.ChainId = {}));
692
693
  /** List of collection types supported by the protocol */
693
694
  exports.CollectionType = void 0;
@@ -1072,81 +1073,30 @@ var asDeployedChain$1 = /*#__PURE__*/Object.freeze({
1072
1073
  asDeployedChain: asDeployedChain
1073
1074
  });
1074
1075
 
1075
- const HYPERCERTS_MARKETPLACE_API_URL = "https://staging.hyperboards.org/api";
1076
- const SUPABASE_HYPERCERTS_URL = "https://clagjjfinooizoqdkvqc.supabase.co";
1077
- const SUPABASE_HYPERCERTS_ANON_KEY = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImNsYWdqamZpbm9vaXpvcWRrdnFjIiwicm9sZSI6ImFub24iLCJpYXQiOjE2NzY5NTAxNDAsImV4cCI6MTk5MjUyNjE0MH0.LOIW3NcYEfF7w893PS3Ne1VrntACE3OPeSRFkspvyqw";
1078
- const supabaseHypercerts = supabaseJs.createClient(SUPABASE_HYPERCERTS_URL, SUPABASE_HYPERCERTS_ANON_KEY);
1079
- const fetchOrderNonce = async ({ address, chainId }) => {
1080
- return fetch(`${HYPERCERTS_MARKETPLACE_API_URL}/marketplace/order-nonce/`, {
1081
- method: "POST",
1082
- headers: {
1083
- "Content-Type": "application/json",
1084
- },
1085
- body: JSON.stringify({
1086
- address,
1087
- chainId,
1088
- }),
1089
- })
1090
- .then((res) => res.json())
1091
- .then((res) => res.data);
1092
- };
1093
- const createOrder = async ({ order, signer, signature, quoteType, chainId, }) => {
1094
- const { globalNonce, ...orderWithoutGlobalNonce } = order;
1095
- return fetch(`${HYPERCERTS_MARKETPLACE_API_URL}/marketplace/order/`, {
1096
- method: "POST",
1097
- headers: {
1098
- "Content-Type": "application/json",
1099
- },
1100
- body: JSON.stringify({
1101
- ...orderWithoutGlobalNonce,
1102
- globalNonce: globalNonce.toString(10),
1103
- price: order.price.toString(10),
1104
- quoteType,
1105
- signer,
1106
- signature,
1107
- chainId,
1108
- }),
1109
- }).then((res) => res.json());
1110
- };
1111
- const fetchOrdersByHypercertId = async ({ hypercertId, chainId }) => {
1112
- const hypercertsClient = new sdk.HypercertClient({
1113
- chain: { id: chainId },
1114
- });
1115
- const fractions = await hypercertsClient.indexer.fractionsByClaim(hypercertId);
1116
- const tokenIds = fractions.claimTokens.map((fraction) => fraction.tokenID);
1117
- return supabaseHypercerts.from("marketplace-orders").select("*").containedBy("itemIds", tokenIds).throwOnError();
1118
- };
1119
-
1120
- var api = /*#__PURE__*/Object.freeze({
1121
- __proto__: null,
1122
- createOrder: createOrder,
1123
- fetchOrderNonce: fetchOrderNonce,
1124
- fetchOrdersByHypercertId: fetchOrdersByHypercertId,
1125
- supabaseHypercerts: supabaseHypercerts
1126
- });
1127
-
1128
1076
  const sepoliaAddresses = {
1129
1077
  EXCHANGE_V2: sdk.deployments[11155111].addresses?.HypercertExchange,
1130
1078
  TRANSFER_MANAGER_V2: sdk.deployments[11155111].addresses?.TransferManager,
1131
1079
  ORDER_VALIDATOR_V2: sdk.deployments[11155111].addresses?.OrderValidator,
1132
1080
  WETH: "0x7b79995e5f793A07Bc00c21412e50Ecae098E7f9",
1081
+ MINTER: sdk.deployments[11155111].addresses?.HypercertMinterUUPS,
1133
1082
  };
1134
1083
  /**
1135
1084
  * List of useful contract addresses
1136
1085
  */
1137
1086
  const addressesByNetwork = {
1138
1087
  [exports.ChainId.SEPOLIA]: sepoliaAddresses,
1088
+ [exports.ChainId.HARDHAT]: sepoliaAddresses,
1139
1089
  };
1140
1090
 
1141
1091
  const chainInfo = {
1142
- [exports.ChainId.GOERLI]: {
1143
- label: "Goerli",
1144
- appUrl: "https://goerli.looksrare.org",
1145
- explorer: "https://goerli.etherscan.io",
1146
- rpcUrl: "https://eth-goerli.g.alchemy.com/v2",
1147
- baseApiUrl: "https://graphql-goerli.looksrare.org",
1148
- osApiUrl: "https://testnets-api.opensea.io",
1149
- },
1092
+ // [ChainId.GOERLI]: {
1093
+ // label: "Goerli",
1094
+ // appUrl: "https://goerli.looksrare.org",
1095
+ // explorer: "https://goerli.etherscan.io",
1096
+ // rpcUrl: "https://eth-goerli.g.alchemy.com/v2",
1097
+ // baseApiUrl: "https://graphql-goerli.looksrare.org",
1098
+ // osApiUrl: "https://testnets-api.opensea.io",
1099
+ // },
1150
1100
  [exports.ChainId.SEPOLIA]: {
1151
1101
  label: "Sepolia",
1152
1102
  appUrl: "https://sepolia.looksrare.org",
@@ -4834,11 +4784,82 @@ const contractName = "LooksRareProtocol";
4834
4784
  */
4835
4785
  const version = 2;
4836
4786
 
4787
+ const HYPERCERTS_MARKETPLACE_API_URL = "https://staging.hyperboards.org/api";
4788
+ const SUPABASE_HYPERCERTS_URL = "https://clagjjfinooizoqdkvqc.supabase.co";
4789
+ const SUPABASE_HYPERCERTS_ANON_KEY = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImNsYWdqamZpbm9vaXpvcWRrdnFjIiwicm9sZSI6ImFub24iLCJpYXQiOjE2NzY5NTAxNDAsImV4cCI6MTk5MjUyNjE0MH0.LOIW3NcYEfF7w893PS3Ne1VrntACE3OPeSRFkspvyqw";
4790
+ const supabaseHypercerts = supabaseJs.createClient(SUPABASE_HYPERCERTS_URL, SUPABASE_HYPERCERTS_ANON_KEY);
4791
+ /**
4792
+ * Fetches order nonce from api
4793
+ * @param address Address
4794
+ * @param chainId Chain ID
4795
+ */
4796
+ const fetchOrderNonce = async ({ address, chainId }) => {
4797
+ return fetch(`${HYPERCERTS_MARKETPLACE_API_URL}/marketplace/order-nonce/`, {
4798
+ method: "POST",
4799
+ headers: {
4800
+ "Content-Type": "application/json",
4801
+ },
4802
+ body: JSON.stringify({
4803
+ address,
4804
+ chainId,
4805
+ }),
4806
+ })
4807
+ .then((res) => res.json())
4808
+ .then((res) => res.data);
4809
+ };
4810
+ /**
4811
+ * Registers order in api
4812
+ * @param order Order
4813
+ * @param signer Signer
4814
+ * @param signature Signature
4815
+ * @param quoteType Quote type
4816
+ * @param chainId Chain ID
4817
+ */
4818
+ const registerOrder = async ({ order, signer, signature, quoteType, chainId, }) => {
4819
+ const { globalNonce, ...orderWithoutGlobalNonce } = order;
4820
+ return fetch(`${HYPERCERTS_MARKETPLACE_API_URL}/marketplace/order/`, {
4821
+ method: "POST",
4822
+ headers: {
4823
+ "Content-Type": "application/json",
4824
+ },
4825
+ body: JSON.stringify({
4826
+ ...orderWithoutGlobalNonce,
4827
+ globalNonce: globalNonce.toString(10),
4828
+ price: order.price.toString(10),
4829
+ quoteType,
4830
+ signer,
4831
+ signature,
4832
+ chainId,
4833
+ }),
4834
+ }).then((res) => res.json());
4835
+ };
4836
+ /**
4837
+ * Fetches orders from api by hypercert ID
4838
+ * @param hypercertId Hypercert ID
4839
+ * @param chainId Chain ID
4840
+ */
4841
+ const fetchOrdersByHypercertId = async ({ hypercertId, chainId }) => {
4842
+ const hypercertsClient = new sdk.HypercertClient({
4843
+ chain: { id: chainId },
4844
+ });
4845
+ const fractions = await hypercertsClient.indexer.fractionsByClaim(hypercertId);
4846
+ const tokenIds = fractions.claimTokens.map((fraction) => fraction.tokenID);
4847
+ return supabaseHypercerts.from("marketplace-orders").select("*").containedBy("itemIds", tokenIds).throwOnError();
4848
+ };
4849
+
4850
+ var api = /*#__PURE__*/Object.freeze({
4851
+ __proto__: null,
4852
+ fetchOrderNonce: fetchOrderNonce,
4853
+ fetchOrdersByHypercertId: fetchOrdersByHypercertId,
4854
+ registerOrder: registerOrder,
4855
+ supabaseHypercerts: supabaseHypercerts
4856
+ });
4857
+
4837
4858
  /**
4838
4859
  * LooksRare
4839
4860
  * This class provides helpers to interact with the LooksRare V2 contracts
4840
4861
  */
4841
- class LooksRare {
4862
+ class HypercertExchangeClient {
4842
4863
  /**
4843
4864
  * LooksRare protocol main class
4844
4865
  * @param chainId Current app chain id
@@ -4851,6 +4872,7 @@ class LooksRare {
4851
4872
  this.addresses = override ?? addressesByNetwork[this.chainId];
4852
4873
  this.signer = signer;
4853
4874
  this.provider = provider;
4875
+ this.api = api;
4854
4876
  }
4855
4877
  /**
4856
4878
  * Return the signer it it's set, throw an exception otherwise
@@ -5228,6 +5250,61 @@ class LooksRare {
5228
5250
  async strategyInfo(strategyId, overrides) {
5229
5251
  return strategyInfo(this.provider, this.addresses.EXCHANGE_V2, strategyId, overrides);
5230
5252
  }
5253
+ /**
5254
+ * Create a maker ask for a collection or singular offer of fractions
5255
+ * @param itemIds Token IDs of the fractions to be sold
5256
+ * @param price Price of the fractions in wei
5257
+ * @param startTime Timestamp in seconds when the order becomes valid
5258
+ * @param endTime Timestamp in seconds when the order becomes invalid
5259
+ * @param additionalParameters Additional parameters used to support complex orders
5260
+ */
5261
+ async createDirectFractionsSaleMakerAsk({ itemIds, price, startTime, endTime, additionalParameters = [], }) {
5262
+ const address = await this.signer?.getAddress();
5263
+ if (!address) {
5264
+ throw new Error("No signer address could be determined");
5265
+ }
5266
+ const chainId = this.chainId;
5267
+ const { nonce_counter } = await fetchOrderNonce({
5268
+ address,
5269
+ chainId,
5270
+ });
5271
+ const amounts = Array.from({ length: itemIds.length }, () => 1);
5272
+ return this.createMakerAsk({
5273
+ // Defaults
5274
+ strategyId: exports.StrategyType.standard,
5275
+ collectionType: 2,
5276
+ collection: this.addresses.MINTER,
5277
+ subsetNonce: 0,
5278
+ currency: this.addresses.WETH,
5279
+ amounts,
5280
+ orderNonce: nonce_counter.toString(),
5281
+ // User specified
5282
+ itemIds,
5283
+ price,
5284
+ startTime,
5285
+ endTime,
5286
+ additionalParameters,
5287
+ });
5288
+ }
5289
+ /**
5290
+ * Register the order with hypercerts marketplace API.
5291
+ * @param order Maker order
5292
+ * @param signature Signature of the maker order
5293
+ */
5294
+ async registerOrder({ order, signature }) {
5295
+ const address = await this.signer?.getAddress();
5296
+ if (!address) {
5297
+ throw new Error("No signer address could be determined");
5298
+ }
5299
+ const chainId = this.chainId;
5300
+ return registerOrder({
5301
+ order,
5302
+ signer: address,
5303
+ signature,
5304
+ quoteType: order.quoteType,
5305
+ chainId,
5306
+ });
5307
+ }
5231
5308
  }
5232
5309
 
5233
5310
  const utils = {
@@ -5241,7 +5318,6 @@ const utils = {
5241
5318
  ...signMakerOrders,
5242
5319
  ...eip712,
5243
5320
  ...asDeployedChain$1,
5244
- api,
5245
5321
  };
5246
5322
 
5247
5323
  exports.Eip712MakerMerkleTree = Eip712MakerMerkleTree;
@@ -5252,10 +5328,10 @@ exports.ErrorQuoteType = ErrorQuoteType;
5252
5328
  exports.ErrorSigner = ErrorSigner;
5253
5329
  exports.ErrorStrategyType = ErrorStrategyType;
5254
5330
  exports.ErrorTimestamp = ErrorTimestamp;
5331
+ exports.HypercertExchangeClient = HypercertExchangeClient;
5255
5332
  exports.IERC1155Abi = IERC1155;
5256
5333
  exports.IERC20Abi = abiIERC20;
5257
5334
  exports.IERC721Abi = abiIERC721;
5258
- exports.LooksRare = LooksRare;
5259
5335
  exports.LooksRareProtocolAbi = LooksRareProtocol;
5260
5336
  exports.MAX_ORDERS_PER_TREE = MAX_ORDERS_PER_TREE;
5261
5337
  exports.OrderValidatorV2AAbi = OrderValidatorV2A;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,4 @@
1
- import * as api from "./utils/api";
2
1
  declare const utils: {
3
- api: typeof api;
4
2
  asDeployedChain: (chainId: number) => import("./types").ChainId;
5
3
  MAKER_HASH: "0x003c1bce41a2de73dfe64d6eeb2b3d7f15f1c0c382d9d963c2c6daeb75f0e539";
6
4
  hashingMakerTypes: string[];
@@ -45,4 +43,4 @@ export * from "./types";
45
43
  export * from "./abis";
46
44
  export { Eip712MakerMerkleTree } from "./utils/Eip712MakerMerkleTree";
47
45
  export { Eip712MerkleTree } from "./utils/Eip712MerkleTree";
48
- export { LooksRare } from "./LooksRare";
46
+ export { HypercertExchangeClient } from "./HypercertExchangeClient";
package/dist/index.esm.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { Contract, ZeroAddress, AbiCoder, TypedDataEncoder, keccak256, solidityPackedKeccak256, ethers, ZeroHash, MaxUint256 } from 'ethers';
2
2
  import { HypercertExchangeAbi, TransferManagerAbi, OrderValidatorV2A as OrderValidatorV2A$1 } from '@hypercerts-org/contracts';
3
3
  import { MerkleTree } from 'merkletreejs';
4
- import { createClient } from '@supabase/supabase-js';
5
- import { HypercertClient, deployments } from '@hypercerts-org/sdk';
4
+ import { deployments, HypercertClient } from '@hypercerts-org/sdk';
6
5
  import { keccak256 as keccak256$1 } from 'js-sha3';
6
+ import { createClient } from '@supabase/supabase-js';
7
7
 
8
8
  var abiIERC721 = [
9
9
  {
@@ -686,6 +686,7 @@ var strategies = /*#__PURE__*/Object.freeze({
686
686
  var ChainId;
687
687
  (function (ChainId) {
688
688
  ChainId[ChainId["SEPOLIA"] = 11155111] = "SEPOLIA";
689
+ ChainId[ChainId["HARDHAT"] = 31337] = "HARDHAT";
689
690
  })(ChainId || (ChainId = {}));
690
691
  /** List of collection types supported by the protocol */
691
692
  var CollectionType;
@@ -1070,81 +1071,30 @@ var asDeployedChain$1 = /*#__PURE__*/Object.freeze({
1070
1071
  asDeployedChain: asDeployedChain
1071
1072
  });
1072
1073
 
1073
- const HYPERCERTS_MARKETPLACE_API_URL = "https://staging.hyperboards.org/api";
1074
- const SUPABASE_HYPERCERTS_URL = "https://clagjjfinooizoqdkvqc.supabase.co";
1075
- const SUPABASE_HYPERCERTS_ANON_KEY = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImNsYWdqamZpbm9vaXpvcWRrdnFjIiwicm9sZSI6ImFub24iLCJpYXQiOjE2NzY5NTAxNDAsImV4cCI6MTk5MjUyNjE0MH0.LOIW3NcYEfF7w893PS3Ne1VrntACE3OPeSRFkspvyqw";
1076
- const supabaseHypercerts = createClient(SUPABASE_HYPERCERTS_URL, SUPABASE_HYPERCERTS_ANON_KEY);
1077
- const fetchOrderNonce = async ({ address, chainId }) => {
1078
- return fetch(`${HYPERCERTS_MARKETPLACE_API_URL}/marketplace/order-nonce/`, {
1079
- method: "POST",
1080
- headers: {
1081
- "Content-Type": "application/json",
1082
- },
1083
- body: JSON.stringify({
1084
- address,
1085
- chainId,
1086
- }),
1087
- })
1088
- .then((res) => res.json())
1089
- .then((res) => res.data);
1090
- };
1091
- const createOrder = async ({ order, signer, signature, quoteType, chainId, }) => {
1092
- const { globalNonce, ...orderWithoutGlobalNonce } = order;
1093
- return fetch(`${HYPERCERTS_MARKETPLACE_API_URL}/marketplace/order/`, {
1094
- method: "POST",
1095
- headers: {
1096
- "Content-Type": "application/json",
1097
- },
1098
- body: JSON.stringify({
1099
- ...orderWithoutGlobalNonce,
1100
- globalNonce: globalNonce.toString(10),
1101
- price: order.price.toString(10),
1102
- quoteType,
1103
- signer,
1104
- signature,
1105
- chainId,
1106
- }),
1107
- }).then((res) => res.json());
1108
- };
1109
- const fetchOrdersByHypercertId = async ({ hypercertId, chainId }) => {
1110
- const hypercertsClient = new HypercertClient({
1111
- chain: { id: chainId },
1112
- });
1113
- const fractions = await hypercertsClient.indexer.fractionsByClaim(hypercertId);
1114
- const tokenIds = fractions.claimTokens.map((fraction) => fraction.tokenID);
1115
- return supabaseHypercerts.from("marketplace-orders").select("*").containedBy("itemIds", tokenIds).throwOnError();
1116
- };
1117
-
1118
- var api = /*#__PURE__*/Object.freeze({
1119
- __proto__: null,
1120
- createOrder: createOrder,
1121
- fetchOrderNonce: fetchOrderNonce,
1122
- fetchOrdersByHypercertId: fetchOrdersByHypercertId,
1123
- supabaseHypercerts: supabaseHypercerts
1124
- });
1125
-
1126
1074
  const sepoliaAddresses = {
1127
1075
  EXCHANGE_V2: deployments[11155111].addresses?.HypercertExchange,
1128
1076
  TRANSFER_MANAGER_V2: deployments[11155111].addresses?.TransferManager,
1129
1077
  ORDER_VALIDATOR_V2: deployments[11155111].addresses?.OrderValidator,
1130
1078
  WETH: "0x7b79995e5f793A07Bc00c21412e50Ecae098E7f9",
1079
+ MINTER: deployments[11155111].addresses?.HypercertMinterUUPS,
1131
1080
  };
1132
1081
  /**
1133
1082
  * List of useful contract addresses
1134
1083
  */
1135
1084
  const addressesByNetwork = {
1136
1085
  [ChainId.SEPOLIA]: sepoliaAddresses,
1086
+ [ChainId.HARDHAT]: sepoliaAddresses,
1137
1087
  };
1138
1088
 
1139
1089
  const chainInfo = {
1140
- [ChainId.GOERLI]: {
1141
- label: "Goerli",
1142
- appUrl: "https://goerli.looksrare.org",
1143
- explorer: "https://goerli.etherscan.io",
1144
- rpcUrl: "https://eth-goerli.g.alchemy.com/v2",
1145
- baseApiUrl: "https://graphql-goerli.looksrare.org",
1146
- osApiUrl: "https://testnets-api.opensea.io",
1147
- },
1090
+ // [ChainId.GOERLI]: {
1091
+ // label: "Goerli",
1092
+ // appUrl: "https://goerli.looksrare.org",
1093
+ // explorer: "https://goerli.etherscan.io",
1094
+ // rpcUrl: "https://eth-goerli.g.alchemy.com/v2",
1095
+ // baseApiUrl: "https://graphql-goerli.looksrare.org",
1096
+ // osApiUrl: "https://testnets-api.opensea.io",
1097
+ // },
1148
1098
  [ChainId.SEPOLIA]: {
1149
1099
  label: "Sepolia",
1150
1100
  appUrl: "https://sepolia.looksrare.org",
@@ -4832,11 +4782,82 @@ const contractName = "LooksRareProtocol";
4832
4782
  */
4833
4783
  const version = 2;
4834
4784
 
4785
+ const HYPERCERTS_MARKETPLACE_API_URL = "https://staging.hyperboards.org/api";
4786
+ const SUPABASE_HYPERCERTS_URL = "https://clagjjfinooizoqdkvqc.supabase.co";
4787
+ const SUPABASE_HYPERCERTS_ANON_KEY = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImNsYWdqamZpbm9vaXpvcWRrdnFjIiwicm9sZSI6ImFub24iLCJpYXQiOjE2NzY5NTAxNDAsImV4cCI6MTk5MjUyNjE0MH0.LOIW3NcYEfF7w893PS3Ne1VrntACE3OPeSRFkspvyqw";
4788
+ const supabaseHypercerts = createClient(SUPABASE_HYPERCERTS_URL, SUPABASE_HYPERCERTS_ANON_KEY);
4789
+ /**
4790
+ * Fetches order nonce from api
4791
+ * @param address Address
4792
+ * @param chainId Chain ID
4793
+ */
4794
+ const fetchOrderNonce = async ({ address, chainId }) => {
4795
+ return fetch(`${HYPERCERTS_MARKETPLACE_API_URL}/marketplace/order-nonce/`, {
4796
+ method: "POST",
4797
+ headers: {
4798
+ "Content-Type": "application/json",
4799
+ },
4800
+ body: JSON.stringify({
4801
+ address,
4802
+ chainId,
4803
+ }),
4804
+ })
4805
+ .then((res) => res.json())
4806
+ .then((res) => res.data);
4807
+ };
4808
+ /**
4809
+ * Registers order in api
4810
+ * @param order Order
4811
+ * @param signer Signer
4812
+ * @param signature Signature
4813
+ * @param quoteType Quote type
4814
+ * @param chainId Chain ID
4815
+ */
4816
+ const registerOrder = async ({ order, signer, signature, quoteType, chainId, }) => {
4817
+ const { globalNonce, ...orderWithoutGlobalNonce } = order;
4818
+ return fetch(`${HYPERCERTS_MARKETPLACE_API_URL}/marketplace/order/`, {
4819
+ method: "POST",
4820
+ headers: {
4821
+ "Content-Type": "application/json",
4822
+ },
4823
+ body: JSON.stringify({
4824
+ ...orderWithoutGlobalNonce,
4825
+ globalNonce: globalNonce.toString(10),
4826
+ price: order.price.toString(10),
4827
+ quoteType,
4828
+ signer,
4829
+ signature,
4830
+ chainId,
4831
+ }),
4832
+ }).then((res) => res.json());
4833
+ };
4834
+ /**
4835
+ * Fetches orders from api by hypercert ID
4836
+ * @param hypercertId Hypercert ID
4837
+ * @param chainId Chain ID
4838
+ */
4839
+ const fetchOrdersByHypercertId = async ({ hypercertId, chainId }) => {
4840
+ const hypercertsClient = new HypercertClient({
4841
+ chain: { id: chainId },
4842
+ });
4843
+ const fractions = await hypercertsClient.indexer.fractionsByClaim(hypercertId);
4844
+ const tokenIds = fractions.claimTokens.map((fraction) => fraction.tokenID);
4845
+ return supabaseHypercerts.from("marketplace-orders").select("*").containedBy("itemIds", tokenIds).throwOnError();
4846
+ };
4847
+
4848
+ var api = /*#__PURE__*/Object.freeze({
4849
+ __proto__: null,
4850
+ fetchOrderNonce: fetchOrderNonce,
4851
+ fetchOrdersByHypercertId: fetchOrdersByHypercertId,
4852
+ registerOrder: registerOrder,
4853
+ supabaseHypercerts: supabaseHypercerts
4854
+ });
4855
+
4835
4856
  /**
4836
4857
  * LooksRare
4837
4858
  * This class provides helpers to interact with the LooksRare V2 contracts
4838
4859
  */
4839
- class LooksRare {
4860
+ class HypercertExchangeClient {
4840
4861
  /**
4841
4862
  * LooksRare protocol main class
4842
4863
  * @param chainId Current app chain id
@@ -4849,6 +4870,7 @@ class LooksRare {
4849
4870
  this.addresses = override ?? addressesByNetwork[this.chainId];
4850
4871
  this.signer = signer;
4851
4872
  this.provider = provider;
4873
+ this.api = api;
4852
4874
  }
4853
4875
  /**
4854
4876
  * Return the signer it it's set, throw an exception otherwise
@@ -5226,6 +5248,61 @@ class LooksRare {
5226
5248
  async strategyInfo(strategyId, overrides) {
5227
5249
  return strategyInfo(this.provider, this.addresses.EXCHANGE_V2, strategyId, overrides);
5228
5250
  }
5251
+ /**
5252
+ * Create a maker ask for a collection or singular offer of fractions
5253
+ * @param itemIds Token IDs of the fractions to be sold
5254
+ * @param price Price of the fractions in wei
5255
+ * @param startTime Timestamp in seconds when the order becomes valid
5256
+ * @param endTime Timestamp in seconds when the order becomes invalid
5257
+ * @param additionalParameters Additional parameters used to support complex orders
5258
+ */
5259
+ async createDirectFractionsSaleMakerAsk({ itemIds, price, startTime, endTime, additionalParameters = [], }) {
5260
+ const address = await this.signer?.getAddress();
5261
+ if (!address) {
5262
+ throw new Error("No signer address could be determined");
5263
+ }
5264
+ const chainId = this.chainId;
5265
+ const { nonce_counter } = await fetchOrderNonce({
5266
+ address,
5267
+ chainId,
5268
+ });
5269
+ const amounts = Array.from({ length: itemIds.length }, () => 1);
5270
+ return this.createMakerAsk({
5271
+ // Defaults
5272
+ strategyId: StrategyType.standard,
5273
+ collectionType: 2,
5274
+ collection: this.addresses.MINTER,
5275
+ subsetNonce: 0,
5276
+ currency: this.addresses.WETH,
5277
+ amounts,
5278
+ orderNonce: nonce_counter.toString(),
5279
+ // User specified
5280
+ itemIds,
5281
+ price,
5282
+ startTime,
5283
+ endTime,
5284
+ additionalParameters,
5285
+ });
5286
+ }
5287
+ /**
5288
+ * Register the order with hypercerts marketplace API.
5289
+ * @param order Maker order
5290
+ * @param signature Signature of the maker order
5291
+ */
5292
+ async registerOrder({ order, signature }) {
5293
+ const address = await this.signer?.getAddress();
5294
+ if (!address) {
5295
+ throw new Error("No signer address could be determined");
5296
+ }
5297
+ const chainId = this.chainId;
5298
+ return registerOrder({
5299
+ order,
5300
+ signer: address,
5301
+ signature,
5302
+ quoteType: order.quoteType,
5303
+ chainId,
5304
+ });
5305
+ }
5229
5306
  }
5230
5307
 
5231
5308
  const utils = {
@@ -5239,7 +5316,6 @@ const utils = {
5239
5316
  ...signMakerOrders,
5240
5317
  ...eip712,
5241
5318
  ...asDeployedChain$1,
5242
- api,
5243
5319
  };
5244
5320
 
5245
- export { ChainId, CollectionType, Eip712MakerMerkleTree, Eip712MerkleTree, ErrorItemId, ErrorMerkleTreeDepth, ErrorQuoteType, ErrorSigner, ErrorStrategyType, ErrorTimestamp, IERC1155 as IERC1155Abi, abiIERC20 as IERC20Abi, abiIERC721 as IERC721Abi, LooksRare, LooksRareProtocol as LooksRareProtocolAbi, MAX_ORDERS_PER_TREE, MerkleTreeNodePosition, OrderValidatorCode, OrderValidatorV2A as OrderValidatorV2AAbi, QuoteType, StrategyType, TransferManager as TransferManagerAbi, WETH as WETHAbi, addressesByNetwork, chainInfo, defaultMerkleTree, utils };
5321
+ export { ChainId, CollectionType, Eip712MakerMerkleTree, Eip712MerkleTree, ErrorItemId, ErrorMerkleTreeDepth, ErrorQuoteType, ErrorSigner, ErrorStrategyType, ErrorTimestamp, HypercertExchangeClient, IERC1155 as IERC1155Abi, abiIERC20 as IERC20Abi, abiIERC721 as IERC721Abi, LooksRareProtocol as LooksRareProtocolAbi, MAX_ORDERS_PER_TREE, MerkleTreeNodePosition, OrderValidatorCode, OrderValidatorV2A as OrderValidatorV2AAbi, QuoteType, StrategyType, TransferManager as TransferManagerAbi, WETH as WETHAbi, addressesByNetwork, chainInfo, defaultMerkleTree, utils };
package/dist/types.d.ts CHANGED
@@ -6,10 +6,12 @@ export interface Addresses {
6
6
  TRANSFER_MANAGER_V2: `0x${string}`;
7
7
  WETH: `0x${string}`;
8
8
  ORDER_VALIDATOR_V2: `0x${string}`;
9
+ MINTER: `0x${string}`;
9
10
  }
10
11
  /** List of supported chains */
11
12
  export declare enum ChainId {
12
- SEPOLIA = 11155111
13
+ SEPOLIA = 11155111,
14
+ HARDHAT = 31337
13
15
  }
14
16
  /** ChainInfo data used to interact with LooksRare ecosystem */
15
17
  export interface ChainInfo {
@@ -724,6 +724,11 @@ export declare const supabaseHypercerts: import("@supabase/supabase-js").Supabas
724
724
  Enums: {};
725
725
  CompositeTypes: {};
726
726
  }>;
727
+ /**
728
+ * Fetches order nonce from api
729
+ * @param address Address
730
+ * @param chainId Chain ID
731
+ */
727
732
  export declare const fetchOrderNonce: ({ address, chainId }: {
728
733
  address: string;
729
734
  chainId: number;
@@ -732,7 +737,15 @@ export declare const fetchOrderNonce: ({ address, chainId }: {
732
737
  address: string;
733
738
  chain_id: number;
734
739
  }>;
735
- export declare const createOrder: ({ order, signer, signature, quoteType, chainId, }: {
740
+ /**
741
+ * Registers order in api
742
+ * @param order Order
743
+ * @param signer Signer
744
+ * @param signature Signature
745
+ * @param quoteType Quote type
746
+ * @param chainId Chain ID
747
+ */
748
+ export declare const registerOrder: ({ order, signer, signature, quoteType, chainId, }: {
736
749
  order: Maker;
737
750
  signer: string;
738
751
  signature: string;
@@ -741,6 +754,11 @@ export declare const createOrder: ({ order, signer, signature, quoteType, chainI
741
754
  }) => Promise<{
742
755
  success: boolean;
743
756
  }>;
757
+ /**
758
+ * Fetches orders from api by hypercert ID
759
+ * @param hypercertId Hypercert ID
760
+ * @param chainId Chain ID
761
+ */
744
762
  export declare const fetchOrdersByHypercertId: ({ hypercertId, chainId }: {
745
763
  hypercertId: string;
746
764
  chainId: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hypercerts-org/marketplace-sdk",
3
- "version": "0.0.16",
3
+ "version": "0.0.17",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",