@medialane/ui 0.183.0 → 0.185.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.
Files changed (259) hide show
  1. package/dist/components/drop/create/artwork-section.cjs +115 -0
  2. package/dist/components/drop/create/artwork-section.cjs.map +1 -0
  3. package/dist/components/drop/create/artwork-section.d.cts +23 -0
  4. package/dist/components/drop/create/artwork-section.d.ts +23 -0
  5. package/dist/components/drop/create/artwork-section.js +79 -0
  6. package/dist/components/drop/create/artwork-section.js.map +1 -0
  7. package/dist/components/drop/create/details-section.cjs +110 -0
  8. package/dist/components/drop/create/details-section.cjs.map +1 -0
  9. package/dist/components/drop/create/details-section.d.cts +11 -0
  10. package/dist/components/drop/create/details-section.d.ts +11 -0
  11. package/dist/components/drop/create/details-section.js +86 -0
  12. package/dist/components/drop/create/details-section.js.map +1 -0
  13. package/dist/components/drop/create/drop-create.cjs +114 -0
  14. package/dist/components/drop/create/drop-create.cjs.map +1 -0
  15. package/dist/components/drop/create/drop-create.d.cts +20 -0
  16. package/dist/components/drop/create/drop-create.d.ts +20 -0
  17. package/dist/components/drop/create/drop-create.js +79 -0
  18. package/dist/components/drop/create/drop-create.js.map +1 -0
  19. package/dist/components/drop/create/exclusive-fields.cjs +45 -0
  20. package/dist/components/drop/create/exclusive-fields.cjs.map +1 -0
  21. package/dist/components/drop/create/exclusive-fields.d.cts +14 -0
  22. package/dist/components/drop/create/exclusive-fields.d.ts +14 -0
  23. package/dist/components/drop/create/exclusive-fields.js +21 -0
  24. package/dist/components/drop/create/exclusive-fields.js.map +1 -0
  25. package/dist/components/drop/create/launch-dialog.cjs +196 -0
  26. package/dist/components/drop/create/launch-dialog.cjs.map +1 -0
  27. package/dist/components/drop/create/launch-dialog.d.cts +21 -0
  28. package/dist/components/drop/create/launch-dialog.d.ts +21 -0
  29. package/dist/components/drop/create/launch-dialog.js +171 -0
  30. package/dist/components/drop/create/launch-dialog.js.map +1 -0
  31. package/dist/components/drop/create/list-section.cjs +67 -0
  32. package/dist/components/drop/create/list-section.cjs.map +1 -0
  33. package/dist/components/drop/create/list-section.d.cts +11 -0
  34. package/dist/components/drop/create/list-section.d.ts +11 -0
  35. package/dist/components/drop/create/list-section.js +43 -0
  36. package/dist/components/drop/create/list-section.js.map +1 -0
  37. package/dist/components/drop/create/sale-section.cjs +78 -0
  38. package/dist/components/drop/create/sale-section.cjs.map +1 -0
  39. package/dist/components/drop/create/sale-section.d.cts +13 -0
  40. package/dist/components/drop/create/sale-section.d.ts +13 -0
  41. package/dist/components/drop/create/sale-section.js +54 -0
  42. package/dist/components/drop/create/sale-section.js.map +1 -0
  43. package/dist/components/drop/drop-card.cjs +81 -0
  44. package/dist/components/drop/drop-card.cjs.map +1 -0
  45. package/dist/components/drop/drop-card.d.cts +18 -0
  46. package/dist/components/drop/drop-card.d.ts +18 -0
  47. package/dist/components/drop/drop-card.js +45 -0
  48. package/dist/components/drop/drop-card.js.map +1 -0
  49. package/dist/components/drop/drop-features.cjs +44 -0
  50. package/dist/components/drop/drop-features.cjs.map +1 -0
  51. package/dist/components/drop/drop-features.d.cts +5 -0
  52. package/dist/components/drop/drop-features.d.ts +5 -0
  53. package/dist/components/drop/drop-features.js +20 -0
  54. package/dist/components/drop/drop-features.js.map +1 -0
  55. package/dist/components/drop/drop-listing.cjs +79 -0
  56. package/dist/components/drop/drop-listing.cjs.map +1 -0
  57. package/dist/components/drop/drop-listing.d.cts +10 -0
  58. package/dist/components/drop/drop-listing.d.ts +10 -0
  59. package/dist/components/drop/drop-listing.js +45 -0
  60. package/dist/components/drop/drop-listing.js.map +1 -0
  61. package/dist/components/{drop-status-display.cjs → drop/drop-status.cjs} +12 -43
  62. package/dist/components/drop/drop-status.cjs.map +1 -0
  63. package/dist/components/drop/drop-status.d.cts +13 -0
  64. package/dist/components/drop/drop-status.d.ts +13 -0
  65. package/dist/components/drop/drop-status.js +47 -0
  66. package/dist/components/drop/drop-status.js.map +1 -0
  67. package/dist/components/drop/drop-token-link.cjs +63 -0
  68. package/dist/components/drop/drop-token-link.cjs.map +1 -0
  69. package/dist/components/drop/drop-token-link.d.cts +9 -0
  70. package/dist/components/drop/drop-token-link.d.ts +9 -0
  71. package/dist/components/drop/drop-token-link.js +29 -0
  72. package/dist/components/drop/drop-token-link.js.map +1 -0
  73. package/dist/components/drop/my-drops.cjs +71 -0
  74. package/dist/components/drop/my-drops.cjs.map +1 -0
  75. package/dist/components/drop/my-drops.d.cts +12 -0
  76. package/dist/components/drop/my-drops.d.ts +12 -0
  77. package/dist/components/drop/my-drops.js +37 -0
  78. package/dist/components/drop/my-drops.js.map +1 -0
  79. package/dist/components/drop/page/drop-action-box.cjs +63 -0
  80. package/dist/components/drop/page/drop-action-box.cjs.map +1 -0
  81. package/dist/components/drop/page/drop-action-box.d.cts +15 -0
  82. package/dist/components/drop/page/drop-action-box.d.ts +15 -0
  83. package/dist/components/drop/page/drop-action-box.js +39 -0
  84. package/dist/components/drop/page/drop-action-box.js.map +1 -0
  85. package/dist/components/drop/page/drop-activity.cjs +42 -0
  86. package/dist/components/drop/page/drop-activity.cjs.map +1 -0
  87. package/dist/components/drop/page/drop-activity.d.cts +8 -0
  88. package/dist/components/drop/page/drop-activity.d.ts +8 -0
  89. package/dist/components/drop/page/drop-activity.js +18 -0
  90. package/dist/components/drop/page/drop-activity.js.map +1 -0
  91. package/dist/components/drop/page/drop-manage.cjs +161 -0
  92. package/dist/components/drop/page/drop-manage.cjs.map +1 -0
  93. package/dist/components/drop/page/drop-manage.d.cts +24 -0
  94. package/dist/components/drop/page/drop-manage.d.ts +24 -0
  95. package/dist/components/drop/page/drop-manage.js +137 -0
  96. package/dist/components/drop/page/drop-manage.js.map +1 -0
  97. package/dist/components/drop/page/drop-mint-dialog.cjs +97 -0
  98. package/dist/components/drop/page/drop-mint-dialog.cjs.map +1 -0
  99. package/dist/components/drop/page/drop-mint-dialog.d.cts +15 -0
  100. package/dist/components/drop/page/drop-mint-dialog.d.ts +15 -0
  101. package/dist/components/drop/page/drop-mint-dialog.js +73 -0
  102. package/dist/components/drop/page/drop-mint-dialog.js.map +1 -0
  103. package/dist/components/drop/page/drop-page.cjs +167 -0
  104. package/dist/components/drop/page/drop-page.cjs.map +1 -0
  105. package/dist/components/drop/page/drop-page.d.cts +15 -0
  106. package/dist/components/drop/page/drop-page.d.ts +15 -0
  107. package/dist/components/drop/page/drop-page.js +133 -0
  108. package/dist/components/drop/page/drop-page.js.map +1 -0
  109. package/dist/components/image.d.cts +2 -0
  110. package/dist/components/image.d.ts +2 -0
  111. package/dist/index.cjs +54 -30
  112. package/dist/index.cjs.map +1 -1
  113. package/dist/index.d.cts +21 -11
  114. package/dist/index.d.ts +21 -11
  115. package/dist/index.js +34 -25
  116. package/dist/index.js.map +1 -1
  117. package/dist/utils/drop/actions.cjs +76 -0
  118. package/dist/utils/drop/actions.cjs.map +1 -0
  119. package/dist/utils/drop/actions.d.cts +46 -0
  120. package/dist/utils/drop/actions.d.ts +46 -0
  121. package/dist/utils/drop/actions.js +49 -0
  122. package/dist/utils/drop/actions.js.map +1 -0
  123. package/dist/utils/drop/allowlist.cjs +50 -0
  124. package/dist/utils/drop/allowlist.cjs.map +1 -0
  125. package/dist/utils/drop/allowlist.d.cts +10 -0
  126. package/dist/utils/drop/allowlist.d.ts +10 -0
  127. package/dist/utils/drop/allowlist.js +26 -0
  128. package/dist/utils/drop/allowlist.js.map +1 -0
  129. package/dist/utils/drop/chain.cjs +37 -0
  130. package/dist/utils/drop/chain.cjs.map +1 -0
  131. package/dist/utils/drop/chain.d.cts +5 -0
  132. package/dist/utils/drop/chain.d.ts +5 -0
  133. package/dist/utils/drop/chain.js +13 -0
  134. package/dist/utils/drop/chain.js.map +1 -0
  135. package/dist/utils/drop/claim-proof.cjs +48 -0
  136. package/dist/utils/drop/claim-proof.cjs.map +1 -0
  137. package/dist/utils/drop/claim-proof.d.cts +9 -0
  138. package/dist/utils/drop/claim-proof.d.ts +9 -0
  139. package/dist/utils/drop/claim-proof.js +24 -0
  140. package/dist/utils/drop/claim-proof.js.map +1 -0
  141. package/dist/utils/drop/draft.cjs +87 -0
  142. package/dist/utils/drop/draft.cjs.map +1 -0
  143. package/dist/utils/drop/draft.d.cts +32 -0
  144. package/dist/utils/drop/draft.d.ts +32 -0
  145. package/dist/utils/drop/draft.js +61 -0
  146. package/dist/utils/drop/draft.js.map +1 -0
  147. package/dist/utils/drop/metadata.cjs +70 -0
  148. package/dist/utils/drop/metadata.cjs.map +1 -0
  149. package/dist/utils/drop/metadata.d.cts +34 -0
  150. package/dist/utils/drop/metadata.d.ts +34 -0
  151. package/dist/utils/drop/metadata.js +43 -0
  152. package/dist/utils/drop/metadata.js.map +1 -0
  153. package/dist/utils/{drop-status.cjs → drop/preview.cjs} +14 -14
  154. package/dist/utils/drop/preview.cjs.map +1 -0
  155. package/dist/utils/drop/preview.d.cts +4 -0
  156. package/dist/utils/drop/preview.d.ts +4 -0
  157. package/dist/utils/drop/preview.js +13 -0
  158. package/dist/utils/drop/preview.js.map +1 -0
  159. package/dist/utils/drop/receipt.cjs +39 -0
  160. package/dist/utils/drop/receipt.cjs.map +1 -0
  161. package/dist/utils/drop/receipt.d.cts +6 -0
  162. package/dist/utils/drop/receipt.d.ts +6 -0
  163. package/dist/utils/drop/receipt.js +15 -0
  164. package/dist/utils/drop/receipt.js.map +1 -0
  165. package/dist/utils/drop/sale.cjs +108 -0
  166. package/dist/utils/drop/sale.cjs.map +1 -0
  167. package/dist/utils/drop/sale.d.cts +52 -0
  168. package/dist/utils/drop/sale.d.ts +52 -0
  169. package/dist/utils/drop/sale.js +78 -0
  170. package/dist/utils/drop/sale.js.map +1 -0
  171. package/dist/utils/drop/types.cjs +17 -0
  172. package/dist/utils/drop/types.cjs.map +1 -0
  173. package/dist/utils/drop/types.d.cts +20 -0
  174. package/dist/utils/drop/types.d.ts +20 -0
  175. package/dist/utils/drop/types.js +1 -0
  176. package/dist/utils/drop/types.js.map +1 -0
  177. package/dist/utils/drop/upload.cjs +48 -0
  178. package/dist/utils/drop/upload.cjs.map +1 -0
  179. package/dist/utils/drop/upload.d.cts +11 -0
  180. package/dist/utils/drop/upload.d.ts +11 -0
  181. package/dist/utils/drop/upload.js +24 -0
  182. package/dist/utils/drop/upload.js.map +1 -0
  183. package/dist/utils/drop/use-now.cjs +38 -0
  184. package/dist/utils/drop/use-now.cjs.map +1 -0
  185. package/dist/utils/drop/use-now.d.cts +4 -0
  186. package/dist/utils/drop/use-now.d.ts +4 -0
  187. package/dist/utils/drop/use-now.js +14 -0
  188. package/dist/utils/drop/use-now.js.map +1 -0
  189. package/dist/utils/drop/view.cjs +89 -0
  190. package/dist/utils/drop/view.cjs.map +1 -0
  191. package/dist/utils/drop/view.d.cts +34 -0
  192. package/dist/utils/drop/view.d.ts +34 -0
  193. package/dist/utils/drop/view.js +64 -0
  194. package/dist/utils/drop/view.js.map +1 -0
  195. package/dist/utils/launchpad-defaults.cjs +0 -22
  196. package/dist/utils/launchpad-defaults.cjs.map +1 -1
  197. package/dist/utils/launchpad-defaults.d.cts +1 -7
  198. package/dist/utils/launchpad-defaults.d.ts +1 -7
  199. package/dist/utils/launchpad-defaults.js +0 -21
  200. package/dist/utils/launchpad-defaults.js.map +1 -1
  201. package/dist/utils/use-drops.cjs +48 -45
  202. package/dist/utils/use-drops.cjs.map +1 -1
  203. package/dist/utils/use-drops.d.cts +33 -23
  204. package/dist/utils/use-drops.d.ts +33 -23
  205. package/dist/utils/use-drops.js +41 -40
  206. package/dist/utils/use-drops.js.map +1 -1
  207. package/package.json +3 -3
  208. package/dist/components/account/account.test.cjs +0 -86
  209. package/dist/components/account/account.test.cjs.map +0 -1
  210. package/dist/components/account/account.test.d.cts +0 -2
  211. package/dist/components/account/account.test.d.ts +0 -2
  212. package/dist/components/account/account.test.js +0 -85
  213. package/dist/components/account/account.test.js.map +0 -1
  214. package/dist/components/drop-create-form.cjs +0 -341
  215. package/dist/components/drop-create-form.cjs.map +0 -1
  216. package/dist/components/drop-create-form.d.cts +0 -39
  217. package/dist/components/drop-create-form.d.ts +0 -39
  218. package/dist/components/drop-create-form.js +0 -322
  219. package/dist/components/drop-create-form.js.map +0 -1
  220. package/dist/components/drop-preview-card.cjs +0 -106
  221. package/dist/components/drop-preview-card.cjs.map +0 -1
  222. package/dist/components/drop-preview-card.d.cts +0 -17
  223. package/dist/components/drop-preview-card.d.ts +0 -17
  224. package/dist/components/drop-preview-card.js +0 -82
  225. package/dist/components/drop-preview-card.js.map +0 -1
  226. package/dist/components/drop-preview-card.test.cjs +0 -84
  227. package/dist/components/drop-preview-card.test.cjs.map +0 -1
  228. package/dist/components/drop-preview-card.test.d.cts +0 -3
  229. package/dist/components/drop-preview-card.test.d.ts +0 -3
  230. package/dist/components/drop-preview-card.test.js +0 -83
  231. package/dist/components/drop-preview-card.test.js.map +0 -1
  232. package/dist/components/drop-status-display.cjs.map +0 -1
  233. package/dist/components/drop-status-display.d.cts +0 -15
  234. package/dist/components/drop-status-display.d.ts +0 -15
  235. package/dist/components/drop-status-display.js +0 -77
  236. package/dist/components/drop-status-display.js.map +0 -1
  237. package/dist/components/drop-status-display.test.cjs +0 -29
  238. package/dist/components/drop-status-display.test.cjs.map +0 -1
  239. package/dist/components/drop-status-display.test.d.cts +0 -2
  240. package/dist/components/drop-status-display.test.d.ts +0 -2
  241. package/dist/components/drop-status-display.test.js +0 -28
  242. package/dist/components/drop-status-display.test.js.map +0 -1
  243. package/dist/components/exclusive-content-section.cjs +0 -88
  244. package/dist/components/exclusive-content-section.cjs.map +0 -1
  245. package/dist/components/exclusive-content-section.d.cts +0 -10
  246. package/dist/components/exclusive-content-section.d.ts +0 -10
  247. package/dist/components/exclusive-content-section.js +0 -64
  248. package/dist/components/exclusive-content-section.js.map +0 -1
  249. package/dist/data/drop-create-schema.cjs +0 -92
  250. package/dist/data/drop-create-schema.cjs.map +0 -1
  251. package/dist/data/drop-create-schema.d.cts +0 -131
  252. package/dist/data/drop-create-schema.d.ts +0 -131
  253. package/dist/data/drop-create-schema.js +0 -58
  254. package/dist/data/drop-create-schema.js.map +0 -1
  255. package/dist/utils/drop-status.cjs.map +0 -1
  256. package/dist/utils/drop-status.d.cts +0 -12
  257. package/dist/utils/drop-status.d.ts +0 -12
  258. package/dist/utils/drop-status.js +0 -13
  259. package/dist/utils/drop-status.js.map +0 -1
