@medialane/ui 0.107.1 → 0.109.0
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/components/listing-card.cjs +4 -2
- package/dist/components/listing-card.cjs.map +1 -1
- package/dist/components/listing-card.d.cts +8 -1
- package/dist/components/listing-card.d.ts +8 -1
- package/dist/components/listing-card.js +4 -2
- package/dist/components/listing-card.js.map +1 -1
- package/dist/components/remixes-tab.cjs +91 -0
- package/dist/components/remixes-tab.cjs.map +1 -0
- package/dist/components/remixes-tab.d.cts +11 -0
- package/dist/components/remixes-tab.d.ts +11 -0
- package/dist/components/remixes-tab.js +57 -0
- package/dist/components/remixes-tab.js.map +1 -0
- package/dist/data/notification.cjs +17 -0
- package/dist/data/notification.cjs.map +1 -0
- package/dist/data/notification.d.cts +34 -0
- package/dist/data/notification.d.ts +34 -0
- package/dist/data/notification.js +1 -0
- package/dist/data/notification.js.map +1 -0
- package/dist/index.cjs +31 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +26 -1
- package/dist/index.js.map +1 -1
- package/dist/utils/api-fetch.cjs +65 -0
- package/dist/utils/api-fetch.cjs.map +1 -0
- package/dist/utils/api-fetch.d.cts +38 -0
- package/dist/utils/api-fetch.d.ts +38 -0
- package/dist/utils/api-fetch.js +40 -0
- package/dist/utils/api-fetch.js.map +1 -0
- package/dist/utils/use-notifications.cjs +169 -0
- package/dist/utils/use-notifications.cjs.map +1 -0
- package/dist/utils/use-notifications.d.cts +12 -0
- package/dist/utils/use-notifications.d.ts +12 -0
- package/dist/utils/use-notifications.js +140 -0
- package/dist/utils/use-notifications.js.map +1 -0
- package/dist/utils/use-orders.cjs +153 -0
- package/dist/utils/use-orders.cjs.map +1 -0
- package/dist/utils/use-orders.d.cts +55 -0
- package/dist/utils/use-orders.d.ts +55 -0
- package/dist/utils/use-orders.js +113 -0
- package/dist/utils/use-orders.js.map +1 -0
- package/dist/utils/use-remix-offers.cjs +49 -0
- package/dist/utils/use-remix-offers.cjs.map +1 -0
- package/dist/utils/use-remix-offers.d.cts +19 -0
- package/dist/utils/use-remix-offers.d.ts +19 -0
- package/dist/utils/use-remix-offers.js +15 -0
- package/dist/utils/use-remix-offers.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
var use_orders_exports = {};
|
|
31
|
+
__export(use_orders_exports, {
|
|
32
|
+
useCollectionFloorListings: () => useCollectionFloorListings,
|
|
33
|
+
useCounterOffers: () => useCounterOffers,
|
|
34
|
+
useOrder: () => useOrder,
|
|
35
|
+
useOrders: () => useOrders,
|
|
36
|
+
useReceivedOffers: () => useReceivedOffers,
|
|
37
|
+
useTokenListings: () => useTokenListings,
|
|
38
|
+
useUserOrders: () => useUserOrders
|
|
39
|
+
});
|
|
40
|
+
module.exports = __toCommonJS(use_orders_exports);
|
|
41
|
+
var import_swr = __toESM(require("swr"), 1);
|
|
42
|
+
var import_sdk = require("@medialane/sdk");
|
|
43
|
+
var import_use_medialane_client = require("./use-medialane-client.js");
|
|
44
|
+
var import_query_keys = require("./query-keys.js");
|
|
45
|
+
var import_api_fetch = require("./api-fetch.js");
|
|
46
|
+
const ACTIVE_ORDER_REFRESH_INTERVAL = 6e4;
|
|
47
|
+
const ACTIVE_ORDER_DEDUPING_INTERVAL = 1e4;
|
|
48
|
+
function useOrders(getClient, query = {}) {
|
|
49
|
+
const client = (0, import_use_medialane_client.useMedialaneClient)(getClient);
|
|
50
|
+
const key = import_query_keys.queryKeys.orders(query);
|
|
51
|
+
const { data, error, isLoading, mutate } = (0, import_swr.default)(
|
|
52
|
+
key,
|
|
53
|
+
() => client.api.getOrders(query),
|
|
54
|
+
{ revalidateOnFocus: false, refreshInterval: 3e4, dedupingInterval: 5e3 }
|
|
55
|
+
);
|
|
56
|
+
return {
|
|
57
|
+
orders: data?.data ?? [],
|
|
58
|
+
meta: data?.meta,
|
|
59
|
+
isLoading,
|
|
60
|
+
error,
|
|
61
|
+
mutate
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function useOrder(getClient, orderHash) {
|
|
65
|
+
const client = (0, import_use_medialane_client.useMedialaneClient)(getClient);
|
|
66
|
+
const { data, error, isLoading } = (0, import_swr.default)(
|
|
67
|
+
orderHash ? import_query_keys.queryKeys.order(orderHash) : null,
|
|
68
|
+
() => client.api.getOrder(orderHash),
|
|
69
|
+
{ revalidateOnFocus: false }
|
|
70
|
+
);
|
|
71
|
+
return { order: data?.data ?? null, isLoading, error };
|
|
72
|
+
}
|
|
73
|
+
function useTokenListings(getClient, contract, tokenId) {
|
|
74
|
+
const client = (0, import_use_medialane_client.useMedialaneClient)(getClient);
|
|
75
|
+
const { data, error, isLoading, mutate } = (0, import_swr.default)(
|
|
76
|
+
contract && tokenId ? import_query_keys.queryKeys.listings(contract, tokenId) : null,
|
|
77
|
+
() => client.api.getActiveOrdersForToken(contract, tokenId),
|
|
78
|
+
{ revalidateOnFocus: false, refreshInterval: ACTIVE_ORDER_REFRESH_INTERVAL, dedupingInterval: ACTIVE_ORDER_DEDUPING_INTERVAL }
|
|
79
|
+
);
|
|
80
|
+
return { listings: data?.data ?? [], isLoading, error, mutate };
|
|
81
|
+
}
|
|
82
|
+
function useUserOrders(getClient, address) {
|
|
83
|
+
const client = (0, import_use_medialane_client.useMedialaneClient)(getClient);
|
|
84
|
+
const normalized = address ? (0, import_sdk.normalizeAddress)("STARKNET", address) : null;
|
|
85
|
+
const { data, error, isLoading, mutate } = (0, import_swr.default)(
|
|
86
|
+
normalized ? import_query_keys.queryKeys.userOrders(normalized) : null,
|
|
87
|
+
() => client.api.getOrdersByUser(normalized),
|
|
88
|
+
{ revalidateOnFocus: false, refreshInterval: ACTIVE_ORDER_REFRESH_INTERVAL, dedupingInterval: ACTIVE_ORDER_DEDUPING_INTERVAL }
|
|
89
|
+
);
|
|
90
|
+
return { orders: data?.data ?? [], isLoading, error, mutate };
|
|
91
|
+
}
|
|
92
|
+
function useCounterOffers(getClient, {
|
|
93
|
+
originalOrderHash,
|
|
94
|
+
sellerAddress
|
|
95
|
+
}) {
|
|
96
|
+
const client = (0, import_use_medialane_client.useMedialaneClient)(getClient);
|
|
97
|
+
const normalized = sellerAddress ? (0, import_sdk.normalizeAddress)("STARKNET", sellerAddress) : null;
|
|
98
|
+
const key = originalOrderHash ? import_query_keys.queryKeys.counterOffersByOrder(originalOrderHash) : normalized ? import_query_keys.queryKeys.counterOffersBySeller(normalized) : null;
|
|
99
|
+
const { data, error, isLoading, mutate } = (0, import_swr.default)(
|
|
100
|
+
key,
|
|
101
|
+
() => client.api.getCounterOffers({
|
|
102
|
+
...originalOrderHash ? { originalOrderHash } : {},
|
|
103
|
+
...normalized ? { sellerAddress: normalized } : {}
|
|
104
|
+
}),
|
|
105
|
+
{ revalidateOnFocus: false, refreshInterval: ACTIVE_ORDER_REFRESH_INTERVAL, dedupingInterval: ACTIVE_ORDER_DEDUPING_INTERVAL }
|
|
106
|
+
);
|
|
107
|
+
return {
|
|
108
|
+
counterOffers: data?.data ?? [],
|
|
109
|
+
total: data?.meta?.total ?? 0,
|
|
110
|
+
isLoading,
|
|
111
|
+
error,
|
|
112
|
+
mutate
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
function useReceivedOffers(apiConfig, address) {
|
|
116
|
+
const normalized = address ? (0, import_sdk.normalizeAddress)("STARKNET", address) : null;
|
|
117
|
+
const { data, error, isLoading, mutate } = (0, import_swr.default)(
|
|
118
|
+
normalized ? ["received-offers", normalized] : null,
|
|
119
|
+
() => (0, import_api_fetch.apiFetch)(apiConfig, `/v1/orders/received/${normalized}?limit=50`),
|
|
120
|
+
{ revalidateOnFocus: false, refreshInterval: ACTIVE_ORDER_REFRESH_INTERVAL, dedupingInterval: ACTIVE_ORDER_DEDUPING_INTERVAL }
|
|
121
|
+
);
|
|
122
|
+
return { orders: data?.data ?? [], isLoading, error, mutate };
|
|
123
|
+
}
|
|
124
|
+
function useCollectionFloorListings(getClient, contract, limit = 20) {
|
|
125
|
+
const client = (0, import_use_medialane_client.useMedialaneClient)(getClient);
|
|
126
|
+
const key = contract ? import_query_keys.queryKeys.floorListings(contract, limit) : null;
|
|
127
|
+
const { data, error, isLoading } = (0, import_swr.default)(
|
|
128
|
+
key,
|
|
129
|
+
() => client.api.getOrders({
|
|
130
|
+
collection: contract,
|
|
131
|
+
status: "ACTIVE",
|
|
132
|
+
sort: "price_asc",
|
|
133
|
+
limit
|
|
134
|
+
}),
|
|
135
|
+
{ revalidateOnFocus: false, refreshInterval: ACTIVE_ORDER_REFRESH_INTERVAL }
|
|
136
|
+
);
|
|
137
|
+
return {
|
|
138
|
+
listings: data?.data ?? [],
|
|
139
|
+
isLoading,
|
|
140
|
+
error
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
144
|
+
0 && (module.exports = {
|
|
145
|
+
useCollectionFloorListings,
|
|
146
|
+
useCounterOffers,
|
|
147
|
+
useOrder,
|
|
148
|
+
useOrders,
|
|
149
|
+
useReceivedOffers,
|
|
150
|
+
useTokenListings,
|
|
151
|
+
useUserOrders
|
|
152
|
+
});
|
|
153
|
+
//# sourceMappingURL=use-orders.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/use-orders.ts"],"sourcesContent":["\"use client\";\n\nimport useSWR from \"swr\";\nimport { normalizeAddress } from \"@medialane/sdk\";\nimport type { MedialaneClient } from \"@medialane/sdk/starknet\";\nimport type { ApiOrdersQuery, ApiOrder, ApiResponse } from \"@medialane/sdk\";\nimport { useMedialaneClient } from \"./use-medialane-client.js\";\nimport { queryKeys } from \"./query-keys.js\";\nimport { apiFetch, type ApiFetchConfig } from \"./api-fetch.js\";\n\nconst ACTIVE_ORDER_REFRESH_INTERVAL = 60_000;\nconst ACTIVE_ORDER_DEDUPING_INTERVAL = 10_000;\n\nexport function useOrders(getClient: () => MedialaneClient, query: ApiOrdersQuery = {}) {\n const client = useMedialaneClient(getClient);\n const key = queryKeys.orders(query);\n\n const { data, error, isLoading, mutate } = useSWR<ApiResponse<ApiOrder[]>>(\n key,\n () => client.api.getOrders(query),\n { revalidateOnFocus: false, refreshInterval: 30000, dedupingInterval: 5000 }\n );\n\n return {\n orders: data?.data ?? [],\n meta: data?.meta,\n isLoading,\n error,\n mutate,\n };\n}\n\nexport function useOrder(getClient: () => MedialaneClient, orderHash: string | null) {\n const client = useMedialaneClient(getClient);\n\n const { data, error, isLoading } = useSWR(\n orderHash ? queryKeys.order(orderHash) : null,\n () => client.api.getOrder(orderHash!),\n { revalidateOnFocus: false }\n );\n\n return { order: data?.data ?? null, isLoading, error };\n}\n\nexport function useTokenListings(getClient: () => MedialaneClient, contract: string | null, tokenId: string | null) {\n const client = useMedialaneClient(getClient);\n\n const { data, error, isLoading, mutate } = useSWR(\n contract && tokenId ? queryKeys.listings(contract, tokenId) : null,\n () => client.api.getActiveOrdersForToken(contract!, tokenId!),\n { revalidateOnFocus: false, refreshInterval: ACTIVE_ORDER_REFRESH_INTERVAL, dedupingInterval: ACTIVE_ORDER_DEDUPING_INTERVAL }\n );\n\n return { listings: data?.data ?? [], isLoading, error, mutate };\n}\n\nexport function useUserOrders(getClient: () => MedialaneClient, address: string | null) {\n const client = useMedialaneClient(getClient);\n const normalized = address ? normalizeAddress(\"STARKNET\", address) : null;\n\n const { data, error, isLoading, mutate } = useSWR(\n normalized ? queryKeys.userOrders(normalized) : null,\n () => client.api.getOrdersByUser(normalized!),\n { revalidateOnFocus: false, refreshInterval: ACTIVE_ORDER_REFRESH_INTERVAL, dedupingInterval: ACTIVE_ORDER_DEDUPING_INTERVAL }\n );\n\n return { orders: data?.data ?? [], isLoading, error, mutate };\n}\n\n/** Fetch counter-offers for a specific original bid (buyer view) or by seller address. */\nexport function useCounterOffers(\n getClient: () => MedialaneClient,\n {\n originalOrderHash,\n sellerAddress,\n }: {\n originalOrderHash?: string | null;\n sellerAddress?: string | null;\n }\n) {\n const client = useMedialaneClient(getClient);\n const normalized = sellerAddress ? normalizeAddress(\"STARKNET\", sellerAddress) : null;\n const key =\n originalOrderHash\n ? queryKeys.counterOffersByOrder(originalOrderHash)\n : normalized\n ? queryKeys.counterOffersBySeller(normalized)\n : null;\n\n const { data, error, isLoading, mutate } = useSWR<ApiResponse<ApiOrder[]>>(\n key,\n () => client.api.getCounterOffers({\n ...(originalOrderHash ? { originalOrderHash } : {}),\n ...(normalized ? { sellerAddress: normalized } : {}),\n }),\n { revalidateOnFocus: false, refreshInterval: ACTIVE_ORDER_REFRESH_INTERVAL, dedupingInterval: ACTIVE_ORDER_DEDUPING_INTERVAL }\n );\n\n return {\n counterOffers: data?.data ?? [],\n total: data?.meta?.total ?? 0,\n isLoading,\n error,\n mutate,\n };\n}\n\n/** Fetch active ERC20 offers received by the given address (offers on tokens they hold). */\nexport function useReceivedOffers(apiConfig: ApiFetchConfig, address: string | null) {\n const normalized = address ? normalizeAddress(\"STARKNET\", address) : null;\n\n const { data, error, isLoading, mutate } = useSWR<ApiResponse<ApiOrder[]>>(\n normalized ? [\"received-offers\", normalized] : null,\n () => apiFetch<ApiResponse<ApiOrder[]>>(apiConfig, `/v1/orders/received/${normalized}?limit=50`),\n { revalidateOnFocus: false, refreshInterval: ACTIVE_ORDER_REFRESH_INTERVAL, dedupingInterval: ACTIVE_ORDER_DEDUPING_INTERVAL }\n );\n\n return { orders: data?.data ?? [], isLoading, error, mutate };\n}\n\nexport function useCollectionFloorListings(getClient: () => MedialaneClient, contract: string | null, limit = 20) {\n const client = useMedialaneClient(getClient);\n const key = contract ? queryKeys.floorListings(contract, limit) : null;\n\n const { data, error, isLoading } = useSWR<ApiResponse<ApiOrder[]>>(\n key,\n () =>\n client.api.getOrders({\n collection: contract!,\n status: \"ACTIVE\",\n sort: \"price_asc\",\n limit,\n }),\n { revalidateOnFocus: false, refreshInterval: ACTIVE_ORDER_REFRESH_INTERVAL }\n );\n\n return {\n listings: data?.data ?? [],\n isLoading,\n error,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,iBAAmB;AACnB,iBAAiC;AAGjC,kCAAmC;AACnC,w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AAA,IAC/C,UAAM,2BAAkC,WAAW,uBAAuB,UAAU,WAAW;AAAA,IAC/F,EAAE,mBAAmB,OAAO,iBAAiB,+BAA+B,kBAAkB,+BAA+B;AAAA,EAC/H;AAEA,SAAO,EAAE,QAAQ,MAAM,QAAQ,CAAC,GAAG,WAAW,OAAO,OAAO;AAC9D;AAEO,SAAS,2BAA2B,WAAkC,UAAyB,QAAQ,IAAI;AAChH,QAAM,aAAS,gDAAmB,SAAS;AAC3C,QAAM,MAAM,WAAW,4BAAU,cAAc,UAAU,KAAK,IAAI;AAElE,QAAM,EAAE,MAAM,OAAO,UAAU,QAAI,WAAAA;AAAA,IACjC;AAAA,IACA,MACE,OAAO,IAAI,UAAU;AAAA,MACnB,YAAY;AAAA,MACZ,QAAQ;AAAA,MACR,MAAM;AAAA,MACN;AAAA,IACF,CAAC;AAAA,IACH,EAAE,mBAAmB,OAAO,iBAAiB,8BAA8B;AAAA,EAC7E;AAEA,SAAO;AAAA,IACL,UAAU,MAAM,QAAQ,CAAC;AAAA,IACzB;AAAA,IACA;AAAA,EACF;AACF;","names":["useSWR"]}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import * as swr from 'swr';
|
|
2
|
+
import * as _medialane_sdk from '@medialane/sdk';
|
|
3
|
+
import { ApiOrder, ApiResponse, ApiOrdersQuery } from '@medialane/sdk';
|
|
4
|
+
import { MedialaneClient } from '@medialane/sdk/starknet';
|
|
5
|
+
import { ApiFetchConfig } from './api-fetch.cjs';
|
|
6
|
+
|
|
7
|
+
declare function useOrders(getClient: () => MedialaneClient, query?: ApiOrdersQuery): {
|
|
8
|
+
orders: ApiOrder[];
|
|
9
|
+
meta: _medialane_sdk.ApiMeta | undefined;
|
|
10
|
+
isLoading: boolean;
|
|
11
|
+
error: any;
|
|
12
|
+
mutate: swr.KeyedMutator<ApiResponse<ApiOrder[]>>;
|
|
13
|
+
};
|
|
14
|
+
declare function useOrder(getClient: () => MedialaneClient, orderHash: string | null): {
|
|
15
|
+
order: ApiOrder | null;
|
|
16
|
+
isLoading: boolean;
|
|
17
|
+
error: any;
|
|
18
|
+
};
|
|
19
|
+
declare function useTokenListings(getClient: () => MedialaneClient, contract: string | null, tokenId: string | null): {
|
|
20
|
+
listings: ApiOrder[];
|
|
21
|
+
isLoading: boolean;
|
|
22
|
+
error: any;
|
|
23
|
+
mutate: swr.KeyedMutator<ApiResponse<ApiOrder[]>>;
|
|
24
|
+
};
|
|
25
|
+
declare function useUserOrders(getClient: () => MedialaneClient, address: string | null): {
|
|
26
|
+
orders: ApiOrder[];
|
|
27
|
+
isLoading: boolean;
|
|
28
|
+
error: any;
|
|
29
|
+
mutate: swr.KeyedMutator<ApiResponse<ApiOrder[]>>;
|
|
30
|
+
};
|
|
31
|
+
/** Fetch counter-offers for a specific original bid (buyer view) or by seller address. */
|
|
32
|
+
declare function useCounterOffers(getClient: () => MedialaneClient, { originalOrderHash, sellerAddress, }: {
|
|
33
|
+
originalOrderHash?: string | null;
|
|
34
|
+
sellerAddress?: string | null;
|
|
35
|
+
}): {
|
|
36
|
+
counterOffers: ApiOrder[];
|
|
37
|
+
total: number;
|
|
38
|
+
isLoading: boolean;
|
|
39
|
+
error: any;
|
|
40
|
+
mutate: swr.KeyedMutator<ApiResponse<ApiOrder[]>>;
|
|
41
|
+
};
|
|
42
|
+
/** Fetch active ERC20 offers received by the given address (offers on tokens they hold). */
|
|
43
|
+
declare function useReceivedOffers(apiConfig: ApiFetchConfig, address: string | null): {
|
|
44
|
+
orders: ApiOrder[];
|
|
45
|
+
isLoading: boolean;
|
|
46
|
+
error: any;
|
|
47
|
+
mutate: swr.KeyedMutator<ApiResponse<ApiOrder[]>>;
|
|
48
|
+
};
|
|
49
|
+
declare function useCollectionFloorListings(getClient: () => MedialaneClient, contract: string | null, limit?: number): {
|
|
50
|
+
listings: ApiOrder[];
|
|
51
|
+
isLoading: boolean;
|
|
52
|
+
error: any;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export { useCollectionFloorListings, useCounterOffers, useOrder, useOrders, useReceivedOffers, useTokenListings, useUserOrders };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import * as swr from 'swr';
|
|
2
|
+
import * as _medialane_sdk from '@medialane/sdk';
|
|
3
|
+
import { ApiOrder, ApiResponse, ApiOrdersQuery } from '@medialane/sdk';
|
|
4
|
+
import { MedialaneClient } from '@medialane/sdk/starknet';
|
|
5
|
+
import { ApiFetchConfig } from './api-fetch.js';
|
|
6
|
+
|
|
7
|
+
declare function useOrders(getClient: () => MedialaneClient, query?: ApiOrdersQuery): {
|
|
8
|
+
orders: ApiOrder[];
|
|
9
|
+
meta: _medialane_sdk.ApiMeta | undefined;
|
|
10
|
+
isLoading: boolean;
|
|
11
|
+
error: any;
|
|
12
|
+
mutate: swr.KeyedMutator<ApiResponse<ApiOrder[]>>;
|
|
13
|
+
};
|
|
14
|
+
declare function useOrder(getClient: () => MedialaneClient, orderHash: string | null): {
|
|
15
|
+
order: ApiOrder | null;
|
|
16
|
+
isLoading: boolean;
|
|
17
|
+
error: any;
|
|
18
|
+
};
|
|
19
|
+
declare function useTokenListings(getClient: () => MedialaneClient, contract: string | null, tokenId: string | null): {
|
|
20
|
+
listings: ApiOrder[];
|
|
21
|
+
isLoading: boolean;
|
|
22
|
+
error: any;
|
|
23
|
+
mutate: swr.KeyedMutator<ApiResponse<ApiOrder[]>>;
|
|
24
|
+
};
|
|
25
|
+
declare function useUserOrders(getClient: () => MedialaneClient, address: string | null): {
|
|
26
|
+
orders: ApiOrder[];
|
|
27
|
+
isLoading: boolean;
|
|
28
|
+
error: any;
|
|
29
|
+
mutate: swr.KeyedMutator<ApiResponse<ApiOrder[]>>;
|
|
30
|
+
};
|
|
31
|
+
/** Fetch counter-offers for a specific original bid (buyer view) or by seller address. */
|
|
32
|
+
declare function useCounterOffers(getClient: () => MedialaneClient, { originalOrderHash, sellerAddress, }: {
|
|
33
|
+
originalOrderHash?: string | null;
|
|
34
|
+
sellerAddress?: string | null;
|
|
35
|
+
}): {
|
|
36
|
+
counterOffers: ApiOrder[];
|
|
37
|
+
total: number;
|
|
38
|
+
isLoading: boolean;
|
|
39
|
+
error: any;
|
|
40
|
+
mutate: swr.KeyedMutator<ApiResponse<ApiOrder[]>>;
|
|
41
|
+
};
|
|
42
|
+
/** Fetch active ERC20 offers received by the given address (offers on tokens they hold). */
|
|
43
|
+
declare function useReceivedOffers(apiConfig: ApiFetchConfig, address: string | null): {
|
|
44
|
+
orders: ApiOrder[];
|
|
45
|
+
isLoading: boolean;
|
|
46
|
+
error: any;
|
|
47
|
+
mutate: swr.KeyedMutator<ApiResponse<ApiOrder[]>>;
|
|
48
|
+
};
|
|
49
|
+
declare function useCollectionFloorListings(getClient: () => MedialaneClient, contract: string | null, limit?: number): {
|
|
50
|
+
listings: ApiOrder[];
|
|
51
|
+
isLoading: boolean;
|
|
52
|
+
error: any;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export { useCollectionFloorListings, useCounterOffers, useOrder, useOrders, useReceivedOffers, useTokenListings, useUserOrders };
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import useSWR from "swr";
|
|
3
|
+
import { normalizeAddress } from "@medialane/sdk";
|
|
4
|
+
import { useMedialaneClient } from "./use-medialane-client.js";
|
|
5
|
+
import { queryKeys } from "./query-keys.js";
|
|
6
|
+
import { apiFetch } from "./api-fetch.js";
|
|
7
|
+
const ACTIVE_ORDER_REFRESH_INTERVAL = 6e4;
|
|
8
|
+
const ACTIVE_ORDER_DEDUPING_INTERVAL = 1e4;
|
|
9
|
+
function useOrders(getClient, query = {}) {
|
|
10
|
+
const client = useMedialaneClient(getClient);
|
|
11
|
+
const key = queryKeys.orders(query);
|
|
12
|
+
const { data, error, isLoading, mutate } = useSWR(
|
|
13
|
+
key,
|
|
14
|
+
() => client.api.getOrders(query),
|
|
15
|
+
{ revalidateOnFocus: false, refreshInterval: 3e4, dedupingInterval: 5e3 }
|
|
16
|
+
);
|
|
17
|
+
return {
|
|
18
|
+
orders: data?.data ?? [],
|
|
19
|
+
meta: data?.meta,
|
|
20
|
+
isLoading,
|
|
21
|
+
error,
|
|
22
|
+
mutate
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function useOrder(getClient, orderHash) {
|
|
26
|
+
const client = useMedialaneClient(getClient);
|
|
27
|
+
const { data, error, isLoading } = useSWR(
|
|
28
|
+
orderHash ? queryKeys.order(orderHash) : null,
|
|
29
|
+
() => client.api.getOrder(orderHash),
|
|
30
|
+
{ revalidateOnFocus: false }
|
|
31
|
+
);
|
|
32
|
+
return { order: data?.data ?? null, isLoading, error };
|
|
33
|
+
}
|
|
34
|
+
function useTokenListings(getClient, contract, tokenId) {
|
|
35
|
+
const client = useMedialaneClient(getClient);
|
|
36
|
+
const { data, error, isLoading, mutate } = useSWR(
|
|
37
|
+
contract && tokenId ? queryKeys.listings(contract, tokenId) : null,
|
|
38
|
+
() => client.api.getActiveOrdersForToken(contract, tokenId),
|
|
39
|
+
{ revalidateOnFocus: false, refreshInterval: ACTIVE_ORDER_REFRESH_INTERVAL, dedupingInterval: ACTIVE_ORDER_DEDUPING_INTERVAL }
|
|
40
|
+
);
|
|
41
|
+
return { listings: data?.data ?? [], isLoading, error, mutate };
|
|
42
|
+
}
|
|
43
|
+
function useUserOrders(getClient, address) {
|
|
44
|
+
const client = useMedialaneClient(getClient);
|
|
45
|
+
const normalized = address ? normalizeAddress("STARKNET", address) : null;
|
|
46
|
+
const { data, error, isLoading, mutate } = useSWR(
|
|
47
|
+
normalized ? queryKeys.userOrders(normalized) : null,
|
|
48
|
+
() => client.api.getOrdersByUser(normalized),
|
|
49
|
+
{ revalidateOnFocus: false, refreshInterval: ACTIVE_ORDER_REFRESH_INTERVAL, dedupingInterval: ACTIVE_ORDER_DEDUPING_INTERVAL }
|
|
50
|
+
);
|
|
51
|
+
return { orders: data?.data ?? [], isLoading, error, mutate };
|
|
52
|
+
}
|
|
53
|
+
function useCounterOffers(getClient, {
|
|
54
|
+
originalOrderHash,
|
|
55
|
+
sellerAddress
|
|
56
|
+
}) {
|
|
57
|
+
const client = useMedialaneClient(getClient);
|
|
58
|
+
const normalized = sellerAddress ? normalizeAddress("STARKNET", sellerAddress) : null;
|
|
59
|
+
const key = originalOrderHash ? queryKeys.counterOffersByOrder(originalOrderHash) : normalized ? queryKeys.counterOffersBySeller(normalized) : null;
|
|
60
|
+
const { data, error, isLoading, mutate } = useSWR(
|
|
61
|
+
key,
|
|
62
|
+
() => client.api.getCounterOffers({
|
|
63
|
+
...originalOrderHash ? { originalOrderHash } : {},
|
|
64
|
+
...normalized ? { sellerAddress: normalized } : {}
|
|
65
|
+
}),
|
|
66
|
+
{ revalidateOnFocus: false, refreshInterval: ACTIVE_ORDER_REFRESH_INTERVAL, dedupingInterval: ACTIVE_ORDER_DEDUPING_INTERVAL }
|
|
67
|
+
);
|
|
68
|
+
return {
|
|
69
|
+
counterOffers: data?.data ?? [],
|
|
70
|
+
total: data?.meta?.total ?? 0,
|
|
71
|
+
isLoading,
|
|
72
|
+
error,
|
|
73
|
+
mutate
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function useReceivedOffers(apiConfig, address) {
|
|
77
|
+
const normalized = address ? normalizeAddress("STARKNET", address) : null;
|
|
78
|
+
const { data, error, isLoading, mutate } = useSWR(
|
|
79
|
+
normalized ? ["received-offers", normalized] : null,
|
|
80
|
+
() => apiFetch(apiConfig, `/v1/orders/received/${normalized}?limit=50`),
|
|
81
|
+
{ revalidateOnFocus: false, refreshInterval: ACTIVE_ORDER_REFRESH_INTERVAL, dedupingInterval: ACTIVE_ORDER_DEDUPING_INTERVAL }
|
|
82
|
+
);
|
|
83
|
+
return { orders: data?.data ?? [], isLoading, error, mutate };
|
|
84
|
+
}
|
|
85
|
+
function useCollectionFloorListings(getClient, contract, limit = 20) {
|
|
86
|
+
const client = useMedialaneClient(getClient);
|
|
87
|
+
const key = contract ? queryKeys.floorListings(contract, limit) : null;
|
|
88
|
+
const { data, error, isLoading } = useSWR(
|
|
89
|
+
key,
|
|
90
|
+
() => client.api.getOrders({
|
|
91
|
+
collection: contract,
|
|
92
|
+
status: "ACTIVE",
|
|
93
|
+
sort: "price_asc",
|
|
94
|
+
limit
|
|
95
|
+
}),
|
|
96
|
+
{ revalidateOnFocus: false, refreshInterval: ACTIVE_ORDER_REFRESH_INTERVAL }
|
|
97
|
+
);
|
|
98
|
+
return {
|
|
99
|
+
listings: data?.data ?? [],
|
|
100
|
+
isLoading,
|
|
101
|
+
error
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
export {
|
|
105
|
+
useCollectionFloorListings,
|
|
106
|
+
useCounterOffers,
|
|
107
|
+
useOrder,
|
|
108
|
+
useOrders,
|
|
109
|
+
useReceivedOffers,
|
|
110
|
+
useTokenListings,
|
|
111
|
+
useUserOrders
|
|
112
|
+
};
|
|
113
|
+
//# sourceMappingURL=use-orders.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/use-orders.ts"],"sourcesContent":["\"use client\";\n\nimport useSWR from \"swr\";\nimport { normalizeAddress } from \"@medialane/sdk\";\nimport type { MedialaneClient } from \"@medialane/sdk/starknet\";\nimport type { ApiOrdersQuery, ApiOrder, ApiResponse } from \"@medialane/sdk\";\nimport { useMedialaneClient } from \"./use-medialane-client.js\";\nimport { queryKeys } from \"./query-keys.js\";\nimport { apiFetch, type ApiFetchConfig } from \"./api-fetch.js\";\n\nconst ACTIVE_ORDER_REFRESH_INTERVAL = 60_000;\nconst ACTIVE_ORDER_DEDUPING_INTERVAL = 10_000;\n\nexport function useOrders(getClient: () => MedialaneClient, query: ApiOrdersQuery = {}) {\n const client = useMedialaneClient(getClient);\n const key = queryKeys.orders(query);\n\n const { data, error, isLoading, mutate } = useSWR<ApiResponse<ApiOrder[]>>(\n key,\n () => client.api.getOrders(query),\n { revalidateOnFocus: false, refreshInterval: 30000, dedupingInterval: 5000 }\n );\n\n return {\n orders: data?.data ?? [],\n meta: data?.meta,\n isLoading,\n error,\n mutate,\n };\n}\n\nexport function useOrder(getClient: () => MedialaneClient, orderHash: string | null) {\n const client = useMedialaneClient(getClient);\n\n const { data, error, isLoading } = useSWR(\n orderHash ? queryKeys.order(orderHash) : null,\n () => client.api.getOrder(orderHash!),\n { revalidateOnFocus: false }\n );\n\n return { order: data?.data ?? null, isLoading, error };\n}\n\nexport function useTokenListings(getClient: () => MedialaneClient, contract: string | null, tokenId: string | null) {\n const client = useMedialaneClient(getClient);\n\n const { data, error, isLoading, mutate } = useSWR(\n contract && tokenId ? queryKeys.listings(contract, tokenId) : null,\n () => client.api.getActiveOrdersForToken(contract!, tokenId!),\n { revalidateOnFocus: false, refreshInterval: ACTIVE_ORDER_REFRESH_INTERVAL, dedupingInterval: ACTIVE_ORDER_DEDUPING_INTERVAL }\n );\n\n return { listings: data?.data ?? [], isLoading, error, mutate };\n}\n\nexport function useUserOrders(getClient: () => MedialaneClient, address: string | null) {\n const client = useMedialaneClient(getClient);\n const normalized = address ? normalizeAddress(\"STARKNET\", address) : null;\n\n const { data, error, isLoading, mutate } = useSWR(\n normalized ? queryKeys.userOrders(normalized) : null,\n () => client.api.getOrdersByUser(normalized!),\n { revalidateOnFocus: false, refreshInterval: ACTIVE_ORDER_REFRESH_INTERVAL, dedupingInterval: ACTIVE_ORDER_DEDUPING_INTERVAL }\n );\n\n return { orders: data?.data ?? [], isLoading, error, mutate };\n}\n\n/** Fetch counter-offers for a specific original bid (buyer view) or by seller address. */\nexport function useCounterOffers(\n getClient: () => MedialaneClient,\n {\n originalOrderHash,\n sellerAddress,\n }: {\n originalOrderHash?: string | null;\n sellerAddress?: string | null;\n }\n) {\n const client = useMedialaneClient(getClient);\n const normalized = sellerAddress ? normalizeAddress(\"STARKNET\", sellerAddress) : null;\n const key =\n originalOrderHash\n ? queryKeys.counterOffersByOrder(originalOrderHash)\n : normalized\n ? queryKeys.counterOffersBySeller(normalized)\n : null;\n\n const { data, error, isLoading, mutate } = useSWR<ApiResponse<ApiOrder[]>>(\n key,\n () => client.api.getCounterOffers({\n ...(originalOrderHash ? { originalOrderHash } : {}),\n ...(normalized ? { sellerAddress: normalized } : {}),\n }),\n { revalidateOnFocus: false, refreshInterval: ACTIVE_ORDER_REFRESH_INTERVAL, dedupingInterval: ACTIVE_ORDER_DEDUPING_INTERVAL }\n );\n\n return {\n counterOffers: data?.data ?? [],\n total: data?.meta?.total ?? 0,\n isLoading,\n error,\n mutate,\n };\n}\n\n/** Fetch active ERC20 offers received by the given address (offers on tokens they hold). */\nexport function useReceivedOffers(apiConfig: ApiFetchConfig, address: string | null) {\n const normalized = address ? normalizeAddress(\"STARKNET\", address) : null;\n\n const { data, error, isLoading, mutate } = useSWR<ApiResponse<ApiOrder[]>>(\n normalized ? [\"received-offers\", normalized] : null,\n () => apiFetch<ApiResponse<ApiOrder[]>>(apiConfig, `/v1/orders/received/${normalized}?limit=50`),\n { revalidateOnFocus: false, refreshInterval: ACTIVE_ORDER_REFRESH_INTERVAL, dedupingInterval: ACTIVE_ORDER_DEDUPING_INTERVAL }\n );\n\n return { orders: data?.data ?? [], isLoading, error, mutate };\n}\n\nexport function useCollectionFloorListings(getClient: () => MedialaneClient, contract: string | null, limit = 20) {\n const client = useMedialaneClient(getClient);\n const key = contract ? queryKeys.floorListings(contract, limit) : null;\n\n const { data, error, isLoading } = useSWR<ApiResponse<ApiOrder[]>>(\n key,\n () =>\n client.api.getOrders({\n collection: contract!,\n status: \"ACTIVE\",\n sort: \"price_asc\",\n limit,\n }),\n { revalidateOnFocus: false, refreshInterval: ACTIVE_ORDER_REFRESH_INTERVAL }\n );\n\n return {\n listings: data?.data ?? [],\n isLoading,\n error,\n };\n}\n"],"mappings":";AAEA,OAAO,YAAY;AACnB,SAAS,wBAAwB;AAGjC,SAAS,0BAA0B;AACnC,SAAS,iBAAiB;AAC1B,SAAS,gBAAqC;AAE9C,MAAM,gCAAgC;AACtC,MAAM,iCAAiC;AAEhC,SAAS,UAAU,WAAkC,QAA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AAE,QAAQ,MAAM,QAAQ,CAAC,GAAG,WAAW,OAAO,OAAO;AAC9D;AAEO,SAAS,2BAA2B,WAAkC,UAAyB,QAAQ,IAAI;AAChH,QAAM,SAAS,mBAAmB,SAAS;AAC3C,QAAM,MAAM,WAAW,UAAU,cAAc,UAAU,KAAK,IAAI;AAElE,QAAM,EAAE,MAAM,OAAO,UAAU,IAAI;AAAA,IACjC;AAAA,IACA,MACE,OAAO,IAAI,UAAU;AAAA,MACnB,YAAY;AAAA,MACZ,QAAQ;AAAA,MACR,MAAM;AAAA,MACN;AAAA,IACF,CAAC;AAAA,IACH,EAAE,mBAAmB,OAAO,iBAAiB,8BAA8B;AAAA,EAC7E;AAEA,SAAO;AAAA,IACL,UAAU,MAAM,QAAQ,CAAC;AAAA,IACzB;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
var use_remix_offers_exports = {};
|
|
31
|
+
__export(use_remix_offers_exports, {
|
|
32
|
+
useTokenRemixes: () => useTokenRemixes
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(use_remix_offers_exports);
|
|
35
|
+
var import_swr = __toESM(require("swr"), 1);
|
|
36
|
+
var import_api_fetch = require("./api-fetch.js");
|
|
37
|
+
function useTokenRemixes(apiConfig, contract, tokenId) {
|
|
38
|
+
const { data, error, isLoading, mutate } = (0, import_swr.default)(
|
|
39
|
+
contract && tokenId ? `token-remixes-${contract}-${tokenId}` : null,
|
|
40
|
+
() => (0, import_api_fetch.apiFetch)(apiConfig, `/v1/tokens/${contract}/${tokenId}/remixes`),
|
|
41
|
+
{ refreshInterval: 6e4, revalidateOnFocus: false }
|
|
42
|
+
);
|
|
43
|
+
return { remixes: data?.data ?? [], total: data?.meta.total ?? 0, isLoading, error, mutate };
|
|
44
|
+
}
|
|
45
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
46
|
+
0 && (module.exports = {
|
|
47
|
+
useTokenRemixes
|
|
48
|
+
});
|
|
49
|
+
//# sourceMappingURL=use-remix-offers.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/use-remix-offers.ts"],"sourcesContent":["\"use client\";\n\nimport useSWR from \"swr\";\nimport { apiFetch, type ApiFetchConfig } from \"./api-fetch.js\";\nimport type { ApiPublicRemix } from \"@medialane/sdk\";\n\n/** Public remixes of a token — no wallet/auth dependency. */\nexport function useTokenRemixes(apiConfig: ApiFetchConfig, contract: string | null, tokenId: string | null) {\n const { data, error, isLoading, mutate } = useSWR<{ data: ApiPublicRemix[]; meta: { total: number } }>(\n contract && tokenId ? `token-remixes-${contract}-${tokenId}` : null,\n () => apiFetch(apiConfig, `/v1/tokens/${contract}/${tokenId}/remixes`),\n { refreshInterval: 60000, revalidateOnFocus: false }\n );\n\n return { remixes: data?.data ?? [], total: data?.meta.total ?? 0, isLoading, error, mutate };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,iBAAmB;AACnB,uBAA8C;AAIvC,SAAS,gBAAgB,WAA2B,UAAyB,SAAwB;AAC1G,QAAM,EAAE,MAAM,OAAO,WAAW,OAAO,QAAI,WAAAA;AAAA,IACzC,YAAY,UAAU,iBAAiB,QAAQ,IAAI,OAAO,KAAK;AAAA,IAC/D,UAAM,2BAAS,WAAW,cAAc,QAAQ,IAAI,OAAO,UAAU;AAAA,IACrE,EAAE,iBAAiB,KAAO,mBAAmB,MAAM;AAAA,EACrD;AAEA,SAAO,EAAE,SAAS,MAAM,QAAQ,CAAC,GAAG,OAAO,MAAM,KAAK,SAAS,GAAG,WAAW,OAAO,OAAO;AAC7F;","names":["useSWR"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as swr from 'swr';
|
|
2
|
+
import { ApiFetchConfig } from './api-fetch.cjs';
|
|
3
|
+
import { ApiPublicRemix } from '@medialane/sdk';
|
|
4
|
+
|
|
5
|
+
/** Public remixes of a token — no wallet/auth dependency. */
|
|
6
|
+
declare function useTokenRemixes(apiConfig: ApiFetchConfig, contract: string | null, tokenId: string | null): {
|
|
7
|
+
remixes: ApiPublicRemix[];
|
|
8
|
+
total: number;
|
|
9
|
+
isLoading: boolean;
|
|
10
|
+
error: any;
|
|
11
|
+
mutate: swr.KeyedMutator<{
|
|
12
|
+
data: ApiPublicRemix[];
|
|
13
|
+
meta: {
|
|
14
|
+
total: number;
|
|
15
|
+
};
|
|
16
|
+
}>;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export { useTokenRemixes };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as swr from 'swr';
|
|
2
|
+
import { ApiFetchConfig } from './api-fetch.js';
|
|
3
|
+
import { ApiPublicRemix } from '@medialane/sdk';
|
|
4
|
+
|
|
5
|
+
/** Public remixes of a token — no wallet/auth dependency. */
|
|
6
|
+
declare function useTokenRemixes(apiConfig: ApiFetchConfig, contract: string | null, tokenId: string | null): {
|
|
7
|
+
remixes: ApiPublicRemix[];
|
|
8
|
+
total: number;
|
|
9
|
+
isLoading: boolean;
|
|
10
|
+
error: any;
|
|
11
|
+
mutate: swr.KeyedMutator<{
|
|
12
|
+
data: ApiPublicRemix[];
|
|
13
|
+
meta: {
|
|
14
|
+
total: number;
|
|
15
|
+
};
|
|
16
|
+
}>;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export { useTokenRemixes };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import useSWR from "swr";
|
|
3
|
+
import { apiFetch } from "./api-fetch.js";
|
|
4
|
+
function useTokenRemixes(apiConfig, contract, tokenId) {
|
|
5
|
+
const { data, error, isLoading, mutate } = useSWR(
|
|
6
|
+
contract && tokenId ? `token-remixes-${contract}-${tokenId}` : null,
|
|
7
|
+
() => apiFetch(apiConfig, `/v1/tokens/${contract}/${tokenId}/remixes`),
|
|
8
|
+
{ refreshInterval: 6e4, revalidateOnFocus: false }
|
|
9
|
+
);
|
|
10
|
+
return { remixes: data?.data ?? [], total: data?.meta.total ?? 0, isLoading, error, mutate };
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
useTokenRemixes
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=use-remix-offers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/use-remix-offers.ts"],"sourcesContent":["\"use client\";\n\nimport useSWR from \"swr\";\nimport { apiFetch, type ApiFetchConfig } from \"./api-fetch.js\";\nimport type { ApiPublicRemix } from \"@medialane/sdk\";\n\n/** Public remixes of a token — no wallet/auth dependency. */\nexport function useTokenRemixes(apiConfig: ApiFetchConfig, contract: string | null, tokenId: string | null) {\n const { data, error, isLoading, mutate } = useSWR<{ data: ApiPublicRemix[]; meta: { total: number } }>(\n contract && tokenId ? `token-remixes-${contract}-${tokenId}` : null,\n () => apiFetch(apiConfig, `/v1/tokens/${contract}/${tokenId}/remixes`),\n { refreshInterval: 60000, revalidateOnFocus: false }\n );\n\n return { remixes: data?.data ?? [], total: data?.meta.total ?? 0, isLoading, error, mutate };\n}\n"],"mappings":";AAEA,OAAO,YAAY;AACnB,SAAS,gBAAqC;AAIvC,SAAS,gBAAgB,WAA2B,UAAyB,SAAwB;AAC1G,QAAM,EAAE,MAAM,OAAO,WAAW,OAAO,IAAI;AAAA,IACzC,YAAY,UAAU,iBAAiB,QAAQ,IAAI,OAAO,KAAK;AAAA,IAC/D,MAAM,SAAS,WAAW,cAAc,QAAQ,IAAI,OAAO,UAAU;AAAA,IACrE,EAAE,iBAAiB,KAAO,mBAAmB,MAAM;AAAA,EACrD;AAEA,SAAO,EAAE,SAAS,MAAM,QAAQ,CAAC,GAAG,OAAO,MAAM,KAAK,SAAS,GAAG,WAAW,OAAO,OAAO;AAC7F;","names":[]}
|