@hypercerts-org/marketplace-sdk 0.3.15 → 0.3.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.
- package/dist/HypercertExchangeClient.d.ts +11 -0
- package/dist/index.cjs.js +32 -0
- package/dist/index.esm.js +32 -0
- package/dist/utils/api.d.ts +6 -1
- package/package.json +1 -1
@@ -216,6 +216,17 @@ 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
|
+
* Utility function to check if a list of orders are valid, according to logic specific for hypercerts using order validation codes.
|
221
|
+
* @param makers List of maker orders
|
222
|
+
* @param signatures List of signatures
|
223
|
+
* @param merkleTrees List of merkle trees (optional)
|
224
|
+
* @param overrides Call overrides (optional)
|
225
|
+
*/
|
226
|
+
checkOrdersValidity(makers: Maker[], signatures: string[], merkleTrees?: MerkleTree[], overrides?: Overrides): Promise<{
|
227
|
+
valid: boolean;
|
228
|
+
validatorCodes: OrderValidatorCode[];
|
229
|
+
}[]>;
|
219
230
|
/**
|
220
231
|
* Retrieve strategy info
|
221
232
|
* @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,20 @@ 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
|
+
* Utility function to check if a list of orders are valid, according to logic specific for hypercerts using order validation codes.
|
7951
|
+
* @param makers List of maker orders
|
7952
|
+
* @param signatures List of signatures
|
7953
|
+
* @param merkleTrees List of merkle trees (optional)
|
7954
|
+
* @param overrides Call overrides (optional)
|
7955
|
+
*/
|
7956
|
+
async checkOrdersValidity(makers, signatures, merkleTrees, overrides) {
|
7957
|
+
const result = await this.verifyMakerOrders(makers, signatures, merkleTrees, overrides);
|
7958
|
+
return result.map((res) => {
|
7959
|
+
const valid = res.every((code) => ACCEPTED_ERROR_CODES.includes(code));
|
7960
|
+
return { valid, validatorCodes: res };
|
7961
|
+
});
|
7962
|
+
}
|
7931
7963
|
/**
|
7932
7964
|
* Retrieve strategy info
|
7933
7965
|
* @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,20 @@ 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
|
+
* Utility function to check if a list of orders are valid, according to logic specific for hypercerts using order validation codes.
|
7949
|
+
* @param makers List of maker orders
|
7950
|
+
* @param signatures List of signatures
|
7951
|
+
* @param merkleTrees List of merkle trees (optional)
|
7952
|
+
* @param overrides Call overrides (optional)
|
7953
|
+
*/
|
7954
|
+
async checkOrdersValidity(makers, signatures, merkleTrees, overrides) {
|
7955
|
+
const result = await this.verifyMakerOrders(makers, signatures, merkleTrees, overrides);
|
7956
|
+
return result.map((res) => {
|
7957
|
+
const valid = res.every((code) => ACCEPTED_ERROR_CODES.includes(code));
|
7958
|
+
return { valid, validatorCodes: res };
|
7959
|
+
});
|
7960
|
+
}
|
7929
7961
|
/**
|
7930
7962
|
* Retrieve strategy info
|
7931
7963
|
* @param strategyId use the enum StrategyType
|
package/dist/utils/api.d.ts
CHANGED
@@ -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}`;
|