@hypercerts-org/marketplace-sdk 0.3.12 → 0.3.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -5514,9 +5514,69 @@ function print(e) {
5514
5514
  return m$1[e.kind] ? m$1[e.kind](e) : "";
5515
5515
  }
5516
5516
 
5517
+ function initGraphQLTada() {
5518
+ function graphql(e, i) {
5519
+ var a = parse(e).definitions;
5520
+ var t = new Set;
5521
+ for (var s of i || []) {
5522
+ for (var d of s.definitions) {
5523
+ if (d.kind === e$2.FRAGMENT_DEFINITION && !t.has(d)) {
5524
+ a.push(d);
5525
+ t.add(d);
5526
+ }
5527
+ }
5528
+ }
5529
+ if (a[0].kind === e$2.FRAGMENT_DEFINITION && a[0].directives) {
5530
+ a[0].directives = a[0].directives.filter((n => "_unmask" !== n.name.value));
5531
+ }
5532
+ return {
5533
+ kind: e$2.DOCUMENT,
5534
+ definitions: a
5535
+ };
5536
+ }
5537
+ graphql.scalar = function scalar(n, r) {
5538
+ return r;
5539
+ };
5540
+ graphql.persisted = function persisted(r, e) {
5541
+ return {
5542
+ kind: e$2.DOCUMENT,
5543
+ definitions: e ? e.definitions : [],
5544
+ documentId: r
5545
+ };
5546
+ };
5547
+ return graphql;
5548
+ }
5549
+
5550
+ var e$1 = initGraphQLTada();
5551
+
5552
+ const fractionsByIdQuery = e$1(`
5553
+ query fractionsById($fraction_id: String!) {
5554
+ fractions(where: { hypercert_id: { eq: $fraction_id } }) {
5555
+ data {
5556
+ creation_block_timestamp
5557
+ fraction_id
5558
+ last_update_block_timestamp
5559
+ owner_address
5560
+ units
5561
+ }
5562
+ }
5563
+ }
5564
+ `);
5565
+ const getFractionsById = async (fractionId, client) => {
5566
+ const { data, error } = await client
5567
+ .query(fractionsByIdQuery, {
5568
+ fraction_id: fractionId,
5569
+ })
5570
+ .toPromise();
5571
+ if (error) {
5572
+ throw new Error(error.message);
5573
+ }
5574
+ return data?.fractions.data;
5575
+ };
5576
+
5517
5577
  var teardownPlaceholder = () => {};
5518
5578
 
5519
- var e$1 = teardownPlaceholder;
5579
+ var e = teardownPlaceholder;
5520
5580
 
