@medialane/ui 0.401.0 → 0.403.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/account/input-otp.d.cts +2 -2
- package/dist/components/account/input-otp.d.ts +2 -2
- package/dist/components/button.d.cts +1 -1
- package/dist/components/button.d.ts +1 -1
- package/dist/components/fast-mint/fast-mint.d.cts +2 -2
- package/dist/components/fast-mint/fast-mint.d.ts +2 -2
- package/dist/components/launchpad/edition-mint-schema.d.cts +4 -4
- package/dist/components/launchpad/edition-mint-schema.d.ts +4 -4
- package/dist/utils/media-wallet/use-erc20-balance.d.cts +1 -1
- package/dist/utils/media-wallet/use-erc20-balance.d.ts +1 -1
- package/dist/utils/server-reads.cjs +87 -0
- package/dist/utils/server-reads.cjs.map +1 -0
- package/dist/utils/server-reads.d.cts +268 -0
- package/dist/utils/server-reads.d.ts +268 -0
- package/dist/utils/server-reads.js +63 -0
- package/dist/utils/server-reads.js.map +1 -0
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as input_otp from 'input-otp';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
|
|
4
|
-
declare const InputOTP: React.ForwardRefExoticComponent<(Omit<Omit<React.InputHTMLAttributes<HTMLInputElement>, "onChange" | "
|
|
4
|
+
declare const InputOTP: React.ForwardRefExoticComponent<(Omit<Omit<React.InputHTMLAttributes<HTMLInputElement>, "onChange" | "value" | "maxLength" | "textAlign" | "onComplete" | "pushPasswordManagerStrategy" | "pasteTransformer" | "containerClassName" | "noScriptCSSFallback"> & {
|
|
5
5
|
value?: string;
|
|
6
6
|
onChange?: (newValue: string) => unknown;
|
|
7
7
|
maxLength: number;
|
|
@@ -14,7 +14,7 @@ declare const InputOTP: React.ForwardRefExoticComponent<(Omit<Omit<React.InputHT
|
|
|
14
14
|
} & {
|
|
15
15
|
render: (props: input_otp.RenderProps) => React.ReactNode;
|
|
16
16
|
children?: never;
|
|
17
|
-
} & React.RefAttributes<HTMLInputElement>, "ref"> | Omit<Omit<React.InputHTMLAttributes<HTMLInputElement>, "onChange" | "
|
|
17
|
+
} & React.RefAttributes<HTMLInputElement>, "ref"> | Omit<Omit<React.InputHTMLAttributes<HTMLInputElement>, "onChange" | "value" | "maxLength" | "textAlign" | "onComplete" | "pushPasswordManagerStrategy" | "pasteTransformer" | "containerClassName" | "noScriptCSSFallback"> & {
|
|
18
18
|
value?: string;
|
|
19
19
|
onChange?: (newValue: string) => unknown;
|
|
20
20
|
maxLength: number;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as input_otp from 'input-otp';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
|
|
4
|
-
declare const InputOTP: React.ForwardRefExoticComponent<(Omit<Omit<React.InputHTMLAttributes<HTMLInputElement>, "onChange" | "
|
|
4
|
+
declare const InputOTP: React.ForwardRefExoticComponent<(Omit<Omit<React.InputHTMLAttributes<HTMLInputElement>, "onChange" | "value" | "maxLength" | "textAlign" | "onComplete" | "pushPasswordManagerStrategy" | "pasteTransformer" | "containerClassName" | "noScriptCSSFallback"> & {
|
|
5
5
|
value?: string;
|
|
6
6
|
onChange?: (newValue: string) => unknown;
|
|
7
7
|
maxLength: number;
|
|
@@ -14,7 +14,7 @@ declare const InputOTP: React.ForwardRefExoticComponent<(Omit<Omit<React.InputHT
|
|
|
14
14
|
} & {
|
|
15
15
|
render: (props: input_otp.RenderProps) => React.ReactNode;
|
|
16
16
|
children?: never;
|
|
17
|
-
} & React.RefAttributes<HTMLInputElement>, "ref"> | Omit<Omit<React.InputHTMLAttributes<HTMLInputElement>, "onChange" | "
|
|
17
|
+
} & React.RefAttributes<HTMLInputElement>, "ref"> | Omit<Omit<React.InputHTMLAttributes<HTMLInputElement>, "onChange" | "value" | "maxLength" | "textAlign" | "onComplete" | "pushPasswordManagerStrategy" | "pasteTransformer" | "containerClassName" | "noScriptCSSFallback"> & {
|
|
18
18
|
value?: string;
|
|
19
19
|
onChange?: (newValue: string) => unknown;
|
|
20
20
|
maxLength: number;
|
|
@@ -4,7 +4,7 @@ import { VariantProps } from 'class-variance-authority';
|
|
|
4
4
|
|
|
5
5
|
declare const buttonVariants: (props?: ({
|
|
6
6
|
variant?: "link" | "default" | "destructive" | "soft" | "secondary" | "ghost" | "tonal" | null | undefined;
|
|
7
|
-
size?: "
|
|
7
|
+
size?: "default" | "icon" | "sm" | "lg" | null | undefined;
|
|
8
8
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
9
9
|
interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
|
|
10
10
|
asChild?: boolean;
|
|
@@ -4,7 +4,7 @@ import { VariantProps } from 'class-variance-authority';
|
|
|
4
4
|
|
|
5
5
|
declare const buttonVariants: (props?: ({
|
|
6
6
|
variant?: "link" | "default" | "destructive" | "soft" | "secondary" | "ghost" | "tonal" | null | undefined;
|
|
7
|
-
size?: "
|
|
7
|
+
size?: "default" | "icon" | "sm" | "lg" | null | undefined;
|
|
8
8
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
9
9
|
interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
|
|
10
10
|
asChild?: boolean;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as React from 'react';
|
|
3
3
|
import { FastMintProps } from './types.cjs';
|
|
4
4
|
import 'starknet';
|
|
5
5
|
import '@medialane/sdk';
|
|
6
6
|
import '@medialane/sdk/starknet';
|
|
7
7
|
|
|
8
|
-
declare function FastMint(props: FastMintProps): string | number | bigint | boolean |
|
|
8
|
+
declare function FastMint(props: FastMintProps): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element | null | undefined;
|
|
9
9
|
|
|
10
10
|
export { FastMint };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as React from 'react';
|
|
3
3
|
import { FastMintProps } from './types.js';
|
|
4
4
|
import 'starknet';
|
|
5
5
|
import '@medialane/sdk';
|
|
6
6
|
import '@medialane/sdk/starknet';
|
|
7
7
|
|
|
8
|
-
declare function FastMint(props: FastMintProps): string | number | bigint | boolean |
|
|
8
|
+
declare function FastMint(props: FastMintProps): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element | null | undefined;
|
|
9
9
|
|
|
10
10
|
export { FastMint };
|
|
@@ -15,11 +15,11 @@ declare const editionMintSchema: z.ZodObject<{
|
|
|
15
15
|
aiPolicy: z.ZodEnum<["Allowed", "Not Allowed", "Training Only"]>;
|
|
16
16
|
royalty: z.ZodNumber;
|
|
17
17
|
}, "strip", z.ZodTypeAny, {
|
|
18
|
-
ipType: "Audio" | "Video" | "Art" | "Photography" | "NFT" | "RWA" | "Posts" | "Publications" | "Documents";
|
|
19
18
|
name: string;
|
|
20
|
-
value: string;
|
|
21
19
|
derivatives: "Allowed" | "Not Allowed" | "Share-Alike";
|
|
20
|
+
value: string;
|
|
22
21
|
recipient: string;
|
|
22
|
+
ipType: "Audio" | "Video" | "Art" | "Photography" | "NFT" | "RWA" | "Posts" | "Publications" | "Documents";
|
|
23
23
|
licenseType: string;
|
|
24
24
|
commercialUse: "Yes" | "No";
|
|
25
25
|
attribution: "Required" | "Not Required";
|
|
@@ -29,11 +29,11 @@ declare const editionMintSchema: z.ZodObject<{
|
|
|
29
29
|
description?: string | undefined;
|
|
30
30
|
external_url?: string | undefined;
|
|
31
31
|
}, {
|
|
32
|
-
ipType: "Audio" | "Video" | "Art" | "Photography" | "NFT" | "RWA" | "Posts" | "Publications" | "Documents";
|
|
33
32
|
name: string;
|
|
34
|
-
value: string;
|
|
35
33
|
derivatives: "Allowed" | "Not Allowed" | "Share-Alike";
|
|
34
|
+
value: string;
|
|
36
35
|
recipient: string;
|
|
36
|
+
ipType: "Audio" | "Video" | "Art" | "Photography" | "NFT" | "RWA" | "Posts" | "Publications" | "Documents";
|
|
37
37
|
licenseType: string;
|
|
38
38
|
commercialUse: "Yes" | "No";
|
|
39
39
|
attribution: "Required" | "Not Required";
|
|
@@ -15,11 +15,11 @@ declare const editionMintSchema: z.ZodObject<{
|
|
|
15
15
|
aiPolicy: z.ZodEnum<["Allowed", "Not Allowed", "Training Only"]>;
|
|
16
16
|
royalty: z.ZodNumber;
|
|
17
17
|
}, "strip", z.ZodTypeAny, {
|
|
18
|
-
ipType: "Audio" | "Video" | "Art" | "Photography" | "NFT" | "RWA" | "Posts" | "Publications" | "Documents";
|
|
19
18
|
name: string;
|
|
20
|
-
value: string;
|
|
21
19
|
derivatives: "Allowed" | "Not Allowed" | "Share-Alike";
|
|
20
|
+
value: string;
|
|
22
21
|
recipient: string;
|
|
22
|
+
ipType: "Audio" | "Video" | "Art" | "Photography" | "NFT" | "RWA" | "Posts" | "Publications" | "Documents";
|
|
23
23
|
licenseType: string;
|
|
24
24
|
commercialUse: "Yes" | "No";
|
|
25
25
|
attribution: "Required" | "Not Required";
|
|
@@ -29,11 +29,11 @@ declare const editionMintSchema: z.ZodObject<{
|
|
|
29
29
|
description?: string | undefined;
|
|
30
30
|
external_url?: string | undefined;
|
|
31
31
|
}, {
|
|
32
|
-
ipType: "Audio" | "Video" | "Art" | "Photography" | "NFT" | "RWA" | "Posts" | "Publications" | "Documents";
|
|
33
32
|
name: string;
|
|
34
|
-
value: string;
|
|
35
33
|
derivatives: "Allowed" | "Not Allowed" | "Share-Alike";
|
|
34
|
+
value: string;
|
|
36
35
|
recipient: string;
|
|
36
|
+
ipType: "Audio" | "Video" | "Art" | "Photography" | "NFT" | "RWA" | "Posts" | "Publications" | "Documents";
|
|
37
37
|
licenseType: string;
|
|
38
38
|
commercialUse: "Yes" | "No";
|
|
39
39
|
attribution: "Required" | "Not Required";
|
|
@@ -7,7 +7,7 @@ declare function useTokenBalance(symbol: string | null, holderAddress: string |
|
|
|
7
7
|
rawBalance: bigint | null;
|
|
8
8
|
isLoading: boolean;
|
|
9
9
|
error: any;
|
|
10
|
-
decimals:
|
|
10
|
+
decimals: 8 | 6 | 18;
|
|
11
11
|
};
|
|
12
12
|
declare function hasSufficientBalance(rawBalance: bigint | null, requiredHuman: string, decimals: number): boolean | null;
|
|
13
13
|
|
|
@@ -7,7 +7,7 @@ declare function useTokenBalance(symbol: string | null, holderAddress: string |
|
|
|
7
7
|
rawBalance: bigint | null;
|
|
8
8
|
isLoading: boolean;
|
|
9
9
|
error: any;
|
|
10
|
-
decimals:
|
|
10
|
+
decimals: 8 | 6 | 18;
|
|
11
11
|
};
|
|
12
12
|
declare function hasSufficientBalance(rawBalance: bigint | null, requiredHuman: string, decimals: number): boolean | null;
|
|
13
13
|
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var server_reads_exports = {};
|
|
20
|
+
__export(server_reads_exports, {
|
|
21
|
+
createServerReads: () => createServerReads
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(server_reads_exports);
|
|
24
|
+
var import_sdk = require("@medialane/sdk");
|
|
25
|
+
var import_ipfs = require("./ipfs.js");
|
|
26
|
+
const DETAIL_REVALIDATE_SECONDS = 300;
|
|
27
|
+
const LIST_REVALIDATE_SECONDS = 60;
|
|
28
|
+
const FAILED_READ_REVALIDATE_SECONDS = 1;
|
|
29
|
+
const ABSENT_STATUSES = /* @__PURE__ */ new Set([400, 404]);
|
|
30
|
+
const isAbsent = (error) => ABSENT_STATUSES.has(error?.status);
|
|
31
|
+
function isAddress(value) {
|
|
32
|
+
try {
|
|
33
|
+
(0, import_sdk.normalizeAddress)("STARKNET", value);
|
|
34
|
+
return true;
|
|
35
|
+
} catch {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function createServerReads({ api, cache }) {
|
|
40
|
+
const expireSoon = cache(async () => null, ["failed-read"], { revalidate: FAILED_READ_REVALIDATE_SECONDS });
|
|
41
|
+
function cached(name, read, revalidate = DETAIL_REVALIDATE_SECONDS) {
|
|
42
|
+
const load = cache(
|
|
43
|
+
async (...args) => {
|
|
44
|
+
try {
|
|
45
|
+
return await read(...args);
|
|
46
|
+
} catch (error) {
|
|
47
|
+
if (isAbsent(error)) return null;
|
|
48
|
+
throw error;
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
[name],
|
|
52
|
+
{ revalidate }
|
|
53
|
+
);
|
|
54
|
+
return async (...args) => {
|
|
55
|
+
try {
|
|
56
|
+
return await load(...args);
|
|
57
|
+
} catch {
|
|
58
|
+
return expireSoon();
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
const atAddress = (read) => async (...args) => isAddress(args[0]) ? read(...args) : null;
|
|
63
|
+
return {
|
|
64
|
+
ipfsToHttpServer: import_ipfs.toAbsoluteImageUrl,
|
|
65
|
+
fetchTokenMeta: cached("token-meta", atAddress((contract, tokenId) => api().tokens.get(contract, tokenId))),
|
|
66
|
+
fetchCollectionMeta: cached("collection-meta", atAddress((contract) => api().collections.get(contract))),
|
|
67
|
+
fetchCollectionBySlug: cached("collection-by-slug", (slug) => api().collections.findBySlug(slug)),
|
|
68
|
+
fetchDropMeta: cached("drop-meta", atAddress((contract) => api().drops.find(contract))),
|
|
69
|
+
fetchCoinMeta: cached("coin-meta", atAddress((contract) => api().coins.get(contract))),
|
|
70
|
+
fetchCreatorProfile: cached("creator-profile", (username) => api().creators.findByUsername(username)),
|
|
71
|
+
fetchFeaturedCollections: cached(
|
|
72
|
+
"featured-collections",
|
|
73
|
+
async (limit) => (await api().collections.list({ page: 1, limit, sort: "recent", isFeatured: true, hideEmpty: true })).data,
|
|
74
|
+
LIST_REVALIDATE_SECONDS
|
|
75
|
+
),
|
|
76
|
+
fetchActiveOrders: cached(
|
|
77
|
+
"active-orders",
|
|
78
|
+
async (limit) => (await api().orders.list({ status: "ACTIVE", sort: "recent", page: 1, limit })).data,
|
|
79
|
+
LIST_REVALIDATE_SECONDS
|
|
80
|
+
)
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
84
|
+
0 && (module.exports = {
|
|
85
|
+
createServerReads
|
|
86
|
+
});
|
|
87
|
+
//# sourceMappingURL=server-reads.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/server-reads.ts"],"sourcesContent":["import { normalizeAddress, type ApiClient } from \"@medialane/sdk\";\nimport { toAbsoluteImageUrl } from \"./ipfs.js\";\n\nconst DETAIL_REVALIDATE_SECONDS = 300;\nconst LIST_REVALIDATE_SECONDS = 60;\nconst FAILED_READ_REVALIDATE_SECONDS = 1;\nconst ABSENT_STATUSES = new Set<unknown>([400, 404]);\n\nexport type ServerReadCache = <T extends (...args: any[]) => Promise<any>>(\n read: T,\n key: string[],\n options: { revalidate: number },\n) => T;\n\nexport interface ServerReadsOptions {\n api: () => ApiClient;\n cache: ServerReadCache;\n}\n\nconst isAbsent = (error: unknown) => ABSENT_STATUSES.has((error as { status?: unknown } | null)?.status);\n\nfunction isAddress(value: string): boolean {\n try {\n normalizeAddress(\"STARKNET\", value);\n return true;\n } catch {\n return false;\n }\n}\n\nexport function createServerReads({ api, cache }: ServerReadsOptions) {\n const expireSoon = cache(async () => null, [\"failed-read\"], { revalidate: FAILED_READ_REVALIDATE_SECONDS });\n\n function cached<A extends (string | number)[], T>(\n name: string,\n read: (...args: A) => Promise<T>,\n revalidate = DETAIL_REVALIDATE_SECONDS,\n ): (...args: A) => Promise<T | null> {\n const load = cache(\n async (...args: A): Promise<T | null> => {\n try {\n return await read(...args);\n } catch (error) {\n if (isAbsent(error)) return null;\n throw error;\n }\n },\n [name],\n { revalidate },\n );\n return async (...args: A) => {\n try {\n return await load(...args);\n } catch {\n return expireSoon();\n }\n };\n }\n\n const atAddress = <A extends [string, ...(string | number)[]], T>(read: (...args: A) => Promise<T>) =>\n async (...args: A): Promise<T | null> => (isAddress(args[0]) ? read(...args) : null);\n\n return {\n ipfsToHttpServer: toAbsoluteImageUrl,\n fetchTokenMeta: cached(\"token-meta\", atAddress((contract: string, tokenId: string) => api().tokens.get(contract, tokenId))),\n fetchCollectionMeta: cached(\"collection-meta\", atAddress((contract: string) => api().collections.get(contract))),\n fetchCollectionBySlug: cached(\"collection-by-slug\", (slug: string) => api().collections.findBySlug(slug)),\n fetchDropMeta: cached(\"drop-meta\", atAddress((contract: string) => api().drops.find(contract))),\n fetchCoinMeta: cached(\"coin-meta\", atAddress((contract: string) => api().coins.get(contract))),\n fetchCreatorProfile: cached(\"creator-profile\", (username: string) => api().creators.findByUsername(username)),\n fetchFeaturedCollections: cached(\n \"featured-collections\",\n async (limit: number) =>\n (await api().collections.list({ page: 1, limit, sort: \"recent\", isFeatured: true, hideEmpty: true })).data,\n LIST_REVALIDATE_SECONDS,\n ),\n fetchActiveOrders: cached(\n \"active-orders\",\n async (limit: number) => (await api().orders.list({ status: \"ACTIVE\", sort: \"recent\", page: 1, limit })).data,\n LIST_REVALIDATE_SECONDS,\n ),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAiD;AACjD,kBAAmC;AAEnC,MAAM,4BAA4B;AAClC,MAAM,0BAA0B;AAChC,MAAM,iCAAiC;AACvC,MAAM,kBAAkB,oBAAI,IAAa,CAAC,KAAK,GAAG,CAAC;AAanD,MAAM,WAAW,CAAC,UAAmB,gBAAgB,IAAK,OAAuC,MAAM;AAEvG,SAAS,UAAU,OAAwB;AACzC,MAAI;AACF,qCAAiB,YAAY,KAAK;AAClC,WAAO;AAAA,EACT,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEO,SAAS,kBAAkB,EAAE,KAAK,MAAM,GAAuB;AACpE,QAAM,aAAa,MAAM,YAAY,MAAM,CAAC,aAAa,GAAG,EAAE,YAAY,+BAA+B,CAAC;AAE1G,WAAS,OACP,MACA,MACA,aAAa,2BACsB;AACnC,UAAM,OAAO;AAAA,MACX,UAAU,SAA+B;AACvC,YAAI;AACF,iBAAO,MAAM,KAAK,GAAG,IAAI;AAAA,QAC3B,SAAS,OAAO;AACd,cAAI,SAAS,KAAK,EAAG,QAAO;AAC5B,gBAAM;AAAA,QACR;AAAA,MACF;AAAA,MACA,CAAC,IAAI;AAAA,MACL,EAAE,WAAW;AAAA,IACf;AACA,WAAO,UAAU,SAAY;AAC3B,UAAI;AACF,eAAO,MAAM,KAAK,GAAG,IAAI;AAAA,MAC3B,QAAQ;AACN,eAAO,WAAW;AAAA,MACpB;AAAA,IACF;AAAA,EACF;AAEA,QAAM,YAAY,CAAgD,SAChE,UAAU,SAAgC,UAAU,KAAK,CAAC,CAAC,IAAI,KAAK,GAAG,IAAI,IAAI;AAEjF,SAAO;AAAA,IACL,kBAAkB;AAAA,IAClB,gBAAgB,OAAO,cAAc,UAAU,CAAC,UAAkB,YAAoB,IAAI,EAAE,OAAO,IAAI,UAAU,OAAO,CAAC,CAAC;AAAA,IAC1H,qBAAqB,OAAO,mBAAmB,UAAU,CAAC,aAAqB,IAAI,EAAE,YAAY,IAAI,QAAQ,CAAC,CAAC;AAAA,IAC/G,uBAAuB,OAAO,sBAAsB,CAAC,SAAiB,IAAI,EAAE,YAAY,WAAW,IAAI,CAAC;AAAA,IACxG,eAAe,OAAO,aAAa,UAAU,CAAC,aAAqB,IAAI,EAAE,MAAM,KAAK,QAAQ,CAAC,CAAC;AAAA,IAC9F,eAAe,OAAO,aAAa,UAAU,CAAC,aAAqB,IAAI,EAAE,MAAM,IAAI,QAAQ,CAAC,CAAC;AAAA,IAC7F,qBAAqB,OAAO,mBAAmB,CAAC,aAAqB,IAAI,EAAE,SAAS,eAAe,QAAQ,CAAC;AAAA,IAC5G,0BAA0B;AAAA,MACxB;AAAA,MACA,OAAO,WACJ,MAAM,IAAI,EAAE,YAAY,KAAK,EAAE,MAAM,GAAG,OAAO,MAAM,UAAU,YAAY,MAAM,WAAW,KAAK,CAAC,GAAG;AAAA,MACxG;AAAA,IACF;AAAA,IACA,mBAAmB;AAAA,MACjB;AAAA,MACA,OAAO,WAAmB,MAAM,IAAI,EAAE,OAAO,KAAK,EAAE,QAAQ,UAAU,MAAM,UAAU,MAAM,GAAG,MAAM,CAAC,GAAG;AAAA,MACzG;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import * as _medialane_sdk from '@medialane/sdk';
|
|
2
|
+
import { ApiClient } from '@medialane/sdk';
|
|
3
|
+
import { toAbsoluteImageUrl } from './ipfs.cjs';
|
|
4
|
+
|
|
5
|
+
type ServerReadCache = <T extends (...args: any[]) => Promise<any>>(read: T, key: string[], options: {
|
|
6
|
+
revalidate: number;
|
|
7
|
+
}) => T;
|
|
8
|
+
interface ServerReadsOptions {
|
|
9
|
+
api: () => ApiClient;
|
|
10
|
+
cache: ServerReadCache;
|
|
11
|
+
}
|
|
12
|
+
declare function createServerReads({ api, cache }: ServerReadsOptions): {
|
|
13
|
+
ipfsToHttpServer: typeof toAbsoluteImageUrl;
|
|
14
|
+
fetchTokenMeta: (contract: string, tokenId: string) => Promise<{
|
|
15
|
+
id: string;
|
|
16
|
+
chain: string;
|
|
17
|
+
contractAddress: string;
|
|
18
|
+
tokenId: string;
|
|
19
|
+
owner: string | null;
|
|
20
|
+
tokenUri: string | null;
|
|
21
|
+
metadataStatus: "PENDING" | "FETCHING" | "FETCHED" | "FAILED";
|
|
22
|
+
isArchived: boolean;
|
|
23
|
+
standard: "ERC721" | "ERC1155" | null;
|
|
24
|
+
metadata: {
|
|
25
|
+
name: string | null;
|
|
26
|
+
description: string | null;
|
|
27
|
+
image: string | null;
|
|
28
|
+
animationUrl: string | null;
|
|
29
|
+
attributes: {
|
|
30
|
+
[x: string]: unknown;
|
|
31
|
+
trait_type: string;
|
|
32
|
+
value: string | number | boolean;
|
|
33
|
+
display_type?: string | undefined;
|
|
34
|
+
}[] | null;
|
|
35
|
+
ipType: string | null;
|
|
36
|
+
licenseType: string | null;
|
|
37
|
+
commercialUse: boolean | null;
|
|
38
|
+
author: string | null;
|
|
39
|
+
externalUrl: string | null;
|
|
40
|
+
};
|
|
41
|
+
balances: {
|
|
42
|
+
owner: string;
|
|
43
|
+
amount: string;
|
|
44
|
+
}[] | null;
|
|
45
|
+
activeOrders: {
|
|
46
|
+
id: string;
|
|
47
|
+
chain: string;
|
|
48
|
+
orderHash: string;
|
|
49
|
+
offerer: string;
|
|
50
|
+
offer: {
|
|
51
|
+
itemType: string;
|
|
52
|
+
token: string;
|
|
53
|
+
identifier: string;
|
|
54
|
+
startAmount: string;
|
|
55
|
+
endAmount: string;
|
|
56
|
+
};
|
|
57
|
+
consideration: {
|
|
58
|
+
itemType: string;
|
|
59
|
+
token: string;
|
|
60
|
+
identifier: string;
|
|
61
|
+
startAmount: string;
|
|
62
|
+
endAmount: string;
|
|
63
|
+
recipient: string;
|
|
64
|
+
};
|
|
65
|
+
startTime: string;
|
|
66
|
+
endTime: string;
|
|
67
|
+
status: "ACTIVE" | "FULFILLED" | "CANCELLED" | "EXPIRED";
|
|
68
|
+
fulfiller: string | null;
|
|
69
|
+
nftContract: string | null;
|
|
70
|
+
nftTokenId: string | null;
|
|
71
|
+
price: {
|
|
72
|
+
raw: string | null;
|
|
73
|
+
formatted: string | null;
|
|
74
|
+
currency: string | null;
|
|
75
|
+
decimals: number;
|
|
76
|
+
};
|
|
77
|
+
txHash: {
|
|
78
|
+
created: string | null;
|
|
79
|
+
fulfilled: string | null;
|
|
80
|
+
cancelled: string | null;
|
|
81
|
+
};
|
|
82
|
+
createdBlockNumber: string;
|
|
83
|
+
remainingAmount: string | null;
|
|
84
|
+
createdAt: string;
|
|
85
|
+
updatedAt: string;
|
|
86
|
+
token: {
|
|
87
|
+
name: string | null;
|
|
88
|
+
image: string | null;
|
|
89
|
+
description: string | null;
|
|
90
|
+
animationUrl: string | null;
|
|
91
|
+
} | null;
|
|
92
|
+
parentOrderHash?: string | null | undefined;
|
|
93
|
+
counterOfferMessage?: string | null | undefined;
|
|
94
|
+
hasActiveCounterOffer?: boolean | undefined;
|
|
95
|
+
}[];
|
|
96
|
+
createdAt: string;
|
|
97
|
+
updatedAt: string;
|
|
98
|
+
holderCount?: number | undefined;
|
|
99
|
+
supply?: string | undefined;
|
|
100
|
+
} | null>;
|
|
101
|
+
fetchCollectionMeta: (contract: string) => Promise<{
|
|
102
|
+
id: string;
|
|
103
|
+
chain: string;
|
|
104
|
+
contractAddress: string;
|
|
105
|
+
collectionId: string | null;
|
|
106
|
+
name: string | null;
|
|
107
|
+
symbol: string | null;
|
|
108
|
+
description: string | null;
|
|
109
|
+
image: string | null;
|
|
110
|
+
attributes: {
|
|
111
|
+
[x: string]: unknown;
|
|
112
|
+
trait_type: string;
|
|
113
|
+
value: string | number | boolean;
|
|
114
|
+
display_type?: string | undefined;
|
|
115
|
+
}[] | null;
|
|
116
|
+
owner: string | null;
|
|
117
|
+
startBlock: string;
|
|
118
|
+
metadataStatus: "PENDING" | "FETCHING" | "FETCHED" | "FAILED";
|
|
119
|
+
standard: "ERC721" | "ERC1155";
|
|
120
|
+
isFeatured: boolean;
|
|
121
|
+
isHidden: boolean;
|
|
122
|
+
service: string | null;
|
|
123
|
+
floorPrice: string | null;
|
|
124
|
+
totalVolume: string | null;
|
|
125
|
+
holderCount: number;
|
|
126
|
+
totalSupply: number;
|
|
127
|
+
createdAt: string;
|
|
128
|
+
updatedAt: string;
|
|
129
|
+
profile: {
|
|
130
|
+
hasGatedContent: boolean;
|
|
131
|
+
gatedContentTitle: string | null;
|
|
132
|
+
slug: string | null;
|
|
133
|
+
image: string | null;
|
|
134
|
+
displayName: string | null;
|
|
135
|
+
description: string | null;
|
|
136
|
+
} | null;
|
|
137
|
+
} | null>;
|
|
138
|
+
fetchCollectionBySlug: (slug: string) => Promise<{
|
|
139
|
+
id: string;
|
|
140
|
+
chain: string;
|
|
141
|
+
contractAddress: string;
|
|
142
|
+
collectionId: string | null;
|
|
143
|
+
name: string | null;
|
|
144
|
+
symbol: string | null;
|
|
145
|
+
description: string | null;
|
|
146
|
+
image: string | null;
|
|
147
|
+
attributes: {
|
|
148
|
+
[x: string]: unknown;
|
|
149
|
+
trait_type: string;
|
|
150
|
+
value: string | number | boolean;
|
|
151
|
+
display_type?: string | undefined;
|
|
152
|
+
}[] | null;
|
|
153
|
+
owner: string | null;
|
|
154
|
+
startBlock: string;
|
|
155
|
+
metadataStatus: "PENDING" | "FETCHING" | "FETCHED" | "FAILED";
|
|
156
|
+
standard: "ERC721" | "ERC1155";
|
|
157
|
+
isFeatured: boolean;
|
|
158
|
+
isHidden: boolean;
|
|
159
|
+
service: string | null;
|
|
160
|
+
floorPrice: string | null;
|
|
161
|
+
totalVolume: string | null;
|
|
162
|
+
holderCount: number;
|
|
163
|
+
totalSupply: number;
|
|
164
|
+
createdAt: string;
|
|
165
|
+
updatedAt: string;
|
|
166
|
+
profile: {
|
|
167
|
+
hasGatedContent: boolean;
|
|
168
|
+
gatedContentTitle: string | null;
|
|
169
|
+
slug: string | null;
|
|
170
|
+
image: string | null;
|
|
171
|
+
displayName: string | null;
|
|
172
|
+
description: string | null;
|
|
173
|
+
} | null;
|
|
174
|
+
} | null>;
|
|
175
|
+
fetchDropMeta: (contract: string) => Promise<_medialane_sdk.ApiDrop | null>;
|
|
176
|
+
fetchCoinMeta: (contract: string) => Promise<_medialane_sdk.ApiCoin | null>;
|
|
177
|
+
fetchCreatorProfile: (username: string) => Promise<_medialane_sdk.ApiCreatorProfile | null>;
|
|
178
|
+
fetchFeaturedCollections: (limit: number) => Promise<{
|
|
179
|
+
id: string;
|
|
180
|
+
chain: string;
|
|
181
|
+
contractAddress: string;
|
|
182
|
+
collectionId: string | null;
|
|
183
|
+
name: string | null;
|
|
184
|
+
symbol: string | null;
|
|
185
|
+
description: string | null;
|
|
186
|
+
image: string | null;
|
|
187
|
+
attributes: {
|
|
188
|
+
[x: string]: unknown;
|
|
189
|
+
trait_type: string;
|
|
190
|
+
value: string | number | boolean;
|
|
191
|
+
display_type?: string | undefined;
|
|
192
|
+
}[] | null;
|
|
193
|
+
owner: string | null;
|
|
194
|
+
startBlock: string;
|
|
195
|
+
metadataStatus: "PENDING" | "FETCHING" | "FETCHED" | "FAILED";
|
|
196
|
+
standard: "ERC721" | "ERC1155";
|
|
197
|
+
isFeatured: boolean;
|
|
198
|
+
isHidden: boolean;
|
|
199
|
+
service: string | null;
|
|
200
|
+
floorPrice: string | null;
|
|
201
|
+
totalVolume: string | null;
|
|
202
|
+
holderCount: number;
|
|
203
|
+
totalSupply: number;
|
|
204
|
+
createdAt: string;
|
|
205
|
+
updatedAt: string;
|
|
206
|
+
profile: {
|
|
207
|
+
hasGatedContent: boolean;
|
|
208
|
+
gatedContentTitle: string | null;
|
|
209
|
+
slug: string | null;
|
|
210
|
+
image: string | null;
|
|
211
|
+
displayName: string | null;
|
|
212
|
+
description: string | null;
|
|
213
|
+
} | null;
|
|
214
|
+
}[] | null>;
|
|
215
|
+
fetchActiveOrders: (limit: number) => Promise<{
|
|
216
|
+
id: string;
|
|
217
|
+
chain: string;
|
|
218
|
+
orderHash: string;
|
|
219
|
+
offerer: string;
|
|
220
|
+
offer: {
|
|
221
|
+
itemType: string;
|
|
222
|
+
token: string;
|
|
223
|
+
identifier: string;
|
|
224
|
+
startAmount: string;
|
|
225
|
+
endAmount: string;
|
|
226
|
+
};
|
|
227
|
+
consideration: {
|
|
228
|
+
itemType: string;
|
|
229
|
+
token: string;
|
|
230
|
+
identifier: string;
|
|
231
|
+
startAmount: string;
|
|
232
|
+
endAmount: string;
|
|
233
|
+
recipient: string;
|
|
234
|
+
};
|
|
235
|
+
startTime: string;
|
|
236
|
+
endTime: string;
|
|
237
|
+
status: "ACTIVE" | "FULFILLED" | "CANCELLED" | "EXPIRED";
|
|
238
|
+
fulfiller: string | null;
|
|
239
|
+
nftContract: string | null;
|
|
240
|
+
nftTokenId: string | null;
|
|
241
|
+
price: {
|
|
242
|
+
raw: string | null;
|
|
243
|
+
formatted: string | null;
|
|
244
|
+
currency: string | null;
|
|
245
|
+
decimals: number;
|
|
246
|
+
};
|
|
247
|
+
txHash: {
|
|
248
|
+
created: string | null;
|
|
249
|
+
fulfilled: string | null;
|
|
250
|
+
cancelled: string | null;
|
|
251
|
+
};
|
|
252
|
+
createdBlockNumber: string;
|
|
253
|
+
remainingAmount: string | null;
|
|
254
|
+
createdAt: string;
|
|
255
|
+
updatedAt: string;
|
|
256
|
+
token: {
|
|
257
|
+
name: string | null;
|
|
258
|
+
image: string | null;
|
|
259
|
+
description: string | null;
|
|
260
|
+
animationUrl: string | null;
|
|
261
|
+
} | null;
|
|
262
|
+
parentOrderHash?: string | null | undefined;
|
|
263
|
+
counterOfferMessage?: string | null | undefined;
|
|
264
|
+
hasActiveCounterOffer?: boolean | undefined;
|
|
265
|
+
}[] | null>;
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
export { type ServerReadCache, type ServerReadsOptions, createServerReads };
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import * as _medialane_sdk from '@medialane/sdk';
|
|
2
|
+
import { ApiClient } from '@medialane/sdk';
|
|
3
|
+
import { toAbsoluteImageUrl } from './ipfs.js';
|
|
4
|
+
|
|
5
|
+
type ServerReadCache = <T extends (...args: any[]) => Promise<any>>(read: T, key: string[], options: {
|
|
6
|
+
revalidate: number;
|
|
7
|
+
}) => T;
|
|
8
|
+
interface ServerReadsOptions {
|
|
9
|
+
api: () => ApiClient;
|
|
10
|
+
cache: ServerReadCache;
|
|
11
|
+
}
|
|
12
|
+
declare function createServerReads({ api, cache }: ServerReadsOptions): {
|
|
13
|
+
ipfsToHttpServer: typeof toAbsoluteImageUrl;
|
|
14
|
+
fetchTokenMeta: (contract: string, tokenId: string) => Promise<{
|
|
15
|
+
id: string;
|
|
16
|
+
chain: string;
|
|
17
|
+
contractAddress: string;
|
|
18
|
+
tokenId: string;
|
|
19
|
+
owner: string | null;
|
|
20
|
+
tokenUri: string | null;
|
|
21
|
+
metadataStatus: "PENDING" | "FETCHING" | "FETCHED" | "FAILED";
|
|
22
|
+
isArchived: boolean;
|
|
23
|
+
standard: "ERC721" | "ERC1155" | null;
|
|
24
|
+
metadata: {
|
|
25
|
+
name: string | null;
|
|
26
|
+
description: string | null;
|
|
27
|
+
image: string | null;
|
|
28
|
+
animationUrl: string | null;
|
|
29
|
+
attributes: {
|
|
30
|
+
[x: string]: unknown;
|
|
31
|
+
trait_type: string;
|
|
32
|
+
value: string | number | boolean;
|
|
33
|
+
display_type?: string | undefined;
|
|
34
|
+
}[] | null;
|
|
35
|
+
ipType: string | null;
|
|
36
|
+
licenseType: string | null;
|
|
37
|
+
commercialUse: boolean | null;
|
|
38
|
+
author: string | null;
|
|
39
|
+
externalUrl: string | null;
|
|
40
|
+
};
|
|
41
|
+
balances: {
|
|
42
|
+
owner: string;
|
|
43
|
+
amount: string;
|
|
44
|
+
}[] | null;
|
|
45
|
+
activeOrders: {
|
|
46
|
+
id: string;
|
|
47
|
+
chain: string;
|
|
48
|
+
orderHash: string;
|
|
49
|
+
offerer: string;
|
|
50
|
+
offer: {
|
|
51
|
+
itemType: string;
|
|
52
|
+
token: string;
|
|
53
|
+
identifier: string;
|
|
54
|
+
startAmount: string;
|
|
55
|
+
endAmount: string;
|
|
56
|
+
};
|
|
57
|
+
consideration: {
|
|
58
|
+
itemType: string;
|
|
59
|
+
token: string;
|
|
60
|
+
identifier: string;
|
|
61
|
+
startAmount: string;
|
|
62
|
+
endAmount: string;
|
|
63
|
+
recipient: string;
|
|
64
|
+
};
|
|
65
|
+
startTime: string;
|
|
66
|
+
endTime: string;
|
|
67
|
+
status: "ACTIVE" | "FULFILLED" | "CANCELLED" | "EXPIRED";
|
|
68
|
+
fulfiller: string | null;
|
|
69
|
+
nftContract: string | null;
|
|
70
|
+
nftTokenId: string | null;
|
|
71
|
+
price: {
|
|
72
|
+
raw: string | null;
|
|
73
|
+
formatted: string | null;
|
|
74
|
+
currency: string | null;
|
|
75
|
+
decimals: number;
|
|
76
|
+
};
|
|
77
|
+
txHash: {
|
|
78
|
+
created: string | null;
|
|
79
|
+
fulfilled: string | null;
|
|
80
|
+
cancelled: string | null;
|
|
81
|
+
};
|
|
82
|
+
createdBlockNumber: string;
|
|
83
|
+
remainingAmount: string | null;
|
|
84
|
+
createdAt: string;
|
|
85
|
+
updatedAt: string;
|
|
86
|
+
token: {
|
|
87
|
+
name: string | null;
|
|
88
|
+
image: string | null;
|
|
89
|
+
description: string | null;
|
|
90
|
+
animationUrl: string | null;
|
|
91
|
+
} | null;
|
|
92
|
+
parentOrderHash?: string | null | undefined;
|
|
93
|
+
counterOfferMessage?: string | null | undefined;
|
|
94
|
+
hasActiveCounterOffer?: boolean | undefined;
|
|
95
|
+
}[];
|
|
96
|
+
createdAt: string;
|
|
97
|
+
updatedAt: string;
|
|
98
|
+
holderCount?: number | undefined;
|
|
99
|
+
supply?: string | undefined;
|
|
100
|
+
} | null>;
|
|
101
|
+
fetchCollectionMeta: (contract: string) => Promise<{
|
|
102
|
+
id: string;
|
|
103
|
+
chain: string;
|
|
104
|
+
contractAddress: string;
|
|
105
|
+
collectionId: string | null;
|
|
106
|
+
name: string | null;
|
|
107
|
+
symbol: string | null;
|
|
108
|
+
description: string | null;
|
|
109
|
+
image: string | null;
|
|
110
|
+
attributes: {
|
|
111
|
+
[x: string]: unknown;
|
|
112
|
+
trait_type: string;
|
|
113
|
+
value: string | number | boolean;
|
|
114
|
+
display_type?: string | undefined;
|
|
115
|
+
}[] | null;
|
|
116
|
+
owner: string | null;
|
|
117
|
+
startBlock: string;
|
|
118
|
+
metadataStatus: "PENDING" | "FETCHING" | "FETCHED" | "FAILED";
|
|
119
|
+
standard: "ERC721" | "ERC1155";
|
|
120
|
+
isFeatured: boolean;
|
|
121
|
+
isHidden: boolean;
|
|
122
|
+
service: string | null;
|
|
123
|
+
floorPrice: string | null;
|
|
124
|
+
totalVolume: string | null;
|
|
125
|
+
holderCount: number;
|
|
126
|
+
totalSupply: number;
|
|
127
|
+
createdAt: string;
|
|
128
|
+
updatedAt: string;
|
|
129
|
+
profile: {
|
|
130
|
+
hasGatedContent: boolean;
|
|
131
|
+
gatedContentTitle: string | null;
|
|
132
|
+
slug: string | null;
|
|
133
|
+
image: string | null;
|
|
134
|
+
displayName: string | null;
|
|
135
|
+
description: string | null;
|
|
136
|
+
} | null;
|
|
137
|
+
} | null>;
|
|
138
|
+
fetchCollectionBySlug: (slug: string) => Promise<{
|
|
139
|
+
id: string;
|
|
140
|
+
chain: string;
|
|
141
|
+
contractAddress: string;
|
|
142
|
+
collectionId: string | null;
|
|
143
|
+
name: string | null;
|
|
144
|
+
symbol: string | null;
|
|
145
|
+
description: string | null;
|
|
146
|
+
image: string | null;
|
|
147
|
+
attributes: {
|
|
148
|
+
[x: string]: unknown;
|
|
149
|
+
trait_type: string;
|
|
150
|
+
value: string | number | boolean;
|
|
151
|
+
display_type?: string | undefined;
|
|
152
|
+
}[] | null;
|
|
153
|
+
owner: string | null;
|
|
154
|
+
startBlock: string;
|
|
155
|
+
metadataStatus: "PENDING" | "FETCHING" | "FETCHED" | "FAILED";
|
|
156
|
+
standard: "ERC721" | "ERC1155";
|
|
157
|
+
isFeatured: boolean;
|
|
158
|
+
isHidden: boolean;
|
|
159
|
+
service: string | null;
|
|
160
|
+
floorPrice: string | null;
|
|
161
|
+
totalVolume: string | null;
|
|
162
|
+
holderCount: number;
|
|
163
|
+
totalSupply: number;
|
|
164
|
+
createdAt: string;
|
|
165
|
+
updatedAt: string;
|
|
166
|
+
profile: {
|
|
167
|
+
hasGatedContent: boolean;
|
|
168
|
+
gatedContentTitle: string | null;
|
|
169
|
+
slug: string | null;
|
|
170
|
+
image: string | null;
|
|
171
|
+
displayName: string | null;
|
|
172
|
+
description: string | null;
|
|
173
|
+
} | null;
|
|
174
|
+
} | null>;
|
|
175
|
+
fetchDropMeta: (contract: string) => Promise<_medialane_sdk.ApiDrop | null>;
|
|
176
|
+
fetchCoinMeta: (contract: string) => Promise<_medialane_sdk.ApiCoin | null>;
|
|
177
|
+
fetchCreatorProfile: (username: string) => Promise<_medialane_sdk.ApiCreatorProfile | null>;
|
|
178
|
+
fetchFeaturedCollections: (limit: number) => Promise<{
|
|
179
|
+
id: string;
|
|
180
|
+
chain: string;
|
|
181
|
+
contractAddress: string;
|
|
182
|
+
collectionId: string | null;
|
|
183
|
+
name: string | null;
|
|
184
|
+
symbol: string | null;
|
|
185
|
+
description: string | null;
|
|
186
|
+
image: string | null;
|
|
187
|
+
attributes: {
|
|
188
|
+
[x: string]: unknown;
|
|
189
|
+
trait_type: string;
|
|
190
|
+
value: string | number | boolean;
|
|
191
|
+
display_type?: string | undefined;
|
|
192
|
+
}[] | null;
|
|
193
|
+
owner: string | null;
|
|
194
|
+
startBlock: string;
|
|
195
|
+
metadataStatus: "PENDING" | "FETCHING" | "FETCHED" | "FAILED";
|
|
196
|
+
standard: "ERC721" | "ERC1155";
|
|
197
|
+
isFeatured: boolean;
|
|
198
|
+
isHidden: boolean;
|
|
199
|
+
service: string | null;
|
|
200
|
+
floorPrice: string | null;
|
|
201
|
+
totalVolume: string | null;
|
|
202
|
+
holderCount: number;
|
|
203
|
+
totalSupply: number;
|
|
204
|
+
createdAt: string;
|
|
205
|
+
updatedAt: string;
|
|
206
|
+
profile: {
|
|
207
|
+
hasGatedContent: boolean;
|
|
208
|
+
gatedContentTitle: string | null;
|
|
209
|
+
slug: string | null;
|
|
210
|
+
image: string | null;
|
|
211
|
+
displayName: string | null;
|
|
212
|
+
description: string | null;
|
|
213
|
+
} | null;
|
|
214
|
+
}[] | null>;
|
|
215
|
+
fetchActiveOrders: (limit: number) => Promise<{
|
|
216
|
+
id: string;
|
|
217
|
+
chain: string;
|
|
218
|
+
orderHash: string;
|
|
219
|
+
offerer: string;
|
|
220
|
+
offer: {
|
|
221
|
+
itemType: string;
|
|
222
|
+
token: string;
|
|
223
|
+
identifier: string;
|
|
224
|
+
startAmount: string;
|
|
225
|
+
endAmount: string;
|
|
226
|
+
};
|
|
227
|
+
consideration: {
|
|
228
|
+
itemType: string;
|
|
229
|
+
token: string;
|
|
230
|
+
identifier: string;
|
|
231
|
+
startAmount: string;
|
|
232
|
+
endAmount: string;
|
|
233
|
+
recipient: string;
|
|
234
|
+
};
|
|
235
|
+
startTime: string;
|
|
236
|
+
endTime: string;
|
|
237
|
+
status: "ACTIVE" | "FULFILLED" | "CANCELLED" | "EXPIRED";
|
|
238
|
+
fulfiller: string | null;
|
|
239
|
+
nftContract: string | null;
|
|
240
|
+
nftTokenId: string | null;
|
|
241
|
+
price: {
|
|
242
|
+
raw: string | null;
|
|
243
|
+
formatted: string | null;
|
|
244
|
+
currency: string | null;
|
|
245
|
+
decimals: number;
|
|
246
|
+
};
|
|
247
|
+
txHash: {
|
|
248
|
+
created: string | null;
|
|
249
|
+
fulfilled: string | null;
|
|
250
|
+
cancelled: string | null;
|
|
251
|
+
};
|
|
252
|
+
createdBlockNumber: string;
|
|
253
|
+
remainingAmount: string | null;
|
|
254
|
+
createdAt: string;
|
|
255
|
+
updatedAt: string;
|
|
256
|
+
token: {
|
|
257
|
+
name: string | null;
|
|
258
|
+
image: string | null;
|
|
259
|
+
description: string | null;
|
|
260
|
+
animationUrl: string | null;
|
|
261
|
+
} | null;
|
|
262
|
+
parentOrderHash?: string | null | undefined;
|
|
263
|
+
counterOfferMessage?: string | null | undefined;
|
|
264
|
+
hasActiveCounterOffer?: boolean | undefined;
|
|
265
|
+
}[] | null>;
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
export { type ServerReadCache, type ServerReadsOptions, createServerReads };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { normalizeAddress } from "@medialane/sdk";
|
|
2
|
+
import { toAbsoluteImageUrl } from "./ipfs.js";
|
|
3
|
+
const DETAIL_REVALIDATE_SECONDS = 300;
|
|
4
|
+
const LIST_REVALIDATE_SECONDS = 60;
|
|
5
|
+
const FAILED_READ_REVALIDATE_SECONDS = 1;
|
|
6
|
+
const ABSENT_STATUSES = /* @__PURE__ */ new Set([400, 404]);
|
|
7
|
+
const isAbsent = (error) => ABSENT_STATUSES.has(error?.status);
|
|
8
|
+
function isAddress(value) {
|
|
9
|
+
try {
|
|
10
|
+
normalizeAddress("STARKNET", value);
|
|
11
|
+
return true;
|
|
12
|
+
} catch {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function createServerReads({ api, cache }) {
|
|
17
|
+
const expireSoon = cache(async () => null, ["failed-read"], { revalidate: FAILED_READ_REVALIDATE_SECONDS });
|
|
18
|
+
function cached(name, read, revalidate = DETAIL_REVALIDATE_SECONDS) {
|
|
19
|
+
const load = cache(
|
|
20
|
+
async (...args) => {
|
|
21
|
+
try {
|
|
22
|
+
return await read(...args);
|
|
23
|
+
} catch (error) {
|
|
24
|
+
if (isAbsent(error)) return null;
|
|
25
|
+
throw error;
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
[name],
|
|
29
|
+
{ revalidate }
|
|
30
|
+
);
|
|
31
|
+
return async (...args) => {
|
|
32
|
+
try {
|
|
33
|
+
return await load(...args);
|
|
34
|
+
} catch {
|
|
35
|
+
return expireSoon();
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
const atAddress = (read) => async (...args) => isAddress(args[0]) ? read(...args) : null;
|
|
40
|
+
return {
|
|
41
|
+
ipfsToHttpServer: toAbsoluteImageUrl,
|
|
42
|
+
fetchTokenMeta: cached("token-meta", atAddress((contract, tokenId) => api().tokens.get(contract, tokenId))),
|
|
43
|
+
fetchCollectionMeta: cached("collection-meta", atAddress((contract) => api().collections.get(contract))),
|
|
44
|
+
fetchCollectionBySlug: cached("collection-by-slug", (slug) => api().collections.findBySlug(slug)),
|
|
45
|
+
fetchDropMeta: cached("drop-meta", atAddress((contract) => api().drops.find(contract))),
|
|
46
|
+
fetchCoinMeta: cached("coin-meta", atAddress((contract) => api().coins.get(contract))),
|
|
47
|
+
fetchCreatorProfile: cached("creator-profile", (username) => api().creators.findByUsername(username)),
|
|
48
|
+
fetchFeaturedCollections: cached(
|
|
49
|
+
"featured-collections",
|
|
50
|
+
async (limit) => (await api().collections.list({ page: 1, limit, sort: "recent", isFeatured: true, hideEmpty: true })).data,
|
|
51
|
+
LIST_REVALIDATE_SECONDS
|
|
52
|
+
),
|
|
53
|
+
fetchActiveOrders: cached(
|
|
54
|
+
"active-orders",
|
|
55
|
+
async (limit) => (await api().orders.list({ status: "ACTIVE", sort: "recent", page: 1, limit })).data,
|
|
56
|
+
LIST_REVALIDATE_SECONDS
|
|
57
|
+
)
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
export {
|
|
61
|
+
createServerReads
|
|
62
|
+
};
|
|
63
|
+
//# sourceMappingURL=server-reads.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/server-reads.ts"],"sourcesContent":["import { normalizeAddress, type ApiClient } from \"@medialane/sdk\";\nimport { toAbsoluteImageUrl } from \"./ipfs.js\";\n\nconst DETAIL_REVALIDATE_SECONDS = 300;\nconst LIST_REVALIDATE_SECONDS = 60;\nconst FAILED_READ_REVALIDATE_SECONDS = 1;\nconst ABSENT_STATUSES = new Set<unknown>([400, 404]);\n\nexport type ServerReadCache = <T extends (...args: any[]) => Promise<any>>(\n read: T,\n key: string[],\n options: { revalidate: number },\n) => T;\n\nexport interface ServerReadsOptions {\n api: () => ApiClient;\n cache: ServerReadCache;\n}\n\nconst isAbsent = (error: unknown) => ABSENT_STATUSES.has((error as { status?: unknown } | null)?.status);\n\nfunction isAddress(value: string): boolean {\n try {\n normalizeAddress(\"STARKNET\", value);\n return true;\n } catch {\n return false;\n }\n}\n\nexport function createServerReads({ api, cache }: ServerReadsOptions) {\n const expireSoon = cache(async () => null, [\"failed-read\"], { revalidate: FAILED_READ_REVALIDATE_SECONDS });\n\n function cached<A extends (string | number)[], T>(\n name: string,\n read: (...args: A) => Promise<T>,\n revalidate = DETAIL_REVALIDATE_SECONDS,\n ): (...args: A) => Promise<T | null> {\n const load = cache(\n async (...args: A): Promise<T | null> => {\n try {\n return await read(...args);\n } catch (error) {\n if (isAbsent(error)) return null;\n throw error;\n }\n },\n [name],\n { revalidate },\n );\n return async (...args: A) => {\n try {\n return await load(...args);\n } catch {\n return expireSoon();\n }\n };\n }\n\n const atAddress = <A extends [string, ...(string | number)[]], T>(read: (...args: A) => Promise<T>) =>\n async (...args: A): Promise<T | null> => (isAddress(args[0]) ? read(...args) : null);\n\n return {\n ipfsToHttpServer: toAbsoluteImageUrl,\n fetchTokenMeta: cached(\"token-meta\", atAddress((contract: string, tokenId: string) => api().tokens.get(contract, tokenId))),\n fetchCollectionMeta: cached(\"collection-meta\", atAddress((contract: string) => api().collections.get(contract))),\n fetchCollectionBySlug: cached(\"collection-by-slug\", (slug: string) => api().collections.findBySlug(slug)),\n fetchDropMeta: cached(\"drop-meta\", atAddress((contract: string) => api().drops.find(contract))),\n fetchCoinMeta: cached(\"coin-meta\", atAddress((contract: string) => api().coins.get(contract))),\n fetchCreatorProfile: cached(\"creator-profile\", (username: string) => api().creators.findByUsername(username)),\n fetchFeaturedCollections: cached(\n \"featured-collections\",\n async (limit: number) =>\n (await api().collections.list({ page: 1, limit, sort: \"recent\", isFeatured: true, hideEmpty: true })).data,\n LIST_REVALIDATE_SECONDS,\n ),\n fetchActiveOrders: cached(\n \"active-orders\",\n async (limit: number) => (await api().orders.list({ status: \"ACTIVE\", sort: \"recent\", page: 1, limit })).data,\n LIST_REVALIDATE_SECONDS,\n ),\n };\n}\n"],"mappings":"AAAA,SAAS,wBAAwC;AACjD,SAAS,0BAA0B;AAEnC,MAAM,4BAA4B;AAClC,MAAM,0BAA0B;AAChC,MAAM,iCAAiC;AACvC,MAAM,kBAAkB,oBAAI,IAAa,CAAC,KAAK,GAAG,CAAC;AAanD,MAAM,WAAW,CAAC,UAAmB,gBAAgB,IAAK,OAAuC,MAAM;AAEvG,SAAS,UAAU,OAAwB;AACzC,MAAI;AACF,qBAAiB,YAAY,KAAK;AAClC,WAAO;AAAA,EACT,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEO,SAAS,kBAAkB,EAAE,KAAK,MAAM,GAAuB;AACpE,QAAM,aAAa,MAAM,YAAY,MAAM,CAAC,aAAa,GAAG,EAAE,YAAY,+BAA+B,CAAC;AAE1G,WAAS,OACP,MACA,MACA,aAAa,2BACsB;AACnC,UAAM,OAAO;AAAA,MACX,UAAU,SAA+B;AACvC,YAAI;AACF,iBAAO,MAAM,KAAK,GAAG,IAAI;AAAA,QAC3B,SAAS,OAAO;AACd,cAAI,SAAS,KAAK,EAAG,QAAO;AAC5B,gBAAM;AAAA,QACR;AAAA,MACF;AAAA,MACA,CAAC,IAAI;AAAA,MACL,EAAE,WAAW;AAAA,IACf;AACA,WAAO,UAAU,SAAY;AAC3B,UAAI;AACF,eAAO,MAAM,KAAK,GAAG,IAAI;AAAA,MAC3B,QAAQ;AACN,eAAO,WAAW;AAAA,MACpB;AAAA,IACF;AAAA,EACF;AAEA,QAAM,YAAY,CAAgD,SAChE,UAAU,SAAgC,UAAU,KAAK,CAAC,CAAC,IAAI,KAAK,GAAG,IAAI,IAAI;AAEjF,SAAO;AAAA,IACL,kBAAkB;AAAA,IAClB,gBAAgB,OAAO,cAAc,UAAU,CAAC,UAAkB,YAAoB,IAAI,EAAE,OAAO,IAAI,UAAU,OAAO,CAAC,CAAC;AAAA,IAC1H,qBAAqB,OAAO,mBAAmB,UAAU,CAAC,aAAqB,IAAI,EAAE,YAAY,IAAI,QAAQ,CAAC,CAAC;AAAA,IAC/G,uBAAuB,OAAO,sBAAsB,CAAC,SAAiB,IAAI,EAAE,YAAY,WAAW,IAAI,CAAC;AAAA,IACxG,eAAe,OAAO,aAAa,UAAU,CAAC,aAAqB,IAAI,EAAE,MAAM,KAAK,QAAQ,CAAC,CAAC;AAAA,IAC9F,eAAe,OAAO,aAAa,UAAU,CAAC,aAAqB,IAAI,EAAE,MAAM,IAAI,QAAQ,CAAC,CAAC;AAAA,IAC7F,qBAAqB,OAAO,mBAAmB,CAAC,aAAqB,IAAI,EAAE,SAAS,eAAe,QAAQ,CAAC;AAAA,IAC5G,0BAA0B;AAAA,MACxB;AAAA,MACA,OAAO,WACJ,MAAM,IAAI,EAAE,YAAY,KAAK,EAAE,MAAM,GAAG,OAAO,MAAM,UAAU,YAAY,MAAM,WAAW,KAAK,CAAC,GAAG;AAAA,MACxG;AAAA,IACF;AAAA,IACA,mBAAmB;AAAA,MACjB;AAAA,MACA,OAAO,WAAmB,MAAM,IAAI,EAAE,OAAO,KAAK,EAAE,QAAQ,UAAU,MAAM,UAAU,MAAM,GAAG,MAAM,CAAC,GAAG;AAAA,MACzG;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|