@hypercerts-org/marketplace-sdk 0.3.15 → 0.3.16

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.
@@ -216,6 +216,10 @@ export declare class HypercertExchangeClient {
216
216
  * @returns A list of OrderValidatorCode for each order (code 0 being valid)
217
217
  */
218
218
  verifyMakerOrders(makerOrders: Maker[], signatures: string[], merkleTrees?: MerkleTree[], overrides?: Overrides): Promise<OrderValidatorCode[][]>;
219
+ /**
220
+ * Is order valid
221
+ */
222
+ checkOrderValidity(makers: Maker[], signatures: string[], merkleTrees: MerkleTree[], overrides?: Overrides): Promise<boolean>;
219
223
  /**
220
224
  * Retrieve strategy info
221
225
  * @param strategyId use the enum StrategyType
package/dist/index.cjs.js CHANGED
@@ -7522,6 +7522,20 @@ class ApiClient {
7522
7522
  }
7523
7523
  return (await res.json());
7524
7524
  };
7525
+ this.updateOrderValidity = async (tokenId, chainId) => {
7526
+ return fetch(`${this._baseUrl}/marketplace/validate/`, {
7527
+ method: "POST",
7528
+ headers: {
7529
+ "Content-Type": "application/json",
7530
+ },
7531
+ body: JSON.stringify({
7532
+ tokenId,
7533
+ chainId,
7534
+ }),
7535
+ })
7536
+ .then((res) => this.handleResponse(res))
7537
+ .then((res) => res.data);
7538
+ };
7525
7539
  const url = baseUrl || `${sdk.CONSTANTS.ENDPOINTS[indexerEnvironment]}/v1`;
7526
7540
  if (!url) {
7527
7541
  throw new Error("No API URL provided");
@@ -7537,6 +7551,10 @@ class ApiClient {
7537
7551
  }
7538
7552
  }
7539
7553
 
7554
+ const ACCEPTED_ERROR_CODES = [
7555
+ exports.OrderValidatorCode.ORDER_EXPECTED_TO_BE_VALID,
7556
+ exports.OrderValidatorCode.TOO_EARLY_TO_EXECUTE_ORDER,
7557
+ ];
7540
7558
  /**
7541
7559
  * HypercertExchange
7542
7560
  * This class provides helpers to interact with the HypercertExchange V2 contracts
@@ -7928,6 +7946,13 @@ class HypercertExchangeClient {
7928
7946
  const _merkleTrees = merkleTrees ?? makerOrders.map(() => defaultMerkleTree);
7929
7947
  return verifyMakerOrders(this.provider, this.addresses.ORDER_VALIDATOR_V2, makerOrders, signatures, _merkleTrees, overrides);
7930
7948
  }
7949
+ /**
7950
+ * Is order valid
7951
+ */
7952
+ async checkOrderValidity(makers, signatures, merkleTrees, overrides) {
7953
+ const result = await this.verifyMakerOrders(makers, signatures, merkleTrees, overrides);
7954
+ return result[0].every((code) => ACCEPTED_ERROR_CODES.includes(code));
7955
+ }
7931
7956
  /**
7932
7957
  * Retrieve strategy info
7933
7958
  * @param strategyId use the enum StrategyType
package/dist/index.esm.js CHANGED
@@ -7520,6 +7520,20 @@ class ApiClient {
7520
7520
  }
7521
7521
  return (await res.json());
7522
7522
  };
7523
+ this.updateOrderValidity = async (tokenId, chainId) => {
7524
+ return fetch(`${this._baseUrl}/marketplace/validate/`, {
7525
+ method: "POST",
7526
+ headers: {
7527
+ "Content-Type": "application/json",
7528
+ },
7529
+ body: JSON.stringify({
7530
+ tokenId,
7531
+ chainId,
7532
+ }),
7533
+ })
7534
+ .then((res) => this.handleResponse(res))
7535
+ .then((res) => res.data);
7536
+ };
7523
7537
  const url = baseUrl || `${CONSTANTS.ENDPOINTS[indexerEnvironment]}/v1`;
7524
7538
  if (!url) {
7525
7539
  throw new Error("No API URL provided");
@@ -7535,6 +7549,10 @@ class ApiClient {
7535
7549
  }
7536
7550
  }
7537
7551
 
7552
+ const ACCEPTED_ERROR_CODES = [
7553
+ OrderValidatorCode.ORDER_EXPECTED_TO_BE_VALID,
7554
+ OrderValidatorCode.TOO_EARLY_TO_EXECUTE_ORDER,
7555
+ ];
7538
7556
  /**
7539
7557
  * HypercertExchange
7540
7558
  * This class provides helpers to interact with the HypercertExchange V2 contracts
@@ -7926,6 +7944,13 @@ class HypercertExchangeClient {
7926
7944
  const _merkleTrees = merkleTrees ?? makerOrders.map(() => defaultMerkleTree);
7927
7945
  return verifyMakerOrders(this.provider, this.addresses.ORDER_VALIDATOR_V2, makerOrders, signatures, _merkleTrees, overrides);
7928
7946
  }
7947
+ /**
7948
+ * Is order valid
7949
+ */
7950
+ async checkOrderValidity(makers, signatures, merkleTrees, overrides) {
7951
+ const result = await this.verifyMakerOrders(makers, signatures, merkleTrees, overrides);
7952
+ return result[0].every((code) => ACCEPTED_ERROR_CODES.includes(code));
7953
+ }
7929
7954
  /**
7930
7955
  * Retrieve strategy info
7931
7956
  * @param strategyId use the enum StrategyType
@@ -1,4 +1,4 @@
1
- import { Maker, QuoteType, StrategyType } from "../types";
1
+ import { Maker, OrderValidatorCode, QuoteType, StrategyType } from "../types";
2
2
  export declare class ApiClient {
3
3
  private readonly baseUrl?;
4
4
  private _baseUrl;
@@ -96,6 +96,11 @@ export declare class ApiClient {
96
96
  validator_codes: number[] | null;
97
97
  }[]>>;
98
98
  handleResponse: <T>(res: Response) => Promise<T>;
99
+ updateOrderValidity: (tokenId: bigint, chainId: number) => Promise<{
100
+ id: string;
101
+ invalidated: boolean;
102
+ validator_codes: OrderValidatorCode[];
103
+ }[]>;
99
104
  }
100
105
  interface FetchOrderArgs {
101
106
  signer: `0x${string}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hypercerts-org/marketplace-sdk",
3
- "version": "0.3.15",
3
+ "version": "0.3.16",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",