@medialane/ui 0.188.0 → 0.190.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 (107) hide show
  1. package/dist/components/drop/create/drop-create.d.cts +1 -1
  2. package/dist/components/drop/create/drop-create.d.ts +1 -1
  3. package/dist/components/drop/create/launch-dialog.cjs +1 -1
  4. package/dist/components/drop/create/launch-dialog.cjs.map +1 -1
  5. package/dist/components/drop/create/launch-dialog.d.cts +1 -1
  6. package/dist/components/drop/create/launch-dialog.d.ts +1 -1
  7. package/dist/components/drop/create/launch-dialog.js +1 -1
  8. package/dist/components/drop/create/launch-dialog.js.map +1 -1
  9. package/dist/components/drop/page/drop-page.cjs +3 -3
  10. package/dist/components/drop/page/drop-page.cjs.map +1 -1
  11. package/dist/components/drop/page/drop-page.d.cts +1 -1
  12. package/dist/components/drop/page/drop-page.d.ts +1 -1
  13. package/dist/components/drop/page/drop-page.js +3 -3
  14. package/dist/components/drop/page/drop-page.js.map +1 -1
  15. package/dist/components/fast-mint/fast-mint.cjs +4 -5
  16. package/dist/components/fast-mint/fast-mint.cjs.map +1 -1
  17. package/dist/components/fast-mint/fast-mint.js +4 -5
  18. package/dist/components/fast-mint/fast-mint.js.map +1 -1
  19. package/dist/components/fast-mint/types.cjs.map +1 -1
  20. package/dist/components/fast-mint/types.d.cts +1 -2
  21. package/dist/components/fast-mint/types.d.ts +1 -2
  22. package/dist/components/media-wallet/media-wallet-activity.d.cts +0 -1
  23. package/dist/components/media-wallet/media-wallet-activity.d.ts +0 -1
  24. package/dist/components/media-wallet/media-wallet-home.cjs +5 -5
  25. package/dist/components/media-wallet/media-wallet-home.cjs.map +1 -1
  26. package/dist/components/media-wallet/media-wallet-home.d.cts +0 -1
  27. package/dist/components/media-wallet/media-wallet-home.d.ts +0 -1
  28. package/dist/components/media-wallet/media-wallet-home.js +5 -5
  29. package/dist/components/media-wallet/media-wallet-home.js.map +1 -1
  30. package/dist/components/media-wallet/media-wallet-overlay.d.cts +0 -1
  31. package/dist/components/media-wallet/media-wallet-overlay.d.ts +0 -1
  32. package/dist/components/media-wallet/media-wallet-send.cjs +7 -7
  33. package/dist/components/media-wallet/media-wallet-send.cjs.map +1 -1
  34. package/dist/components/media-wallet/media-wallet-send.d.cts +0 -1
  35. package/dist/components/media-wallet/media-wallet-send.d.ts +0 -1
  36. package/dist/components/media-wallet/media-wallet-send.js +7 -7
  37. package/dist/components/media-wallet/media-wallet-send.js.map +1 -1
  38. package/dist/components/media-wallet/media-wallet-token-detail.cjs +2 -2
  39. package/dist/components/media-wallet/media-wallet-token-detail.cjs.map +1 -1
  40. package/dist/components/media-wallet/media-wallet-token-detail.d.cts +0 -1
  41. package/dist/components/media-wallet/media-wallet-token-detail.d.ts +0 -1
  42. package/dist/components/media-wallet/media-wallet-token-detail.js +2 -2
  43. package/dist/components/media-wallet/media-wallet-token-detail.js.map +1 -1
  44. package/dist/components/media-wallet/media-wallet.d.cts +0 -1
  45. package/dist/components/media-wallet/media-wallet.d.ts +0 -1
  46. package/dist/components/media-wallet/types.cjs.map +1 -1
  47. package/dist/components/media-wallet/types.d.cts +0 -2
  48. package/dist/components/media-wallet/types.d.ts +0 -2
  49. package/dist/components/media-wallet/types.js.map +1 -1
  50. package/dist/index.cjs +4 -0
  51. package/dist/index.cjs.map +1 -1
  52. package/dist/index.d.cts +4 -4
  53. package/dist/index.d.ts +4 -4
  54. package/dist/index.js +5 -1
  55. package/dist/index.js.map +1 -1
  56. package/dist/utils/app-wallet.cjs +4 -3
  57. package/dist/utils/app-wallet.cjs.map +1 -1
  58. package/dist/utils/app-wallet.d.cts +2 -2
  59. package/dist/utils/app-wallet.d.ts +2 -2
  60. package/dist/utils/app-wallet.js +4 -3
  61. package/dist/utils/app-wallet.js.map +1 -1
  62. package/dist/utils/describe-error.cjs +17 -11
  63. package/dist/utils/describe-error.cjs.map +1 -1
  64. package/dist/utils/describe-error.d.cts +3 -2
  65. package/dist/utils/describe-error.d.ts +3 -2
  66. package/dist/utils/describe-error.js +16 -11
  67. package/dist/utils/describe-error.js.map +1 -1
  68. package/dist/utils/drop/actions.cjs +3 -3
  69. package/dist/utils/drop/actions.cjs.map +1 -1
  70. package/dist/utils/drop/actions.d.cts +2 -3
  71. package/dist/utils/drop/actions.d.ts +2 -3
  72. package/dist/utils/drop/actions.js +3 -3
  73. package/dist/utils/drop/actions.js.map +1 -1
  74. package/dist/utils/drop/types.cjs.map +1 -1
  75. package/dist/utils/drop/types.d.cts +3 -6
  76. package/dist/utils/drop/types.d.ts +3 -6
  77. package/dist/utils/ipfs-upload.cjs +13 -2
  78. package/dist/utils/ipfs-upload.cjs.map +1 -1
  79. package/dist/utils/ipfs-upload.d.cts +2 -1
  80. package/dist/utils/ipfs-upload.d.ts +2 -1
  81. package/dist/utils/ipfs-upload.js +13 -3
  82. package/dist/utils/ipfs-upload.js.map +1 -1
  83. package/dist/utils/media-wallet/use-erc20-balance.cjs +14 -17
  84. package/dist/utils/media-wallet/use-erc20-balance.cjs.map +1 -1
  85. package/dist/utils/media-wallet/use-erc20-balance.d.cts +5 -4
  86. package/dist/utils/media-wallet/use-erc20-balance.d.ts +5 -4
  87. package/dist/utils/media-wallet/use-erc20-balance.js +14 -18
  88. package/dist/utils/media-wallet/use-erc20-balance.js.map +1 -1
  89. package/dist/utils/use-drops.cjs +6 -6
  90. package/dist/utils/use-drops.cjs.map +1 -1
  91. package/dist/utils/use-drops.d.cts +2 -6
  92. package/dist/utils/use-drops.d.ts +2 -6
  93. package/dist/utils/use-drops.js +7 -7
  94. package/dist/utils/use-drops.js.map +1 -1
  95. package/dist/utils/use-pop.cjs +3 -2
  96. package/dist/utils/use-pop.cjs.map +1 -1
  97. package/dist/utils/use-pop.d.cts +1 -2
  98. package/dist/utils/use-pop.d.ts +1 -2
  99. package/dist/utils/use-pop.js +3 -2
  100. package/dist/utils/use-pop.js.map +1 -1
  101. package/package.json +3 -3
  102. package/dist/utils/drop/chain.cjs +0 -37
  103. package/dist/utils/drop/chain.cjs.map +0 -1
  104. package/dist/utils/drop/chain.d.cts +0 -5
  105. package/dist/utils/drop/chain.d.ts +0 -5
  106. package/dist/utils/drop/chain.js +0 -13
  107. package/dist/utils/drop/chain.js.map +0 -1
@@ -1,13 +1,12 @@
1
1
  import { DropTermsBody, CreateDropManageIntentParams } from '@medialane/sdk';
2
2
  import { MedialaneClient } from '@medialane/sdk/starknet';
3
- import { DropProvider, DropSigner } from './types.cjs';
4
- import 'starknet';
3
+ import { DropSigner } from './types.cjs';
5
4
  import '../../components/fast-mint/types.cjs';
6
5
  import 'react';
6
+ import 'starknet';
7
7
 
8
8
  interface DropDeps {
9
9
  client: MedialaneClient;
10
- provider: DropProvider;
11
10
  signer: DropSigner;
12
11
  }
