@hypercerts-org/marketplace-sdk 0.1.2 → 0.1.4
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 +11 -4
- package/dist/index.esm.js +11 -4
- package/dist/utils/api.d.ts +7 -7
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
@@ -4817,7 +4817,7 @@ class ApiClient {
|
|
4817
4817
|
* @param chainId Chain ID
|
4818
4818
|
*/
|
4819
4819
|
this.fetchOrderNonce = async ({ address, chainId }) => {
|
4820
|
-
return fetch(`${this.
|
4820
|
+
return fetch(`${this._baseUrl}/marketplace/order-nonce/`, {
|
4821
4821
|
method: "POST",
|
4822
4822
|
headers: {
|
4823
4823
|
"Content-Type": "application/json",
|
@@ -4827,7 +4827,7 @@ class ApiClient {
|
|
4827
4827
|
chainId,
|
4828
4828
|
}),
|
4829
4829
|
})
|
4830
|
-
.then((res) =>
|
4830
|
+
.then((res) => this.handleResponse(res))
|
4831
4831
|
.then((res) => res.data);
|
4832
4832
|
};
|
4833
4833
|
/**
|
@@ -4840,7 +4840,7 @@ class ApiClient {
|
|
4840
4840
|
*/
|
4841
4841
|
this.registerOrder = async ({ order, signer, signature, quoteType, chainId, }) => {
|
4842
4842
|
const { globalNonce, ...orderWithoutGlobalNonce } = order;
|
4843
|
-
return fetch(`${this.
|
4843
|
+
return fetch(`${this._baseUrl}/marketplace/order/`, {
|
4844
4844
|
method: "POST",
|
4845
4845
|
headers: {
|
4846
4846
|
"Content-Type": "application/json",
|
@@ -4854,7 +4854,7 @@ class ApiClient {
|
|
4854
4854
|
signature,
|
4855
4855
|
chainId,
|
4856
4856
|
}),
|
4857
|
-
}).then((res) =>
|
4857
|
+
}).then((res) => this.handleResponse(res));
|
4858
4858
|
};
|
4859
4859
|
/**
|
4860
4860
|
* Fetch existing open orders from the marketplace API
|
@@ -4892,6 +4892,13 @@ class ApiClient {
|
|
4892
4892
|
const tokenIds = fractions.claimTokens.map((fraction) => fraction.tokenID);
|
4893
4893
|
return supabaseHypercerts.from("marketplace-orders").select("*").containedBy("itemIds", tokenIds).throwOnError();
|
4894
4894
|
};
|
4895
|
+
this.handleResponse = async (res) => {
|
4896
|
+
if (!res.ok) {
|
4897
|
+
const error = await res.json();
|
4898
|
+
throw new Error(error.message);
|
4899
|
+
}
|
4900
|
+
return (await res.json());
|
4901
|
+
};
|
4895
4902
|
const url = baseUrl || HYPERCERTS_MARKETPLACE_API_URL;
|
4896
4903
|
if (!url) {
|
4897
4904
|
throw new Error("No API URL provided");
|
package/dist/index.esm.js
CHANGED
@@ -4815,7 +4815,7 @@ class ApiClient {
|
|
4815
4815
|
* @param chainId Chain ID
|
4816
4816
|
*/
|
4817
4817
|
this.fetchOrderNonce = async ({ address, chainId }) => {
|
4818
|
-
return fetch(`${this.
|
4818
|
+
return fetch(`${this._baseUrl}/marketplace/order-nonce/`, {
|
4819
4819
|
method: "POST",
|
4820
4820
|
headers: {
|
4821
4821
|
"Content-Type": "application/json",
|
@@ -4825,7 +4825,7 @@ class ApiClient {
|
|
4825
4825
|
chainId,
|
4826
4826
|
}),
|
4827
4827
|
})
|
4828
|
-
.then((res) =>
|
4828
|
+
.then((res) => this.handleResponse(res))
|
4829
4829
|
.then((res) => res.data);
|
4830
4830
|
};
|
4831
4831
|
/**
|
@@ -4838,7 +4838,7 @@ class ApiClient {
|
|
4838
4838
|
*/
|
4839
4839
|
this.registerOrder = async ({ order, signer, signature, quoteType, chainId, }) => {
|
4840
4840
|
const { globalNonce, ...orderWithoutGlobalNonce } = order;
|
4841
|
-
return fetch(`${this.
|
4841
|
+
return fetch(`${this._baseUrl}/marketplace/order/`, {
|
4842
4842
|
method: "POST",
|
4843
4843
|
headers: {
|
4844
4844
|
"Content-Type": "application/json",
|
@@ -4852,7 +4852,7 @@ class ApiClient {
|
|
4852
4852
|
signature,
|
4853
4853
|
chainId,
|
4854
4854
|
}),
|
4855
|
-
}).then((res) =>
|
4855
|
+
}).then((res) => this.handleResponse(res));
|
4856
4856
|
};
|
4857
4857
|
/**
|
4858
4858
|
* Fetch existing open orders from the marketplace API
|
@@ -4890,6 +4890,13 @@ class ApiClient {
|
|
4890
4890
|
const tokenIds = fractions.claimTokens.map((fraction) => fraction.tokenID);
|
4891
4891
|
return supabaseHypercerts.from("marketplace-orders").select("*").containedBy("itemIds", tokenIds).throwOnError();
|
4892
4892
|
};
|
4893
|
+
this.handleResponse = async (res) => {
|
4894
|
+
if (!res.ok) {
|
4895
|
+
const error = await res.json();
|
4896
|
+
throw new Error(error.message);
|
4897
|
+
}
|
4898
|
+
return (await res.json());
|
4899
|
+
};
|
4893
4900
|
const url = baseUrl || HYPERCERTS_MARKETPLACE_API_URL;
|
4894
4901
|
if (!url) {
|
4895
4902
|
throw new Error("No API URL provided");
|
package/dist/utils/api.d.ts
CHANGED
@@ -85,13 +85,7 @@ export declare const supabaseHypercerts: import("@supabase/supabase-js").Supabas
|
|
85
85
|
id?: number | undefined;
|
86
86
|
};
|
87
87
|
Relationships: [];
|
88
|
-
};
|
89
|
-
* Fetch existing open orders from the marketplace API
|
90
|
-
* @param signer address of the user that created the order
|
91
|
-
* @param claimTokenIds a list of claimTokenIds - will return any order that is for one or more of these claimTokenIds
|
92
|
-
* @param chainId chain id for the order
|
93
|
-
* @param strategy strategy for the order
|
94
|
-
*/
|
88
|
+
};
|
95
89
|
"allowlistCache-optimism": {
|
96
90
|
Row: {
|
97
91
|
address: string | null;
|
@@ -122,6 +116,11 @@ export declare const supabaseHypercerts: import("@supabase/supabase-js").Supabas
|
|
122
116
|
"allowlistCache-sepolia": {
|
123
117
|
Row: {
|
124
118
|
address: string | null;
|
119
|
+
/**
|
120
|
+
* Fetches orders from api by hypercert ID
|
121
|
+
* @param hypercertId Hypercert ID
|
122
|
+
* @param chainId Chain ID
|
123
|
+
*/
|
125
124
|
claimId: string | null;
|
126
125
|
created_at: string | null;
|
127
126
|
fractionCounter: number | null;
|
@@ -821,6 +820,7 @@ export declare class ApiClient {
|
|
821
820
|
strategyId: number;
|
822
821
|
subsetNonce: number;
|
823
822
|
}[]>>;
|
823
|
+
handleResponse: <T>(res: Response) => Promise<T>;
|
824
824
|
}
|
825
825
|
interface FetchOrderArgs {
|
826
826
|
signer: `0x${string}`;
|