@@ -29,66 +29,69 @@ 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
- useDropCollections: () => useDropCollections,
33
- useDropInfo: () => useDropInfo,
34
- useDropMintStatus: () => useDropMintStatus,
35
- useMyDrops: () => useMyDrops,
36
- useOnChainDropState: () => useOnChainDropState
32
+ useDrop: () => useDrop,
33
+ useDropChain: () => useDropChain,
34
+ useDropFee: () => useDropFee,
35
+ useDropFile: () => useDropFile,
36
+ useDropMints: () => useDropMints,
37
+ useDrops: () => useDrops,
38
+ useMyDrops: () => useMyDrops
37
39
  });
38
40
  module.exports = __toCommonJS(use_drops_exports);
39
41
  var import_swr = __toESM(require("swr"), 1);
42
+ var import_starknet = require("@medialane/sdk/starknet");
40
43
  var import_use_medialane_client = require("./use-medialane-client.js");
41
- function useDropCollections(getClient) {
44
+ var import_chain = require("./drop/chain.js");
45
+ const quiet = { revalidateOnFocus: false, shouldRetryOnError: false };
46
+ function useDrops(getClient, status) {
42
47
  const client = (0, import_use_medialane_client.useMedialaneClient)(getClient);
43
- const { data, error, isLoading, mutate } = (0, import_swr.default)(
44
- "drop-collections",
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 };
48
+ const { data, error, isLoading } = (0, import_swr.default)(["drops", status], () => client.api.getDrops({ status, limit: 48 }), quiet);
49
+ return { drops: data?.data ?? [], isLoading, error };
49
50
  }
50
- function useMyDrops(getClient, owner) {
51
+ function useMyDrops(getClient, organizer) {
51
52
  const client = (0, import_use_medialane_client.useMedialaneClient)(getClient);
52
- const { data, error, isLoading, mutate } = (0, import_swr.default)(
53
- owner ? `my-drops-${owner}` : null,
54
- async () => (await client.api.listCollections({ service: "drop-collection", owner, limit: 50 })).data ?? [],
55
- { revalidateOnFocus: false }
56
- );
57
- return { drops: data ?? [], isLoading, error, mutate };
53
+ const { data, error, isLoading } = (0, import_swr.default)(organizer ? ["my-drops", organizer] : null, () => client.api.getDrops({ organizer, limit: 100 }), quiet);
54
+ return { drops: data?.data ?? [], isLoading, error };
58
55
  }
59
- function useDropMintStatus(getClient, collection, wallet) {
56
+ function useDrop(getClient, contract) {
60
57
  const client = (0, import_use_medialane_client.useMedialaneClient)(getClient);
61
- const { data, error, isLoading, mutate } = (0, import_swr.default)(
62
- collection && wallet ? `drop-mint-status-${collection}-${wallet}` : null,
63
- () => client.api.getDropMintStatus(collection, wallet),
64
- { revalidateOnFocus: false, shouldRetryOnError: false }
65
- );
66
- return { mintStatus: data ?? null, isLoading, error, mutate };
58
+ const { data, error, isLoading, mutate } = (0, import_swr.default)(contract ? ["drop", contract] : null, () => client.api.getDrop(contract), { ...quiet, refreshInterval: 3e4 });
59
+ return { drop: data ?? null, isLoading, error, mutate };
67
60
  }
68
- function useDropInfo(getClient, contract) {
61
+ function useDropMints(getClient, contract) {
69
62
  const client = (0, import_use_medialane_client.useMedialaneClient)(getClient);
70
- const { data, error, isLoading } = (0, import_swr.default)(
71
- contract ? `drop-info-${contract}` : null,
72
- () => client.api.getDropInfo(contract),
73
- { revalidateOnFocus: false, shouldRetryOnError: false }
74
- );
75
- return { dropInfo: data ?? null, isLoading, error };
63
+ const { data, isLoading, mutate } = (0, import_swr.default)(contract ? ["drop-mints", contract] : null, () => client.api.getDropMints(contract, { limit: 20 }), { ...quiet, refreshInterval: 3e4 });
64
+ return { mints: data?.data ?? [], isLoading, mutate };
76
65
  }
77
- function useOnChainDropState(getClient, contract) {
66
+ function useDropFee(getClient) {
78
67
  const client = (0, import_use_medialane_client.useMedialaneClient)(getClient);
79
- const { data, error, isLoading, mutate } = (0, import_swr.default)(
80
- contract ? `drop-onchain-${contract}` : null,
81
- () => client.api.getDropState(contract),
82
- { revalidateOnFocus: false, refreshInterval: 3e4, shouldRetryOnError: false }
83
- );
84
- return { state: data ?? null, isLoading, error, mutate };
68
+ const { data } = (0, import_swr.default)("drop-fee", () => client.api.getDropFee(), { revalidateOnFocus: false });
69
+ return data?.launchpadBps ?? null;
70
+ }
71
+ function useDropFile(getClient, baseUri, name) {
72
+ const client = (0, import_use_medialane_client.useMedialaneClient)(getClient);
73
+ const { data } = (0, import_swr.default)(baseUri ? ["drop-file", baseUri, name] : null, async () => (await client.api.resolveMetadata(`${baseUri}${name}`)).data, quiet);
74
+ return data ?? null;
75
+ }
76
+ function useDropChain(provider, contract, wallet) {
77
+ const { data, mutate, error } = (0, import_swr.default)(contract ? ["drop-chain", contract, wallet] : null, async () => {
78
+ const drop = await (0, import_starknet.readDrop)(provider, contract);
79
+ const [claimed, balance] = await Promise.all([
80
+ wallet ? (0, import_starknet.dropClaimedBy)(provider, contract, wallet) : Promise.resolve(null),
81
+ wallet && drop.price > 0n ? (0, import_chain.erc20Balance)(provider, drop.paymentToken, wallet) : Promise.resolve(null)
82
+ ]);
83
+ return { drop, claimed, balance };
84
+ }, { revalidateOnFocus: true, refreshInterval: 15e3 });
85
+ return { ...data ?? { drop: null, claimed: null, balance: null }, error, mutate };
85
86
  }
86
87
  // Annotate the CommonJS export names for ESM import in node:
87
88
  0 && (module.exports = {
88
- useDropCollections,
89
- useDropInfo,
90
- useDropMintStatus,
91
- useMyDrops,
92
- useOnChainDropState
89
+ useDrop,
90
+ useDropChain,
91
+ useDropFee,
92
+ useDropFile,
93
+ useDropMints,
94
+ useDrops,
95
+ useMyDrops
93
96
  });
94
97
  //# 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 { ApiCollection, ApiDropInfo, ApiDropState, ApiMeta, DropMintStatus } from \"@medialane/sdk\";\nimport type { MedialaneClient } from \"@medialane/sdk/starknet\";\nimport { useMedialaneClient } from \"./use-medialane-client.js\";\n\nexport function useDropCollections(getClient: () => MedialaneClient) {\n const client = useMedialaneClient(getClient);\n const { data, error, isLoading, mutate } = useSWR<{ data: ApiCollection[]; meta?: ApiMeta }>(\n \"drop-collections\",\n () => client.api.listCollections({ service: \"drop-collection\", hideEmpty: false, limit: 50 }),\n { revalidateOnFocus: false }\n );\n return { collections: data?.data ?? [], meta: data?.meta, isLoading, error, mutate };\n}\n\nexport function useMyDrops(getClient: () => MedialaneClient, owner: string | null) {\n const client = useMedialaneClient(getClient);\n const { data, error, isLoading, mutate } = useSWR<ApiCollection[]>(\n owner ? `my-drops-${owner}` : null,\n async () => (await client.api.listCollections({ service: \"drop-collection\", owner: owner!, limit: 50 })).data ?? [],\n { revalidateOnFocus: false }\n );\n return { drops: data ?? [], isLoading, error, mutate };\n}\n\nexport function useDropMintStatus(getClient: () => MedialaneClient, collection: string | null, wallet: string | null) {\n const client = useMedialaneClient(getClient);\n const { data, error, isLoading, mutate } = useSWR<DropMintStatus>(\n collection && wallet ? `drop-mint-status-${collection}-${wallet}` : null,\n () => client.api.getDropMintStatus(collection!, wallet!),\n { revalidateOnFocus: false, shouldRetryOnError: false }\n );\n return { mintStatus: data ?? null, isLoading, error, mutate };\n}\n\nexport function useDropInfo(getClient: () => MedialaneClient, contract: string | null) {\n const client = useMedialaneClient(getClient);\n const { data, error, isLoading } = useSWR<ApiDropInfo | null>(\n contract ? `drop-info-${contract}` : null,\n () => client.api.getDropInfo(contract!),\n { revalidateOnFocus: false, shouldRetryOnError: false }\n );\n return { dropInfo: data ?? null, isLoading, error };\n}\n\nexport function useOnChainDropState(getClient: () => MedialaneClient, contract: string | null) {\n const client = useMedialaneClient(getClient);\n const { data, error, isLoading, mutate } = useSWR<ApiDropState>(\n contract ? `drop-onchain-${contract}` : null,\n () => client.api.getDropState(contract!),\n { revalidateOnFocus: false, refreshInterval: 30_000, shouldRetryOnError: false }\n );\n return { state: data ?? null, isLoading, error, mutate };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,iBAAmB;AAGnB,kCAAmC;AAE5B,SAAS,mBAAmB,WAAkC;AACnE,QAAM,aAAS,gDAAmB,SAAS;AAC3C,QAAM,EAAE,MAAM,OAAO,WAAW,OAAO,QAAI,WAAAA;AAAA,IACzC;AAAA,IACA,MAAM,OAAO,IAAI,gBAAgB,EAAE,SAAS,mBAAmB,WAAW,OAAO,OAAO,GAAG,CAAC;AAAA,IAC5F,EAAE,mBAAmB,MAAM;AAAA,EAC7B;AACA,SAAO,EAAE,aAAa,MAAM,QAAQ,CAAC,GAAG,MAAM,MAAM,MAAM,WAAW,OAAO,OAAO;AACrF;AAEO,SAAS,WAAW,WAAkC,OAAsB;AACjF,QAAM,aAAS,gDAAmB,SAAS;AAC3C,QAAM,EAAE,MAAM,OAAO,WAAW,OAAO,QAAI,WAAAA;AAAA,IACzC,QAAQ,YAAY,KAAK,KAAK;AAAA,IAC9B,aAAa,MAAM,OAAO,IAAI,gBAAgB,EAAE,SAAS,mBAAmB,OAAe,OAAO,GAAG,CAAC,GAAG,QAAQ,CAAC;AAAA,IAClH,EAAE,mBAAmB,MAAM;AAAA,EAC7B;AACA,SAAO,EAAE,OAAO,QAAQ,CAAC,GAAG,WAAW,OAAO,OAAO;AACvD;AAEO,SAAS,kBAAkB,WAAkC,YAA2B,QAAuB;AACpH,QAAM,aAAS,gDAAmB,SAAS;AAC3C,QAAM,EAAE,MAAM,OAAO,WAAW,OAAO,QAAI,WAAAA;AAAA,IACzC,cAAc,SAAS,oBAAoB,UAAU,IAAI,MAAM,KAAK;AAAA,IACpE,MAAM,OAAO,IAAI,kBAAkB,YAAa,MAAO;AAAA,IACvD,EAAE,mBAAmB,OAAO,oBAAoB,MAAM;AAAA,EACxD;AACA,SAAO,EAAE,YAAY,QAAQ,MAAM,WAAW,OAAO,OAAO;AAC9D;AAEO,SAAS,YAAY,WAAkC,UAAyB;AACrF,QAAM,aAAS,gDAAmB,SAAS;AAC3C,QAAM,EAAE,MAAM,OAAO,UAAU,QAAI,WAAAA;AAAA,IACjC,WAAW,aAAa,QAAQ,KAAK;AAAA,IACrC,MAAM,OAAO,IAAI,YAAY,QAAS;AAAA,IACtC,EAAE,mBAAmB,OAAO,oBAAoB,MAAM;AAAA,EACxD;AACA,SAAO,EAAE,UAAU,QAAQ,MAAM,WAAW,MAAM;AACpD;AAEO,SAAS,oBAAoB,WAAkC,UAAyB;AAC7F,QAAM,aAAS,gDAAmB,SAAS;AAC3C,QAAM,EAAE,MAAM,OAAO,WAAW,OAAO,QAAI,WAAAA;AAAA,IACzC,WAAW,gBAAgB,QAAQ,KAAK;AAAA,IACxC,MAAM,OAAO,IAAI,aAAa,QAAS;AAAA,IACvC,EAAE,mBAAmB,OAAO,iBAAiB,KAAQ,oBAAoB,MAAM;AAAA,EACjF;AACA,SAAO,EAAE,OAAO,QAAQ,MAAM,WAAW,OAAO,OAAO;AACzD;","names":["useSWR"]}
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/** The platform fee, in basis points, the backend adds to a mint for this app; null until known. */\nexport function useDropFee(getClient: () => MedialaneClient): number | null {\n const client = useMedialaneClient(getClient);\n const { data } = useSWR(\"drop-fee\", () => client.api.getDropFee(), { revalidateOnFocus: false });\n return data?.launchpadBps ?? null;\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;AAAA;AAEA,iBAAmB;AAEnB,sBAAgF;AAChF,kCAAmC;AACnC,mBAA6B;AAG7B,MAAM,QAAQ,EAAE,mBAAmB,OAAO,oBAAoB,MAAM;AAE7D,SAAS,SAAS,WAAkC,QAA2B;AACpF,QAAM,aAAS,gDAAmB,SAAS;AAC3C,QAAM,EAAE,MAAM,OAAO,UAAU,QAAI,WAAAA,SAAO,CAAC,SAAS,MAAM,GAAG,MAAM,OAAO,IAAI,SAAS,EAAE,QAAQ,OAAO,GAAG,CAAC,GAAG,KAAK;AACpH,SAAO,EAAE,OAAO,MAAM,QAAS,CAAC,GAAiB,WAAW,MAAM;AACpE;AAEO,SAAS,WAAW,WAAkC,WAA0B;AACrF,QAAM,aAAS,gDAAmB,SAAS;AAC3C,QAAM,EAAE,MAAM,OAAO,UAAU,QAAI,WAAAA,SAAO,YAAY,CAAC,YAAY,SAAS,IAAI,MAAM,MAAM,OAAO,IAAI,SAAS,EAAE,WAAuB,OAAO,IAAI,CAAC,GAAG,KAAK;AAC7J,SAAO,EAAE,OAAO,MAAM,QAAS,CAAC,GAAiB,WAAW,MAAM;AACpE;AAEO,SAAS,QAAQ,WAAkC,UAAyB;AACjF,QAAM,aAAS,gDAAmB,SAAS;AAC3C,QAAM,EAAE,MAAM,OAAO,WAA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Q,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,49 @@
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 { ApiCollection, ApiMeta, ApiDropInfo, DropMintStatus, ApiDropState } from '@medialane/sdk';
3
- import { MedialaneClient } from '@medialane/sdk/starknet';
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 useDropCollections(getClient: () => MedialaneClient): {
6
- collections: ApiCollection[];
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, owner: string | null): {
16
- drops: ApiCollection[];
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 useDropMintStatus(getClient: () => MedialaneClient, collection: string | null, wallet: string | null): {
22
- mintStatus: DropMintStatus | null;
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<DropMintStatus>;
24
+ mutate: swr.KeyedMutator<ApiDrop | null>;
26
25
  };
27
- declare function useDropInfo(getClient: () => MedialaneClient, contract: string | null): {
28
- dropInfo: ApiDropInfo | null;
26
+ declare function useDropMints(getClient: () => MedialaneClient, contract: string | null): {
27
+ mints: ApiDropMint[];
29
28
  isLoading: boolean;
30
- error: any;
29
+ mutate: swr.KeyedMutator<_medialane_sdk.ApiResponse<ApiDropMint[]>>;
31
30
  };
32
- declare function useOnChainDropState(getClient: () => MedialaneClient, contract: string | null): {
33
- state: ApiDropState | null;
34
- isLoading: boolean;
31
+ /** The platform fee, in basis points, the backend adds to a mint for this app; null until known. */
32
+ declare function useDropFee(getClient: () => MedialaneClient): number | null;
33
+ /** A file from the drop's metadata folder ("1" or "collection.json"). */
34
+ declare function useDropFile<T = Record<string, unknown>>(getClient: () => MedialaneClient, baseUri: string | null, name: string): NonNullable<T> | null;
35
+ interface DropChainState {
36
+ drop: DropOnchain | null;
37
+ claimed: bigint | null;
38
+ balance: bigint | null;
39
+ }
40
+ /** The drop's terms and supply, the wallet's claims and balance — read from chain. */
41
+ declare function useDropChain(provider: DropProvider, contract: string | null, wallet: string | null): {
35
42
  error: any;
36
- mutate: swr.KeyedMutator<ApiDropState>;
43
+ mutate: swr.KeyedMutator<DropChainState>;
44
+ drop: DropOnchain | null;
45
+ claimed: bigint | null;
46
+ balance: bigint | null;
37
47
  };
38
48
 
39
- export { useDropCollections, useDropInfo, useDropMintStatus, useMyDrops, useOnChainDropState };
49
+ export { type DropChainState, useDrop, useDropChain, useDropFee, useDropFile, useDropMints, useDrops, useMyDrops };
@@ -1,39 +1,49 @@
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 { ApiCollection, ApiMeta, ApiDropInfo, DropMintStatus, ApiDropState } from '@medialane/sdk';
3
- import { MedialaneClient } from '@medialane/sdk/starknet';
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 useDropCollections(getClient: () => MedialaneClient): {
6
- collections: ApiCollection[];
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, owner: string | null): {
16
- drops: ApiCollection[];
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 useDropMintStatus(getClient: () => MedialaneClient, collection: string | null, wallet: string | null): {
22
- mintStatus: DropMintStatus | null;
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<DropMintStatus>;
24
+ mutate: swr.KeyedMutator<ApiDrop | null>;
26
25
  };
27
- declare function useDropInfo(getClient: () => MedialaneClient, contract: string | null): {
28
- dropInfo: ApiDropInfo | null;
26
+ declare function useDropMints(getClient: () => MedialaneClient, contract: string | null): {
27
+ mints: ApiDropMint[];
29
28
  isLoading: boolean;
30
- error: any;
29
+ mutate: swr.KeyedMutator<_medialane_sdk.ApiResponse<ApiDropMint[]>>;
31
30
  };
32
- declare function useOnChainDropState(getClient: () => MedialaneClient, contract: string | null): {
33
- state: ApiDropState | null;
34
- isLoading: boolean;
31
+ /** The platform fee, in basis points, the backend adds to a mint for this app; null until known. */
32
+ declare function useDropFee(getClient: () => MedialaneClient): number | null;
33
+ /** A file from the drop's metadata folder ("1" or "collection.json"). */
34
+ declare function useDropFile<T = Record<string, unknown>>(getClient: () => MedialaneClient, baseUri: string | null, name: string): NonNullable<T> | null;
35
+ interface DropChainState {
36
+ drop: DropOnchain | null;
37
+ claimed: bigint | null;
38
+ balance: bigint | null;
39
+ }
40
+ /** The drop's terms and supply, the wallet's claims and balance — read from chain. */
41
+ declare function useDropChain(provider: DropProvider, contract: string | null, wallet: string | null): {
35
42
  error: any;
36
- mutate: swr.KeyedMutator<ApiDropState>;
43
+ mutate: swr.KeyedMutator<DropChainState>;
44
+ drop: DropOnchain | null;
45
+ claimed: bigint | null;
46
+ balance: bigint | null;
37
47
  };
38
48
 
39
- export { useDropCollections, useDropInfo, useDropMintStatus, useMyDrops, useOnChainDropState };
49
+ export { type DropChainState, useDrop, useDropChain, useDropFee, useDropFile, useDropMints, useDrops, useMyDrops };
@@ -1,56 +1,57 @@
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
- function useDropCollections(getClient) {
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, mutate } = useSWR(
7
- "drop-collections",
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, owner) {
12
+ function useMyDrops(getClient, organizer) {
14
13
  const client = useMedialaneClient(getClient);
15
- const { data, error, isLoading, mutate } = useSWR(
16
- owner ? `my-drops-${owner}` : null,
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 useDropMintStatus(getClient, collection, wallet) {
17
+ function useDrop(getClient, contract) {
23
18
  const client = useMedialaneClient(getClient);
24
- const { data, error, isLoading, mutate } = useSWR(
25
- collection && wallet ? `drop-mint-status-${collection}-${wallet}` : null,
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 useDropInfo(getClient, contract) {
22
+ function useDropMints(getClient, contract) {
32
23
  const client = useMedialaneClient(getClient);
33
- const { data, error, isLoading } = useSWR(
34
- contract ? `drop-info-${contract}` : null,
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 useOnChainDropState(getClient, contract) {
27
+ function useDropFee(getClient) {
41
28
  const client = useMedialaneClient(getClient);
42
- const { data, error, isLoading, mutate } = useSWR(
43
- contract ? `drop-onchain-${contract}` : null,
44
- () => client.api.getDropState(contract),
45
- { revalidateOnFocus: false, refreshInterval: 3e4, shouldRetryOnError: false }
46
- );
47
- return { state: data ?? null, isLoading, error, mutate };
29
+ const { data } = useSWR("drop-fee", () => client.api.getDropFee(), { revalidateOnFocus: false });
30
+ return data?.launchpadBps ?? null;
31
+ }
32
+ function useDropFile(getClient, baseUri, name) {
33
+ const client = useMedialaneClient(getClient);
34
+ const { data } = useSWR(baseUri ? ["drop-file", baseUri, name] : null, async () => (await client.api.resolveMetadata(`${baseUri}${name}`)).data, quiet);
35
+ return data ?? null;
36
+ }
37
+ function useDropChain(provider, contract, wallet) {
38
+ const { data, mutate, error } = useSWR(contract ? ["drop-chain", contract, wallet] : null, async () => {
39
+ const drop = await readDrop(provider, contract);
40
+ const [claimed, balance] = await Promise.all([
41
+ wallet ? dropClaimedBy(provider, contract, wallet) : Promise.resolve(null),
42
+ wallet && drop.price > 0n ? erc20Balance(provider, drop.paymentToken, wallet) : Promise.resolve(null)
43
+ ]);
44
+ return { drop, claimed, balance };
45
+ }, { revalidateOnFocus: true, refreshInterval: 15e3 });
46
+ return { ...data ?? { drop: null, claimed: null, balance: null }, error, mutate };
48
47
  }
49
48
  export {
50
- useDropCollections,
51
- useDropInfo,
52
- useDropMintStatus,
53
- useMyDrops,
54
- useOnChainDropState
49
+ useDrop,
50
+ useDropChain,
51
+ useDropFee,
52
+ useDropFile,
53
+ useDropMints,
54
+ useDrops,
55
+ useMyDrops
55
56
  };
56
57
  //# 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 { ApiCollection, ApiDropInfo, ApiDropState, ApiMeta, DropMintStatus } from \"@medialane/sdk\";\nimport type { MedialaneClient } from \"@medialane/sdk/starknet\";\nimport { useMedialaneClient } from \"./use-medialane-client.js\";\n\nexport function useDropCollections(getClient: () => MedialaneClient) {\n const client = useMedialaneClient(getClient);\n const { data, error, isLoading, mutate } = useSWR<{ data: ApiCollection[]; meta?: ApiMeta }>(\n \"drop-collections\",\n () => client.api.listCollections({ service: \"drop-collection\", hideEmpty: false, limit: 50 }),\n { revalidateOnFocus: false }\n );\n return { collections: data?.data ?? [], meta: data?.meta, isLoading, error, mutate };\n}\n\nexport function useMyDrops(getClient: () => MedialaneClient, owner: string | null) {\n const client = useMedialaneClient(getClient);\n const { data, error, isLoading, mutate } = useSWR<ApiCollection[]>(\n owner ? `my-drops-${owner}` : null,\n async () => (await client.api.listCollections({ service: \"drop-collection\", owner: owner!, limit: 50 })).data ?? [],\n { revalidateOnFocus: false }\n );\n return { drops: data ?? [], isLoading, error, mutate };\n}\n\nexport function useDropMintStatus(getClient: () => MedialaneClient, collection: string | null, wallet: string | null) {\n const client = useMedialaneClient(getClient);\n const { data, error, isLoading, mutate } = useSWR<DropMintStatus>(\n collection && wallet ? `drop-mint-status-${collection}-${wallet}` : null,\n () => client.api.getDropMintStatus(collection!, wallet!),\n { revalidateOnFocus: false, shouldRetryOnError: false }\n );\n return { mintStatus: data ?? null, isLoading, error, mutate };\n}\n\nexport function useDropInfo(getClient: () => MedialaneClient, contract: string | null) {\n const client = useMedialaneClient(getClient);\n const { data, error, isLoading } = useSWR<ApiDropInfo | null>(\n contract ? `drop-info-${contract}` : null,\n () => client.api.getDropInfo(contract!),\n { revalidateOnFocus: false, shouldRetryOnError: false }\n );\n return { dropInfo: data ?? null, isLoading, error };\n}\n\nexport function useOnChainDropState(getClient: () => MedialaneClient, contract: string | null) {\n const client = useMedialaneClient(getClient);\n const { data, error, isLoading, mutate } = useSWR<ApiDropState>(\n contract ? `drop-onchain-${contract}` : null,\n () => client.api.getDropState(contract!),\n { revalidateOnFocus: false, refreshInterval: 30_000, shouldRetryOnError: false }\n );\n return { state: data ?? null, isLoading, error, mutate };\n}\n"],"mappings":";AAEA,OAAO,YAAY;AAGnB,SAAS,0BAA0B;AAE5B,SAAS,mBAAm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Y,QAAS;AAAA,IACtC,EAAE,mBAAmB,OAAO,oBAAoB,MAAM;AAAA,EACxD;AACA,SAAO,EAAE,UAAU,QAAQ,MAAM,WAAW,MAAM;AACpD;AAEO,SAAS,oBAAoB,WAAkC,UAAyB;AAC7F,QAAM,SAAS,mBAAmB,SAAS;AAC3C,QAAM,EAAE,MAAM,OAAO,WAAW,OAAO,IAAI;AAAA,IACzC,WAAW,gBAAgB,QAAQ,KAAK;AAAA,IACxC,MAAM,OAAO,IAAI,aAAa,QAAS;AAAA,IACvC,EAAE,mBAAmB,OAAO,iBAAiB,KAAQ,oBAAoB,MAAM;AAAA,EACjF;AACA,SAAO,EAAE,OAAO,QAAQ,MAAM,WAAW,OAAO,OAAO;AACzD;","names":[]}
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/** The platform fee, in basis points, the backend adds to a mint for this app; null until known. */\nexport function useDropFee(getClient: () => MedialaneClient): number | null {\n const client = useMedialaneClient(getClient);\n const { data } = useSWR(\"drop-fee\", () => client.api.getDropFee(), { revalidateOnFocus: false });\n return data?.launchpadBps ?? null;\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"],"mapp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": "0.183.0",
3
+ "version": "0.185.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.161.0",
54
+ "@medialane/sdk": ">=0.171.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.168.0",
83
+ "@medialane/sdk": "0.171.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,uCAAwC;AACxC,wBAA2D;AAG3D,MAAM,YAAY,CAAC,WAA+C;AAAA,EAChE,OAAO,EAAE,GAAG,yCAAuB,GAAG,MAAM;AAAA,EAC5C,SAAS,MAAM;AAAA,EAAC;AAAA,EAChB,MAAM,YAAY;AAAA,EAClB,MAAM,MAAM;AAAA,EAAC;AAAA,EACb,QAAQ,YAAY;AAAA,EACpB,WAAW,MAAM;AAAA,EAAC;AACpB;AAEA,MAAM,SAAS;AAAA,EACb,WAAW,YAAY,CAAC;AAAA,EACxB,WAAW,YAAY;AAAA,EACvB,cAAc,YAAY;AAAA,EAC1B,cAAc,YAAY,CAAC;AAAA,EAC3B,WAAW,aAAa,EAAE,YAAY,QAAQ,QAAQ,QAAQ,SAAS,EAAE;AAAA,EACzE,kBAAkB,YAAY;AAAA,EAC9B,cAAc,YAAY;AAC5B;AAAA,IAEA,0BAAS,sBAAsB,MAAM;AACnC,4BAAK,4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