13
12
  declare function launchDrop(deps: DropDeps, input: {
@@ -1,13 +1,12 @@
1
1
  import { DropTermsBody, CreateDropManageIntentParams } from '@medialane/sdk';
2
2
  import { MedialaneClient } from '@medialane/sdk/starknet';
3
- import { DropProvider, DropSigner } from './types.js';
4
- import 'starknet';
3
+ import { DropSigner } from './types.js';
5
4
  import '../../components/fast-mint/types.js';
6
5
  import 'react';
6
+ import 'starknet';
7
7
 
8
8
  interface DropDeps {
9
9
  client: MedialaneClient;
10
- provider: DropProvider;
11
10
  signer: DropSigner;
12
11
  }
13
12
  declare function launchDrop(deps: DropDeps, input: {
@@ -13,7 +13,7 @@ async function launchDrop(deps, input) {
13
13
  ...input.description ? { description: input.description } : {},
14
14
  ...input.image ? { image: input.image } : {}
15
15
  });
16
- const { txHash, receipt } = await executeIntent(deps.provider, deps.signer, deps.client, res.data);
16
+ const { txHash, receipt } = await executeIntent(deps.signer, deps.client, res.data);
17
17
  const collection = deployedCollectionFromReceipt(receipt, "drop-collection");
18
18
  if (!collection) throw new Error("Your drop launched, but its address wasn't found yet. Check My drops in a minute.");
19
19
  return { collection, txHash };
@@ -25,12 +25,12 @@ async function mintDrop(deps, input) {
25
25
  quantity: input.quantity.toString(),
26
26
  ...input.proof ? { proof: input.proof } : {}
27
27
  });
28
- const { txHash, receipt } = await executeIntent(deps.provider, deps.signer, deps.client, res.data);
28
+ const { txHash, receipt } = await executeIntent(deps.signer, deps.client, res.data);
29
29
  return { txHash, tokenIds: claimedTokenIds(receipt, input.collection) };
30
30
  }
31
31
  async function manageDrop(deps, params) {
32
32
  const res = await deps.client.api.createDropManageIntent(params);
33
- const { txHash } = await executeIntent(deps.provider, deps.signer, deps.client, res.data);
33
+ const { txHash } = await executeIntent(deps.signer, deps.client, res.data);
34
34
  return { txHash };
35
35
  }
36
36
  async function saveExclusiveContent(client, collection, content) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/drop/actions.ts"],"sourcesContent":["import type { CreateDropManageIntentParams, DropTermsBody } from \"@medialane/sdk\";\nimport { deployedCollectionFromReceipt, executeIntent, type MedialaneClient } from \"@medialane/sdk/starknet\";\nimport { claimedTokenIds } from \"./receipt.js\";\nimport type { DropProvider, DropSigner } from \"./types.js\";\n\nexport interface DropDeps {\n client: MedialaneClient;\n provider: DropProvider;\n signer: DropSigner;\n}\n\nexport async function launchDrop(\n deps: DropDeps,\n input: {\n owner: string; name: string; symbol: string; baseUri: string; maxSupply: number;\n terms: DropTermsBody; allowlistRoot?: string; description?: string; image?: string;\n },\n): Promise<{ collection: string; txHash: string }> {\n const res = await deps.client.api.createCollectionIntent({\n owner: input.owner,\n name: input.name,\n symbol: input.symbol,\n baseUri: input.baseUri,\n service: \"drop-collection\",\n maxSupply: String(input.maxSupply),\n terms: input.terms,\n ...(input.allowlistRoot ? { allowlistRoot: input.allowlistRoot } : {}),\n ...(input.description ? { description: input.description } : {}),\n ...(input.image ? { image: input.image } : {}),\n });\n const { txHash, receipt } = await executeIntent(deps.provider, deps.signer, deps.client, res.data);\n const collection = deployedCollectionFromReceipt(receipt, \"drop-collection\");\n if (!collection) throw new Error(\"Your drop launched, but its address wasn't found yet. Check My drops in a minute.\");\n return { collection, txHash };\n}\n\nexport async function mintDrop(\n deps: DropDeps,\n input: { claimer: string; collection: string; quantity: bigint; proof: string[] | null },\n): Promise<{ txHash: string; tokenIds: string[] }> {\n const res = await deps.client.api.createDropClaimIntent({\n claimer: input.claimer,\n collection: input.collection,\n quantity: input.quantity.toString(),\n ...(input.proof ? { proof: input.proof } : {}),\n });\n const { txHash, receipt } = await executeIntent(deps.provider, deps.signer, deps.client, res.data);\n return { txHash, tokenIds: claimedTokenIds(receipt, input.collection) };\n}\n\nexport async function manageDrop(deps: DropDeps, params: CreateDropManageIntentParams): Promise<{ txHash: string }> {\n const res = await deps.client.api.createDropManageIntent(params);\n const { txHash } = await executeIntent(deps.provider, deps.signer, deps.client, res.data);\n return { txHash };\n}\n\nexport interface ExclusiveContent {\n title: string;\n url: string;\n type: string;\n}\n\nexport async function saveExclusiveContent(client: MedialaneClient, collection: string, content: ExclusiveContent | null): Promise<void> {\n await client.api.updateCollectionProfile(collection, {\n gatedContentTitle: content?.title || null,\n gatedContentUrl: content?.url || null,\n gatedContentType: (content?.type || null) as never,\n });\n}\n"],"mappings":"AACA,SAAS,+BAA+B,qBAA2C;AACnF,SAAS,uBAAuB;AAShC,eAAsB,WACpB,MACA,OAIiD;AACjD,QAAM,MAAM,MAAM,KAAK,OAAO,IAAI,uBAAuB;AAAA,IACvD,OAAO,MAAM;AAAA,IACb,MAAM,MAAM;AAAA,IACZ,QAAQ,MAAM;AAAA,IACd,SAAS,MAAM;AAAA,IACf,SAAS;AAAA,IACT,WAAW,OAAO,MAAM,SAAS;AAAA,IACjC,OAAO,MAAM;AAAA,IACb,GAAI,MAAM,gBAAgB,EAAE,eAAe,MAAM,cAAc,IAAI,CAAC;AAAA,IACpE,GAAI,MAAM,cAAc,EAAE,aAAa,MAAM,YAAY,IAAI,CAAC;AAAA,IAC9D,GAAI,MAAM,QAAQ,EAAE,OAAO,MAAM,MAAM,IAAI,CAAC;AAAA,EAC9C,CAAC;AACD,QAAM,EAAE,QAAQ,QAAQ,IAAI,MAAM,cAAc,KAAK,UAAU,KAAK,QAAQ,KAAK,QAAQ,IAAI,IAAI;AACjG,QAAM,aAAa,8BAA8B,SAAS,iBAAiB;AAC3E,MAAI,CAAC,WAAY,OAAM,IAAI,MAAM,mFAAmF;AACpH,SAAO,EAAE,YAAY,OAAO;AAC9B;AAEA,eAAsB,SACpB,MACA,OACiD;AACjD,QAAM,MAAM,MAAM,KAAK,OAAO,IAAI,sBAAsB;AAAA,IACtD,SAAS,MAAM;AAAA,IACf,YAAY,MAAM;AAAA,IAClB,UAAU,MAAM,SAAS,SAAS;AAAA,IAClC,GAAI,MAAM,QAAQ,EAAE,OAAO,MAAM,MAAM,IAAI,CAAC;AAAA,EAC9C,CAAC;AACD,QAAM,EAAE,QAAQ,QAAQ,IAAI,MAAM,cAAc,KAAK,UAAU,KAAK,QAAQ,KAAK,QAAQ,IAAI,IAAI;AACjG,SAAO,EAAE,QAAQ,UAAU,gBAAgB,SAAS,MAAM,UAAU,EAAE;AACxE;AAEA,eAAsB,WAAW,MAAgB,QAAmE;AAClH,QAAM,MAAM,MAAM,KAAK,OAAO,IAAI,uBAAuB,MAAM;AAC/D,QAAM,EAAE,OAAO,IAAI,MAAM,cAAc,KAAK,UAAU,KAAK,QAAQ,KAAK,QAAQ,IAAI,IAAI;AACxF,SAAO,EAAE,OAAO;AAClB;AAQA,eAAsB,qBAAqB,QAAyB,YAAoB,SAAiD;AACvI,QAAM,OAAO,IAAI,wBAAwB,YAAY;AAAA,IACnD,mBAAmB,SAAS,SAAS;AAAA,IACrC,iBAAiB,SAAS,OAAO;AAAA,IACjC,kBAAmB,SAAS,QAAQ;AAAA,EACtC,CAAC;AACH;","names":[]}
