@medialane/ui 0.183.0 → 0.184.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/drop/create/artwork-section.cjs +115 -0
- package/dist/components/drop/create/artwork-section.cjs.map +1 -0
- package/dist/components/drop/create/artwork-section.d.cts +23 -0
- package/dist/components/drop/create/artwork-section.d.ts +23 -0
- package/dist/components/drop/create/artwork-section.js +79 -0
- package/dist/components/drop/create/artwork-section.js.map +1 -0
- package/dist/components/drop/create/details-section.cjs +110 -0
- package/dist/components/drop/create/details-section.cjs.map +1 -0
- package/dist/components/drop/create/details-section.d.cts +11 -0
- package/dist/components/drop/create/details-section.d.ts +11 -0
- package/dist/components/drop/create/details-section.js +86 -0
- package/dist/components/drop/create/details-section.js.map +1 -0
- package/dist/components/drop/create/drop-create.cjs +112 -0
- package/dist/components/drop/create/drop-create.cjs.map +1 -0
- package/dist/components/drop/create/drop-create.d.cts +22 -0
- package/dist/components/drop/create/drop-create.d.ts +22 -0
- package/dist/components/drop/create/drop-create.js +77 -0
- package/dist/components/drop/create/drop-create.js.map +1 -0
- package/dist/components/drop/create/exclusive-fields.cjs +45 -0
- package/dist/components/drop/create/exclusive-fields.cjs.map +1 -0
- package/dist/components/drop/create/exclusive-fields.d.cts +14 -0
- package/dist/components/drop/create/exclusive-fields.d.ts +14 -0
- package/dist/components/drop/create/exclusive-fields.js +21 -0
- package/dist/components/drop/create/exclusive-fields.js.map +1 -0
- package/dist/components/drop/create/launch-dialog.cjs +193 -0
- package/dist/components/drop/create/launch-dialog.cjs.map +1 -0
- package/dist/components/drop/create/launch-dialog.d.cts +21 -0
- package/dist/components/drop/create/launch-dialog.d.ts +21 -0
- package/dist/components/drop/create/launch-dialog.js +168 -0
- package/dist/components/drop/create/launch-dialog.js.map +1 -0
- package/dist/components/drop/create/list-section.cjs +67 -0
- package/dist/components/drop/create/list-section.cjs.map +1 -0
- package/dist/components/drop/create/list-section.d.cts +11 -0
- package/dist/components/drop/create/list-section.d.ts +11 -0
- package/dist/components/drop/create/list-section.js +43 -0
- package/dist/components/drop/create/list-section.js.map +1 -0
- package/dist/components/drop/create/sale-section.cjs +78 -0
- package/dist/components/drop/create/sale-section.cjs.map +1 -0
- package/dist/components/drop/create/sale-section.d.cts +13 -0
- package/dist/components/drop/create/sale-section.d.ts +13 -0
- package/dist/components/drop/create/sale-section.js +54 -0
- package/dist/components/drop/create/sale-section.js.map +1 -0
- package/dist/components/drop/drop-card.cjs +81 -0
- package/dist/components/drop/drop-card.cjs.map +1 -0
- package/dist/components/drop/drop-card.d.cts +18 -0
- package/dist/components/drop/drop-card.d.ts +18 -0
- package/dist/components/drop/drop-card.js +45 -0
- package/dist/components/drop/drop-card.js.map +1 -0
- package/dist/components/drop/drop-listing.cjs +79 -0
- package/dist/components/drop/drop-listing.cjs.map +1 -0
- package/dist/components/drop/drop-listing.d.cts +10 -0
- package/dist/components/drop/drop-listing.d.ts +10 -0
- package/dist/components/drop/drop-listing.js +45 -0
- package/dist/components/drop/drop-listing.js.map +1 -0
- package/dist/components/drop/drop-token-link.cjs +63 -0
- package/dist/components/drop/drop-token-link.cjs.map +1 -0
- package/dist/components/drop/drop-token-link.d.cts +9 -0
- package/dist/components/drop/drop-token-link.d.ts +9 -0
- package/dist/components/drop/drop-token-link.js +29 -0
- package/dist/components/drop/drop-token-link.js.map +1 -0
- package/dist/components/drop/my-drops.cjs +71 -0
- package/dist/components/drop/my-drops.cjs.map +1 -0
- package/dist/components/drop/my-drops.d.cts +12 -0
- package/dist/components/drop/my-drops.d.ts +12 -0
- package/dist/components/drop/my-drops.js +37 -0
- package/dist/components/drop/my-drops.js.map +1 -0
- package/dist/components/drop/page/drop-action-box.cjs +63 -0
- package/dist/components/drop/page/drop-action-box.cjs.map +1 -0
- package/dist/components/drop/page/drop-action-box.d.cts +16 -0
- package/dist/components/drop/page/drop-action-box.d.ts +16 -0
- package/dist/components/drop/page/drop-action-box.js +39 -0
- package/dist/components/drop/page/drop-action-box.js.map +1 -0
- package/dist/components/drop/page/drop-activity.cjs +42 -0
- package/dist/components/drop/page/drop-activity.cjs.map +1 -0
- package/dist/components/drop/page/drop-activity.d.cts +8 -0
- package/dist/components/drop/page/drop-activity.d.ts +8 -0
- package/dist/components/drop/page/drop-activity.js +18 -0
- package/dist/components/drop/page/drop-activity.js.map +1 -0
- package/dist/components/drop/page/drop-manage.cjs +161 -0
- package/dist/components/drop/page/drop-manage.cjs.map +1 -0
- package/dist/components/drop/page/drop-manage.d.cts +24 -0
- package/dist/components/drop/page/drop-manage.d.ts +24 -0
- package/dist/components/drop/page/drop-manage.js +137 -0
- package/dist/components/drop/page/drop-manage.js.map +1 -0
- package/dist/components/drop/page/drop-mint-dialog.cjs +97 -0
- package/dist/components/drop/page/drop-mint-dialog.cjs.map +1 -0
- package/dist/components/drop/page/drop-mint-dialog.d.cts +15 -0
- package/dist/components/drop/page/drop-mint-dialog.d.ts +15 -0
- package/dist/components/drop/page/drop-mint-dialog.js +73 -0
- package/dist/components/drop/page/drop-mint-dialog.js.map +1 -0
- package/dist/components/drop/page/drop-page.cjs +165 -0
- package/dist/components/drop/page/drop-page.cjs.map +1 -0
- package/dist/components/drop/page/drop-page.d.cts +16 -0
- package/dist/components/drop/page/drop-page.d.ts +16 -0
- package/dist/components/drop/page/drop-page.js +131 -0
- package/dist/components/drop/page/drop-page.js.map +1 -0
- package/dist/components/drop-status-display.cjs +7 -38
- package/dist/components/drop-status-display.cjs.map +1 -1
- package/dist/components/drop-status-display.d.cts +6 -7
- package/dist/components/drop-status-display.d.ts +6 -7
- package/dist/components/drop-status-display.js +7 -37
- package/dist/components/drop-status-display.js.map +1 -1
- package/dist/components/image.d.cts +2 -0
- package/dist/components/image.d.ts +2 -0
- package/dist/index.cjs +46 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +20 -11
- package/dist/index.d.ts +20 -11
- package/dist/index.js +31 -25
- package/dist/index.js.map +1 -1
- package/dist/utils/drop/actions.cjs +76 -0
- package/dist/utils/drop/actions.cjs.map +1 -0
- package/dist/utils/drop/actions.d.cts +46 -0
- package/dist/utils/drop/actions.d.ts +46 -0
- package/dist/utils/drop/actions.js +49 -0
- package/dist/utils/drop/actions.js.map +1 -0
- package/dist/utils/drop/allowlist.cjs +50 -0
- package/dist/utils/drop/allowlist.cjs.map +1 -0
- package/dist/utils/drop/allowlist.d.cts +10 -0
- package/dist/utils/drop/allowlist.d.ts +10 -0
- package/dist/utils/drop/allowlist.js +26 -0
- package/dist/utils/drop/allowlist.js.map +1 -0
- package/dist/utils/drop/chain.cjs +37 -0
- package/dist/utils/drop/chain.cjs.map +1 -0
- package/dist/utils/drop/chain.d.cts +5 -0
- package/dist/utils/drop/chain.d.ts +5 -0
- package/dist/utils/drop/chain.js +13 -0
- package/dist/utils/drop/chain.js.map +1 -0
- package/dist/utils/drop/claim-proof.cjs +48 -0
- package/dist/utils/drop/claim-proof.cjs.map +1 -0
- package/dist/utils/drop/claim-proof.d.cts +9 -0
- package/dist/utils/drop/claim-proof.d.ts +9 -0
- package/dist/utils/drop/claim-proof.js +24 -0
- package/dist/utils/drop/claim-proof.js.map +1 -0
- package/dist/utils/drop/draft.cjs +87 -0
- package/dist/utils/drop/draft.cjs.map +1 -0
- package/dist/utils/drop/draft.d.cts +32 -0
- package/dist/utils/drop/draft.d.ts +32 -0
- package/dist/utils/drop/draft.js +61 -0
- package/dist/utils/drop/draft.js.map +1 -0
- package/dist/utils/drop/metadata.cjs +70 -0
- package/dist/utils/drop/metadata.cjs.map +1 -0
- package/dist/utils/drop/metadata.d.cts +34 -0
- package/dist/utils/drop/metadata.d.ts +34 -0
- package/dist/utils/drop/metadata.js +43 -0
- package/dist/utils/drop/metadata.js.map +1 -0
- package/dist/utils/{drop-status.cjs → drop/preview.cjs} +14 -14
- package/dist/utils/drop/preview.cjs.map +1 -0
- package/dist/utils/drop/preview.d.cts +4 -0
- package/dist/utils/drop/preview.d.ts +4 -0
- package/dist/utils/drop/preview.js +13 -0
- package/dist/utils/drop/preview.js.map +1 -0
- package/dist/utils/drop/receipt.cjs +39 -0
- package/dist/utils/drop/receipt.cjs.map +1 -0
- package/dist/utils/drop/receipt.d.cts +6 -0
- package/dist/utils/drop/receipt.d.ts +6 -0
- package/dist/utils/drop/receipt.js +15 -0
- package/dist/utils/drop/receipt.js.map +1 -0
- package/dist/utils/drop/sale.cjs +108 -0
- package/dist/utils/drop/sale.cjs.map +1 -0
- package/dist/utils/drop/sale.d.cts +52 -0
- package/dist/utils/drop/sale.d.ts +52 -0
- package/dist/utils/drop/sale.js +78 -0
- package/dist/utils/drop/sale.js.map +1 -0
- package/dist/utils/drop/types.cjs +17 -0
- package/dist/utils/drop/types.cjs.map +1 -0
- package/dist/utils/drop/types.d.cts +20 -0
- package/dist/utils/drop/types.d.ts +20 -0
- package/dist/utils/drop/types.js +1 -0
- package/dist/utils/drop/types.js.map +1 -0
- package/dist/utils/drop/upload.cjs +48 -0
- package/dist/utils/drop/upload.cjs.map +1 -0
- package/dist/utils/drop/upload.d.cts +11 -0
- package/dist/utils/drop/upload.d.ts +11 -0
- package/dist/utils/drop/upload.js +24 -0
- package/dist/utils/drop/upload.js.map +1 -0
- package/dist/utils/drop/use-now.cjs +38 -0
- package/dist/utils/drop/use-now.cjs.map +1 -0
- package/dist/utils/drop/use-now.d.cts +4 -0
- package/dist/utils/drop/use-now.d.ts +4 -0
- package/dist/utils/drop/use-now.js +14 -0
- package/dist/utils/drop/use-now.js.map +1 -0
- package/dist/utils/drop/view.cjs +89 -0
- package/dist/utils/drop/view.cjs.map +1 -0
- package/dist/utils/drop/view.d.cts +34 -0
- package/dist/utils/drop/view.d.ts +34 -0
- package/dist/utils/drop/view.js +64 -0
- package/dist/utils/drop/view.js.map +1 -0
- package/dist/utils/launchpad-defaults.cjs +0 -22
- package/dist/utils/launchpad-defaults.cjs.map +1 -1
- package/dist/utils/launchpad-defaults.d.cts +1 -7
- package/dist/utils/launchpad-defaults.d.ts +1 -7
- package/dist/utils/launchpad-defaults.js +0 -21
- package/dist/utils/launchpad-defaults.js.map +1 -1
- package/dist/utils/use-drops.cjs +41 -45
- package/dist/utils/use-drops.cjs.map +1 -1
- package/dist/utils/use-drops.d.cts +31 -23
- package/dist/utils/use-drops.d.ts +31 -23
- package/dist/utils/use-drops.js +35 -40
- package/dist/utils/use-drops.js.map +1 -1
- package/package.json +3 -3
- package/dist/components/account/account.test.cjs +0 -86
- package/dist/components/account/account.test.cjs.map +0 -1
- package/dist/components/account/account.test.d.cts +0 -2
- package/dist/components/account/account.test.d.ts +0 -2
- package/dist/components/account/account.test.js +0 -85
- package/dist/components/account/account.test.js.map +0 -1
- package/dist/components/drop-create-form.cjs +0 -341
- package/dist/components/drop-create-form.cjs.map +0 -1
- package/dist/components/drop-create-form.d.cts +0 -39
- package/dist/components/drop-create-form.d.ts +0 -39
- package/dist/components/drop-create-form.js +0 -322
- package/dist/components/drop-create-form.js.map +0 -1
- package/dist/components/drop-preview-card.cjs +0 -106
- package/dist/components/drop-preview-card.cjs.map +0 -1
- package/dist/components/drop-preview-card.d.cts +0 -17
- package/dist/components/drop-preview-card.d.ts +0 -17
- package/dist/components/drop-preview-card.js +0 -82
- package/dist/components/drop-preview-card.js.map +0 -1
- package/dist/components/drop-preview-card.test.cjs +0 -84
- package/dist/components/drop-preview-card.test.cjs.map +0 -1
- package/dist/components/drop-preview-card.test.d.cts +0 -3
- package/dist/components/drop-preview-card.test.d.ts +0 -3
- package/dist/components/drop-preview-card.test.js +0 -83
- package/dist/components/drop-preview-card.test.js.map +0 -1
- package/dist/components/drop-status-display.test.cjs +0 -29
- package/dist/components/drop-status-display.test.cjs.map +0 -1
- package/dist/components/drop-status-display.test.d.cts +0 -2
- package/dist/components/drop-status-display.test.d.ts +0 -2
- package/dist/components/drop-status-display.test.js +0 -28
- package/dist/components/drop-status-display.test.js.map +0 -1
- package/dist/components/exclusive-content-section.cjs +0 -88
- package/dist/components/exclusive-content-section.cjs.map +0 -1
- package/dist/components/exclusive-content-section.d.cts +0 -10
- package/dist/components/exclusive-content-section.d.ts +0 -10
- package/dist/components/exclusive-content-section.js +0 -64
- package/dist/components/exclusive-content-section.js.map +0 -1
- package/dist/data/drop-create-schema.cjs +0 -92
- package/dist/data/drop-create-schema.cjs.map +0 -1
- package/dist/data/drop-create-schema.d.cts +0 -131
- package/dist/data/drop-create-schema.d.ts +0 -131
- package/dist/data/drop-create-schema.js +0 -58
- package/dist/data/drop-create-schema.js.map +0 -1
- package/dist/utils/drop-status.cjs.map +0 -1
- package/dist/utils/drop-status.d.cts +0 -12
- package/dist/utils/drop-status.d.ts +0 -12
- package/dist/utils/drop-status.js +0 -13
- package/dist/utils/drop-status.js.map +0 -1
package/dist/utils/use-drops.cjs
CHANGED
|
@@ -29,66 +29,62 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
29
29
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
30
|
var use_drops_exports = {};
|
|
31
31
|
__export(use_drops_exports, {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
useDrop: () => useDrop,
|
|
33
|
+
useDropChain: () => useDropChain,
|
|
34
|
+
useDropFile: () => useDropFile,
|
|
35
|
+
useDropMints: () => useDropMints,
|
|
36
|
+
useDrops: () => useDrops,
|
|
37
|
+
useMyDrops: () => useMyDrops
|
|
37
38
|
});
|
|
38
39
|
module.exports = __toCommonJS(use_drops_exports);
|
|
39
40
|
var import_swr = __toESM(require("swr"), 1);
|
|
41
|
+
var import_starknet = require("@medialane/sdk/starknet");
|
|
40
42
|
var import_use_medialane_client = require("./use-medialane-client.js");
|
|
41
|
-
|
|
43
|
+
var import_chain = require("./drop/chain.js");
|
|
44
|
+
const quiet = { revalidateOnFocus: false, shouldRetryOnError: false };
|
|
45
|
+
function useDrops(getClient, status) {
|
|
42
46
|
const client = (0, import_use_medialane_client.useMedialaneClient)(getClient);
|
|
43
|
-
const { data, error, isLoading
|
|
44
|
-
|
|
45
|
-
() => client.api.listCollections({ service: "drop-collection", hideEmpty: false, limit: 50 }),
|
|
46
|
-
{ revalidateOnFocus: false }
|
|
47
|
-
);
|
|
48
|
-
return { collections: data?.data ?? [], meta: data?.meta, isLoading, error, mutate };
|
|
47
|
+
const { data, error, isLoading } = (0, import_swr.default)(["drops", status], () => client.api.getDrops({ status, limit: 48 }), quiet);
|
|
48
|
+
return { drops: data?.data ?? [], isLoading, error };
|
|
49
49
|
}
|
|
50
|
-
function useMyDrops(getClient,
|
|
50
|
+
function useMyDrops(getClient, organizer) {
|
|
51
51
|
const client = (0, import_use_medialane_client.useMedialaneClient)(getClient);
|
|
52
|
-
const { data, error, isLoading
|
|
53
|
-
|
|
54
|
-
async () => (await client.api.listCollections({ service: "drop-collection", owner, limit: 50 })).data ?? [],
|
|
55
|
-
{ revalidateOnFocus: false }
|
|
56
|
-
);
|
|
57
|
-
return { drops: data ?? [], isLoading, error, mutate };
|
|
52
|
+
const { data, error, isLoading } = (0, import_swr.default)(organizer ? ["my-drops", organizer] : null, () => client.api.getDrops({ organizer, limit: 100 }), quiet);
|
|
53
|
+
return { drops: data?.data ?? [], isLoading, error };
|
|
58
54
|
}
|
|
59
|
-
function
|
|
55
|
+
function useDrop(getClient, contract) {
|
|
60
56
|
const client = (0, import_use_medialane_client.useMedialaneClient)(getClient);
|
|
61
|
-
const { data, error, isLoading, mutate } = (0, import_swr.default)(
|
|
62
|
-
|
|
63
|
-
() => client.api.getDropMintStatus(collection, wallet),
|
|
64
|
-
{ revalidateOnFocus: false, shouldRetryOnError: false }
|
|
65
|
-
);
|
|
66
|
-
return { mintStatus: data ?? null, isLoading, error, mutate };
|
|
57
|
+
const { data, error, isLoading, mutate } = (0, import_swr.default)(contract ? ["drop", contract] : null, () => client.api.getDrop(contract), { ...quiet, refreshInterval: 3e4 });
|
|
58
|
+
return { drop: data ?? null, isLoading, error, mutate };
|
|
67
59
|
}
|
|
68
|
-
function
|
|
60
|
+
function useDropMints(getClient, contract) {
|
|
69
61
|
const client = (0, import_use_medialane_client.useMedialaneClient)(getClient);
|
|
70
|
-
const { data,
|
|
71
|
-
|
|
72
|
-
() => client.api.getDropInfo(contract),
|
|
73
|
-
{ revalidateOnFocus: false, shouldRetryOnError: false }
|
|
74
|
-
);
|
|
75
|
-
return { dropInfo: data ?? null, isLoading, error };
|
|
62
|
+
const { data, isLoading, mutate } = (0, import_swr.default)(contract ? ["drop-mints", contract] : null, () => client.api.getDropMints(contract, { limit: 20 }), { ...quiet, refreshInterval: 3e4 });
|
|
63
|
+
return { mints: data?.data ?? [], isLoading, mutate };
|
|
76
64
|
}
|
|
77
|
-
function
|
|
65
|
+
function useDropFile(getClient, baseUri, name) {
|
|
78
66
|
const client = (0, import_use_medialane_client.useMedialaneClient)(getClient);
|
|
79
|
-
const { data
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
)
|
|
84
|
-
|
|
67
|
+
const { data } = (0, import_swr.default)(baseUri ? ["drop-file", baseUri, name] : null, async () => (await client.api.resolveMetadata(`${baseUri}${name}`)).data, quiet);
|
|
68
|
+
return data ?? null;
|
|
69
|
+
}
|
|
70
|
+
function useDropChain(provider, contract, wallet) {
|
|
71
|
+
const { data, mutate, error } = (0, import_swr.default)(contract ? ["drop-chain", contract, wallet] : null, async () => {
|
|
72
|
+
const drop = await (0, import_starknet.readDrop)(provider, contract);
|
|
73
|
+
const [claimed, balance] = await Promise.all([
|
|
74
|
+
wallet ? (0, import_starknet.dropClaimedBy)(provider, contract, wallet) : Promise.resolve(null),
|
|
75
|
+
wallet && drop.price > 0n ? (0, import_chain.erc20Balance)(provider, drop.paymentToken, wallet) : Promise.resolve(null)
|
|
76
|
+
]);
|
|
77
|
+
return { drop, claimed, balance };
|
|
78
|
+
}, { revalidateOnFocus: true, refreshInterval: 15e3 });
|
|
79
|
+
return { ...data ?? { drop: null, claimed: null, balance: null }, error, mutate };
|
|
85
80
|
}
|
|
86
81
|
// Annotate the CommonJS export names for ESM import in node:
|
|
87
82
|
0 && (module.exports = {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
83
|
+
useDrop,
|
|
84
|
+
useDropChain,
|
|
85
|
+
useDropFile,
|
|
86
|
+
useDropMints,
|
|
87
|
+
useDrops,
|
|
88
|
+
useMyDrops
|
|
93
89
|
});
|
|
94
90
|
//# sourceMappingURL=use-drops.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/use-drops.ts"],"sourcesContent":["\"use client\";\n\nimport useSWR from \"swr\";\nimport type {
|
|
1
|
+
{"version":3,"sources":["../../src/utils/use-drops.ts"],"sourcesContent":["\"use client\";\n\nimport useSWR from \"swr\";\nimport type { ApiDrop, ApiDropListStatus, ApiDropMint } from \"@medialane/sdk\";\nimport { dropClaimedBy, readDrop, type DropOnchain, type MedialaneClient } from \"@medialane/sdk/starknet\";\nimport { useMedialaneClient } from \"./use-medialane-client.js\";\nimport { erc20Balance } from \"./drop/chain.js\";\nimport type { DropProvider } from \"./drop/types.js\";\n\nconst quiet = { revalidateOnFocus: false, shouldRetryOnError: false } as const;\n\nexport function useDrops(getClient: () => MedialaneClient, status: ApiDropListStatus) {\n const client = useMedialaneClient(getClient);\n const { data, error, isLoading } = useSWR([\"drops\", status], () => client.api.getDrops({ status, limit: 48 }), quiet);\n return { drops: data?.data ?? ([] as ApiDrop[]), isLoading, error };\n}\n\nexport function useMyDrops(getClient: () => MedialaneClient, organizer: string | null) {\n const client = useMedialaneClient(getClient);\n const { data, error, isLoading } = useSWR(organizer ? [\"my-drops\", organizer] : null, () => client.api.getDrops({ organizer: organizer!, limit: 100 }), quiet);\n return { drops: data?.data ?? ([] as ApiDrop[]), isLoading, error };\n}\n\nexport function useDrop(getClient: () => MedialaneClient, contract: string | null) {\n const client = useMedialaneClient(getClient);\n const { data, error, isLoading, mutate } = useSWR(contract ? [\"drop\", contract] : null, () => client.api.getDrop(contract!), { ...quiet, refreshInterval: 30_000 });\n return { drop: data ?? null, isLoading, error, mutate };\n}\n\nexport function useDropMints(getClient: () => MedialaneClient, contract: string | null) {\n const client = useMedialaneClient(getClient);\n const { data, isLoading, mutate } = useSWR(contract ? [\"drop-mints\", contract] : null, () => client.api.getDropMints(contract!, { limit: 20 }), { ...quiet, refreshInterval: 30_000 });\n return { mints: data?.data ?? ([] as ApiDropMint[]), isLoading, mutate };\n}\n\n/** A file from the drop's metadata folder (\"1\" or \"collection.json\"). */\nexport function useDropFile<T = Record<string, unknown>>(getClient: () => MedialaneClient, baseUri: string | null, name: string) {\n const client = useMedialaneClient(getClient);\n const { data } = useSWR(baseUri ? [\"drop-file\", baseUri, name] : null, async () => (await client.api.resolveMetadata(`${baseUri}${name}`)).data as T, quiet);\n return data ?? null;\n}\n\nexport interface DropChainState {\n drop: DropOnchain | null;\n claimed: bigint | null;\n balance: bigint | null;\n}\n\n/** The drop's terms and supply, the wallet's claims and balance — read from chain. */\nexport function useDropChain(provider: DropProvider, contract: string | null, wallet: string | null) {\n const { data, mutate, error } = useSWR(contract ? [\"drop-chain\", contract, wallet] : null, async (): Promise<DropChainState> => {\n const drop = await readDrop(provider, contract!);\n const [claimed, balance] = await Promise.all([\n wallet ? dropClaimedBy(provider, contract!, wallet) : Promise.resolve(null),\n wallet && drop.price > 0n ? erc20Balance(provider, drop.paymentToken, wallet) : Promise.resolve(null),\n ]);\n return { drop, claimed, balance };\n }, { revalidateOnFocus: true, refreshInterval: 15_000 });\n return { ...(data ?? { drop: null, claimed: null, balance: null }), error, mutate };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,iBAAmB;AAEnB,sBAAgF;AAChF,kCAAmC;AACnC,mBAA6B;AAG7B,MAAM,QAAQ,EAAE,mBAAmB,OAAO,oBAAoB,MAAM;AAE7D,SAAS,SAAS,WAAk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,aAAS,gDAAmB,SAAS;AAC3C,QAAM,EAAE,KAAK,QAAI,WAAAA,SAAO,UAAU,CAAC,aAAa,SAAS,IAAI,IAAI,MAAM,aAAa,MAAM,OAAO,IAAI,gBAAgB,GAAG,OAAO,GAAG,IAAI,EAAE,GAAG,MAAW,KAAK;AAC3J,SAAO,QAAQ;AACjB;AASO,SAAS,aAAa,UAAwB,UAAyB,QAAuB;AACnG,QAAM,EAAE,MAAM,QAAQ,MAAM,QAAI,WAAAA,SAAO,WAAW,CAAC,cAAc,UAAU,MAAM,IAAI,MAAM,YAAqC;AAC9H,UAAM,OAAO,UAAM,0BAAS,UAAU,QAAS;AAC/C,UAAM,CAAC,SAAS,OAAO,IAAI,MAAM,QAAQ,IAAI;AAAA,MAC3C,aAAS,+BAAc,UAAU,UAAW,MAAM,IAAI,QAAQ,QAAQ,IAAI;AAAA,MAC1E,UAAU,KAAK,QAAQ,SAAK,2BAAa,UAAU,KAAK,cAAc,MAAM,IAAI,QAAQ,QAAQ,IAAI;AAAA,IACtG,CAAC;AACD,WAAO,EAAE,MAAM,SAAS,QAAQ;AAAA,EAClC,GAAG,EAAE,mBAAmB,MAAM,iBAAiB,KAAO,CAAC;AACvD,SAAO,EAAE,GAAI,QAAQ,EAAE,MAAM,MAAM,SAAS,MAAM,SAAS,KAAK,GAAI,OAAO,OAAO;AACpF;","names":["useSWR"]}
|
|
@@ -1,39 +1,47 @@
|
|
|
1
|
+
import * as _medialane_sdk from '@medialane/sdk';
|
|
2
|
+
import { ApiDrop, ApiDropMint, ApiDropListStatus } from '@medialane/sdk';
|
|
1
3
|
import * as swr from 'swr';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
+
import { DropOnchain, MedialaneClient } from '@medialane/sdk/starknet';
|
|
5
|
+
import { DropProvider } from './drop/types.cjs';
|
|
6
|
+
import 'starknet';
|
|
7
|
+
import '../components/fast-mint/types.cjs';
|
|
8
|
+
import 'react';
|
|
4
9
|
|
|
5
|
-
declare function
|
|
6
|
-
|
|
7
|
-
meta: ApiMeta | undefined;
|
|
10
|
+
declare function useDrops(getClient: () => MedialaneClient, status: ApiDropListStatus): {
|
|
11
|
+
drops: ApiDrop[];
|
|
8
12
|
isLoading: boolean;
|
|
9
13
|
error: any;
|
|
10
|
-
mutate: swr.KeyedMutator<{
|
|
11
|
-
data: ApiCollection[];
|
|
12
|
-
meta?: ApiMeta;
|
|
13
|
-
}>;
|
|
14
14
|
};
|
|
15
|
-
declare function useMyDrops(getClient: () => MedialaneClient,
|
|
16
|
-
drops:
|
|
15
|
+
declare function useMyDrops(getClient: () => MedialaneClient, organizer: string | null): {
|
|
16
|
+
drops: ApiDrop[];
|
|
17
17
|
isLoading: boolean;
|
|
18
18
|
error: any;
|
|
19
|
-
mutate: swr.KeyedMutator<ApiCollection[]>;
|
|
20
19
|
};
|
|
21
|
-
declare function
|
|
22
|
-
|
|
20
|
+
declare function useDrop(getClient: () => MedialaneClient, contract: string | null): {
|
|
21
|
+
drop: ApiDrop | null;
|
|
23
22
|
isLoading: boolean;
|
|
24
23
|
error: any;
|
|
25
|
-
mutate: swr.KeyedMutator<
|
|
24
|
+
mutate: swr.KeyedMutator<ApiDrop | null>;
|
|
26
25
|
};
|
|
27
|
-
declare function
|
|
28
|
-
|
|
26
|
+
declare function useDropMints(getClient: () => MedialaneClient, contract: string | null): {
|
|
27
|
+
mints: ApiDropMint[];
|
|
29
28
|
isLoading: boolean;
|
|
30
|
-
|
|
29
|
+
mutate: swr.KeyedMutator<_medialane_sdk.ApiResponse<ApiDropMint[]>>;
|
|
31
30
|
};
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
/** A file from the drop's metadata folder ("1" or "collection.json"). */
|
|
32
|
+
declare function useDropFile<T = Record<string, unknown>>(getClient: () => MedialaneClient, baseUri: string | null, name: string): NonNullable<T> | null;
|
|
33
|
+
interface DropChainState {
|
|
34
|
+
drop: DropOnchain | null;
|
|
35
|
+
claimed: bigint | null;
|
|
36
|
+
balance: bigint | null;
|
|
37
|
+
}
|
|
38
|
+
/** The drop's terms and supply, the wallet's claims and balance — read from chain. */
|
|
39
|
+
declare function useDropChain(provider: DropProvider, contract: string | null, wallet: string | null): {
|
|
35
40
|
error: any;
|
|
36
|
-
mutate: swr.KeyedMutator<
|
|
41
|
+
mutate: swr.KeyedMutator<DropChainState>;
|
|
42
|
+
drop: DropOnchain | null;
|
|
43
|
+
claimed: bigint | null;
|
|
44
|
+
balance: bigint | null;
|
|
37
45
|
};
|
|
38
46
|
|
|
39
|
-
export {
|
|
47
|
+
export { type DropChainState, useDrop, useDropChain, useDropFile, useDropMints, useDrops, useMyDrops };
|
|
@@ -1,39 +1,47 @@
|
|
|
1
|
+
import * as _medialane_sdk from '@medialane/sdk';
|
|
2
|
+
import { ApiDrop, ApiDropMint, ApiDropListStatus } from '@medialane/sdk';
|
|
1
3
|
import * as swr from 'swr';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
+
import { DropOnchain, MedialaneClient } from '@medialane/sdk/starknet';
|
|
5
|
+
import { DropProvider } from './drop/types.js';
|
|
6
|
+
import 'starknet';
|
|
7
|
+
import '../components/fast-mint/types.js';
|
|
8
|
+
import 'react';
|
|
4
9
|
|
|
5
|
-
declare function
|
|
6
|
-
|
|
7
|
-
meta: ApiMeta | undefined;
|
|
10
|
+
declare function useDrops(getClient: () => MedialaneClient, status: ApiDropListStatus): {
|
|
11
|
+
drops: ApiDrop[];
|
|
8
12
|
isLoading: boolean;
|
|
9
13
|
error: any;
|
|
10
|
-
mutate: swr.KeyedMutator<{
|
|
11
|
-
data: ApiCollection[];
|
|
12
|
-
meta?: ApiMeta;
|
|
13
|
-
}>;
|
|
14
14
|
};
|
|
15
|
-
declare function useMyDrops(getClient: () => MedialaneClient,
|
|
16
|
-
drops:
|
|
15
|
+
declare function useMyDrops(getClient: () => MedialaneClient, organizer: string | null): {
|
|
16
|
+
drops: ApiDrop[];
|
|
17
17
|
isLoading: boolean;
|
|
18
18
|
error: any;
|
|
19
|
-
mutate: swr.KeyedMutator<ApiCollection[]>;
|
|
20
19
|
};
|
|
21
|
-
declare function
|
|
22
|
-
|
|
20
|
+
declare function useDrop(getClient: () => MedialaneClient, contract: string | null): {
|
|
21
|
+
drop: ApiDrop | null;
|
|
23
22
|
isLoading: boolean;
|
|
24
23
|
error: any;
|
|
25
|
-
mutate: swr.KeyedMutator<
|
|
24
|
+
mutate: swr.KeyedMutator<ApiDrop | null>;
|
|
26
25
|
};
|
|
27
|
-
declare function
|
|
28
|
-
|
|
26
|
+
declare function useDropMints(getClient: () => MedialaneClient, contract: string | null): {
|
|
27
|
+
mints: ApiDropMint[];
|
|
29
28
|
isLoading: boolean;
|
|
30
|
-
|
|
29
|
+
mutate: swr.KeyedMutator<_medialane_sdk.ApiResponse<ApiDropMint[]>>;
|
|
31
30
|
};
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
/** A file from the drop's metadata folder ("1" or "collection.json"). */
|
|
32
|
+
declare function useDropFile<T = Record<string, unknown>>(getClient: () => MedialaneClient, baseUri: string | null, name: string): NonNullable<T> | null;
|
|
33
|
+
interface DropChainState {
|
|
34
|
+
drop: DropOnchain | null;
|
|
35
|
+
claimed: bigint | null;
|
|
36
|
+
balance: bigint | null;
|
|
37
|
+
}
|
|
38
|
+
/** The drop's terms and supply, the wallet's claims and balance — read from chain. */
|
|
39
|
+
declare function useDropChain(provider: DropProvider, contract: string | null, wallet: string | null): {
|
|
35
40
|
error: any;
|
|
36
|
-
mutate: swr.KeyedMutator<
|
|
41
|
+
mutate: swr.KeyedMutator<DropChainState>;
|
|
42
|
+
drop: DropOnchain | null;
|
|
43
|
+
claimed: bigint | null;
|
|
44
|
+
balance: bigint | null;
|
|
37
45
|
};
|
|
38
46
|
|
|
39
|
-
export {
|
|
47
|
+
export { type DropChainState, useDrop, useDropChain, useDropFile, useDropMints, useDrops, useMyDrops };
|
package/dist/utils/use-drops.js
CHANGED
|
@@ -1,56 +1,51 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import useSWR from "swr";
|
|
3
|
+
import { dropClaimedBy, readDrop } from "@medialane/sdk/starknet";
|
|
3
4
|
import { useMedialaneClient } from "./use-medialane-client.js";
|
|
4
|
-
|
|
5
|
+
import { erc20Balance } from "./drop/chain.js";
|
|
6
|
+
const quiet = { revalidateOnFocus: false, shouldRetryOnError: false };
|
|
7
|
+
function useDrops(getClient, status) {
|
|
5
8
|
const client = useMedialaneClient(getClient);
|
|
6
|
-
const { data, error, isLoading
|
|
7
|
-
|
|
8
|
-
() => client.api.listCollections({ service: "drop-collection", hideEmpty: false, limit: 50 }),
|
|
9
|
-
{ revalidateOnFocus: false }
|
|
10
|
-
);
|
|
11
|
-
return { collections: data?.data ?? [], meta: data?.meta, isLoading, error, mutate };
|
|
9
|
+
const { data, error, isLoading } = useSWR(["drops", status], () => client.api.getDrops({ status, limit: 48 }), quiet);
|
|
10
|
+
return { drops: data?.data ?? [], isLoading, error };
|
|
12
11
|
}
|
|
13
|
-
function useMyDrops(getClient,
|
|
12
|
+
function useMyDrops(getClient, organizer) {
|
|
14
13
|
const client = useMedialaneClient(getClient);
|
|
15
|
-
const { data, error, isLoading
|
|
16
|
-
|
|
17
|
-
async () => (await client.api.listCollections({ service: "drop-collection", owner, limit: 50 })).data ?? [],
|
|
18
|
-
{ revalidateOnFocus: false }
|
|
19
|
-
);
|
|
20
|
-
return { drops: data ?? [], isLoading, error, mutate };
|
|
14
|
+
const { data, error, isLoading } = useSWR(organizer ? ["my-drops", organizer] : null, () => client.api.getDrops({ organizer, limit: 100 }), quiet);
|
|
15
|
+
return { drops: data?.data ?? [], isLoading, error };
|
|
21
16
|
}
|
|
22
|
-
function
|
|
17
|
+
function useDrop(getClient, contract) {
|
|
23
18
|
const client = useMedialaneClient(getClient);
|
|
24
|
-
const { data, error, isLoading, mutate } = useSWR(
|
|
25
|
-
|
|
26
|
-
() => client.api.getDropMintStatus(collection, wallet),
|
|
27
|
-
{ revalidateOnFocus: false, shouldRetryOnError: false }
|
|
28
|
-
);
|
|
29
|
-
return { mintStatus: data ?? null, isLoading, error, mutate };
|
|
19
|
+
const { data, error, isLoading, mutate } = useSWR(contract ? ["drop", contract] : null, () => client.api.getDrop(contract), { ...quiet, refreshInterval: 3e4 });
|
|
20
|
+
return { drop: data ?? null, isLoading, error, mutate };
|
|
30
21
|
}
|
|
31
|
-
function
|
|
22
|
+
function useDropMints(getClient, contract) {
|
|
32
23
|
const client = useMedialaneClient(getClient);
|
|
33
|
-
const { data,
|
|
34
|
-
|
|
35
|
-
() => client.api.getDropInfo(contract),
|
|
36
|
-
{ revalidateOnFocus: false, shouldRetryOnError: false }
|
|
37
|
-
);
|
|
38
|
-
return { dropInfo: data ?? null, isLoading, error };
|
|
24
|
+
const { data, isLoading, mutate } = useSWR(contract ? ["drop-mints", contract] : null, () => client.api.getDropMints(contract, { limit: 20 }), { ...quiet, refreshInterval: 3e4 });
|
|
25
|
+
return { mints: data?.data ?? [], isLoading, mutate };
|
|
39
26
|
}
|
|
40
|
-
function
|
|
27
|
+
function useDropFile(getClient, baseUri, name) {
|
|
41
28
|
const client = useMedialaneClient(getClient);
|
|
42
|
-
const { data,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
)
|
|
47
|
-
|
|
29
|
+
const { data } = useSWR(baseUri ? ["drop-file", baseUri, name] : null, async () => (await client.api.resolveMetadata(`${baseUri}${name}`)).data, quiet);
|
|
30
|
+
return data ?? null;
|
|
31
|
+
}
|
|
32
|
+
function useDropChain(provider, contract, wallet) {
|
|
33
|
+
const { data, mutate, error } = useSWR(contract ? ["drop-chain", contract, wallet] : null, async () => {
|
|
34
|
+
const drop = await readDrop(provider, contract);
|
|
35
|
+
const [claimed, balance] = await Promise.all([
|
|
36
|
+
wallet ? dropClaimedBy(provider, contract, wallet) : Promise.resolve(null),
|
|
37
|
+
wallet && drop.price > 0n ? erc20Balance(provider, drop.paymentToken, wallet) : Promise.resolve(null)
|
|
38
|
+
]);
|
|
39
|
+
return { drop, claimed, balance };
|
|
40
|
+
}, { revalidateOnFocus: true, refreshInterval: 15e3 });
|
|
41
|
+
return { ...data ?? { drop: null, claimed: null, balance: null }, error, mutate };
|
|
48
42
|
}
|
|
49
43
|
export {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
44
|
+
useDrop,
|
|
45
|
+
useDropChain,
|
|
46
|
+
useDropFile,
|
|
47
|
+
useDropMints,
|
|
48
|
+
useDrops,
|
|
49
|
+
useMyDrops
|
|
55
50
|
};
|
|
56
51
|
//# sourceMappingURL=use-drops.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/use-drops.ts"],"sourcesContent":["\"use client\";\n\nimport useSWR from \"swr\";\nimport type {
|
|
1
|
+
{"version":3,"sources":["../../src/utils/use-drops.ts"],"sourcesContent":["\"use client\";\n\nimport useSWR from \"swr\";\nimport type { ApiDrop, ApiDropListStatus, ApiDropMint } from \"@medialane/sdk\";\nimport { dropClaimedBy, readDrop, type DropOnchain, type MedialaneClient } from \"@medialane/sdk/starknet\";\nimport { useMedialaneClient } from \"./use-medialane-client.js\";\nimport { erc20Balance } from \"./drop/chain.js\";\nimport type { DropProvider } from \"./drop/types.js\";\n\nconst quiet = { revalidateOnFocus: false, shouldRetryOnError: false } as const;\n\nexport function useDrops(getClient: () => MedialaneClient, status: ApiDropListStatus) {\n const client = useMedialaneClient(getClient);\n const { data, error, isLoading } = useSWR([\"drops\", status], () => client.api.getDrops({ status, limit: 48 }), quiet);\n return { drops: data?.data ?? ([] as ApiDrop[]), isLoading, error };\n}\n\nexport function useMyDrops(getClient: () => MedialaneClient, organizer: string | null) {\n const client = useMedialaneClient(getClient);\n const { data, error, isLoading } = useSWR(organizer ? [\"my-drops\", organizer] : null, () => client.api.getDrops({ organizer: organizer!, limit: 100 }), quiet);\n return { drops: data?.data ?? ([] as ApiDrop[]), isLoading, error };\n}\n\nexport function useDrop(getClient: () => MedialaneClient, contract: string | null) {\n const client = useMedialaneClient(getClient);\n const { data, error, isLoading, mutate } = useSWR(contract ? [\"drop\", contract] : null, () => client.api.getDrop(contract!), { ...quiet, refreshInterval: 30_000 });\n return { drop: data ?? null, isLoading, error, mutate };\n}\n\nexport function useDropMints(getClient: () => MedialaneClient, contract: string | null) {\n const client = useMedialaneClient(getClient);\n const { data, isLoading, mutate } = useSWR(contract ? [\"drop-mints\", contract] : null, () => client.api.getDropMints(contract!, { limit: 20 }), { ...quiet, refreshInterval: 30_000 });\n return { mints: data?.data ?? ([] as ApiDropMint[]), isLoading, mutate };\n}\n\n/** A file from the drop's metadata folder (\"1\" or \"collection.json\"). */\nexport function useDropFile<T = Record<string, unknown>>(getClient: () => MedialaneClient, baseUri: string | null, name: string) {\n const client = useMedialaneClient(getClient);\n const { data } = useSWR(baseUri ? [\"drop-file\", baseUri, name] : null, async () => (await client.api.resolveMetadata(`${baseUri}${name}`)).data as T, quiet);\n return data ?? null;\n}\n\nexport interface DropChainState {\n drop: DropOnchain | null;\n claimed: bigint | null;\n balance: bigint | null;\n}\n\n/** The drop's terms and supply, the wallet's claims and balance — read from chain. */\nexport function useDropChain(provider: DropProvider, contract: string | null, wallet: string | null) {\n const { data, mutate, error } = useSWR(contract ? [\"drop-chain\", contract, wallet] : null, async (): Promise<DropChainState> => {\n const drop = await readDrop(provider, contract!);\n const [claimed, balance] = await Promise.all([\n wallet ? dropClaimedBy(provider, contract!, wallet) : Promise.resolve(null),\n wallet && drop.price > 0n ? erc20Balance(provider, drop.paymentToken, wallet) : Promise.resolve(null),\n ]);\n return { drop, claimed, balance };\n }, { revalidateOnFocus: true, refreshInterval: 15_000 });\n return { ...(data ?? { drop: null, claimed: null, balance: null }), error, mutate };\n}\n"],"mappings":";AAEA,OAAO,YAAY;AAEnB,SAAS,eAAe,gBAAwD;AAChF,SAAS,0BAA0B;AACnC,SAAS,oBAAoB;AAG7B,MAAM,QAAQ,EAAE,mBAAmB,OAAO,oBAAoB,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M,SAAS,mBAAmB,SAAS;AAC3C,QAAM,EAAE,KAAK,IAAI,OAAO,UAAU,CAAC,aAAa,SAAS,IAAI,IAAI,MAAM,aAAa,MAAM,OAAO,IAAI,gBAAgB,GAAG,OAAO,GAAG,IAAI,EAAE,GAAG,MAAW,KAAK;AAC3J,SAAO,QAAQ;AACjB;AASO,SAAS,aAAa,UAAwB,UAAyB,QAAuB;AACnG,QAAM,EAAE,MAAM,QAAQ,MAAM,IAAI,OAAO,WAAW,CAAC,cAAc,UAAU,MAAM,IAAI,MAAM,YAAqC;AAC9H,UAAM,OAAO,MAAM,SAAS,UAAU,QAAS;AAC/C,UAAM,CAAC,SAAS,OAAO,IAAI,MAAM,QAAQ,IAAI;AAAA,MAC3C,SAAS,cAAc,UAAU,UAAW,MAAM,IAAI,QAAQ,QAAQ,IAAI;AAAA,MAC1E,UAAU,KAAK,QAAQ,KAAK,aAAa,UAAU,KAAK,cAAc,MAAM,IAAI,QAAQ,QAAQ,IAAI;AAAA,IACtG,CAAC;AACD,WAAO,EAAE,MAAM,SAAS,QAAQ;AAAA,EAClC,GAAG,EAAE,mBAAmB,MAAM,iBAAiB,KAAO,CAAC;AACvD,SAAO,EAAE,GAAI,QAAQ,EAAE,MAAM,MAAM,SAAS,MAAM,SAAS,KAAK,GAAI,OAAO,OAAO;AACpF;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medialane/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.184.0",
|
|
4
4
|
"description": "Shared UI components for Medialane apps",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"preview": "vite --config preview/vite.config.ts"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
|
-
"@medialane/sdk": ">=0.
|
|
54
|
+
"@medialane/sdk": ">=0.170.0",
|
|
55
55
|
"@radix-ui/react-checkbox": ">=1.1.0",
|
|
56
56
|
"@radix-ui/react-collapsible": ">=1.1.0",
|
|
57
57
|
"@radix-ui/react-dialog": ">=1.1.0",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"zod": "^3.25.0"
|
|
81
81
|
},
|
|
82
82
|
"devDependencies": {
|
|
83
|
-
"@medialane/sdk": "0.
|
|
83
|
+
"@medialane/sdk": "0.170.0",
|
|
84
84
|
"@radix-ui/react-checkbox": "^1.3.8",
|
|
85
85
|
"@radix-ui/react-collapsible": "^1.1.17",
|
|
86
86
|
"@radix-ui/react-dialog": "^1.1.20",
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
3
|
-
var import_bun_test = require("bun:test");
|
|
4
|
-
var import_server = require("react-dom/server");
|
|
5
|
-
var import_lucide_react = require("lucide-react");
|
|
6
|
-
var import_account_section = require("./account-section.js");
|
|
7
|
-
var import_email_code_entry = require("./email-code-entry.js");
|
|
8
|
-
var import_devices_section = require("./devices-section.js");
|
|
9
|
-
var import_guardian_recovery_section = require("./guardian-recovery-section.js");
|
|
10
|
-
var import_email_code = require("../../utils/email-code.js");
|
|
11
|
-
const emailCode = (state) => ({
|
|
12
|
-
state: { ...import_email_code.initialEmailCodeState, ...state },
|
|
13
|
-
setCode: () => {
|
|
14
|
-
},
|
|
15
|
-
send: async () => true,
|
|
16
|
-
fail: () => {
|
|
17
|
-
},
|
|
18
|
-
verify: async () => true,
|
|
19
|
-
markReady: () => {
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
const wallet = {
|
|
23
|
-
getOwners: async () => [],
|
|
24
|
-
addDevice: async () => "",
|
|
25
|
-
removeDevice: async () => "",
|
|
26
|
-
getGuardians: async () => [],
|
|
27
|
-
getEscape: async () => ({ escapeType: "None", status: "None", readyAt: 0 }),
|
|
28
|
-
setFirstGuardian: async () => "",
|
|
29
|
-
cancelEscape: async () => ""
|
|
30
|
-
};
|
|
31
|
-
(0, import_bun_test.describe)("an account section", () => {
|
|
32
|
-
(0, import_bun_test.test)("shows its title, description and content", () => {
|
|
33
|
-
const html = (0, import_server.renderToStaticMarkup)(
|
|
34
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_account_section.AccountSection, { icon: import_lucide_react.Shield, title: "Devices", description: "Who can sign", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "content" }) })
|
|
35
|
-
);
|
|
36
|
-
(0, import_bun_test.expect)(html).toContain("Devices");
|
|
37
|
-
(0, import_bun_test.expect)(html).toContain("Who can sign");
|
|
38
|
-
(0, import_bun_test.expect)(html).toContain("content");
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
(0, import_bun_test.describe)("the email code entry", () => {
|
|
42
|
-
(0, import_bun_test.test)("says the code is being sent", () => {
|
|
43
|
-
(0, import_bun_test.expect)((0, import_server.renderToStaticMarkup)(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_email_code_entry.EmailCodeEntry, { emailCode: emailCode({ status: "sending" }), onVerify: () => {
|
|
44
|
-
} }))).toContain("Sending code");
|
|
45
|
-
});
|
|
46
|
-
(0, import_bun_test.test)("shows an error", () => {
|
|
47
|
-
const html = (0, import_server.renderToStaticMarkup)(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_email_code_entry.EmailCodeEntry, { emailCode: emailCode({ status: "ready", error: "Incorrect code" }), onVerify: () => {
|
|
48
|
-
} }));
|
|
49
|
-
(0, import_bun_test.expect)(html).toContain("Incorrect code");
|
|
50
|
-
});
|
|
51
|
-
(0, import_bun_test.test)("counts down before the code can be sent again", () => {
|
|
52
|
-
const html = (0, import_server.renderToStaticMarkup)(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_email_code_entry.EmailCodeEntry, { emailCode: emailCode({ status: "ready", cooldown: 30 }), onVerify: () => {
|
|
53
|
-
} }));
|
|
54
|
-
(0, import_bun_test.expect)(html).toContain("resend in 30s");
|
|
55
|
-
(0, import_bun_test.expect)(html).not.toContain("resend the code");
|
|
56
|
-
});
|
|
57
|
-
(0, import_bun_test.test)("offers a resend once the cooldown is over, and keeps verify off until six digits", () => {
|
|
58
|
-
const html = (0, import_server.renderToStaticMarkup)(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_email_code_entry.EmailCodeEntry, { emailCode: emailCode({ status: "ready", cooldown: 0, code: "123" }), onVerify: () => {
|
|
59
|
-
} }));
|
|
60
|
-
(0, import_bun_test.expect)(html).toContain("resend the code");
|
|
61
|
-
(0, import_bun_test.expect)(html).toMatch(/<button[^>]*disabled[^>]*>[^<]*Verify/);
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
(0, import_bun_test.describe)("the devices section", () => {
|
|
65
|
-
(0, import_bun_test.test)("starts with its heading and the add button while devices load", () => {
|
|
66
|
-
const html = (0, import_server.renderToStaticMarkup)(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_devices_section.DevicesSection, { walletAddress: "0x1", wallet, loadSealed: () => null }));
|
|
67
|
-
(0, import_bun_test.expect)(html).toContain("Your devices");
|
|
68
|
-
(0, import_bun_test.expect)(html).toContain("Add");
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
(0, import_bun_test.describe)("the guardian recovery section", () => {
|
|
72
|
-
(0, import_bun_test.test)("links to the app's recovery page", () => {
|
|
73
|
-
const html = (0, import_server.renderToStaticMarkup)(
|
|
74
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_guardian_recovery_section.GuardianRecoverySection, { walletAddress: "0x1", wallet, loadSealed: () => null, guardianRecoveryAvailable: true, recoverHref: "/settings/recovery" })
|
|
75
|
-
);
|
|
76
|
-
(0, import_bun_test.expect)(html).toContain("Guardian recovery");
|
|
77
|
-
(0, import_bun_test.expect)(html).toContain('href="/settings/recovery"');
|
|
78
|
-
});
|
|
79
|
-
(0, import_bun_test.test)("defaults the recovery link to /recover", () => {
|
|
80
|
-
const html = (0, import_server.renderToStaticMarkup)(
|
|
81
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_guardian_recovery_section.GuardianRecoverySection, { walletAddress: "0x1", wallet, loadSealed: () => null, guardianRecoveryAvailable: false })
|
|
82
|
-
);
|
|
83
|
-
(0, import_bun_test.expect)(html).toContain('href="/recover"');
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
//# sourceMappingURL=account.test.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/account/account.test.tsx"],"sourcesContent":["import { describe, expect, test } from \"bun:test\";\nimport { renderToStaticMarkup } from \"react-dom/server\";\nimport { Shield } from \"lucide-react\";\nimport { AccountSection } from \"./account-section.js\";\nimport { EmailCodeEntry } from \"./email-code-entry.js\";\nimport { DevicesSection } from \"./devices-section.js\";\nimport { GuardianRecoverySection } from \"./guardian-recovery-section.js\";\nimport { initialEmailCodeState, type EmailCodeState } from \"../../utils/email-code.js\";\nimport type { EmailCode } from \"../../utils/use-email-code.js\";\n\nconst emailCode = (state: Partial<EmailCodeState>): EmailCode => ({\n state: { ...initialEmailCodeState, ...state },\n setCode: () => {},\n send: async () => true,\n fail: () => {},\n verify: async () => true,\n markReady: () => {},\n});\n\nconst wallet = {\n getOwners: async () => [],\n addDevice: async () => \"\",\n removeDevice: async () => \"\",\n getGuardians: async () => [],\n getEscape: async () => ({ escapeType: \"None\", status: \"None\", readyAt: 0 }),\n setFirstGuardian: async () => \"\",\n cancelEscape: async () => \"\",\n} as never;\n\ndescribe(\"an account section\", () => {\n test(\"shows its title, description and content\", () => {\n const html = renderToStaticMarkup(\n <AccountSection icon={Shield} title=\"Devices\" description=\"Who can sign\">\n <p>content</p>\n </AccountSection>,\n );\n expect(html).toContain(\"Devices\");\n expect(html).toContain(\"Who can sign\");\n expect(html).toContain(\"content\");\n });\n});\n\ndescribe(\"the email code entry\", () => {\n test(\"says the code is being sent\", () => {\n expect(renderToStaticMarkup(<EmailCodeEntry emailCode={emailCode({ status: \"sending\" })} onVerify={() => {}} />)).toContain(\"Sending code\");\n });\n\n test(\"shows an error\", () => {\n const html = renderToStaticMarkup(<EmailCodeEntry emailCode={emailCode({ status: \"ready\", error: \"Incorrect code\" })} onVerify={() => {}} />);\n expect(html).toContain(\"Incorrect code\");\n });\n\n test(\"counts down before the code can be sent again\", () => {\n const html = renderToStaticMarkup(<EmailCodeEntry emailCode={emailCode({ status: \"ready\", cooldown: 30 })} onVerify={() => {}} />);\n expect(html).toContain(\"resend in 30s\");\n expect(html).not.toContain(\"resend the code\");\n });\n\n test(\"offers a resend once the cooldown is over, and keeps verify off until six digits\", () => {\n const html = renderToStaticMarkup(<EmailCodeEntry emailCode={emailCode({ status: \"ready\", cooldown: 0, code: \"123\" })} onVerify={() => {}} />);\n expect(html).toContain(\"resend the code\");\n expect(html).toMatch(/<button[^>]*disabled[^>]*>[^<]*Verify/);\n });\n});\n\ndescribe(\"the devices section\", () => {\n test(\"starts with its heading and the add button while devices load\", () => {\n const html = renderToStaticMarkup(<DevicesSection walletAddress=\"0x1\" wallet={wallet} loadSealed={() => null} />);\n expect(html).toContain(\"Your devices\");\n expect(html).toContain(\"Add\");\n });\n});\n\ndescribe(\"the guardian recovery section\", () => {\n test(\"links to the app's recovery page\", () => {\n const html = renderToStaticMarkup(\n <GuardianRecoverySection walletAddress=\"0x1\" wallet={wallet} loadSealed={() => null} guardianRecoveryAvailable recoverHref=\"/settings/recovery\" />,\n );\n expect(html).toContain(\"Guardian recovery\");\n expect(html).toContain('href=\"/settings/recovery\"');\n });\n\n test(\"defaults the recovery link to /recover\", () => {\n const html = renderToStaticMarkup(\n <GuardianRecoverySection walletAddress=\"0x1\" wallet={wallet} loadSealed={() => null} guardianRecoveryAvailable={false} />,\n );\n expect(html).toContain('href=\"/recover\"');\n });\n});\n"],"mappings":";AAiCQ;AAjCR,sBAAuC;AACvC,oBAAqC;AACrC,0BAAuB;AACvB,6BAA+B;AAC/B,8BAA+B;AAC/B,6BAA+B;AAC/B,uC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