@hypercerts-org/marketplace-sdk 0.3.22 → 0.3.24
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 +5 -0
- package/dist/index.cjs.js +116 -3
- package/dist/index.esm.js +116 -3
- package/dist/utils/api.d.ts +51 -22
- package/dist/utils/graphl.d.ts +54 -0
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
@@ -5702,6 +5702,76 @@ const getFractionsById = async (fractionId, client) => {
|
|
5702
5702
|
}
|
5703
5703
|
return data?.fractions.data;
|
5704
5704
|
};
|
5705
|
+
const ordersQuery = e$1(`
|
5706
|
+
query OrdersQuery($chainId: BigInt, $signer: String) {
|
5707
|
+
orders(where: { chainId: { eq: $chainId }, signer: { eq: $signer } }) {
|
5708
|
+
count
|
5709
|
+
data {
|
5710
|
+
id
|
5711
|
+
hypercert {
|
5712
|
+
hypercert_id
|
5713
|
+
creator_address
|
5714
|
+
contracts_id
|
5715
|
+
creation_block_number
|
5716
|
+
creation_block_timestamp
|
5717
|
+
id
|
5718
|
+
last_update_block_number
|
5719
|
+
last_update_block_timestamp
|
5720
|
+
metadata {
|
5721
|
+
allow_list_uri
|
5722
|
+
contributors
|
5723
|
+
description
|
5724
|
+
external_url
|
5725
|
+
id
|
5726
|
+
impact_scope
|
5727
|
+
impact_timeframe_from
|
5728
|
+
impact_timeframe_to
|
5729
|
+
name
|
5730
|
+
properties
|
5731
|
+
rights
|
5732
|
+
uri
|
5733
|
+
work_scope
|
5734
|
+
work_timeframe_from
|
5735
|
+
work_timeframe_to
|
5736
|
+
}
|
5737
|
+
token_id
|
5738
|
+
units
|
5739
|
+
uri
|
5740
|
+
}
|
5741
|
+
additionalParameters
|
5742
|
+
amounts
|
5743
|
+
chainId
|
5744
|
+
collection
|
5745
|
+
collectionType
|
5746
|
+
createdAt
|
5747
|
+
currency
|
5748
|
+
endTime
|
5749
|
+
globalNonce
|
5750
|
+
itemIds
|
5751
|
+
orderNonce
|
5752
|
+
price
|
5753
|
+
quoteType
|
5754
|
+
signature
|
5755
|
+
signer
|
5756
|
+
startTime
|
5757
|
+
strategyId
|
5758
|
+
subsetNonce
|
5759
|
+
}
|
5760
|
+
}
|
5761
|
+
}
|
5762
|
+
`);
|
5763
|
+
const getOrders = async ({ chainId, signer }, client) => {
|
5764
|
+
const { data, error } = await client
|
5765
|
+
.query(ordersQuery, {
|
5766
|
+
chainId,
|
5767
|
+
signer,
|
5768
|
+
})
|
5769
|
+
.toPromise();
|
5770
|
+
if (error) {
|
5771
|
+
throw new Error(error.message);
|
5772
|
+
}
|
5773
|
+
return data?.orders.data;
|
5774
|
+
};
|
5705
5775
|
|
5706
5776
|
var teardownPlaceholder = () => {};
|
5707
5777
|
|
@@ -7502,7 +7572,7 @@ class ApiClient {
|
|
7502
7572
|
if (strategy) {
|
7503
7573
|
baseQuery.eq("strategyId", strategy);
|
7504
7574
|
}
|
7505
|
-
return
|
7575
|
+
return await getOrders({ signer, chainId: chainId ? BigInt(chainId) : undefined }, this._urqlClient);
|
7506
7576
|
};
|
7507
7577
|
/**
|
7508
7578
|
* Fetches orders from api by hypercert ID
|
@@ -7536,6 +7606,20 @@ class ApiClient {
|
|
7536
7606
|
.then((res) => this.handleResponse(res))
|
7537
7607
|
.then((res) => res.data);
|
7538
7608
|
};
|
7609
|
+
this.deleteOrder = async (orderId, signature) => {
|
7610
|
+
return fetch(`${this._baseUrl}/marketplace/orders`, {
|
7611
|
+
method: "DELETE",
|
7612
|
+
headers: {
|
7613
|
+
"Content-Type": "application/json",
|
7614
|
+
},
|
7615
|
+
body: JSON.stringify({
|
7616
|
+
orderId,
|
7617
|
+
signature,
|
7618
|
+
}),
|
7619
|
+
})
|
7620
|
+
.then((res) => this.handleResponse(res))
|
7621
|
+
.then((res) => res.success);
|
7622
|
+
};
|
7539
7623
|
const url = baseUrl || `${sdk.CONSTANTS.ENDPOINTS[indexerEnvironment]}/v1`;
|
7540
7624
|
if (!url) {
|
7541
7625
|
throw new Error("No API URL provided");
|
@@ -7956,12 +8040,29 @@ class HypercertExchangeClient {
|
|
7956
8040
|
const signatures = [];
|
7957
8041
|
const makers = [];
|
7958
8042
|
for (const order of orders) {
|
7959
|
-
const { signature, chainId
|
8043
|
+
const { signature, chainId } = order;
|
7960
8044
|
if (chainId !== this.chainId) {
|
7961
8045
|
throw new Error("Chain ID mismatch when checking order validity");
|
7962
8046
|
}
|
7963
8047
|
signatures.push(signature);
|
7964
|
-
|
8048
|
+
const maker = {
|
8049
|
+
quoteType: order.quoteType,
|
8050
|
+
globalNonce: order.globalNonce,
|
8051
|
+
subsetNonce: order.subsetNonce,
|
8052
|
+
strategyId: order.strategyId,
|
8053
|
+
collectionType: order.collectionType,
|
8054
|
+
orderNonce: order.orderNonce,
|
8055
|
+
collection: order.collection,
|
8056
|
+
currency: order.currency,
|
8057
|
+
signer: order.signer,
|
8058
|
+
startTime: order.startTime,
|
8059
|
+
endTime: order.endTime,
|
8060
|
+
price: order.price,
|
8061
|
+
itemIds: order.itemIds,
|
8062
|
+
amounts: order.amounts,
|
8063
|
+
additionalParameters: order.additionalParameters,
|
8064
|
+
};
|
8065
|
+
makers.push(maker);
|
7965
8066
|
}
|
7966
8067
|
const result = await this.verifyMakerOrders(makers, signatures, undefined, overrides);
|
7967
8068
|
return result.map((res, index) => {
|
@@ -8098,6 +8199,18 @@ class HypercertExchangeClient {
|
|
8098
8199
|
chainId,
|
8099
8200
|
});
|
8100
8201
|
}
|
8202
|
+
/**
|
8203
|
+
* Delete the order
|
8204
|
+
* @param orderId Order ID
|
8205
|
+
*/
|
8206
|
+
async deleteOrder(orderId) {
|
8207
|
+
const signer = this.getSigner();
|
8208
|
+
if (!signer) {
|
8209
|
+
throw new Error(`No signer address could be determined when deleting order ${orderId}`);
|
8210
|
+
}
|
8211
|
+
const signedMessage = await signer.signMessage(`Delete order ${orderId}`);
|
8212
|
+
return this.api.deleteOrder(orderId, signedMessage);
|
8213
|
+
}
|
8101
8214
|
}
|
8102
8215
|
|
8103
8216
|
const utils = {
|
package/dist/index.esm.js
CHANGED
@@ -5700,6 +5700,76 @@ const getFractionsById = async (fractionId, client) => {
|
|
5700
5700
|
}
|
5701
5701
|
return data?.fractions.data;
|
5702
5702
|
};
|
5703
|
+
const ordersQuery = e$1(`
|
5704
|
+
query OrdersQuery($chainId: BigInt, $signer: String) {
|
5705
|
+
orders(where: { chainId: { eq: $chainId }, signer: { eq: $signer } }) {
|
5706
|
+
count
|
5707
|
+
data {
|
5708
|
+
id
|
5709
|
+
hypercert {
|
5710
|
+
hypercert_id
|
5711
|
+
creator_address
|
5712
|
+
contracts_id
|
5713
|
+
creation_block_number
|
5714
|
+
creation_block_timestamp
|
5715
|
+
id
|
5716
|
+
last_update_block_number
|
5717
|
+
last_update_block_timestamp
|
5718
|
+
metadata {
|
5719
|
+
allow_list_uri
|
5720
|
+
contributors
|
5721
|
+
description
|
5722
|
+
external_url
|
5723
|
+
id
|
5724
|
+
impact_scope
|
5725
|
+
impact_timeframe_from
|
5726
|
+
impact_timeframe_to
|
5727
|
+
name
|
5728
|
+
properties
|
5729
|
+
rights
|
5730
|
+
uri
|
5731
|
+
work_scope
|
5732
|
+
work_timeframe_from
|
5733
|
+
work_timeframe_to
|
5734
|
+
}
|
5735
|
+
token_id
|
5736
|
+
units
|
5737
|
+
uri
|
5738
|
+
}
|
5739
|
+
additionalParameters
|
5740
|
+
amounts
|
5741
|
+
chainId
|
5742
|
+
collection
|
5743
|
+
collectionType
|
5744
|
+
createdAt
|
5745
|
+
currency
|
5746
|
+
endTime
|
5747
|
+
globalNonce
|
5748
|
+
itemIds
|
5749
|
+
orderNonce
|
5750
|
+
price
|
5751
|
+
quoteType
|
5752
|
+
signature
|
5753
|
+
signer
|
5754
|
+
startTime
|
5755
|
+
strategyId
|
5756
|
+
subsetNonce
|
5757
|
+
}
|
5758
|
+
}
|
5759
|
+
}
|
5760
|
+
`);
|
5761
|
+
const getOrders = async ({ chainId, signer }, client) => {
|
5762
|
+
const { data, error } = await client
|
5763
|
+
.query(ordersQuery, {
|
5764
|
+
chainId,
|
5765
|
+
signer,
|
5766
|
+
})
|
5767
|
+
.toPromise();
|
5768
|
+
if (error) {
|
5769
|
+
throw new Error(error.message);
|
5770
|
+
}
|
5771
|
+
return data?.orders.data;
|
5772
|
+
};
|
5703
5773
|
|
5704
5774
|
var teardownPlaceholder = () => {};
|
5705
5775
|
|
@@ -7500,7 +7570,7 @@ class ApiClient {
|
|
7500
7570
|
if (strategy) {
|
7501
7571
|
baseQuery.eq("strategyId", strategy);
|
7502
7572
|
}
|
7503
|
-
return
|
7573
|
+
return await getOrders({ signer, chainId: chainId ? BigInt(chainId) : undefined }, this._urqlClient);
|
7504
7574
|
};
|
7505
7575
|
/**
|
7506
7576
|
* Fetches orders from api by hypercert ID
|
@@ -7534,6 +7604,20 @@ class ApiClient {
|
|
7534
7604
|
.then((res) => this.handleResponse(res))
|
7535
7605
|
.then((res) => res.data);
|
7536
7606
|
};
|
7607
|
+
this.deleteOrder = async (orderId, signature) => {
|
7608
|
+
return fetch(`${this._baseUrl}/marketplace/orders`, {
|
7609
|
+
method: "DELETE",
|
7610
|
+
headers: {
|
7611
|
+
"Content-Type": "application/json",
|
7612
|
+
},
|
7613
|
+
body: JSON.stringify({
|
7614
|
+
orderId,
|
7615
|
+
signature,
|
7616
|
+
}),
|
7617
|
+
})
|
7618
|
+
.then((res) => this.handleResponse(res))
|
7619
|
+
.then((res) => res.success);
|
7620
|
+
};
|
7537
7621
|
const url = baseUrl || `${CONSTANTS.ENDPOINTS[indexerEnvironment]}/v1`;
|
7538
7622
|
if (!url) {
|
7539
7623
|
throw new Error("No API URL provided");
|
@@ -7954,12 +8038,29 @@ class HypercertExchangeClient {
|
|
7954
8038
|
const signatures = [];
|
7955
8039
|
const makers = [];
|
7956
8040
|
for (const order of orders) {
|
7957
|
-
const { signature, chainId
|
8041
|
+
const { signature, chainId } = order;
|
7958
8042
|
if (chainId !== this.chainId) {
|
7959
8043
|
throw new Error("Chain ID mismatch when checking order validity");
|
7960
8044
|
}
|
7961
8045
|
signatures.push(signature);
|
7962
|
-
|
8046
|
+
const maker = {
|
8047
|
+
quoteType: order.quoteType,
|
8048
|
+
globalNonce: order.globalNonce,
|
8049
|
+
subsetNonce: order.subsetNonce,
|
8050
|
+
strategyId: order.strategyId,
|
8051
|
+
collectionType: order.collectionType,
|
8052
|
+
orderNonce: order.orderNonce,
|
8053
|
+
collection: order.collection,
|
8054
|
+
currency: order.currency,
|
8055
|
+
signer: order.signer,
|
8056
|
+
startTime: order.startTime,
|
8057
|
+
endTime: order.endTime,
|
8058
|
+
price: order.price,
|
8059
|
+
itemIds: order.itemIds,
|
8060
|
+
amounts: order.amounts,
|
8061
|
+
additionalParameters: order.additionalParameters,
|
8062
|
+
};
|
8063
|
+
makers.push(maker);
|
7963
8064
|
}
|
7964
8065
|
const result = await this.verifyMakerOrders(makers, signatures, undefined, overrides);
|
7965
8066
|
return result.map((res, index) => {
|
@@ -8096,6 +8197,18 @@ class HypercertExchangeClient {
|
|
8096
8197
|
chainId,
|
8097
8198
|
});
|
8098
8199
|
}
|
8200
|
+
/**
|
8201
|
+
* Delete the order
|
8202
|
+
* @param orderId Order ID
|
8203
|
+
*/
|
8204
|
+
async deleteOrder(orderId) {
|
8205
|
+
const signer = this.getSigner();
|
8206
|
+
if (!signer) {
|
8207
|
+
throw new Error(`No signer address could be determined when deleting order ${orderId}`);
|
8208
|
+
}
|
8209
|
+
const signedMessage = await signer.signMessage(`Delete order ${orderId}`);
|
8210
|
+
return this.api.deleteOrder(orderId, signedMessage);
|
8211
|
+
}
|
8099
8212
|
}
|
8100
8213
|
|
8101
8214
|
const utils = {
|
package/dist/utils/api.d.ts
CHANGED
@@ -2,7 +2,7 @@ import { Maker, OrderValidatorCode, QuoteType, StrategyType } from "../types";
|
|
2
2
|
export declare class ApiClient {
|
3
3
|
private readonly baseUrl?;
|
4
4
|
private _baseUrl;
|
5
|
-
private _urqlClient;
|
5
|
+
private readonly _urqlClient;
|
6
6
|
private _supabaseHypercerts;
|
7
7
|
constructor(indexerEnvironment: "test" | "production", baseUrl?: string | undefined);
|
8
8
|
/**
|
@@ -42,29 +42,57 @@ export declare class ApiClient {
|
|
42
42
|
* @param chainId chain id for the order
|
43
43
|
* @param strategy strategy for the order
|
44
44
|
*/
|
45
|
-
fetchOrders: ({ signer, claimTokenIds, chainId, strategy }: Partial<FetchOrderArgs>) => Promise<
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
45
|
+
fetchOrders: ({ signer, claimTokenIds, chainId, strategy }: Partial<FetchOrderArgs>) => Promise<{
|
46
|
+
subsetNonce: number;
|
47
|
+
strategyId: number;
|
48
|
+
startTime: number;
|
49
|
+
signer: string;
|
50
|
+
signature: string;
|
51
|
+
quoteType: number;
|
52
|
+
price: string;
|
53
|
+
orderNonce: string;
|
54
|
+
itemIds: string[];
|
54
55
|
globalNonce: string;
|
56
|
+
endTime: number;
|
57
|
+
currency: string;
|
58
|
+
createdAt: string;
|
59
|
+
collectionType: number;
|
60
|
+
collection: string;
|
61
|
+
chainId: unknown;
|
62
|
+
amounts: number[];
|
63
|
+
additionalParameters: string;
|
64
|
+
hypercert: {
|
65
|
+
uri: string | null;
|
66
|
+
units: unknown;
|
67
|
+
token_id: unknown;
|
68
|
+
metadata: {
|
69
|
+
work_timeframe_to: unknown;
|
70
|
+
work_timeframe_from: unknown;
|
71
|
+
work_scope: string[] | null;
|
72
|
+
uri: string | null;
|
73
|
+
rights: string[] | null;
|
74
|
+
properties: unknown;
|
75
|
+
name: string | null;
|
76
|
+
impact_timeframe_to: unknown;
|
77
|
+
impact_timeframe_from: unknown;
|
78
|
+
impact_scope: string[] | null;
|
79
|
+
id: string;
|
80
|
+
external_url: string | null;
|
81
|
+
description: string | null;
|
82
|
+
contributors: string[] | null;
|
83
|
+
allow_list_uri: string | null;
|
84
|
+
} | null;
|
85
|
+
last_update_block_timestamp: unknown;
|
86
|
+
last_update_block_number: unknown;
|
87
|
+
id: string;
|
88
|
+
creation_block_timestamp: unknown;
|
89
|
+
creation_block_number: unknown;
|
90
|
+
contracts_id: string | null;
|
91
|
+
creator_address: string | null;
|
92
|
+
hypercert_id: string | null;
|
93
|
+
} | null;
|
55
94
|
id: string;
|
56
|
-
|
57
|
-
itemIds: string[];
|
58
|
-
orderNonce: string;
|
59
|
-
price: string;
|
60
|
-
quoteType: number;
|
61
|
-
signature: string;
|
62
|
-
signer: string;
|
63
|
-
startTime: number;
|
64
|
-
strategyId: number;
|
65
|
-
subsetNonce: number;
|
66
|
-
validator_codes: number[] | null;
|
67
|
-
}[]>>;
|
95
|
+
}[] | null | undefined>;
|
68
96
|
/**
|
69
97
|
* Fetches orders from api by hypercert ID
|
70
98
|
* @param hypercertId Hypercert ID
|
@@ -101,6 +129,7 @@ export declare class ApiClient {
|
|
101
129
|
invalidated: boolean;
|
102
130
|
validator_codes: OrderValidatorCode[];
|
103
131
|
}[]>;
|
132
|
+
deleteOrder: (orderId: string, signature: string) => Promise<boolean>;
|
104
133
|
}
|
105
134
|
interface FetchOrderArgs {
|
106
135
|
signer: `0x${string}`;
|
package/dist/utils/graphl.d.ts
CHANGED
@@ -6,3 +6,57 @@ export declare const getFractionsById: (fractionId: string, client: Client) => P
|
|
6
6
|
fraction_id: string | null;
|
7
7
|
creation_block_timestamp: unknown;
|
8
8
|
}[] | null | undefined>;
|
9
|
+
export declare const getOrders: ({ chainId, signer }: {
|
10
|
+
chainId?: BigInt | undefined;
|
11
|
+
signer?: `0x${string}` | undefined;
|
12
|
+
}, client: Client) => Promise<{
|
13
|
+
subsetNonce: number;
|
14
|
+
strategyId: number;
|
15
|
+
startTime: number;
|
16
|
+
signer: string;
|
17
|
+
signature: string;
|
18
|
+
quoteType: number;
|
19
|
+
price: string;
|
20
|
+
orderNonce: string;
|
21
|
+
itemIds: string[];
|
22
|
+
globalNonce: string;
|
23
|
+
endTime: number;
|
24
|
+
currency: string;
|
25
|
+
createdAt: string;
|
26
|
+
collectionType: number;
|
27
|
+
collection: string;
|
28
|
+
chainId: unknown;
|
29
|
+
amounts: number[];
|
30
|
+
additionalParameters: string;
|
31
|
+
hypercert: {
|
32
|
+
uri: string | null;
|
33
|
+
units: unknown;
|
34
|
+
token_id: unknown;
|
35
|
+
metadata: {
|
36
|
+
work_timeframe_to: unknown;
|
37
|
+
work_timeframe_from: unknown;
|
38
|
+
work_scope: string[] | null;
|
39
|
+
uri: string | null;
|
40
|
+
rights: string[] | null;
|
41
|
+
properties: unknown;
|
42
|
+
name: string | null;
|
43
|
+
impact_timeframe_to: unknown;
|
44
|
+
impact_timeframe_from: unknown;
|
45
|
+
impact_scope: string[] | null;
|
46
|
+
id: string;
|
47
|
+
external_url: string | null;
|
48
|
+
description: string | null;
|
49
|
+
contributors: string[] | null;
|
50
|
+
allow_list_uri: string | null;
|
51
|
+
} | null;
|
52
|
+
last_update_block_timestamp: unknown;
|
53
|
+
last_update_block_number: unknown;
|
54
|
+
id: string;
|
55
|
+
creation_block_timestamp: unknown;
|
56
|
+
creation_block_number: unknown;
|
57
|
+
contracts_id: string | null;
|
58
|
+
creator_address: string | null;
|
59
|
+
hypercert_id: string | null;
|
60
|
+
} | null;
|
61
|
+
id: string;
|
62
|
+
}[] | null | undefined>;
|