5521
5581
  function start(e) {
5522
5582
  return {
@@ -5538,7 +5598,7 @@ var identity = e => e;
5538
5598
 
5539
5599
  function filter(r) {
5540
5600
  return t => i => {
5541
- var a = e$1;
5601
+ var a = e;
5542
5602
  t((e => {
5543
5603
  if (0 === e) {
5544
5604
  i(0);
@@ -5567,7 +5627,7 @@ function map(e) {
5567
5627
  function mergeMap(r) {
5568
5628
  return t => i => {
5569
5629
  var a = [];
5570
- var f = e$1;
5630
+ var f = e;
5571
5631
  var n = !1;
5572
5632
  var s = !1;
5573
5633
  t((t => {
@@ -5581,7 +5641,7 @@ function mergeMap(r) {
5581
5641
  } else {
5582
5642
  n = !1;
5583
5643
  !function applyInnerSource(r) {
5584
- var t = e$1;
5644
+ var t = e;
5585
5645
  r((e => {
5586
5646
  if (0 === e) {
5587
5647
  if (a.length) {
@@ -5710,7 +5770,7 @@ function onStart(e) {
5710
5770
 
5711
5771
  function share(r) {
5712
5772
  var t = [];
5713
- var i = e$1;
5773
+ var i = e;
5714
5774
  var a = !1;
5715
5775
  return e => {
5716
5776
  t.push(e);
@@ -5750,8 +5810,8 @@ function share(r) {
5750
5810
 
5751
5811
  function switchMap(r) {
5752
5812
  return t => i => {
5753
- var a = e$1;
5754
- var f = e$1;
5813
+ var a = e;
5814
+ var f = e;
5755
5815
  var n = !1;
5756
5816
  var s = !1;
5757
5817
  var l = !1;
@@ -5767,7 +5827,7 @@ function switchMap(r) {
5767
5827
  } else {
5768
5828
  if (l) {
5769
5829
  f(1);
5770
- f = e$1;
5830
+ f = e;
5771
5831
  }
5772
5832
  if (!n) {
5773
5833
  n = !0;
@@ -5827,7 +5887,7 @@ function switchMap(r) {
5827
5887
 
5828
5888
  function take(r) {
5829
5889
  return t => i => {
5830
- var a = e$1;
5890
+ var a = e;
5831
5891
  var f = !1;
5832
5892
  var n = 0;
5833
5893
  t((e => {
@@ -5866,8 +5926,8 @@ function take(r) {
5866
5926
 
5867
5927
  function takeUntil(r) {
5868
5928
  return t => i => {
5869
- var a = e$1;
5870
- var f = e$1;
5929
+ var a = e;
5930
+ var f = e;
5871
5931
  var n = !1;
5872
5932
  t((e => {
5873
5933
  if (n) ; else if (0 === e) {
@@ -5904,7 +5964,7 @@ function takeUntil(r) {
5904
5964
 
5905
5965
  function takeWhile(r, t) {
5906
5966
  return i => a => {
5907
- var f = e$1;
5967
+ var f = e;
5908
5968
  var n = !1;
5909
5969
  i((e => {
5910
5970
  if (n) ; else if (0 === e) {
@@ -6088,7 +6148,7 @@ function makeSubject() {
6088
6148
 
6089
6149
  function subscribe(r) {
6090
6150
  return t => {
6091
- var i = e$1;
6151
+ var i = e;
6092
6152
  var a = !1;
6093
6153
  t((e => {
6094
6154
  if (0 === e) {
@@ -6117,7 +6177,7 @@ function publish(e) {
6117
6177
 
6118
6178
  function toPromise(r) {
6119
6179
  return new Promise((t => {
6120
- var i = e$1;
6180
+ var i = e;
6121
6181
  var a;
6122
6182
  r((e => {
6123
6183
  if (0 === e) {
@@ -7240,76 +7300,12 @@ var C = function Client(e) {
7240
7300
  return p;
7241
7301
  };
7242
7302
 
7243
- function initGraphQLTada() {
7244
- function graphql(e, i) {
7245
- var a = parse(e).definitions;
7246
- var t = new Set;
7247
- for (var s of i || []) {
7248
- for (var d of s.definitions) {
7249
- if (d.kind === e$2.FRAGMENT_DEFINITION && !t.has(d)) {
7250
- a.push(d);
7251
- t.add(d);
7252
- }
7253
- }
7254
- }
7255
- if (a[0].kind === e$2.FRAGMENT_DEFINITION && a[0].directives) {
7256
- a[0].directives = a[0].directives.filter((n => "_unmask" !== n.name.value));
7257
- }
7258
- return {
7259
- kind: e$2.DOCUMENT,
7260
- definitions: a
7261
- };
7262
- }
7263
- graphql.scalar = function scalar(n, r) {
7264
- return r;
7265
- };
7266
- graphql.persisted = function persisted(r, e) {
7267
- return {
7268
- kind: e$2.DOCUMENT,
7269
- definitions: e ? e.definitions : [],
7270
- documentId: r
7271
- };
7272
- };
7273
- return graphql;
7274
- }
7275
-
7276
- var e = initGraphQLTada();
7277
-
7278
- const urqlClient = new C({
7279
- url: sdk.CONSTANTS.ENDPOINTS["test"],
7280
- exchanges: [cacheExchange, fetchExchange],
7281
- });
7282
- const fractionsByIdQuery = e(`
7283
- query fractionsById($fraction_id: String!) {
7284
- fractions(where: { hypercert_id: { eq: $fraction_id } }) {
7285
- data {
7286
- creation_block_timestamp
7287
- fraction_id
7288
- last_update_block_timestamp
7289
- owner_address
7290
- units
7291
- }
7292
- }
7293
- }
7294
- `);
7295
- const getFractionsById = async (fractionId) => {
7296
- const { data, error } = await urqlClient
7297
- .query(fractionsByIdQuery, {
7298
- fraction_id: fractionId,
7299
- })
7300
- .toPromise();
7301
- if (error) {
7302
- throw new Error(error.message);
7303
- }
7304
- return data?.fractions.data;
7305
- };
7306
-
7307
- const HYPERCERTS_MARKETPLACE_API_URL = process.env.HYPERCERTS_MARKETPLACE_API_URL;
7308
- const SUPABASE_HYPERCERTS_URL = process.env.SUPABASE_HYPERCERTS_URL;
7309
- const SUPABASE_HYPERCERTS_ANON_KEY = process.env.SUPABASE_HYPERCERTS_ANON_KEY;
7310
- const supabaseHypercerts = supabaseJs.createClient(SUPABASE_HYPERCERTS_URL, SUPABASE_HYPERCERTS_ANON_KEY);
7303
+ const SUPABASE_HYPERCERTS_DATA_STAGING_URL = "https://zgvoyckkistexkfdmjqc.supabase.co";
7304
+ const SUPABASE_HYPERCERTS_DATA_STAGING_ANON_KEY_STAGING = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inpndm95Y2traXN0ZXhrZmRtanFjIiwicm9sZSI6ImFub24iLCJpYXQiOjE2OTc4ODM1MjAsImV4cCI6MjAxMzQ1OTUyMH0.6FWDhwP3ZOM1O3ObvyRKtOsvwhJjbrZL2B1N-0MSpFg";
7305
+ const SUPABASE_HYPERCERTS_DATA_PRODUCTION_URL = "https://ueebbafxdbglaqtyslwv.supabase.co";
7306
+ const SUPABASE_HYPERCERTS_DATA_PRODUCTION_ANON_KEY = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InVlZWJiYWZ4ZGJnbGFxdHlzbHd2Iiwicm9sZSI6ImFub24iLCJpYXQiOjE2OTc1NTA1MzUsImV4cCI6MjAxMzEyNjUzNX0.mhClRFe8QL6IQLMvTXjdprR6agr_OXF9g2CUJBww4mE";
7311
7307
  class ApiClient {
7312
- constructor(baseUrl) {
7308
+ constructor(indexerEnvironment, baseUrl) {
7313
7309
  this.baseUrl = baseUrl;
7314
7310
  /**
7315
7311
  * Fetches order nonce from api
@@ -7364,7 +7360,7 @@ class ApiClient {
7364
7360
  * @param strategy strategy for the order
7365
7361
  */
7366
7362
  this.fetchOrders = async ({ signer, claimTokenIds, chainId, strategy }) => {
7367
- let baseQuery = supabaseHypercerts.from("marketplace_orders").select("*");
7363
+ let baseQuery = this._supabaseHypercerts.from("marketplace_orders").select("*");
7368
7364
  if (signer) {
7369
7365
  baseQuery.eq("signer", signer);
7370
7366
  }
@@ -7385,9 +7381,9 @@ class ApiClient {
7385
7381
  * @param chainId Chain ID
7386
7382
  */
7387
7383
  this.fetchOrdersByHypercertId = async ({ hypercertId }) => {
7388
- const fractions = await getFractionsById(hypercertId);
7384
+ const fractions = await getFractionsById(hypercertId, this._urqlClient);
7389
7385
  const tokenIds = fractions?.flatMap(() => fractions.map((fraction) => sdk.parseClaimOrFractionId(fraction.fraction_id).id)) || [];
7390
- const result = await supabaseHypercerts.from("marketplace_orders").select("*").overlaps("itemIds", tokenIds);
7386
+ const result = await this._supabaseHypercerts.from("marketplace_orders").select("*").overlaps("itemIds", tokenIds);
7391
7387
  return result;
7392
7388
  };
7393
7389
  this.handleResponse = async (res) => {
@@ -7397,11 +7393,18 @@ class ApiClient {
7397
7393
  }
7398
7394
  return (await res.json());
7399
7395
  };
7400
- const url = baseUrl || HYPERCERTS_MARKETPLACE_API_URL;
7396
+ const url = baseUrl || `${sdk.CONSTANTS.ENDPOINTS[indexerEnvironment]}/v1`;
7401
7397
  if (!url) {
7402
7398
  throw new Error("No API URL provided");
7403
7399
  }
7404
7400
  this._baseUrl = url;
7401
+ this._urqlClient = new C({
7402
+ url: `${sdk.CONSTANTS.ENDPOINTS[indexerEnvironment]}/v1/graphql`,
7403
+ exchanges: [cacheExchange, fetchExchange],
7404
+ });
7405
+ this._supabaseHypercerts = supabaseJs.createClient(indexerEnvironment === "test" ? SUPABASE_HYPERCERTS_DATA_STAGING_URL : SUPABASE_HYPERCERTS_DATA_PRODUCTION_URL, indexerEnvironment === "test"
7406
+ ? SUPABASE_HYPERCERTS_DATA_STAGING_ANON_KEY_STAGING
7407
+ : SUPABASE_HYPERCERTS_DATA_PRODUCTION_ANON_KEY);
7405
7408
  }
7406
7409
  }
7407
7410
 
@@ -7418,11 +7421,16 @@ class HypercertExchangeClient {
7418
7421
  * @param overrides Override contract addresses or api endpoint used
7419
7422
  */
7420
7423
  constructor(chainId, provider, signer, overrides) {
7424
+ const deployment = sdk.CONSTANTS.DEPLOYMENTS[contracts.asDeployedChain(chainId)];
7425
+ if (!deployment) {
7426
+ throw new Error("Chain not supported");
7427
+ }
7428
+ const indexerEnvironment = deployment.isTestnet ? "test" : "production";
7421
7429
  this.chainId = chainId;
7422
7430
  this.addresses = overrides?.addresses ?? addressesByNetwork[this.chainId];
7423
7431
  this.signer = signer;
7424
7432
  this.provider = provider;
7425
- this.api = new ApiClient(overrides?.apiEndpoint);
7433
+ this.api = new ApiClient(indexerEnvironment, overrides?.apiEndpoint);
7426
7434
  }
7427
7435
  /**
7428
7436
  * Return the signer it it's set, throw an exception otherwise
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
- import { HypercertExchangeAbi, TransferManagerAbi, OrderValidatorV2AAbi, deployments } from '@hypercerts-org/contracts';
2
+ import { HypercertExchangeAbi, TransferManagerAbi, OrderValidatorV2AAbi, deployments, asDeployedChain as asDeployedChain$2 } from '@hypercerts-org/contracts';
3
3
  import { MerkleTree } from 'merkletreejs';
4
4
  import { keccak256 as keccak256$1 } from 'js-sha3';
5
5
  import { createClient } from '@supabase/supabase-js';
6
- import { CONSTANTS, parseClaimOrFractionId } from '@hypercerts-org/sdk';
6
+ import { parseClaimOrFractionId, CONSTANTS } from '@hypercerts-org/sdk';
7
7
 
8
8
  var abiIERC721 = [
9
9
  {
@@ -5512,9 +5512,69 @@ function print(e) {
5512
5512
  return m$1[e.kind] ? m$1[e.kind](e) : "";
5513
5513
  }
5514
5514
 
5515
+ function initGraphQLTada() {
5516
+ function graphql(e, i) {
5517
+ var a = parse(e).definitions;
5518
+ var t = new Set;
5519
+ for (var s of i || []) {
5520
+ for (var d of s.definitions) {
5521
+ if (d.kind === e$2.FRAGMENT_DEFINITION && !t.has(d)) {
5522
+ a.push(d);
5523
+ t.add(d);
5524
+ }
5525
+ }
5526
+ }
5527
+ if (a[0].kind === e$2.FRAGMENT_DEFINITION && a[0].directives) {
5528
+ a[0].directives = a[0].directives.filter((n => "_unmask" !== n.name.value));
5529
+ }
5530
+ return {
5531
+ kind: e$2.DOCUMENT,
5532
+ definitions: a
5533
+ };
5534
+ }
5535
+ graphql.scalar = function scalar(n, r) {
5536
+ return r;
5537
+ };
5538
+ graphql.persisted = function persisted(r, e) {
5539
+ return {
5540
+ kind: e$2.DOCUMENT,
5541
+ definitions: e ? e.definitions : [],
5542
+ documentId: r
5543
+ };
5544
+ };
5545
+ return graphql;
5546
+ }
5547
+
5548
+ var e$1 = initGraphQLTada();
5549
+
5550
+ const fractionsByIdQuery = e$1(`
5551
+ query fractionsById($fraction_id: String!) {
5552
+ fractions(where: { hypercert_id: { eq: $fraction_id } }) {
5553
+ data {
5554
+ creation_block_timestamp
5555
+ fraction_id
5556
+ last_update_block_timestamp
5557
+ owner_address
5558
+ units
5559
+ }
5560
+ }
5561
+ }
5562
+ `);
5563
+ const getFractionsById = async (fractionId, client) => {
5564
+ const { data, error } = await client
5565
+ .query(fractionsByIdQuery, {
5566
+ fraction_id: fractionId,
5567
+ })
5568
+ .toPromise();
5569
+ if (error) {
5570
+ throw new Error(error.message);
5571
+ }
5572
+ return data?.fractions.data;
5573
+ };
5574
+
5515
5575
  var teardownPlaceholder = () => {};
5516
5576
 
5517
- var e$1 = teardownPlaceholder;
5577
+ var e = teardownPlaceholder;
5518
5578
 
5519
5579
  function start(e) {
5520
5580
  return {
@@ -5536,7 +5596,7 @@ var identity = e => e;
5536
5596
 
5537
5597
  function filter(r) {
5538
5598
  return t => i => {
5539
- var a = e$1;
5599
+ var a = e;
5540
5600
  t((e => {
5541
5601
  if (0 === e) {
5542
5602
  i(0);
@@ -5565,7 +5625,7 @@ function map(e) {
5565
5625
  function mergeMap(r) {
5566
5626
  return t => i => {
5567
5627
  var a = [];
5568
- var f = e$1;
5628
+ var f = e;
5569
5629
  var n = !1;
5570
5630
  var s = !1;
5571
5631
  t((t => {
@@ -5579,7 +5639,7 @@ function mergeMap(r) {
5579
5639
  } else {
5580
5640
  n = !1;
5581
5641
  !function applyInnerSource(r) {
5582
- var t = e$1;
5642
+ var t = e;
5583
5643
  r((e => {
5584
5644
  if (0 === e) {
5585
5645
  if (a.length) {
@@ -5708,7 +5768,7 @@ function onStart(e) {
5708
5768
 
5709
5769
  function share(r) {
5710
5770
  var t = [];
5711
- var i = e$1;
5771
+ var i = e;
5712
5772
  var a = !1;
5713
5773
  return e => {
5714
5774
  t.push(e);
@@ -5748,8 +5808,8 @@ function share(r) {
5748
5808
 
5749
5809
  function switchMap(r) {
5750
5810
  return t => i => {
5751
- var a = e$1;
5752
- var f = e$1;
5811
+ var a = e;
5812
+ var f = e;
5753
5813
  var n = !1;
5754
5814
  var s = !1;
5755
5815
  var l = !1;
@@ -5765,7 +5825,7 @@ function switchMap(r) {
5765
5825
  } else {
5766
5826
  if (l) {
5767
5827
  f(1);
5768
- f = e$1;
5828
+ f = e;
5769
5829
  }
5770
5830
  if (!n) {
5771
5831
  n = !0;
@@ -5825,7 +5885,7 @@ function switchMap(r) {
5825
5885
 
5826
5886
  function take(r) {
5827
5887
  return t => i => {
5828
- var a = e$1;
5888
+ var a = e;
5829
5889
  var f = !1;
5830
5890
  var n = 0;
5831
5891
  t((e => {
@@ -5864,8 +5924,8 @@ function take(r) {
5864
5924
 
5865
5925
  function takeUntil(r) {
5866
5926
  return t => i => {
5867
- var a = e$1;
5868
- var f = e$1;
5927
+ var a = e;
5928
+ var f = e;
5869
5929
  var n = !1;
5870
5930
  t((e => {
5871
5931
  if (n) ; else if (0 === e) {
@@ -5902,7 +5962,7 @@ function takeUntil(r) {
5902
5962
 
5903
5963
  function takeWhile(r, t) {
5904
5964
  return i => a => {
5905
- var f = e$1;
5965
+ var f = e;
5906
5966
  var n = !1;
5907
5967
  i((e => {
5908
5968
  if (n) ; else if (0 === e) {
@@ -6086,7 +6146,7 @@ function makeSubject() {
6086
6146
 
6087
6147
  function subscribe(r) {
6088
6148
  return t => {
6089
- var i = e$1;
6149
+ var i = e;
6090
6150
  var a = !1;
6091
6151
  t((e => {
6092
6152
  if (0 === e) {
@@ -6115,7 +6175,7 @@ function publish(e) {
6115
6175
 
6116
6176
  function toPromise(r) {
6117
6177
  return new Promise((t => {
6118
- var i = e$1;
6178
+ var i = e;
6119
6179
  var a;
6120
6180
  r((e => {
6121
6181
  if (0 === e) {
@@ -7238,76 +7298,12 @@ var C = function Client(e) {
7238
7298
  return p;
7239
7299
  };
7240
7300
 
7241
- function initGraphQLTada() {
7242
- function graphql(e, i) {
7243
- var a = parse(e).definitions;
7244
- var t = new Set;
7245
- for (var s of i || []) {
7246
- for (var d of s.definitions) {
7247
- if (d.kind === e$2.FRAGMENT_DEFINITION && !t.has(d)) {
7248
- a.push(d);
7249
- t.add(d);
7250
- }
7251
- }
7252
- }
7253
- if (a[0].kind === e$2.FRAGMENT_DEFINITION && a[0].directives) {
7254
- a[0].directives = a[0].directives.filter((n => "_unmask" !== n.name.value));
7255
- }
7256
- return {
7257
- kind: e$2.DOCUMENT,
7258
- definitions: a
7259
- };
7260
- }
7261
- graphql.scalar = function scalar(n, r) {
7262
- return r;
7263
- };
7264
- graphql.persisted = function persisted(r, e) {
7265
- return {
7266
- kind: e$2.DOCUMENT,
7267
- definitions: e ? e.definitions : [],
7268
- documentId: r
7269
- };
7270
- };
7271
- return graphql;
7272
- }
7273
-
7274
- var e = initGraphQLTada();
7275
-
7276
- const urqlClient = new C({
7277
- url: CONSTANTS.ENDPOINTS["test"],
7278
- exchanges: [cacheExchange, fetchExchange],
7279
- });
7280
- const fractionsByIdQuery = e(`
7281
- query fractionsById($fraction_id: String!) {
7282
- fractions(where: { hypercert_id: { eq: $fraction_id } }) {
7283
- data {
7284
- creation_block_timestamp
7285
- fraction_id
7286
- last_update_block_timestamp
7287
- owner_address
7288
- units
7289
- }
7290
- }
7291
- }
7292
- `);
7293
- const getFractionsById = async (fractionId) => {
7294
- const { data, error } = await urqlClient
7295
- .query(fractionsByIdQuery, {
7296
- fraction_id: fractionId,
7297
- })
7298
- .toPromise();
7299
- if (error) {
7300
- throw new Error(error.message);
7301
- }
7302
- return data?.fractions.data;
7303
- };
7304
-
7305
- const HYPERCERTS_MARKETPLACE_API_URL = process.env.HYPERCERTS_MARKETPLACE_API_URL;
7306
- const SUPABASE_HYPERCERTS_URL = process.env.SUPABASE_HYPERCERTS_URL;
7307
- const SUPABASE_HYPERCERTS_ANON_KEY = process.env.SUPABASE_HYPERCERTS_ANON_KEY;
7308
- const supabaseHypercerts = createClient(SUPABASE_HYPERCERTS_URL, SUPABASE_HYPERCERTS_ANON_KEY);
7301
+ const SUPABASE_HYPERCERTS_DATA_STAGING_URL = "https://zgvoyckkistexkfdmjqc.supabase.co";
7302
+ const SUPABASE_HYPERCERTS_DATA_STAGING_ANON_KEY_STAGING = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inpndm95Y2traXN0ZXhrZmRtanFjIiwicm9sZSI6ImFub24iLCJpYXQiOjE2OTc4ODM1MjAsImV4cCI6MjAxMzQ1OTUyMH0.6FWDhwP3ZOM1O3ObvyRKtOsvwhJjbrZL2B1N-0MSpFg";
7303
+ const SUPABASE_HYPERCERTS_DATA_PRODUCTION_URL = "https://ueebbafxdbglaqtyslwv.supabase.co";
7304
+ const SUPABASE_HYPERCERTS_DATA_PRODUCTION_ANON_KEY = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InVlZWJiYWZ4ZGJnbGFxdHlzbHd2Iiwicm9sZSI6ImFub24iLCJpYXQiOjE2OTc1NTA1MzUsImV4cCI6MjAxMzEyNjUzNX0.mhClRFe8QL6IQLMvTXjdprR6agr_OXF9g2CUJBww4mE";
7309
7305
  class ApiClient {
7310
- constructor(baseUrl) {
7306
+ constructor(indexerEnvironment, baseUrl) {
7311
7307
  this.baseUrl = baseUrl;
7312
7308
  /**
7313
7309
  * Fetches order nonce from api
@@ -7362,7 +7358,7 @@ class ApiClient {
7362
7358
  * @param strategy strategy for the order
7363
7359
  */
7364
7360
  this.fetchOrders = async ({ signer, claimTokenIds, chainId, strategy }) => {
7365
- let baseQuery = supabaseHypercerts.from("marketplace_orders").select("*");
7361
+ let baseQuery = this._supabaseHypercerts.from("marketplace_orders").select("*");
7366
7362
  if (signer) {
7367
7363
  baseQuery.eq("signer", signer);
7368
7364
  }
@@ -7383,9 +7379,9 @@ class ApiClient {
7383
7379
  * @param chainId Chain ID
7384
7380
  */
7385
7381
  this.fetchOrdersByHypercertId = async ({ hypercertId }) => {
7386
- const fractions = await getFractionsById(hypercertId);
7382
+ const fractions = await getFractionsById(hypercertId, this._urqlClient);
7387
7383
  const tokenIds = fractions?.flatMap(() => fractions.map((fraction) => parseClaimOrFractionId(fraction.fraction_id).id)) || [];
7388
- const result = await supabaseHypercerts.from("marketplace_orders").select("*").overlaps("itemIds", tokenIds);
7384
+ const result = await this._supabaseHypercerts.from("marketplace_orders").select("*").overlaps("itemIds", tokenIds);
7389
7385
  return result;
7390
7386
  };
7391
7387
  this.handleResponse = async (res) => {
@@ -7395,11 +7391,18 @@ class ApiClient {
7395
7391
  }
7396
7392
  return (await res.json());
7397
7393
  };
7398
- const url = baseUrl || HYPERCERTS_MARKETPLACE_API_URL;
7394
+ const url = baseUrl || `${CONSTANTS.ENDPOINTS[indexerEnvironment]}/v1`;
7399
7395
  if (!url) {
7400
7396
  throw new Error("No API URL provided");
7401
7397
  }
7402
7398
  this._baseUrl = url;
7399
+ this._urqlClient = new C({
7400
+ url: `${CONSTANTS.ENDPOINTS[indexerEnvironment]}/v1/graphql`,
7401
+ exchanges: [cacheExchange, fetchExchange],
7402
+ });
7403
+ this._supabaseHypercerts = createClient(indexerEnvironment === "test" ? SUPABASE_HYPERCERTS_DATA_STAGING_URL : SUPABASE_HYPERCERTS_DATA_PRODUCTION_URL, indexerEnvironment === "test"
7404
+ ? SUPABASE_HYPERCERTS_DATA_STAGING_ANON_KEY_STAGING
7405
+ : SUPABASE_HYPERCERTS_DATA_PRODUCTION_ANON_KEY);
7403
7406
  }
7404
7407
  }
7405
7408
 
@@ -7416,11 +7419,16 @@ class HypercertExchangeClient {
7416
7419
  * @param overrides Override contract addresses or api endpoint used
7417
7420
  */
7418
7421
  constructor(chainId, provider, signer, overrides) {
7422
+ const deployment = CONSTANTS.DEPLOYMENTS[asDeployedChain$2(chainId)];
7423
+ if (!deployment) {
7424
+ throw new Error("Chain not supported");
7425
+ }
7426
+ const indexerEnvironment = deployment.isTestnet ? "test" : "production";
7419
7427
  this.chainId = chainId;
7420
7428
  this.addresses = overrides?.addresses ?? addressesByNetwork[this.chainId];
7421
7429
  this.signer = signer;
7422
7430
  this.provider = provider;
7423
- this.api = new ApiClient(overrides?.apiEndpoint);
7431
+ this.api = new ApiClient(indexerEnvironment, overrides?.apiEndpoint);
7424
7432
  }
7425
7433
  /**
7426
7434
  * Return the signer it it's set, throw an exception otherwise
@@ -1,516 +1,10 @@
1
1
  import { Maker, QuoteType, StrategyType } from "../types";
2
- import { Database as HypercertsDatabase } from "./hypercerts-database-types";
3
- export declare const supabaseHypercerts: import("@supabase/supabase-js").SupabaseClient<HypercertsDatabase, "public", {
4
- Tables: {
5
- blueprints: {
6
- Row: {
7
- admin_id: string;
8
- created_at: string;
9
- display_size: number;
10
- form_values: import("./hypercerts-database-types").Json;
11
- id: number;
12
- minter_address: string;
13
- registry_id: string;
14
- };
15
- Insert: {
16
- admin_id: string;
17
- created_at?: string | undefined;
18
- display_size?: number | undefined;
19
- form_values: import("./hypercerts-database-types").Json;
20
- id?: number | undefined;
21
- minter_address: string;
22
- registry_id: string;
23
- };
24
- Update: {
25
- admin_id?: string | undefined;
26
- created_at?: string | undefined;
27
- display_size?: number | undefined;
28
- form_values?: import("./hypercerts-database-types").Json | undefined;
29
- id?: number | undefined;
30
- minter_address?: string | undefined;
31
- registry_id?: string | undefined;
32
- };
33
- Relationships: [{
34
- foreignKeyName: "blueprints_admin_id_fkey";
35
- columns: ["admin_id"];
36
- isOneToOne: false;
37
- referencedRelation: "users";
38
- referencedColumns: ["address"];
39
- }, {
40
- foreignKeyName: "blueprints_registry_id_fkey";
41
- columns: ["registry_id"];
42
- isOneToOne: false;
43
- referencedRelation: "registries";
44
- referencedColumns: ["id"];
45
- }];
46
- };
47
- claims: {
48
- Row: {
49
- admin_id: string;
50
- chain_id: number;
51
- created_at: string;
52
- display_size: number;
53
- hypercert_id: string;
54
- id: string;
55
- owner_id: string;
56
- registry_id: string;
57
- };
58
- Insert: {
59
- admin_id: string;
60
- chain_id: number;
61
- created_at?: string | undefined;
62
- display_size?: number | undefined;
63
- hypercert_id: string;
64
- id?: string | undefined;
65
- owner_id: string;
66
- registry_id: string;
67
- };
68
- Update: {
69
- admin_id?: string | undefined;
70
- chain_id?: number | undefined;
71
- created_at?: string | undefined;
72
- display_size?: number | undefined;
73
- hypercert_id?: string | undefined;
74
- id?: string | undefined;
75
- owner_id?: string | undefined;
76
- registry_id?: string | undefined;
77
- };
78
- Relationships: [{
79
- foreignKeyName: "claims_registry_id_fkey";
80
- columns: ["registry_id"];
81
- isOneToOne: false;
82
- referencedRelation: "registries";
83
- referencedColumns: ["id"];
84
- }];
85
- };
86
- default_sponsor_metadata: {
87
- Row: {
88
- address: string;
89
- companyName: string | null;
90
- created_at: string;
91
- firstName: string | null;
92
- image: string;
93
- lastName: string | null;
94
- type: string;
95
- };
96
- Insert: {
97
- address: string;
98
- companyName?: string | null | undefined;
99
- created_at?: string | undefined;
100
- firstName?: string | null | undefined;
101
- image: string;
102
- lastName?: string | null | undefined;
103
- type: string;
104
- };
105
- Update: {
106
- address?: string | undefined;
107
- companyName?: string | null | undefined;
108
- created_at?: string | undefined;
109
- firstName?: string | null | undefined;
110
- image?: string | undefined;
111
- lastName?: string | null | undefined;
112
- type?: string | undefined;
113
- };
114
- Relationships: [];
115
- };
116
- fraction_sponsor_metadata: {
117
- Row: {
118
- chain_id: number;
119
- companyName: string | null;
120
- created_at: string;
121
- firstName: string | null;
122
- fraction_id: string;
123
- hypercert_id: string;
124
- id: string;
125
- image: string;
126
- lastName: string | null;
127
- strategy: string;
128
- type: string;
129
- value: string;
130
- };
131
- Insert: {
132
- chain_id: number;
133
- companyName?: string | null | undefined;
134
- created_at?: string | undefined;
135
- firstName?: string | null | undefined;
136
- fraction_id: string;
137
- hypercert_id: string;
138
- id?: string | undefined;
139
- image: string;
140
- lastName?: string | null | undefined;
141
- strategy: string;
142
- type: string;
143
- value: string;
144
- };
145
- Update: {
146
- chain_id?: number | undefined;
147
- companyName?: string | null | undefined;
148
- created_at?: string | undefined;
149
- firstName?: string | null | undefined;
150
- fraction_id?: string | undefined;
151
- hypercert_id?: string | undefined;
152
- id?: string | undefined;
153
- image?: string | undefined;
154
- lastName?: string | null | undefined;
155
- strategy?: string | undefined;
156
- type?: string | undefined;
157
- value?: string | undefined;
158
- };
159
- Relationships: [];
160
- };
161
- hyperboard_registries: {
162
- Row: {
163
- created_at: string | null;
164
- hyperboard_id: string;
165
- label: string | null;
166
- registry_id: string;
167
- render_method: string;
168
- };
169
- Insert: {
170
- created_at?: string | null | undefined;
171
- hyperboard_id: string;
172
- label?: string | null | undefined;
173
- registry_id: string;
174
- render_method?: string | undefined;
175
- };
176
- Update: {
177
- created_at?: string | null | undefined;
178
- hyperboard_id?: string | undefined;
179
- label?: string | null | undefined;
180
- registry_id?: string | undefined;
181
- render_method?: string | undefined;
182
- };
183
- Relationships: [{
184
- foreignKeyName: "hyperboard_registries_hyperboard_id_fkey";
185
- columns: ["hyperboard_id"];
186
- isOneToOne: false;
187
- referencedRelation: "hyperboards";
188
- referencedColumns: ["id"];
189
- }, {
190
- foreignKeyName: "hyperboard_registries_registries_id_fk";
191
- columns: ["registry_id"];
192
- isOneToOne: false;
193
- referencedRelation: "registries";
194
- referencedColumns: ["id"];
195
- }];
196
- };
197
- hyperboards: {
198
- Row: {
199
- admin_id: string;
200
- background_image: string | null;
201
- chain_id: number;
202
- created_at: string | null;
203
- grayscale_images: boolean;
204
- id: string;
205
- name: string;
206
- tile_border_color: string | null;
207
- };
208
- Insert: {
209
- admin_id: string;
210
- background_image?: string | null | undefined;
211
- chain_id: number;
212
- created_at?: string | null | undefined;
213
- grayscale_images?: boolean | undefined;
214
- id?: string | undefined;
215
- name: string;
216
- tile_border_color?: string | null | undefined;
217
- };
218
- Update: {
219
- admin_id?: string | undefined;
220
- background_image?: string | null | undefined;
221
- chain_id?: number | undefined;
222
- created_at?: string | null | undefined;
223
- grayscale_images?: boolean | undefined;
224
- id?: string | undefined;
225
- name?: string | undefined;
226
- tile_border_color?: string | null | undefined;
227
- };
228
- Relationships: [];
229
- };
230
- marketplace_order_nonces: {
231
- Row: {
232
- address: string;
233
- chain_id: number;
234
- created_at: string;
235
- nonce_counter: number;
236
- };
237
- Insert: {
238
- address: string;
239
- chain_id: number;
240
- created_at?: string | undefined;
241
- nonce_counter?: number | undefined;
242
- };
243
- Update: {
244
- address?: string | undefined;
245
- chain_id?: number | undefined;
246
- created_at?: string | undefined;
247
- nonce_counter?: number | undefined;
248
- };
249
- Relationships: [];
250
- };
251
- marketplace_orders: {
252
- Row: {
253
- additionalParameters: string;
254
- amounts: number[];
255
- chainId: number;
256
- collection: string;
257
- collectionType: number;
258
- createdAt: string;
259
- currency: string;
260
- endTime: number;
261
- globalNonce: string;
262
- id: string;
263
- invalidated: boolean;
264
- itemIds: string[];
265
- orderNonce: string;
266
- price: string;
267
- quoteType: number;
268
- signature: string;
269
- signer: string;
270
- startTime: number;
271
- strategyId: number;
272
- subsetNonce: number;
273
- validator_codes: number[] | null;
274
- };
275
- Insert: {
276
- additionalParameters: string;
277
- amounts: number[];
278
- chainId: number;
279
- collection: string;
280
- collectionType: number;
281
- createdAt?: string | undefined;
282
- currency: string;
283
- endTime: number;
284
- globalNonce: string;
285
- id?: string | undefined;
286
- invalidated?: boolean | undefined;
287
- itemIds: string[];
288
- orderNonce: string;
289
- price: string;
290
- quoteType: number;
291
- signature: string;
292
- signer: string;
293
- startTime: number;
294
- strategyId: number;
295
- subsetNonce: number;
296
- validator_codes?: number[] | null | undefined;
297
- };
298
- Update: {
299
- additionalParameters?: string | undefined;
300
- amounts?: number[] | undefined;
301
- chainId?: number | undefined;
302
- collection?: string | undefined;
303
- collectionType?: number | undefined;
304
- createdAt?: string | undefined;
305
- currency?: string | undefined;
306
- endTime?: number | undefined;
307
- globalNonce?: string | undefined;
308
- id?: string | undefined;
309
- invalidated?: boolean | undefined;
310
- itemIds?: string[] | undefined;
311
- orderNonce?: string | undefined;
312
- price?: string | undefined;
313
- quoteType?: number | undefined;
314
- signature?: string | undefined;
315
- signer?: string | undefined;
316
- startTime?: number | undefined;
317
- strategyId?: number | undefined;
318
- subsetNonce?: number | undefined;
319
- validator_codes?: number[] | null | undefined;
320
- };
321
- Relationships: [];
322
- };
323
- registries: {
324
- Row: {
325
- admin_id: string;
326
- chain_id: number;
327
- created_at: string;
328
- description: string;
329
- hidden: boolean;
330
- id: string;
331
- name: string;
332
- };
333
- Insert: {
334
- admin_id: string;
335
- chain_id: number;
336
- created_at?: string | undefined;
337
- description: string;
338
- hidden?: boolean | undefined;
339
- id?: string | undefined;
340
- name: string;
341
- };
342
- Update: {
343
- admin_id?: string | undefined;
344
- chain_id?: number | undefined;
345
- created_at?: string | undefined;
346
- description?: string | undefined;
347
- hidden?: boolean | undefined;
348
- id?: string | undefined;
349
- name?: string | undefined;
350
- };
351
- Relationships: [];
352
- };
353
- users: {
354
- Row: {
355
- address: string;
356
- auth: import("./hypercerts-database-types").Json;
357
- created_at: string;
358
- email: string | null;
359
- id: string | null;
360
- };
361
- Insert: {
362
- address: string;
363
- auth?: import("./hypercerts-database-types").Json | undefined;
364
- created_at?: string | undefined;
365
- email?: string | null | undefined;
366
- id?: string | null | undefined;
367
- };
368
- Update: {
369
- address?: string | undefined;
370
- auth?: import("./hypercerts-database-types").Json | undefined;
371
- created_at?: string | undefined;
372
- email?: string | null | undefined;
373
- id?: string | null | undefined;
374
- };
375
- Relationships: [];
376
- };
377
- zuconnect_voting: {
378
- Row: {
379
- allocation_hc01: number | null;
380
- allocation_hc02: number | null;
381
- allocation_hc03: number | null;
382
- allocation_hc04: number | null;
383
- allocation_hc05: number | null;
384
- allocation_hc06: number | null;
385
- allocation_hc07: number | null;
386
- allocation_hc08: number | null;
387
- created_at: string;
388
- feedback: string | null;
389
- fid: string | null;
390
- id: number;
391
- link_to_image: string | null;
392
- percent_core_team: number | null;
393
- percent_direct_allocation: number | null;
394
- percent_matching_fund: number | null;
395
- };
396
- Insert: {
397
- allocation_hc01?: number | null | undefined;
398
- allocation_hc02?: number | null | undefined;
399
- allocation_hc03?: number | null | undefined;
400
- allocation_hc04?: number | null | undefined;
401
- allocation_hc05?: number | null | undefined;
402
- allocation_hc06?: number | null | undefined;
403
- allocation_hc07?: number | null | undefined;
404
- allocation_hc08?: number | null | undefined;
405
- created_at?: string | undefined;
406
- feedback?: string | null | undefined;
407
- fid?: string | null | undefined;
408
- id?: number | undefined;
409
- link_to_image?: string | null | undefined;
410
- percent_core_team?: number | null | undefined;
411
- percent_direct_allocation?: number | null | undefined;
412
- percent_matching_fund?: number | null | undefined;
413
- };
414
- Update: {
415
- allocation_hc01?: number | null | undefined;
416
- allocation_hc02?: number | null | undefined;
417
- allocation_hc03?: number | null | undefined;
418
- allocation_hc04?: number | null | undefined;
419
- allocation_hc05?: number | null | undefined;
420
- allocation_hc06?: number | null | undefined;
421
- allocation_hc07?: number | null | undefined;
422
- allocation_hc08?: number | null | undefined;
423
- created_at?: string | undefined;
424
- feedback?: string | null | undefined;
425
- fid?: string | null | undefined;
426
- id?: number | undefined;
427
- link_to_image?: string | null | undefined;
428
- percent_core_team?: number | null | undefined;
429
- percent_direct_allocation?: number | null | undefined;
430
- percent_matching_fund?: number | null | undefined;
431
- };
432
- Relationships: [];
433
- };
434
- zuzalu_donations: {
435
- Row: {
436
- address: string;
437
- amount: string | null;
438
- created_at: string;
439
- email: string;
440
- id: number;
441
- };
442
- Insert: {
443
- address: string;
444
- amount?: string | null | undefined;
445
- created_at?: string | undefined;
446
- email: string;
447
- id?: number | undefined;
448
- };
449
- Update: {
450
- address?: string | undefined;
451
- amount?: string | null | undefined;
452
- created_at?: string | undefined;
453
- email?: string | undefined;
454
- id?: number | undefined;
455
- };
456
- Relationships: [];
457
- };
458
- };
459
- Views: {};
460
- Functions: {
461
- add_claim_from_blueprint: {
462
- Args: {
463
- registry_id: string;
464
- hypercert_id: string;
465
- chain_id: number;
466
- admin_id: string;
467
- owner_id: string;
468
- blueprint_id: number;
469
- };
470
- Returns: string;
471
- };
472
- default_sponsor_metadata_by_address: {
473
- Args: {
474
- addresses: string[];
475
- };
476
- Returns: {
477
- address: string;
478
- companyName: string | null;
479
- created_at: string;
480
- firstName: string | null;
481
- image: string;
482
- lastName: string | null;
483
- type: string;
484
- }[];
485
- };
486
- fraction_sponsor_metadata_by_fraction_id: {
487
- Args: {
488
- fractions: string[];
489
- chain: number;
490
- };
491
- Returns: {
492
- chain_id: number;
493
- companyName: string | null;
494
- created_at: string;
495
- firstName: string | null;
496
- fraction_id: string;
497
- hypercert_id: string;
498
- id: string;
499
- image: string;
500
- lastName: string | null;
501
- strategy: string;
502
- type: string;
503
- value: string;
504
- }[];
505
- };
506
- };
507
- Enums: {};
508
- CompositeTypes: {};
509
- }>;
510
2
  export declare class ApiClient {
511
3
  private readonly baseUrl?;
512
4
  private _baseUrl;
513
- constructor(baseUrl?: string | undefined);
5
+ private _urqlClient;
6
+ private _supabaseHypercerts;
7
+ constructor(indexerEnvironment: "test" | "production", baseUrl?: string | undefined);
514
8
  /**
515
9
  * Fetches order nonce from api
516
10
  * @param address Address
@@ -1,6 +1,5 @@
1
1
  import { Client } from "@urql/core";
2
- export declare const urqlClient: Client;
3
- export declare const getFractionsById: (fractionId: string) => Promise<{
2
+ export declare const getFractionsById: (fractionId: string, client: Client) => Promise<{
4
3
  units: unknown;
5
4
  owner_address: string | null;
6
5
  last_update_block_timestamp: unknown;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hypercerts-org/marketplace-sdk",
3
- "version": "0.3.12",
3
+ "version": "0.3.13",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -24,6 +24,20 @@
24
24
  "engines": {
25
25
  "node": ">= 16.15.1 <= 20.x"
26
26
  },
27
+ "scripts": {
28
+ "prebuild": "rm -rf ./src/typechain ./src/artifacts cache dist",
29
+ "dev": "rollup -c --bundleConfigAsCjs -w",
30
+ "build:ts": "rollup -c --bundleConfigAsCjs",
31
+ "build:sc": "hardhat compile",
32
+ "build": "yarn build:sc && yarn build:ts",
33
+ "test": "nyc hardhat test",
34
+ "doc": "typedoc --plugin typedoc-plugin-markdown --tsconfig tsconfig.build.json",
35
+ "lint": "eslint --max-warnings 0 'src/**/*.{js,ts}'",
36
+ "format:check": "prettier --check 'src/**/*.{js,ts,json,yaml,yml,md}'",
37
+ "format:write": "prettier --write 'src/**/*.{js,ts,json,yaml,yml,md}'",
38
+ "release": "release-it --only-version --set-upstream",
39
+ "supabase:types:hypercerts": "npx supabase gen types typescript --project-id zgvoyckkistexkfdmjqc --schema public > src/utils/hypercerts-database-types.ts"
40
+ },
27
41
  "lint-staged": {
28
42
  "*.{js,jsx,ts,tsx,json,yaml,yml}": "yarn format:write"
29
43
  },
@@ -85,19 +99,5 @@
85
99
  "ethers": "^6.6.2",
86
100
  "gql.tada": "^1.7.6",
87
101
  "merkletreejs": "^0.3.9"
88
- },
89
- "scripts": {
90
- "prebuild": "rm -rf ./src/typechain ./src/artifacts cache dist",
91
- "dev": "rollup -c --bundleConfigAsCjs -w",
92
- "build:ts": "rollup -c --bundleConfigAsCjs",
93
- "build:sc": "hardhat compile",
94
- "build": "yarn build:sc && yarn build:ts",
95
- "test": "nyc hardhat test",
96
- "doc": "typedoc --plugin typedoc-plugin-markdown --tsconfig tsconfig.build.json",
97
- "lint": "eslint --max-warnings 0 'src/**/*.{js,ts}'",
98
- "format:check": "prettier --check 'src/**/*.{js,ts,json,yaml,yml,md}'",
99
- "format:write": "prettier --write 'src/**/*.{js,ts,json,yaml,yml,md}'",
100
- "release": "release-it --only-version --set-upstream",
101
- "supabase:types:hypercerts": "npx supabase gen types typescript --project-id zgvoyckkistexkfdmjqc --schema public > src/utils/hypercerts-database-types.ts"
102
102
  }
103
- }
103
+ }