1
+ {"version":3,"sources":["../../../src/utils/drop/actions.ts"],"sourcesContent":["import type { CreateDropManageIntentParams, DropTermsBody } from \"@medialane/sdk\";\nimport { deployedCollectionFromReceipt, executeIntent, type MedialaneClient } from \"@medialane/sdk/starknet\";\nimport { claimedTokenIds } from \"./receipt.js\";\nimport type { DropSigner } from \"./types.js\";\n\nexport interface DropDeps {\n client: MedialaneClient;\n signer: DropSigner;\n}\n\nexport async function launchDrop(\n deps: DropDeps,\n input: {\n owner: string; name: string; symbol: string; baseUri: string; maxSupply: number;\n terms: DropTermsBody; allowlistRoot?: string; description?: string; image?: string;\n },\n): Promise<{ collection: string; txHash: string }> {\n const res = await deps.client.api.createCollectionIntent({\n owner: input.owner,\n name: input.name,\n symbol: input.symbol,\n baseUri: input.baseUri,\n service: \"drop-collection\",\n maxSupply: String(input.maxSupply),\n terms: input.terms,\n ...(input.allowlistRoot ? { allowlistRoot: input.allowlistRoot } : {}),\n ...(input.description ? { description: input.description } : {}),\n ...(input.image ? { image: input.image } : {}),\n });\n const { txHash, receipt } = await executeIntent(deps.signer, deps.client, res.data);\n const collection = deployedCollectionFromReceipt(receipt, \"drop-collection\");\n if (!collection) throw new Error(\"Your drop launched, but its address wasn't found yet. Check My drops in a minute.\");\n return { collection, txHash };\n}\n\nexport async function mintDrop(\n deps: DropDeps,\n input: { claimer: string; collection: string; quantity: bigint; proof: string[] | null },\n): Promise<{ txHash: string; tokenIds: string[] }> {\n const res = await deps.client.api.createDropClaimIntent({\n claimer: input.claimer,\n collection: input.collection,\n quantity: input.quantity.toString(),\n ...(input.proof ? { proof: input.proof } : {}),\n });\n const { txHash, receipt } = await executeIntent(deps.signer, deps.client, res.data);\n return { txHash, tokenIds: claimedTokenIds(receipt, input.collection) };\n}\n\nexport async function manageDrop(deps: DropDeps, params: CreateDropManageIntentParams): Promise<{ txHash: string }> {\n const res = await deps.client.api.createDropManageIntent(params);\n const { txHash } = await executeIntent(deps.signer, deps.client, res.data);\n return { txHash };\n}\n\nexport interface ExclusiveContent {\n title: string;\n url: string;\n type: string;\n}\n\nexport async function saveExclusiveContent(client: MedialaneClient, collection: string, content: ExclusiveContent | null): Promise<void> {\n await client.api.updateCollectionProfile(collection, {\n gatedContentTitle: content?.title || null,\n gatedContentUrl: content?.url || null,\n gatedContentType: (content?.type || null) as never,\n });\n}\n"],"mappings":"AACA,SAAS,+B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,QAAM,EAAE,OAAO,IAAI,MAAM,cAAc,KAAK,QAAQ,KAAK,QAAQ,IAAI,IAAI;AACzE,SAAO,EAAE,OAAO;AAClB;AAQA,eAAsB,qBAAqB,QAAyB,YAAoB,SAAiD;AACvI,QAAM,OAAO,IAAI,wBAAwB,YAAY;AAAA,IACnD,mBAAmB,SAAS,SAAS;AAAA,IACrC,iBAAiB,SAAS,OAAO;AAAA,IACjC,kBAAmB,SAAS,QAAQ;AAAA,EACtC,CAAC;AACH;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/drop/types.ts"],"sourcesContent":["import type { ProviderInterface } from \"starknet\";\nimport type { MedialaneClient, ReceiptProvider } from \"@medialane/sdk/starknet\";\nimport type { FastMintSigner } from \"../../components/fast-mint/types.js\";\n\nexport type DropSigner = FastMintSigner;\n\n/** Receipts for confirmations, contract reads for live drop state. */\nexport type DropProvider = ReceiptProvider & Pick<ProviderInterface, \"callContract\">;\n\n/** What every drop screen takes from the app. */\nexport interface DropAppProps {\n getClient: () => MedialaneClient;\n provider: DropProvider;\n getSigner: () => Promise<DropSigner> | DropSigner;\n walletAddress: string | null;\n onRequireWallet: () => void;\n connectLabel?: string;\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../../../src/utils/drop/types.ts"],"sourcesContent":["import type { MedialaneClient } from \"@medialane/sdk/starknet\";\nimport type { FastMintSigner } from \"../../components/fast-mint/types.js\";\n\nexport type DropSigner = FastMintSigner;\n\n/** What every drop screen takes from the app. */\nexport interface DropAppProps {\n getClient: () => MedialaneClient;\n getSigner: () => Promise<DropSigner> | DropSigner;\n walletAddress: string | null;\n onRequireWallet: () => void;\n connectLabel?: string;\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -1,20 +1,17 @@
1
- import { ProviderInterface } from 'starknet';
2
- import { MedialaneClient, ReceiptProvider } from '@medialane/sdk/starknet';
1
+ import { MedialaneClient } from '@medialane/sdk/starknet';
3
2
  import { FastMintSigner } from '../../components/fast-mint/types.cjs';
4
3
  import 'react';
4
+ import 'starknet';
5
5
  import '@medialane/sdk';
6
6
 
7
7
  type DropSigner = FastMintSigner;
8
- /** Receipts for confirmations, contract reads for live drop state. */
9
- type DropProvider = ReceiptProvider & Pick<ProviderInterface, "callContract">;
10
8
  /** What every drop screen takes from the app. */
11
9
  interface DropAppProps {
12
10
  getClient: () => MedialaneClient;
13
- provider: DropProvider;
14
11
  getSigner: () => Promise<DropSigner> | DropSigner;
15
12
  walletAddress: string | null;
16
13
  onRequireWallet: () => void;
17
14
  connectLabel?: string;
18
15
  }
19
16
 
20
- export type { DropAppProps, DropProvider, DropSigner };
17
+ export type { DropAppProps, DropSigner };
@@ -1,20 +1,17 @@
1
- import { ProviderInterface } from 'starknet';
2
- import { MedialaneClient, ReceiptProvider } from '@medialane/sdk/starknet';
1
+ import { MedialaneClient } from '@medialane/sdk/starknet';
3
2
  import { FastMintSigner } from '../../components/fast-mint/types.js';
4
3
  import 'react';
4
+ import 'starknet';
5
5
  import '@medialane/sdk';
6
6
 
7
7
  type DropSigner = FastMintSigner;
8
- /** Receipts for confirmations, contract reads for live drop state. */
9
- type DropProvider = ReceiptProvider & Pick<ProviderInterface, "callContract">;
10
8
  /** What every drop screen takes from the app. */
11
9
  interface DropAppProps {
12
10
  getClient: () => MedialaneClient;
13
- provider: DropProvider;
14
11
  getSigner: () => Promise<DropSigner> | DropSigner;
15
12
  walletAddress: string | null;
16
13
  onRequireWallet: () => void;
17
14
  connectLabel?: string;
18
15
  }
19
16
 
20
- export type { DropAppProps, DropProvider, DropSigner };
17
+ export type { DropAppProps, DropSigner };
@@ -18,6 +18,7 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var ipfs_upload_exports = {};
20
20
  __export(ipfs_upload_exports, {
21
+ FILE_UPLOAD_FAILED: () => FILE_UPLOAD_FAILED,
21
22
  isUserRejection: () => isUserRejection,
22
23
  pinAssetMetadata: () => pinAssetMetadata,
23
24
  uploadDirectoryToIpfs: () => uploadDirectoryToIpfs,
@@ -27,6 +28,10 @@ __export(ipfs_upload_exports, {
27
28
  });
28
29
  module.exports = __toCommonJS(ipfs_upload_exports);
29
30
  var import_sdk = require("@medialane/sdk");
31
+ const FILE_UPLOAD_FAILED = "We couldn't upload your file. Check your connection and try again, or choose a different file.";
32
+ function uploadFailed(cause) {
33
+ return Object.assign(new import_sdk.UserFacingError(FILE_UPLOAD_FAILED), { cause });
34
+ }
30
35
  async function uploadFileToIpfs(api, file, kind = "image") {
31
36
  const signedUrl = (await api.getMetadataSignedUrl(kind)).data?.url;
32
37
  if (!signedUrl) throw new Error("Failed to prepare the upload");
@@ -34,11 +39,16 @@ async function uploadFileToIpfs(api, file, kind = "image") {
34
39
  formData.append("file", file, file.name);
35
40
  formData.append("network", "public");
36
41
  formData.append("name", file.name);
37
- const uploadRes = await fetch(signedUrl, { method: "POST", body: formData });
42
+ let uploadRes;
43
+ try {
44
+ uploadRes = await fetch(signedUrl, { method: "POST", body: formData });
45
+ } catch (err) {
46
+ throw uploadFailed(err);
47
+ }
38
48
  const uploadJson = await uploadRes.json().catch(() => ({}));
39
49
  const cid = uploadJson.data?.cid;
40
50
  if (!uploadRes.ok || !cid) {
41
- throw new Error("Upload to IPFS failed");
51
+ throw uploadFailed(new Error(`File upload returned HTTP ${uploadRes.status}${cid ? "" : " without a cid"}`));
42
52
  }
43
53
  return { cid, uri: `ipfs://${cid}` };
44
54
  }
@@ -84,6 +94,7 @@ async function pinAssetMetadata(api, input) {
84
94
  }
85
95
  // Annotate the CommonJS export names for ESM import in node:
86
96
  0 && (module.exports = {
97
+ FILE_UPLOAD_FAILED,
87
98
  isUserRejection,
88
99
  pinAssetMetadata,
89
100
  uploadDirectoryToIpfs,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/ipfs-upload.ts"],"sourcesContent":["import { buildAssetMetadata, type ApiClient, type BuildAssetMetadataInput } from \"@medialane/sdk\";\n\nexport interface UploadedIpfsFile {\n cid: string;\n uri: string;\n}\n\nexport type SignedUploadKind = \"image\" | \"document\" | \"media\";\n\nexport async function uploadFileToIpfs(\n api: ApiClient,\n file: File,\n kind: SignedUploadKind = \"image\",\n): Promise<UploadedIpfsFile> {\n const signedUrl = (await api.getMetadataSignedUrl(kind)).data?.url;\n if (!signedUrl) throw new Error(\"Failed to prepare the upload\");\n\n const formData = new FormData();\n formData.append(\"file\", file, file.name);\n formData.append(\"network\", \"public\");\n formData.append(\"name\", file.name);\n\n const uploadRes = await fetch(signedUrl, { method: \"POST\", body: formData });\n const uploadJson = (await uploadRes.json().catch(() => ({}))) as { data?: { cid?: string } };\n const cid = uploadJson.data?.cid;\n if (!uploadRes.ok || !cid) {\n throw new Error(\"Upload to IPFS failed\");\n }\n\n return { cid, uri: `ipfs://${cid}` };\n}\n\nexport async function uploadJsonToIpfs(api: ApiClient, payload: unknown): Promise<string> {\n const uri = (await api.uploadMetadata(payload as Record<string, unknown>)).data?.url;\n if (!uri) throw new Error(\"Metadata upload failed\");\n return uri;\n}\n\nexport function uploadDirectoryToIpfs(\n api: ApiClient,\n files: { name: string; content: unknown }[],\n): Promise<{ cid: string; baseUri: string }> {\n return api.uploadMetadataDirectory(files);\n}\n\nexport function isUserRejection(err: unknown): boolean {\n const msg = err instanceof Error ? err.message : String(err ?? \"\");\n return /reject|denied|declin|abort|cancel|refus/i.test(msg);\n}\n\nexport function uploadFailureToast(err: unknown): { title: string; description?: string } {\n if (isUserRejection(err)) {\n return {\n title: \"Signature declined\",\n description: \"Try again and approve the request in your wallet.\",\n };\n }\n return {\n title: \"Upload failed\",\n description: err instanceof Error ? err.message : undefined,\n };\n}\n\nexport interface PinAssetMetadataInput extends Omit<BuildAssetMetadataInput, \"registrationDate\"> {\n imageFile?: File | null;\n}\n\nexport interface PinnedAsset {\n uri: string;\n imageUri: string | null;\n}\n\nexport async function pinAssetMetadata(api: ApiClient, input: PinAssetMetadataInput): Promise<PinnedAsset> {\n const { imageFile, ...fields } = input;\n\n let imageUri = fields.imageUri ?? null;\n if (!imageUri && imageFile && imageFile.size > 0) {\n imageUri = (await uploadFileToIpfs(api, imageFile)).uri;\n }\n\n const uri = await uploadJsonToIpfs(\n api,\n buildAssetMetadata({\n ...fields,\n imageUri,\n externalUrl: fields.externalUrl || \"https://medialane.io\",\n }),\n );\n\n return { uri, imageUri };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAiF;AASjF,eAAsB,iBACpB,KACA,MACA,OAAyB,SACE;AAC3B,QAAM,aAAa,MAAM,IAAI,qBAAqB,IAAI,GAAG,MAAM;AAC/D,MAAI,CAAC,UAAW,OAAM,IAAI,MAAM,8BAA8B;AAE9D,QAAM,WAAW,IAAI,SAAS;AAC9B,WAAS,OAAO,QAAQ,MAAM,KAAK,IAAI;AACvC,WAAS,OAAO,WAAW,QAAQ;AACnC,WAAS,OAAO,QAAQ,KAAK,IAAI;AAEjC,QAAM,YAAY,MAAM,MAAM,WAAW,EAAE,QAAQ,QAAQ,MAAM,SAAS,CAAC;AAC3E,QAAM,aAAc,MAAM,UAAU,KAAK,EAAE,MAAM,OAAO,CAAC,EAAE;AAC3D,QAAM,MAAM,WAAW,MAAM;AAC7B,MAAI,CAAC,UAAU,MAAM,CAAC,KAAK;AACzB,UAAM,IAAI,MAAM,uBAAuB;AAAA,EACzC;AAEA,SAAO,EAAE,KAAK,KAAK,UAAU,GAAG,GAAG;AACrC;AAEA,eAAsB,iBAAiB,KAAgB,SAAmC;AACxF,QAAM,OAAO,MAAM,IAAI,eAAe,OAAkC,GAAG,MAAM;AACjF,MAAI,CAAC,IAAK,OAAM,IAAI,MAAM,wBAAwB;AAClD,SAAO;AACT;AAEO,SAAS,sBACd,KACA,OAC2C;AAC3C,SAAO,IAAI,wBAAwB,KAAK;AAC1C;AAEO,SAAS,gBAAgB,KAAuB;AACrD,QAAM,MAAM,eAAe,QAAQ,IAAI,UAAU,OAAO,OAAO,EAAE;AACjE,SAAO,2CAA2C,KAAK,GAAG;AAC5D;AAEO,SAAS,mBAAmB,KAAuD;AACxF,MAAI,gBAAgB,GAAG,GAAG;AACxB,WAAO;AAAA,MACL,OAAO;AAAA,MACP,aAAa;AAAA,IACf;AAAA,EACF;AACA,SAAO;AAAA,IACL,OAAO;AAAA,IACP,aAAa,eAAe,QAAQ,IAAI,UAAU;AAAA,EACpD;AACF;AAWA,eAAsB,iBAAiB,KAAgB,OAAoD;AACzG,QAAM,EAAE,WAAW,GAAG,OAAO,IAAI;AAEjC,MAAI,WAAW,OAAO,YAAY;AAClC,MAAI,CAAC,YAAY,aAAa,UAAU,OAAO,GAAG;AAChD,gBAAY,MAAM,iBAAiB,KAAK,SAAS,GAAG;AAAA,EACtD;AAEA,QAAM,MAAM,MAAM;AAAA,IAChB;AAAA,QACA,+BAAmB;AAAA,MACjB,GAAG;AAAA,MACH;AAAA,MACA,aAAa,OAAO,eAAe;AAAA,IACrC,CAAC;AAAA,EACH;AAEA,SAAO,EAAE,KAAK,SAAS;AACzB;","names":[]}
1
+ {"version":3,"sources":["../../src/utils/ipfs-upload.ts"],"sourcesContent":["import { buildAssetMetadata, UserFacingError, type ApiClient, type BuildAssetMetadataInput } from \"@medialane/sdk\";\n\nexport const FILE_UPLOAD_FAILED =\n \"We couldn't upload your file. Check your connection and try again, or choose a different file.\";\n\nfunction uploadFailed(cause: unknown): UserFacingError {\n return Object.assign(new UserFacingError(FILE_UPLOAD_FAILED), { cause });\n}\n\nexport interface UploadedIpfsFile {\n cid: string;\n uri: string;\n}\n\nexport type SignedUploadKind = \"image\" | \"document\" | \"media\";\n\nexport async function uploadFileToIpfs(\n api: ApiClient,\n file: File,\n kind: SignedUploadKind = \"image\",\n): Promise<UploadedIpfsFile> {\n const signedUrl = (await api.getMetadataSignedUrl(kind)).data?.url;\n if (!signedUrl) throw new Error(\"Failed to prepare the upload\");\n\n const formData = new FormData();\n formData.append(\"file\", file, file.name);\n formData.append(\"network\", \"public\");\n formData.append(\"name\", file.name);\n\n let uploadRes: Response;\n try {\n uploadRes = await fetch(signedUrl, { method: \"POST\", body: formData });\n } catch (err) {\n throw uploadFailed(err);\n }\n const uploadJson = (await uploadRes.json().catch(() => ({}))) as { data?: { cid?: string } };\n const cid = uploadJson.data?.cid;\n if (!uploadRes.ok || !cid) {\n throw uploadFailed(new Error(`File upload returned HTTP ${uploadRes.status}${cid ? \"\" : \" without a cid\"}`));\n }\n\n return { cid, uri: `ipfs://${cid}` };\n}\n\nexport async function uploadJsonToIpfs(api: ApiClient, payload: unknown): Promise<string> {\n const uri = (await api.uploadMetadata(payload as Record<string, unknown>)).data?.url;\n if (!uri) throw new Error(\"Metadata upload failed\");\n return uri;\n}\n\nexport function uploadDirectoryToIpfs(\n api: ApiClient,\n files: { name: string; content: unknown }[],\n): Promise<{ cid: string; baseUri: string }> {\n return api.uploadMetadataDirectory(files);\n}\n\nexport function isUserRejection(err: unknown): boolean {\n const msg = err instanceof Error ? err.message : String(err ?? \"\");\n return /reject|denied|declin|abort|cancel|refus/i.test(msg);\n}\n\nexport function uploadFailureToast(err: unknown): { title: string; description?: string } {\n if (isUserRejection(err)) {\n return {\n title: \"Signature declined\",\n description: \"Try again and approve the request in your wallet.\",\n };\n }\n return {\n title: \"Upload failed\",\n description: err instanceof Error ? err.message : undefined,\n };\n}\n\nexport interface PinAssetMetadataInput extends Omit<BuildAssetMetadataInput, \"registrationDate\"> {\n imageFile?: File | null;\n}\n\nexport interface PinnedAsset {\n uri: string;\n imageUri: string | null;\n}\n\nexport async function pinAssetMetadata(api: ApiClient, input: PinAssetMetadataInput): Promise<PinnedAsset> {\n const { imageFile, ...fields } = input;\n\n let imageUri = fields.imageUri ?? null;\n if (!imageUri && imageFile && imageFile.size > 0) {\n imageUri = (await uploadFileToIpfs(api, imageFile)).uri;\n }\n\n const uri = await uploadJsonToIpfs(\n api,\n buildAssetMetadata({\n ...fields,\n imageUri,\n externalUrl: fields.externalUrl || \"https://medialane.io\",\n }),\n );\n\n return { uri, imageUri };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAkG;AAE3F,MAAM,qBACX;AAEF,SAAS,aAAa,OAAiC;AACrD,SAAO,OAAO,OAAO,IAAI,2BAAgB,kBAAkB,GAAG,EAAE,MAAM,CAAC;AACzE;AASA,eAAsB,iBACpB,KACA,MACA,OAAyB,SACE;AAC3B,QAAM,aAAa,MAAM,IAAI,qBAAqB,IAAI,GAAG,MAAM;AAC/D,MAAI,CAAC,UAAW,OAAM,IAAI,MAAM,8BAA8B;AAE9D,QAAM,WAAW,IAAI,SAAS;AAC9B,WAAS,OAAO,QAAQ,MAAM,KAAK,IAAI;AACvC,WAAS,OAAO,WAAW,QAAQ;AACnC,WAAS,OAAO,QAAQ,KAAK,IAAI;AAEjC,MAAI;AACJ,MAAI;AACF,gBAAY,MAAM,MAAM,WAAW,EAAE,QAAQ,QAAQ,MAAM,SAAS,CAAC;AAAA,EACvE,SAAS,KAAK;AACZ,UAAM,aAAa,GAAG;AAAA,EACxB;AACA,QAAM,aAAc,MAAM,UAAU,KAAK,EAAE,MAAM,OAAO,CAAC,EAAE;AAC3D,QAAM,MAAM,WAAW,MAAM;AAC7B,MAAI,CAAC,UAAU,MAAM,CAAC,KAAK;AACzB,UAAM,aAAa,IAAI,MAAM,6BAA6B,UAAU,MAAM,GAAG,MAAM,KAAK,gBAAgB,EAAE,CAAC;AAAA,EAC7G;AAEA,SAAO,EAAE,KAAK,KAAK,UAAU,GAAG,GAAG;AACrC;AAEA,eAAsB,iBAAiB,KAAgB,SAAmC;AACxF,QAAM,OAAO,MAAM,IAAI,eAAe,OAAkC,GAAG,MAAM;AACjF,MAAI,CAAC,IAAK,OAAM,IAAI,MAAM,wBAAwB;AAClD,SAAO;AACT;AAEO,SAAS,sBACd,KACA,OAC2C;AAC3C,SAAO,IAAI,wBAAwB,KAAK;AAC1C;AAEO,SAAS,gBAAgB,KAAuB;AACrD,QAAM,MAAM,eAAe,QAAQ,IAAI,UAAU,OAAO,OAAO,EAAE;AACjE,SAAO,2CAA2C,KAAK,GAAG;AAC5D;AAEO,SAAS,mBAAmB,KAAuD;AACxF,MAAI,gBAAgB,GAAG,GAAG;AACxB,WAAO;AAAA,MACL,OAAO;AAAA,MACP,aAAa;AAAA,IACf;AAAA,EACF;AACA,SAAO;AAAA,IACL,OAAO;AAAA,IACP,aAAa,eAAe,QAAQ,IAAI,UAAU;AAAA,EACpD;AACF;AAWA,eAAsB,iBAAiB,KAAgB,OAAoD;AACzG,QAAM,EAAE,WAAW,GAAG,OAAO,IAAI;AAEjC,MAAI,WAAW,OAAO,YAAY;AAClC,MAAI,CAAC,YAAY,aAAa,UAAU,OAAO,GAAG;AAChD,gBAAY,MAAM,iBAAiB,KAAK,SAAS,GAAG;AAAA,EACtD;AAEA,QAAM,MAAM,MAAM;AAAA,IAChB;AAAA,QACA,+BAAmB;AAAA,MACjB,GAAG;AAAA,MACH;AAAA,MACA,aAAa,OAAO,eAAe;AAAA,IACrC,CAAC;AAAA,EACH;AAEA,SAAO,EAAE,KAAK,SAAS;AACzB;","names":[]}
@@ -1,5 +1,6 @@
1
1
  import { BuildAssetMetadataInput, ApiClient } from '@medialane/sdk';
2
2
 
3
+ declare const FILE_UPLOAD_FAILED = "We couldn't upload your file. Check your connection and try again, or choose a different file.";
3
4
  interface UploadedIpfsFile {
4
5
  cid: string;
5
6
  uri: string;
@@ -28,4 +29,4 @@ interface PinnedAsset {
28
29
  }
29
30
  declare function pinAssetMetadata(api: ApiClient, input: PinAssetMetadataInput): Promise<PinnedAsset>;
30
31
 
31
- export { type PinAssetMetadataInput, type PinnedAsset, type SignedUploadKind, type UploadedIpfsFile, isUserRejection, pinAssetMetadata, uploadDirectoryToIpfs, uploadFailureToast, uploadFileToIpfs, uploadJsonToIpfs };
32
+ export { FILE_UPLOAD_FAILED, type PinAssetMetadataInput, type PinnedAsset, type SignedUploadKind, type UploadedIpfsFile, isUserRejection, pinAssetMetadata, uploadDirectoryToIpfs, uploadFailureToast, uploadFileToIpfs, uploadJsonToIpfs };
@@ -1,5 +1,6 @@
1
1
  import { BuildAssetMetadataInput, ApiClient } from '@medialane/sdk';
2
2
 
3
+ declare const FILE_UPLOAD_FAILED = "We couldn't upload your file. Check your connection and try again, or choose a different file.";
3
4
  interface UploadedIpfsFile {
4
5
  cid: string;
5
6
  uri: string;
@@ -28,4 +29,4 @@ interface PinnedAsset {
28
29
  }
29
30
  declare function pinAssetMetadata(api: ApiClient, input: PinAssetMetadataInput): Promise<PinnedAsset>;
30
31
 
31
- export { type PinAssetMetadataInput, type PinnedAsset, type SignedUploadKind, type UploadedIpfsFile, isUserRejection, pinAssetMetadata, uploadDirectoryToIpfs, uploadFailureToast, uploadFileToIpfs, uploadJsonToIpfs };
32
+ export { FILE_UPLOAD_FAILED, type PinAssetMetadataInput, type PinnedAsset, type SignedUploadKind, type UploadedIpfsFile, isUserRejection, pinAssetMetadata, uploadDirectoryToIpfs, uploadFailureToast, uploadFileToIpfs, uploadJsonToIpfs };
@@ -1,4 +1,8 @@
1
- import { buildAssetMetadata } from "@medialane/sdk";
1
+ import { buildAssetMetadata, UserFacingError } from "@medialane/sdk";
2
+ const FILE_UPLOAD_FAILED = "We couldn't upload your file. Check your connection and try again, or choose a different file.";
3
+ function uploadFailed(cause) {
4
+ return Object.assign(new UserFacingError(FILE_UPLOAD_FAILED), { cause });
5
+ }
2
6
  async function uploadFileToIpfs(api, file, kind = "image") {
3
7
  const signedUrl = (await api.getMetadataSignedUrl(kind)).data?.url;
4
8
  if (!signedUrl) throw new Error("Failed to prepare the upload");
@@ -6,11 +10,16 @@ async function uploadFileToIpfs(api, file, kind = "image") {
6
10
  formData.append("file", file, file.name);
7
11
  formData.append("network", "public");
8
12
  formData.append("name", file.name);
9
- const uploadRes = await fetch(signedUrl, { method: "POST", body: formData });
13
+ let uploadRes;
14
+ try {
15
+ uploadRes = await fetch(signedUrl, { method: "POST", body: formData });
16
+ } catch (err) {
17
+ throw uploadFailed(err);
18
+ }
10
19
  const uploadJson = await uploadRes.json().catch(() => ({}));
11
20
  const cid = uploadJson.data?.cid;
12
21
  if (!uploadRes.ok || !cid) {
13
- throw new Error("Upload to IPFS failed");
22
+ throw uploadFailed(new Error(`File upload returned HTTP ${uploadRes.status}${cid ? "" : " without a cid"}`));
14
23
  }
15
24
  return { cid, uri: `ipfs://${cid}` };
16
25
  }
@@ -55,6 +64,7 @@ async function pinAssetMetadata(api, input) {
55
64
  return { uri, imageUri };
56
65
  }
57
66
  export {
67
+ FILE_UPLOAD_FAILED,
58
68
  isUserRejection,
59
69
  pinAssetMetadata,
60
70
  uploadDirectoryToIpfs,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/ipfs-upload.ts"],"sourcesContent":["import { buildAssetMetadata, type ApiClient, type BuildAssetMetadataInput } from \"@medialane/sdk\";\n\nexport interface UploadedIpfsFile {\n cid: string;\n uri: string;\n}\n\nexport type SignedUploadKind = \"image\" | \"document\" | \"media\";\n\nexport async function uploadFileToIpfs(\n api: ApiClient,\n file: File,\n kind: SignedUploadKind = \"image\",\n): Promise<UploadedIpfsFile> {\n const signedUrl = (await api.getMetadataSignedUrl(kind)).data?.url;\n if (!signedUrl) throw new Error(\"Failed to prepare the upload\");\n\n const formData = new FormData();\n formData.append(\"file\", file, file.name);\n formData.append(\"network\", \"public\");\n formData.append(\"name\", file.name);\n\n const uploadRes = await fetch(signedUrl, { method: \"POST\", body: formData });\n const uploadJson = (await uploadRes.json().catch(() => ({}))) as { data?: { cid?: string } };\n const cid = uploadJson.data?.cid;\n if (!uploadRes.ok || !cid) {\n throw new Error(\"Upload to IPFS failed\");\n }\n\n return { cid, uri: `ipfs://${cid}` };\n}\n\nexport async function uploadJsonToIpfs(api: ApiClient, payload: unknown): Promise<string> {\n const uri = (await api.uploadMetadata(payload as Record<string, unknown>)).data?.url;\n if (!uri) throw new Error(\"Metadata upload failed\");\n return uri;\n}\n\nexport function uploadDirectoryToIpfs(\n api: ApiClient,\n files: { name: string; content: unknown }[],\n): Promise<{ cid: string; baseUri: string }> {\n return api.uploadMetadataDirectory(files);\n}\n\nexport function isUserRejection(err: unknown): boolean {\n const msg = err instanceof Error ? err.message : String(err ?? \"\");\n return /reject|denied|declin|abort|cancel|refus/i.test(msg);\n}\n\nexport function uploadFailureToast(err: unknown): { title: string; description?: string } {\n if (isUserRejection(err)) {\n return {\n title: \"Signature declined\",\n description: \"Try again and approve the request in your wallet.\",\n };\n }\n return {\n title: \"Upload failed\",\n description: err instanceof Error ? err.message : undefined,\n };\n}\n\nexport interface PinAssetMetadataInput extends Omit<BuildAssetMetadataInput, \"registrationDate\"> {\n imageFile?: File | null;\n}\n\nexport interface PinnedAsset {\n uri: string;\n imageUri: string | null;\n}\n\nexport async function pinAssetMetadata(api: ApiClient, input: PinAssetMetadataInput): Promise<PinnedAsset> {\n const { imageFile, ...fields } = input;\n\n let imageUri = fields.imageUri ?? null;\n if (!imageUri && imageFile && imageFile.size > 0) {\n imageUri = (await uploadFileToIpfs(api, imageFile)).uri;\n }\n\n const uri = await uploadJsonToIpfs(\n api,\n buildAssetMetadata({\n ...fields,\n imageUri,\n externalUrl: fields.externalUrl || \"https://medialane.io\",\n }),\n );\n\n return { uri, imageUri };\n}\n"],"mappings":"AAAA,SAAS,0BAAwE;AASjF,eAAsB,iBACpB,KACA,MACA,OAAyB,SACE;AAC3B,QAAM,aAAa,MAAM,IAAI,qBAAqB,IAAI,GAAG,MAAM;AAC/D,MAAI,CAAC,UAAW,OAAM,IAAI,MAAM,8BAA8B;AAE9D,QAAM,WAAW,IAAI,SAAS;AAC9B,WAAS,OAAO,QAAQ,MAAM,KAAK,IAAI;AACvC,WAAS,OAAO,WAAW,QAAQ;AACnC,WAAS,OAAO,QAAQ,KA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,IACrC,CAAC;AAAA,EACH;AAEA,SAAO,EAAE,KAAK,SAAS;AACzB;","names":[]}
1
+ {"version":3,"sources":["../../src/utils/ipfs-upload.ts"],"sourcesContent":["import { buildAssetMetadata, UserFacingError, type ApiClient, type BuildAssetMetadataInput } from \"@medialane/sdk\";\n\nexport const FILE_UPLOAD_FAILED =\n \"We couldn't upload your file. Check your connection and try again, or choose a different file.\";\n\nfunction uploadFailed(cause: unknown): UserFacingError {\n return Object.assign(new UserFacingError(FILE_UPLOAD_FAILED), { cause });\n}\n\nexport interface UploadedIpfsFile {\n cid: string;\n uri: string;\n}\n\nexport type SignedUploadKind = \"image\" | \"document\" | \"media\";\n\nexport async function uploadFileToIpfs(\n api: ApiClient,\n file: File,\n kind: SignedUploadKind = \"image\",\n): Promise<UploadedIpfsFile> {\n const signedUrl = (await api.getMetadataSignedUrl(kind)).data?.url;\n if (!signedUrl) throw new Error(\"Failed to prepare the upload\");\n\n const formData = new FormData();\n formData.append(\"file\", file, file.name);\n formData.append(\"network\", \"public\");\n formData.append(\"name\", file.name);\n\n let uploadRes: Response;\n try {\n uploadRes = await fetch(signedUrl, { method: \"POST\", body: formData });\n } catch (err) {\n throw uploadFailed(err);\n }\n const uploadJson = (await uploadRes.json().catch(() => ({}))) as { data?: { cid?: string } };\n const cid = uploadJson.data?.cid;\n if (!uploadRes.ok || !cid) {\n throw uploadFailed(new Error(`File upload returned HTTP ${uploadRes.status}${cid ? \"\" : \" without a cid\"}`));\n }\n\n return { cid, uri: `ipfs://${cid}` };\n}\n\nexport async function uploadJsonToIpfs(api: ApiClient, payload: unknown): Promise<string> {\n const uri = (await api.uploadMetadata(payload as Record<string, unknown>)).data?.url;\n if (!uri) throw new Error(\"Metadata upload failed\");\n return uri;\n}\n\nexport function uploadDirectoryToIpfs(\n api: ApiClient,\n files: { name: string; content: unknown }[],\n): Promise<{ cid: string; baseUri: string }> {\n return api.uploadMetadataDirectory(files);\n}\n\nexport function isUserRejection(err: unknown): boolean {\n const msg = err instanceof Error ? err.message : String(err ?? \"\");\n return /reject|denied|declin|abort|cancel|refus/i.test(msg);\n}\n\nexport function uploadFailureToast(err: unknown): { title: string; description?: string } {\n if (isUserRejection(err)) {\n return {\n title: \"Signature declined\",\n description: \"Try again and approve the request in your wallet.\",\n };\n }\n return {\n title: \"Upload failed\",\n description: err instanceof Error ? err.message : undefined,\n };\n}\n\nexport interface PinAssetMetadataInput extends Omit<BuildAssetMetadataInput, \"registrationDate\"> {\n imageFile?: File | null;\n}\n\nexport interface PinnedAsset {\n uri: string;\n imageUri: string | null;\n}\n\nexport async function pinAssetMetadata(api: ApiClient, input: PinAssetMetadataInput): Promise<PinnedAsset> {\n const { imageFile, ...fields } = input;\n\n let imageUri = fields.imageUri ?? null;\n if (!imageUri && imageFile && imageFile.size > 0) {\n imageUri = (await uploadFileToIpfs(api, imageFile)).uri;\n }\n\n const uri = await uploadJsonToIpfs(\n api,\n buildAssetMetadata({\n ...fields,\n imageUri,\n externalUrl: fields.externalUrl || \"https://medialane.io\",\n }),\n );\n\n return { uri, imageUri };\n}\n"],"mappings":"AAAA,SAAS,oBAAoB,uBAAqE;AAE3F,MAAM,qBACX;AAEF,SAAS,aAAa,OAAiC;AACrD,SAAO,OAAO,OAAO,IAAI,gBAAgB,kBAAkB,GAAG,EAAE,MAAM,CAAC;AACzE;AASA,eAAsB,iBACpB,KACA,MACA,OAAyB,SACE;AAC3B,QAAM,aAAa,MAAM,IAAI,qBAAqB,IAAI,GAAG,MAAM;AAC/D,MAAI,CAAC,UAAW,OAAM,IAAI,MAAM,8BAA8B;AAE9D,QAAM,WAAW,IAAI,SAAS;AAC9B,WAAS,OAAO,QAAQ,MAAM,KAAK,IAAI;AACvC,WAAS,OAAO,WAAW,QAAQ;AACnC,WAAS,OAAO,QAAQ,KAAK,IAAI;AAEjC,MAAI;AACJ,MAAI;AACF,gBAAY,MAAM,MAAM,WAAW,EAAE,QAAQ,QAAQ,MAAM,SAAS,CAAC;AAAA,EACvE,SAAS,K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eAAe;AAAA,IACrC,CAAC;AAAA,EACH;AAEA,SAAO,EAAE,KAAK,SAAS;AACzB;","names":[]}
@@ -29,29 +29,18 @@ 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_erc20_balance_exports = {};
31
31
  __export(use_erc20_balance_exports, {
32
+ hasSufficientBalance: () => hasSufficientBalance,
32
33
  useErc20Balance: () => useErc20Balance,
33
34
  useTokenBalance: () => useTokenBalance
34
35
  });
35
36
  module.exports = __toCommonJS(use_erc20_balance_exports);
36
37
  var import_swr = __toESM(require("swr"), 1);
37
38
  var import_sdk = require("@medialane/sdk");
38
- async function fetchErc20Balance(provider, tokenAddress, holderAddress) {
39
- const result = await provider.callContract(
40
- {
41
- contractAddress: tokenAddress,
42
- entrypoint: "balanceOf",
43
- calldata: [holderAddress]
44
- },
45
- "latest"
46
- );
47
- const low = BigInt(result[0]);
48
- const high = BigInt(result[1]);
49
- return low + (high << 128n);
50
- }
51
- function useErc20Balance(provider, tokenAddress, holderAddress) {
39
+ var import_starknet = require("@medialane/sdk/starknet");
40
+ function useErc20Balance(getClient, tokenAddress, holderAddress) {
52
41
  const { data, error, isLoading } = (0, import_swr.default)(
53
42
  tokenAddress && holderAddress ? ["erc20-balance", tokenAddress, holderAddress] : null,
54
- ([, addr, holder]) => fetchErc20Balance(provider, addr, holder),
43
+ ([, addr, holder]) => (0, import_starknet.erc20Balance)(getClient().provider, addr, holder),
55
44
  {
56
45
  refreshInterval: 3e4,
57
46
  revalidateOnFocus: false,
@@ -62,13 +51,21 @@ function useErc20Balance(provider, tokenAddress, holderAddress) {
62
51
  );
63
52
  return { rawBalance: data ?? null, isLoading, error };
64
53
  }
65
- function useTokenBalance(provider, symbol, holderAddress) {
54
+ function useTokenBalance(getClient, symbol, holderAddress) {
66
55
  const token = symbol ? (0, import_sdk.getListableTokens)().find((t) => t.symbol === symbol) ?? null : null;
67
- const { rawBalance, isLoading, error } = useErc20Balance(provider, token?.address ?? null, holderAddress);
56
+ const { rawBalance, isLoading, error } = useErc20Balance(getClient, token?.address ?? null, holderAddress);
68
57
  return { rawBalance, isLoading, error, decimals: token?.decimals ?? 18 };
69
58
  }
59
+ function hasSufficientBalance(rawBalance, requiredHuman, decimals) {
60
+ if (rawBalance === null) return null;
61
+ const n = parseFloat(requiredHuman);
62
+ if (!requiredHuman || isNaN(n) || n <= 0) return null;
63
+ const required = BigInt((0, import_sdk.parseAmount)(requiredHuman, decimals));
64
+ return rawBalance >= required;
65
+ }
70
66
  // Annotate the CommonJS export names for ESM import in node:
71
67
  0 && (module.exports = {
68
+ hasSufficientBalance,
72
69
  useErc20Balance,
73
70
  useTokenBalance
74
71
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/media-wallet/use-erc20-balance.ts"],"sourcesContent":["\"use client\";\n\nimport useSWR from \"swr\";\nimport type { ProviderInterface } from \"starknet\";\nimport { getListableTokens } from \"@medialane/sdk\";\n\nasync function fetchErc20Balance(provider: ProviderInterface, tokenAddress: string, holderAddress: string): Promise<bigint> {\n const result = await provider.callContract(\n {\n contractAddress: tokenAddress,\n entrypoint: \"balanceOf\",\n calldata: [holderAddress],\n },\n \"latest\"\n );\n\n const low = BigInt(result[0]);\n const high = BigInt(result[1]);\n return low + (high << 128n);\n}\n\nexport function useErc20Balance(provider: ProviderInterface, tokenAddress: string | null, holderAddress: string | null) {\n const { data, error, isLoading } = useSWR(\n tokenAddress && holderAddress ? [\"erc20-balance\", tokenAddress, holderAddress] : null,\n ([, addr, holder]) => fetchErc20Balance(provider, addr, holder),\n {\n refreshInterval: 30_000,\n revalidateOnFocus: false,\n shouldRetryOnError: false,\n onError: () => {},\n }\n );\n return { rawBalance: data ?? null, isLoading, error };\n}\n\nexport function useTokenBalance(provider: ProviderInterface, symbol: string | null, holderAddress: string | null) {\n const token = symbol ? getListableTokens().find((t) => t.symbol === symbol) ?? null : null;\n const { rawBalance, isLoading, error } = useErc20Balance(provider, token?.address ?? null, holderAddress);\n return { rawBalance, isLoading, error, decimals: token?.decimals ?? 18 };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,iBAAmB;AAEnB,iBAAkC;AAElC,eAAe,kBAAkB,UAA6B,cAAsB,eAAwC;AAC1H,QAAM,SAAS,MAAM,SAAS;AAAA,IAC5B;AAAA,MACE,iBAAiB;AAAA,MACjB,YAAY;AAAA,MACZ,UAAU,CAAC,aAAa;AAAA,IAC1B;AAAA,IACA;AAAA,EACF;AAEA,QAAM,MAAM,OAAO,OAAO,CAAC,CAAC;AAC5B,QAAM,OAAO,OAAO,OAAO,CAAC,CAAC;AAC7B,SAAO,OAAO,QAAQ;AACxB;AAEO,SAAS,gBAAgB,UAA6B,cAA6B,eAA8B;AACtH,QAAM,EAAE,MAAM,OAAO,UAAU,QAAI,WAAAA;AAAA,IACjC,gBAAgB,gBAAgB,CAAC,iBAAiB,cAAc,aAAa,IAAI;AAAA,IACjF,CAAC,CAAC,EAAE,MAAM,MAAM,MAAM,kBAAkB,UAAU,MAAM,MAAM;AAAA,IAC9D;AAAA,MACE,iBAAiB;AAAA,MACjB,mBAAmB;AAAA,MACnB,oBAAoB;AAAA,MACpB,SAAS,MAAM;AAAA,MAAC;AAAA,IAClB;AAAA,EACF;AACA,SAAO,EAAE,YAAY,QAAQ,MAAM,WAAW,MAAM;AACtD;AAEO,SAAS,gBAAgB,UAA6B,QAAuB,eAA8B;AAChH,QAAM,QAAQ,aAAS,8BAAkB,EAAE,KAAK,CAAC,MAAM,EAAE,WAAW,MAAM,KAAK,OAAO;AACtF,QAAM,EAAE,YAAY,WAAW,MAAM,IAAI,gBAAgB,UAAU,OAAO,WAAW,MAAM,aAAa;AACxG,SAAO,EAAE,YAAY,WAAW,OAAO,UAAU,OAAO,YAAY,GAAG;AACzE;","names":["useSWR"]}
1
+ {"version":3,"sources":["../../../src/utils/media-wallet/use-erc20-balance.ts"],"sourcesContent":["\"use client\";\n\nimport useSWR from \"swr\";\nimport { getListableTokens, parseAmount } from \"@medialane/sdk\";\nimport { erc20Balance, type MedialaneClient } from \"@medialane/sdk/starknet\";\n\nexport function useErc20Balance(getClient: () => MedialaneClient, tokenAddress: string | null, holderAddress: string | null) {\n const { data, error, isLoading } = useSWR(\n tokenAddress && holderAddress ? [\"erc20-balance\", tokenAddress, holderAddress] : null,\n ([, addr, holder]) => erc20Balance(getClient().provider, addr, holder),\n {\n refreshInterval: 30_000,\n revalidateOnFocus: false,\n shouldRetryOnError: false,\n onError: () => {},\n }\n );\n return { rawBalance: data ?? null, isLoading, error };\n}\n\nexport function useTokenBalance(getClient: () => MedialaneClient, symbol: string | null, holderAddress: string | null) {\n const token = symbol ? getListableTokens().find((t) => t.symbol === symbol) ?? null : null;\n const { rawBalance, isLoading, error } = useErc20Balance(getClient, token?.address ?? null, holderAddress);\n return { rawBalance, isLoading, error, decimals: token?.decimals ?? 18 };\n}\n\nexport function hasSufficientBalance(\n rawBalance: bigint | null,\n requiredHuman: string,\n decimals: number\n): boolean | null {\n if (rawBalance === null) return null;\n const n = parseFloat(requiredHuman);\n if (!requiredHuman || isNaN(n) || n <= 0) return null;\n const required = BigInt(parseAmount(requiredHuman, decimals));\n return rawBalance >= required;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,iBAAmB;AACnB,iBAA+C;AAC/C,sBAAmD;AAE5C,SAAS,gBAAgB,WAAkC,cAA6B,eAA8B;AAC3H,QAAM,EAAE,MAAM,OAAO,UAAU,QAAI,WAAAA;AAAA,IACjC,gBAAgB,gBAAgB,CAAC,iBAAiB,cAAc,aAAa,IAAI;AAAA,IACjF,CAAC,CAAC,EAAE,MAAM,MAAM,UAAM,8BAAa,UAAU,EAAE,UAAU,MAAM,MAAM;AAAA,IACrE;AAAA,MACE,iBAAiB;AAAA,MACjB,mBAAmB;AAAA,MACnB,oBAAoB;AAAA,MACpB,SAAS,MAAM;AAAA,MAAC;AAAA,IAClB;AAAA,EACF;AACA,SAAO,EAAE,YAAY,QAAQ,MAAM,WAAW,MAAM;AACtD;AAEO,SAAS,gBAAgB,WAAkC,QAAuB,eAA8B;AACrH,QAAM,QAAQ,aAAS,8BAAkB,EAAE,KAAK,CAAC,MAAM,EAAE,WAAW,MAAM,KAAK,OAAO;AACtF,QAAM,EAAE,YAAY,WAAW,MAAM,IAAI,gBAAgB,WAAW,OAAO,WAAW,MAAM,aAAa;AACzG,SAAO,EAAE,YAAY,WAAW,OAAO,UAAU,OAAO,YAAY,GAAG;AACzE;AAEO,SAAS,qBACd,YACA,eACA,UACgB;AAChB,MAAI,eAAe,KAAM,QAAO;AAChC,QAAM,IAAI,WAAW,aAAa;AAClC,MAAI,CAAC,iBAAiB,MAAM,CAAC,KAAK,KAAK,EAAG,QAAO;AACjD,QAAM,WAAW,WAAO,wBAAY,eAAe,QAAQ,CAAC;AAC5D,SAAO,cAAc;AACvB;","names":["useSWR"]}
@@ -1,15 +1,16 @@
1
- import { ProviderInterface } from 'starknet';
1
+ import { MedialaneClient } from '@medialane/sdk/starknet';
2
2
 
3
- declare function useErc20Balance(provider: ProviderInterface, tokenAddress: string | null, holderAddress: string | null): {
3
+ declare function useErc20Balance(getClient: () => MedialaneClient, tokenAddress: string | null, holderAddress: string | null): {
4
4
  rawBalance: bigint | null;
5
5
  isLoading: boolean;
6
6
  error: any;
7
7
  };
8
- declare function useTokenBalance(provider: ProviderInterface, symbol: string | null, holderAddress: string | null): {
8
+ declare function useTokenBalance(getClient: () => MedialaneClient, symbol: string | null, holderAddress: string | null): {
9
9
  rawBalance: bigint | null;
10
10
  isLoading: boolean;
11
11
  error: any;
12
12
  decimals: 6 | 18 | 8;
13
13
  };
14
+ declare function hasSufficientBalance(rawBalance: bigint | null, requiredHuman: string, decimals: number): boolean | null;
14
15
 
15
- export { useErc20Balance, useTokenBalance };
16
+ export { hasSufficientBalance, useErc20Balance, useTokenBalance };
@@ -1,15 +1,16 @@
1
- import { ProviderInterface } from 'starknet';
1
+ import { MedialaneClient } from '@medialane/sdk/starknet';
2
2
 
3
- declare function useErc20Balance(provider: ProviderInterface, tokenAddress: string | null, holderAddress: string | null): {
3
+ declare function useErc20Balance(getClient: () => MedialaneClient, tokenAddress: string | null, holderAddress: string | null): {
4
4
  rawBalance: bigint | null;
5
5
  isLoading: boolean;
6
6
  error: any;
7
7
  };
8
- declare function useTokenBalance(provider: ProviderInterface, symbol: string | null, holderAddress: string | null): {
8
+ declare function useTokenBalance(getClient: () => MedialaneClient, symbol: string | null, holderAddress: string | null): {
9
9
  rawBalance: bigint | null;
10
10
  isLoading: boolean;
11
11
  error: any;
12
12
  decimals: 6 | 18 | 8;
13
13
  };
14
+ declare function hasSufficientBalance(rawBalance: bigint | null, requiredHuman: string, decimals: number): boolean | null;
14
15
 
15
- export { useErc20Balance, useTokenBalance };
16
+ export { hasSufficientBalance, useErc20Balance, useTokenBalance };
@@ -1,23 +1,11 @@
1
1
  "use client";
2
2
  import useSWR from "swr";
3
- import { getListableTokens } from "@medialane/sdk";
4
- async function fetchErc20Balance(provider, tokenAddress, holderAddress) {
5
- const result = await provider.callContract(
6
- {
7
- contractAddress: tokenAddress,
8
- entrypoint: "balanceOf",
9
- calldata: [holderAddress]
10
- },
11
- "latest"
12
- );
13
- const low = BigInt(result[0]);
14
- const high = BigInt(result[1]);
15
- return low + (high << 128n);
16
- }
17
- function useErc20Balance(provider, tokenAddress, holderAddress) {
3
+ import { getListableTokens, parseAmount } from "@medialane/sdk";
4
+ import { erc20Balance } from "@medialane/sdk/starknet";
5
+ function useErc20Balance(getClient, tokenAddress, holderAddress) {
18
6
  const { data, error, isLoading } = useSWR(
19
7
  tokenAddress && holderAddress ? ["erc20-balance", tokenAddress, holderAddress] : null,
20
- ([, addr, holder]) => fetchErc20Balance(provider, addr, holder),
8
+ ([, addr, holder]) => erc20Balance(getClient().provider, addr, holder),
21
9
  {
22
10
  refreshInterval: 3e4,
23
11
  revalidateOnFocus: false,
@@ -28,12 +16,20 @@ function useErc20Balance(provider, tokenAddress, holderAddress) {
28
16
  );
29
17
  return { rawBalance: data ?? null, isLoading, error };
30
18
  }
31
- function useTokenBalance(provider, symbol, holderAddress) {
19
+ function useTokenBalance(getClient, symbol, holderAddress) {
32
20
  const token = symbol ? getListableTokens().find((t) => t.symbol === symbol) ?? null : null;
33
- const { rawBalance, isLoading, error } = useErc20Balance(provider, token?.address ?? null, holderAddress);
21
+ const { rawBalance, isLoading, error } = useErc20Balance(getClient, token?.address ?? null, holderAddress);
34
22
  return { rawBalance, isLoading, error, decimals: token?.decimals ?? 18 };
35
23
  }
24
+ function hasSufficientBalance(rawBalance, requiredHuman, decimals) {
25
+ if (rawBalance === null) return null;
26
+ const n = parseFloat(requiredHuman);
27
+ if (!requiredHuman || isNaN(n) || n <= 0) return null;
28
+ const required = BigInt(parseAmount(requiredHuman, decimals));
29
+ return rawBalance >= required;
30
+ }
36
31
  export {
32
+ hasSufficientBalance,
37
33
  useErc20Balance,
38
34
  useTokenBalance
39
35
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/media-wallet/use-erc20-balance.ts"],"sourcesContent":["\"use client\";\n\nimport useSWR from \"swr\";\nimport type { ProviderInterface } from \"starknet\";\nimport { getListableTokens } from \"@medialane/sdk\";\n\nasync function fetchErc20Balance(provider: ProviderInterface, tokenAddress: string, holderAddress: string): Promise<bigint> {\n const result = await provider.callContract(\n {\n contractAddress: tokenAddress,\n entrypoint: \"balanceOf\",\n calldata: [holderAddress],\n },\n \"latest\"\n );\n\n const low = BigInt(result[0]);\n const high = BigInt(result[1]);\n return low + (high << 128n);\n}\n\nexport function useErc20Balance(provider: ProviderInterface, tokenAddress: string | null, holderAddress: string | null) {\n const { data, error, isLoading } = useSWR(\n tokenAddress && holderAddress ? [\"erc20-balance\", tokenAddress, holderAddress] : null,\n ([, addr, holder]) => fetchErc20Balance(provider, addr, holder),\n {\n refreshInterval: 30_000,\n revalidateOnFocus: false,\n shouldRetryOnError: false,\n onError: () => {},\n }\n );\n return { rawBalance: data ?? null, isLoading, error };\n}\n\nexport function useTokenBalance(provider: ProviderInterface, symbol: string | null, holderAddress: string | null) {\n const token = symbol ? getListableTokens().find((t) => t.symbol === symbol) ?? null : null;\n const { rawBalance, isLoading, error } = useErc20Balance(provider, token?.address ?? null, holderAddress);\n return { rawBalance, isLoading, error, decimals: token?.decimals ?? 18 };\n}\n"],"mappings":";AAEA,OAAO,YAAY;AAEnB,SAAS,yBAAyB;AAElC,eAAe,kBAAkB,UAA6B,cAAsB,eAAwC;AAC1H,QAAM,SAAS,MAAM,SAAS;AAAA,IAC5B;AAAA,MACE,iBAAiB;AAAA,MACjB,YAAY;AAAA,MACZ,UAAU,CAAC,aAAa;AAAA,IAC1B;AAAA,IACA;AAAA,EACF;AAEA,QAAM,MAAM,OAAO,OAAO,CAAC,CAAC;AAC5B,QAAM,OAAO,OAAO,OAAO,CAAC,CAAC;AAC7B,SAAO,OAAO,QAAQ;AACxB;AAEO,SAAS,gBAAgB,UAA6B,cAA6B,eAA8B;AACtH,QAAM,EAAE,MAAM,OAAO,UAAU,IAAI;AAAA,IACjC,gBAAgB,gBAAgB,CAAC,iBAAiB,cAAc,aAAa,IAAI;AAAA,IACjF,CAAC,CAAC,EAAE,MAAM,MAAM,MAAM,kBAAkB,UAAU,MAAM,MAAM;AAAA,IAC9D;AAAA,MACE,iBAAiB;AAAA,MACjB,mBAAmB;AAAA,MACnB,oBAAoB;AAAA,MACpB,SAAS,MAAM;AAAA,MAAC;AAAA,IAClB;AAAA,EACF;AACA,SAAO,EAAE,YAAY,QAAQ,MAAM,WAAW,MAAM;AACtD;AAEO,SAAS,gBAAgB,UAA6B,QAAuB,eAA8B;AAChH,QAAM,QAAQ,SAAS,kBAAkB,EAAE,KAAK,CAAC,MAAM,EAAE,WAAW,MAAM,KAAK,OAAO;AACtF,QAAM,EAAE,YAAY,WAAW,MAAM,IAAI,gBAAgB,UAAU,OAAO,WAAW,MAAM,aAAa;AACxG,SAAO,EAAE,YAAY,WAAW,OAAO,UAAU,OAAO,YAAY,GAAG;AACzE;","names":[]}
1
+ {"version":3,"sources":["../../../src/utils/media-wallet/use-erc20-balance.ts"],"sourcesContent":["\"use client\";\n\nimport useSWR from \"swr\";\nimport { getListableTokens, parseAmount } from \"@medialane/sdk\";\nimport { erc20Balance, type MedialaneClient } from \"@medialane/sdk/starknet\";\n\nexport function useErc20Balance(getClient: () => MedialaneClient, tokenAddress: string | null, holderAddress: string | null) {\n const { data, error, isLoading } = useSWR(\n tokenAddress && holderAddress ? [\"erc20-balance\", tokenAddress, holderAddress] : null,\n ([, addr, holder]) => erc20Balance(getClient().provider, addr, holder),\n {\n refreshInterval: 30_000,\n revalidateOnFocus: false,\n shouldRetryOnError: false,\n onError: () => {},\n }\n );\n return { rawBalance: data ?? null, isLoading, error };\n}\n\nexport function useTokenBalance(getClient: () => MedialaneClient, symbol: string | null, holderAddress: string | null) {\n const token = symbol ? getListableTokens().find((t) => t.symbol === symbol) ?? null : null;\n const { rawBalance, isLoading, error } = useErc20Balance(getClient, token?.address ?? null, holderAddress);\n return { rawBalance, isLoading, error, decimals: token?.decimals ?? 18 };\n}\n\nexport function hasSufficientBalance(\n rawBalance: bigint | null,\n requiredHuman: string,\n decimals: number\n): boolean | null {\n if (rawBalance === null) return null;\n const n = parseFloat(requiredHuman);\n if (!requiredHuman || isNaN(n) || n <= 0) return null;\n const required = BigInt(parseAmount(requiredHuman, decimals));\n return rawBalance >= required;\n}\n"],"mappings":";AAEA,OAAO,YAAY;AACnB,SAAS,mBAAmB,mBAAmB;AAC/C,SAAS,oBAA0C;AAE5C,SAAS,gBAAgB,WAAkC,cAA6B,eAA8B;AAC3H,QAAM,EAAE,MAAM,OAAO,UAAU,IAAI;AAAA,IACjC,gBAAgB,gBAAgB,CAAC,iBAAiB,cAAc,aAAa,IAAI;AAAA,IACjF,CAAC,CAAC,EAAE,MAAM,MAAM,MAAM,aAAa,UAAU,EAAE,UAAU,MAAM,MAAM;AAAA,IACrE;AAAA,MACE,iBAAiB;AAAA,MACjB,mBAAmB;AAAA,MACnB,oBAAoB;AAAA,MACpB,SAAS,MAAM;AAAA,MAAC;AAAA,IAClB;AAAA,EACF;AACA,SAAO,EAAE,YAAY,QAAQ,MAAM,WAAW,MAAM;AACtD;AAEO,SAAS,gBAAgB,WAAkC,QAAuB,eAA8B;AACrH,QAAM,QAAQ,SAAS,kBAAkB,EAAE,KAAK,CAAC,MAAM,EAAE,WAAW,MAAM,KAAK,OAAO;AACtF,QAAM,EAAE,YAAY,WAAW,MAAM,IAAI,gBAAgB,WAAW,OAAO,WAAW,MAAM,aAAa;AACzG,SAAO,EAAE,YAAY,WAAW,OAAO,UAAU,OAAO,YAAY,GAAG;AACzE;AAEO,SAAS,qBACd,YACA,eACA,UACgB;AAChB,MAAI,eAAe,KAAM,QAAO;AAChC,QAAM,IAAI,WAAW,aAAa;AAClC,MAAI,CAAC,iBAAiB,MAAM,CAAC,KAAK,KAAK,EAAG,QAAO;AACjD,QAAM,WAAW,OAAO,YAAY,eAAe,QAAQ,CAAC;AAC5D,SAAO,cAAc;AACvB;","names":[]}
@@ -40,9 +40,9 @@ __export(use_drops_exports, {
40
40
  });
41
41
  module.exports = __toCommonJS(use_drops_exports);
42
42
  var import_swr = __toESM(require("swr"), 1);
43
+ var import_sdk = require("@medialane/sdk");
43
44
  var import_starknet = require("@medialane/sdk/starknet");
44
45
  var import_use_medialane_client = require("./use-medialane-client.js");
45
- var import_chain = require("./drop/chain.js");
46
46
  const quiet = { revalidateOnFocus: false, shouldRetryOnError: false };
47
47
  function useDrops(getClient, status) {
48
48
  const client = (0, import_use_medialane_client.useMedialaneClient)(getClient);
@@ -74,20 +74,20 @@ function useDropFile(getClient, baseUri, name) {
74
74
  const { data } = (0, import_swr.default)(baseUri ? ["drop-file", baseUri, name] : null, async () => (await client.api.resolveMetadata(`${baseUri}${name}`)).data, quiet);
75
75
  return data ?? null;
76
76
  }
77
- async function readDropState(client, provider, contract, wallet) {
77
+ async function readDropState(client, contract, wallet) {
78
78
  const drop = await client.api.getDropState(contract);
79
79
  if (!drop) throw new Error("Drop not found");
80
80
  const [claimed, balance] = await Promise.all([
81
- wallet ? (0, import_starknet.dropClaimedBy)(provider, contract, wallet) : Promise.resolve(null),
82
- wallet && drop.price > 0n ? (0, import_chain.erc20Balance)(provider, drop.paymentToken, wallet) : Promise.resolve(null)
81
+ wallet ? (0, import_starknet.dropClaimedBy)(client.provider, contract, wallet) : Promise.resolve(null),
82
+ wallet && drop.price > 0n ? (0, import_starknet.erc20Balance)(client.provider, (0, import_sdk.normalizeAddress)("STARKNET", drop.paymentToken), (0, import_sdk.normalizeAddress)("STARKNET", wallet)) : Promise.resolve(null)
83
83
  ]);
84
84
  return { drop, claimed, balance };
85
85
  }
86
- function useDropChain(getClient, provider, contract, wallet) {
86
+ function useDropChain(getClient, contract, wallet) {
87
87
  const client = (0, import_use_medialane_client.useMedialaneClient)(getClient);
88
88
  const { data, mutate, error } = (0, import_swr.default)(
89
89
  contract ? ["drop-chain", contract, wallet] : null,
90
- () => readDropState(client, provider, contract, wallet),
90
+ () => readDropState(client, contract, wallet),
91
91
  { revalidateOnFocus: true, refreshInterval: 15e3 }
92
92
  );
93
93
  return { ...data ?? { drop: null, claimed: null, balance: null }, error, mutate };
@@ -1 +1 @@
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, 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\nexport async function readDropState(\n client: MedialaneClient,\n provider: DropProvider,\n contract: string,\n wallet: string | null,\n): Promise<DropChainState> {\n const drop = await client.api.getDropState(contract);\n if (!drop) throw new Error(\"Drop not found\");\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}\n\nexport function useDropChain(\n getClient: () => MedialaneClient,\n provider: DropProvider,\n contract: string | null,\n wallet: string | null,\n) {\n const client = useMedialaneClient(getClient);\n const { data, mutate, error } = useSWR(\n contract ? [\"drop-chain\", contract, wallet] : null,\n () => readDropState(client, provider, contract!, wallet),\n { revalidateOnFocus: true, refreshInterval: 15_000 },\n );\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;AAAA;AAEA,iBAAmB;AAEnB,sBAAsE;AACtE,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,IA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cACpB,QACA,UACA,UACA,QACyB;AACzB,QAAM,OAAO,MAAM,OAAO,IAAI,aAAa,QAAQ;AACnD,MAAI,CAAC,KAAM,OAAM,IAAI,MAAM,gBAAgB;AAC3C,QAAM,CAAC,SAAS,OAAO,IAAI,MAAM,QAAQ,IAAI;AAAA,IAC3C,aAAS,+BAAc,UAAU,UAAU,MAAM,IAAI,QAAQ,QAAQ,IAAI;AAAA,IACzE,UAAU,KAAK,QAAQ,SAAK,2BAAa,UAAU,KAAK,cAAc,MAAM,IAAI,QAAQ,QAAQ,IAAI;AAAA,EACtG,CAAC;AACD,SAAO,EAAE,MAAM,SAAS,QAAQ;AAClC;AAEO,SAAS,aACd,WACA,UACA,UACA,QACA;AACA,QAAM,aAAS,gDAAmB,SAAS;AAC3C,QAAM,EAAE,MAAM,QAAQ,MAAM,QAAI,WAAAA;AAAA,IAC9B,WAAW,CAAC,cAAc,UAAU,MAAM,IAAI;AAAA,IAC9C,MAAM,cAAc,QAAQ,UAAU,UAAW,MAAM;AAAA,IACvD,EAAE,mBAAmB,MAAM,iBAAiB,KAAO;AAAA,EACrD;AACA,SAAO,EAAE,GAAI,QAAQ,EAAE,MAAM,MAAM,SAAS,MAAM,SAAS,KAAK,GAAI,OAAO,OAAO;AACpF;","names":["useSWR"]}
1
+ {"version":3,"sources":["../../src/utils/use-drops.ts"],"sourcesContent":["\"use client\";\n\nimport useSWR from \"swr\";\nimport { normalizeAddress, type ApiDrop, type ApiDropListStatus, type ApiDropMint } from \"@medialane/sdk\";\nimport { dropClaimedBy, erc20Balance, type DropOnchain, type MedialaneClient } from \"@medialane/sdk/starknet\";\nimport { useMedialaneClient } from \"./use-medialane-client.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\nexport async function readDropState(\n client: MedialaneClient,\n contract: string,\n wallet: string | null,\n): Promise<DropChainState> {\n const drop = await client.api.getDropState(contract);\n if (!drop) throw new Error(\"Drop not found\");\n const [claimed, balance] = await Promise.all([\n wallet ? dropClaimedBy(client.provider, contract, wallet) : Promise.resolve(null),\n wallet && drop.price > 0n ? erc20Balance(client.provider, normalizeAddress(\"STARKNET\", drop.paymentToken), normalizeAddress(\"STARKNET\", wallet)) : Promise.resolve(null),\n ]);\n return { drop, claimed, balance };\n}\n\nexport function useDropChain(\n getClient: () => MedialaneClient,\n contract: string | null,\n wallet: string | null,\n) {\n const client = useMedialaneClient(getClient);\n const { data, mutate, error } = useSWR(\n contract ? [\"drop-chain\", contract, wallet] : null,\n () => readDropState(client, contract!, wallet),\n { revalidateOnFocus: true, refreshInterval: 15_000 },\n );\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;AAAA;AAEA,iBAAmB;AACnB,iBAAyF;AACzF,sBAAoF;AACpF,kCAAmC;AAEnC,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,MAA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gBAAgB;AAC3C,QAAM,CAAC,SAAS,OAAO,IAAI,MAAM,QAAQ,IAAI;AAAA,IAC3C,aAAS,+BAAc,OAAO,UAAU,UAAU,MAAM,IAAI,QAAQ,QAAQ,IAAI;AAAA,IAChF,UAAU,KAAK,QAAQ,SAAK,8BAAa,OAAO,cAAU,6BAAiB,YAAY,KAAK,YAAY,OAAG,6BAAiB,YAAY,MAAM,CAAC,IAAI,QAAQ,QAAQ,IAAI;AAAA,EACzK,CAAC;AACD,SAAO,EAAE,MAAM,SAAS,QAAQ;AAClC;AAEO,SAAS,aACd,WACA,UACA,QACA;AACA,QAAM,aAAS,gDAAmB,SAAS;AAC3C,QAAM,EAAE,MAAM,QAAQ,MAAM,QAAI,WAAAA;AAAA,IAC9B,WAAW,CAAC,cAAc,UAAU,MAAM,IAAI;AAAA,IAC9C,MAAM,cAAc,QAAQ,UAAW,MAAM;AAAA,IAC7C,EAAE,mBAAmB,MAAM,iBAAiB,KAAO;AAAA,EACrD;AACA,SAAO,EAAE,GAAI,QAAQ,EAAE,MAAM,MAAM,SAAS,MAAM,SAAS,KAAK,GAAI,OAAO,OAAO;AACpF;","names":["useSWR"]}
@@ -2,10 +2,6 @@ import * as _medialane_sdk from '@medialane/sdk';
2
2
  import { ApiDrop, ApiDropMint, ApiDropListStatus } from '@medialane/sdk';
3
3
  import * as swr from 'swr';
4
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';
9
5
 
10
6
  declare function useDrops(getClient: () => MedialaneClient, status: ApiDropListStatus): {
11
7
  drops: ApiDrop[];
@@ -37,8 +33,8 @@ interface DropChainState {
37
33
  claimed: bigint | null;
38
34
  balance: bigint | null;
39
35
  }
40
- declare function readDropState(client: MedialaneClient, provider: DropProvider, contract: string, wallet: string | null): Promise<DropChainState>;
41
- declare function useDropChain(getClient: () => MedialaneClient, provider: DropProvider, contract: string | null, wallet: string | null): {
36
+ declare function readDropState(client: MedialaneClient, contract: string, wallet: string | null): Promise<DropChainState>;
37
+ declare function useDropChain(getClient: () => MedialaneClient, contract: string | null, wallet: string | null): {
42
38
  error: any;
43
39
  mutate: swr.KeyedMutator<DropChainState>;
44
40
  drop: DropOnchain | null;
@@ -2,10 +2,6 @@ import * as _medialane_sdk from '@medialane/sdk';
2
2
  import { ApiDrop, ApiDropMint, ApiDropListStatus } from '@medialane/sdk';
3
3
  import * as swr from 'swr';
4
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';
9
5
 
10
6
  declare function useDrops(getClient: () => MedialaneClient, status: ApiDropListStatus): {
11
7
  drops: ApiDrop[];
@@ -37,8 +33,8 @@ interface DropChainState {
37
33
  claimed: bigint | null;
38
34
  balance: bigint | null;
39
35
  }
40
- declare function readDropState(client: MedialaneClient, provider: DropProvider, contract: string, wallet: string | null): Promise<DropChainState>;
41
- declare function useDropChain(getClient: () => MedialaneClient, provider: DropProvider, contract: string | null, wallet: string | null): {
36
+ declare function readDropState(client: MedialaneClient, contract: string, wallet: string | null): Promise<DropChainState>;
37
+ declare function useDropChain(getClient: () => MedialaneClient, contract: string | null, wallet: string | null): {
42
38
  error: any;
43
39
  mutate: swr.KeyedMutator<DropChainState>;
44
40
  drop: DropOnchain | null;