@hypercerts-org/marketplace-sdk 0.3.16 → 0.3.18

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,6 +1,7 @@
1
1
  import { BigNumberish, ContractTransactionResponse, Overrides, Provider, Signer, TypedDataDomain } from "ethers";
2
2
  import { Addresses, BatchTransferItem, ChainId, ContractMethods, CreateMakerAskOutput, CreateMakerBidOutput, CreateMakerCollectionOfferInput, CreateMakerCollectionOfferWithProofInput, CreateMakerInput, Currencies, Maker, MerkleTree, OrderValidatorCode, SignMerkleTreeOrdersOutput, StrategyInfo, StrategyType, Taker } from "./types";
3
3
  import { ApiClient } from "./utils/api";
4
+ import { Database } from "./utils/hypercerts-database-types";
4
5
  /**
5
6
  * HypercertExchange
6
7
  * This class provides helpers to interact with the HypercertExchange V2 contracts
@@ -217,9 +218,15 @@ export declare class HypercertExchangeClient {
217
218
  */
218
219
  verifyMakerOrders(makerOrders: Maker[], signatures: string[], merkleTrees?: MerkleTree[], overrides?: Overrides): Promise<OrderValidatorCode[][]>;
219
220
  /**
220
- * Is order valid
221
+ * Utility function to check if a list of orders are valid, according to logic specific for hypercerts using order validation codes.
222
+ * @param orders List of orders to be checked
223
+ * @param overrides Call overrides (optional)
221
224
  */
222
- checkOrderValidity(makers: Maker[], signatures: string[], merkleTrees: MerkleTree[], overrides?: Overrides): Promise<boolean>;
225
+ checkOrdersValidity(orders: Database["public"]["Tables"]["marketplace_orders"]["Row"][], overrides?: Overrides): Promise<{
226
+ id: string;
227
+ valid: boolean;
228
+ validatorCodes: OrderValidatorCode[];
229
+ }[]>;
223
230
  /**
224
231
  * Retrieve strategy info
225
232
  * @param strategyId use the enum StrategyType
package/dist/index.cjs.js CHANGED
@@ -7947,11 +7947,28 @@ class HypercertExchangeClient {
7947
7947
  return verifyMakerOrders(this.provider, this.addresses.ORDER_VALIDATOR_V2, makerOrders, signatures, _merkleTrees, overrides);
7948
7948
  }
7949
7949
  /**
7950
- * Is order valid
7950
+ * Utility function to check if a list of orders are valid, according to logic specific for hypercerts using order validation codes.
7951
+ * @param orders List of orders to be checked
7952
+ * @param overrides Call overrides (optional)
7951
7953
  */
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));
7954
+ async checkOrdersValidity(orders, overrides) {
7955
+ // Prepare matching orders for validation
7956
+ const signatures = [];
7957
+ const makers = [];
7958
+ for (const order of orders) {
7959
+ const { signature, chainId, id: __, ...orderWithoutSignature } = order;
7960
+ if (chainId !== this.chainId) {
7961
+ throw new Error("Chain ID mismatch when checking order validity");
7962
+ }
7963
+ signatures.push(signature);
7964
+ makers.push(orderWithoutSignature);
7965
+ }
7966
+ const result = await this.verifyMakerOrders(makers, signatures, undefined, overrides);
7967
+ return result.map((res, index) => {
7968
+ const order = orders[index];
7969
+ const valid = res.every((code) => ACCEPTED_ERROR_CODES.includes(code));
7970
+ return { id: order.id, valid, validatorCodes: res };
7971
+ });
7955
7972
  }
7956
7973
  /**
7957
7974
  * Retrieve strategy info
package/dist/index.esm.js CHANGED
@@ -7945,11 +7945,28 @@ class HypercertExchangeClient {
7945
7945
  return verifyMakerOrders(this.provider, this.addresses.ORDER_VALIDATOR_V2, makerOrders, signatures, _merkleTrees, overrides);
7946
7946
  }
7947
7947
  /**
7948
- * Is order valid
7948
+ * Utility function to check if a list of orders are valid, according to logic specific for hypercerts using order validation codes.
7949
+ * @param orders List of orders to be checked
7950
+ * @param overrides Call overrides (optional)
7949
7951
  */
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));
7952
+ async checkOrdersValidity(orders, overrides) {
7953
+ // Prepare matching orders for validation
7954
+ const signatures = [];
7955
+ const makers = [];
7956
+ for (const order of orders) {
7957
+ const { signature, chainId, id: __, ...orderWithoutSignature } = order;
7958
+ if (chainId !== this.chainId) {
7959
+ throw new Error("Chain ID mismatch when checking order validity");
7960
+ }
7961
+ signatures.push(signature);
7962
+ makers.push(orderWithoutSignature);
7963
+ }
7964
+ const result = await this.verifyMakerOrders(makers, signatures, undefined, overrides);
7965
+ return result.map((res, index) => {
7966
+ const order = orders[index];
7967
+ const valid = res.every((code) => ACCEPTED_ERROR_CODES.includes(code));
7968
+ return { id: order.id, valid, validatorCodes: res };
7969
+ });
7953
7970
  }
7954
7971
  /**
7955
7972
  * Retrieve strategy info
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hypercerts-org/marketplace-sdk",
3
- "version": "0.3.16",
3
+ "version": "0.3.18",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",