@medialane/ui 0.187.0 → 0.189.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/drop/create/drop-create.d.cts +1 -1
- package/dist/components/drop/create/drop-create.d.ts +1 -1
- package/dist/components/drop/create/launch-dialog.cjs +1 -1
- package/dist/components/drop/create/launch-dialog.cjs.map +1 -1
- package/dist/components/drop/create/launch-dialog.d.cts +1 -1
- package/dist/components/drop/create/launch-dialog.d.ts +1 -1
- package/dist/components/drop/create/launch-dialog.js +1 -1
- package/dist/components/drop/create/launch-dialog.js.map +1 -1
- package/dist/components/drop/page/drop-page.cjs +3 -3
- package/dist/components/drop/page/drop-page.cjs.map +1 -1
- package/dist/components/drop/page/drop-page.d.cts +1 -1
- package/dist/components/drop/page/drop-page.d.ts +1 -1
- package/dist/components/drop/page/drop-page.js +3 -3
- package/dist/components/drop/page/drop-page.js.map +1 -1
- package/dist/components/fast-mint/fast-mint.cjs +4 -5
- package/dist/components/fast-mint/fast-mint.cjs.map +1 -1
- package/dist/components/fast-mint/fast-mint.js +4 -5
- package/dist/components/fast-mint/fast-mint.js.map +1 -1
- package/dist/components/fast-mint/types.cjs.map +1 -1
- package/dist/components/fast-mint/types.d.cts +1 -2
- package/dist/components/fast-mint/types.d.ts +1 -2
- package/dist/components/media-wallet/media-wallet-activity.d.cts +0 -1
- package/dist/components/media-wallet/media-wallet-activity.d.ts +0 -1
- package/dist/components/media-wallet/media-wallet-home.cjs +5 -5
- package/dist/components/media-wallet/media-wallet-home.cjs.map +1 -1
- package/dist/components/media-wallet/media-wallet-home.d.cts +0 -1
- package/dist/components/media-wallet/media-wallet-home.d.ts +0 -1
- package/dist/components/media-wallet/media-wallet-home.js +5 -5
- package/dist/components/media-wallet/media-wallet-home.js.map +1 -1
- package/dist/components/media-wallet/media-wallet-overlay.d.cts +0 -1
- package/dist/components/media-wallet/media-wallet-overlay.d.ts +0 -1
- package/dist/components/media-wallet/media-wallet-send.cjs +7 -7
- package/dist/components/media-wallet/media-wallet-send.cjs.map +1 -1
- package/dist/components/media-wallet/media-wallet-send.d.cts +0 -1
- package/dist/components/media-wallet/media-wallet-send.d.ts +0 -1
- package/dist/components/media-wallet/media-wallet-send.js +7 -7
- package/dist/components/media-wallet/media-wallet-send.js.map +1 -1
- package/dist/components/media-wallet/media-wallet-token-detail.cjs +2 -2
- package/dist/components/media-wallet/media-wallet-token-detail.cjs.map +1 -1
- package/dist/components/media-wallet/media-wallet-token-detail.d.cts +0 -1
- package/dist/components/media-wallet/media-wallet-token-detail.d.ts +0 -1
- package/dist/components/media-wallet/media-wallet-token-detail.js +2 -2
- package/dist/components/media-wallet/media-wallet-token-detail.js.map +1 -1
- package/dist/components/media-wallet/media-wallet.d.cts +0 -1
- package/dist/components/media-wallet/media-wallet.d.ts +0 -1
- package/dist/components/media-wallet/types.cjs.map +1 -1
- package/dist/components/media-wallet/types.d.cts +0 -2
- package/dist/components/media-wallet/types.d.ts +0 -2
- package/dist/components/media-wallet/types.js.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js.map +1 -1
- package/dist/utils/app-wallet.cjs +4 -3
- package/dist/utils/app-wallet.cjs.map +1 -1
- package/dist/utils/app-wallet.d.cts +2 -2
- package/dist/utils/app-wallet.d.ts +2 -2
- package/dist/utils/app-wallet.js +4 -3
- package/dist/utils/app-wallet.js.map +1 -1
- package/dist/utils/drop/actions.cjs +3 -3
- package/dist/utils/drop/actions.cjs.map +1 -1
- package/dist/utils/drop/actions.d.cts +2 -3
- package/dist/utils/drop/actions.d.ts +2 -3
- package/dist/utils/drop/actions.js +3 -3
- package/dist/utils/drop/actions.js.map +1 -1
- package/dist/utils/drop/types.cjs.map +1 -1
- package/dist/utils/drop/types.d.cts +3 -6
- package/dist/utils/drop/types.d.ts +3 -6
- package/dist/utils/media-wallet/use-erc20-balance.cjs +14 -17
- package/dist/utils/media-wallet/use-erc20-balance.cjs.map +1 -1
- package/dist/utils/media-wallet/use-erc20-balance.d.cts +5 -4
- package/dist/utils/media-wallet/use-erc20-balance.d.ts +5 -4
- package/dist/utils/media-wallet/use-erc20-balance.js +14 -18
- package/dist/utils/media-wallet/use-erc20-balance.js.map +1 -1
- package/dist/utils/use-drops.cjs +19 -10
- package/dist/utils/use-drops.cjs.map +1 -1
- package/dist/utils/use-drops.d.cts +3 -7
- package/dist/utils/use-drops.d.ts +3 -7
- package/dist/utils/use-drops.js +19 -11
- package/dist/utils/use-drops.js.map +1 -1
- package/dist/utils/use-pop.cjs +3 -2
- package/dist/utils/use-pop.cjs.map +1 -1
- package/dist/utils/use-pop.d.cts +1 -2
- package/dist/utils/use-pop.d.ts +1 -2
- package/dist/utils/use-pop.js +3 -2
- package/dist/utils/use-pop.js.map +1 -1
- package/package.json +3 -3
- package/dist/utils/drop/chain.cjs +0 -37
- package/dist/utils/drop/chain.cjs.map +0 -1
- package/dist/utils/drop/chain.d.cts +0 -5
- package/dist/utils/drop/chain.d.ts +0 -5
- package/dist/utils/drop/chain.js +0 -13
- package/dist/utils/drop/chain.js.map +0 -1
|
@@ -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
|
-
|
|
41
|
-
declare function useDropChain(
|
|
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;
|
|
@@ -46,4 +42,4 @@ declare function useDropChain(provider: DropProvider, contract: string | null, w
|
|
|
46
42
|
balance: bigint | null;
|
|
47
43
|
};
|
|
48
44
|
|
|
49
|
-
export { type DropChainState, useDrop, useDropChain, useDropFee, useDropFile, useDropMints, useDrops, useMyDrops };
|
|
45
|
+
export { type DropChainState, readDropState, useDrop, useDropChain, useDropFee, useDropFile, useDropMints, useDrops, useMyDrops };
|
|
@@ -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
|
-
|
|
41
|
-
declare function useDropChain(
|
|
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;
|
|
@@ -46,4 +42,4 @@ declare function useDropChain(provider: DropProvider, contract: string | null, w
|
|
|
46
42
|
balance: bigint | null;
|
|
47
43
|
};
|
|
48
44
|
|
|
49
|
-
export { type DropChainState, useDrop, useDropChain, useDropFee, useDropFile, useDropMints, useDrops, useMyDrops };
|
|
45
|
+
export { type DropChainState, readDropState, useDrop, useDropChain, useDropFee, useDropFile, useDropMints, useDrops, useMyDrops };
|
package/dist/utils/use-drops.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import useSWR from "swr";
|
|
3
|
-
import {
|
|
3
|
+
import { normalizeAddress } from "@medialane/sdk";
|
|
4
|
+
import { dropClaimedBy, erc20Balance } from "@medialane/sdk/starknet";
|
|
4
5
|
import { useMedialaneClient } from "./use-medialane-client.js";
|
|
5
|
-
import { erc20Balance } from "./drop/chain.js";
|
|
6
6
|
const quiet = { revalidateOnFocus: false, shouldRetryOnError: false };
|
|
7
7
|
function useDrops(getClient, status) {
|
|
8
8
|
const client = useMedialaneClient(getClient);
|
|
@@ -34,18 +34,26 @@ function useDropFile(getClient, baseUri, name) {
|
|
|
34
34
|
const { data } = useSWR(baseUri ? ["drop-file", baseUri, name] : null, async () => (await client.api.resolveMetadata(`${baseUri}${name}`)).data, quiet);
|
|
35
35
|
return data ?? null;
|
|
36
36
|
}
|
|
37
|
-
function
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
37
|
+
async function readDropState(client, contract, wallet) {
|
|
38
|
+
const drop = await client.api.getDropState(contract);
|
|
39
|
+
if (!drop) throw new Error("Drop not found");
|
|
40
|
+
const [claimed, balance] = await Promise.all([
|
|
41
|
+
wallet ? dropClaimedBy(client.provider, contract, wallet) : Promise.resolve(null),
|
|
42
|
+
wallet && drop.price > 0n ? erc20Balance(client.provider, normalizeAddress("STARKNET", drop.paymentToken), normalizeAddress("STARKNET", wallet)) : Promise.resolve(null)
|
|
43
|
+
]);
|
|
44
|
+
return { drop, claimed, balance };
|
|
45
|
+
}
|
|
46
|
+
function useDropChain(getClient, contract, wallet) {
|
|
47
|
+
const client = useMedialaneClient(getClient);
|
|
48
|
+
const { data, mutate, error } = useSWR(
|
|
49
|
+
contract ? ["drop-chain", contract, wallet] : null,
|
|
50
|
+
() => readDropState(client, contract, wallet),
|
|
51
|
+
{ revalidateOnFocus: true, refreshInterval: 15e3 }
|
|
52
|
+
);
|
|
46
53
|
return { ...data ?? { drop: null, claimed: null, balance: null }, error, mutate };
|
|
47
54
|
}
|
|
48
55
|
export {
|
|
56
|
+
readDropState,
|
|
49
57
|
useDrop,
|
|
50
58
|
useDropChain,
|
|
51
59
|
useDropFee,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/use-drops.ts"],"sourcesContent":["\"use client\";\n\nimport useSWR from \"swr\";\nimport type
|
|
1
|
+
{"version":3,"sources":["../../src/utils/use-drops.ts"],"sourcesContent":["\"use client\";\n\nimport useSWR from \"swr\";\nimport { 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":"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","names":[]}
|
package/dist/utils/use-pop.cjs
CHANGED
|
@@ -59,10 +59,11 @@ function useMyPopEvents(getClient, owner) {
|
|
|
59
59
|
function popClaimedKey(collection, wallet) {
|
|
60
60
|
return collection && wallet ? `pop-claimed-${collection}-${wallet}` : null;
|
|
61
61
|
}
|
|
62
|
-
function usePopClaimStatus(
|
|
62
|
+
function usePopClaimStatus(getClient, collection, wallet) {
|
|
63
|
+
const client = (0, import_use_medialane_client.useMedialaneClient)(getClient);
|
|
63
64
|
const { data, error, isLoading, mutate } = (0, import_swr.default)(
|
|
64
65
|
popClaimedKey(collection, wallet),
|
|
65
|
-
() => (0, import_starknet.popHasClaimed)(provider, collection, wallet),
|
|
66
|
+
() => (0, import_starknet.popHasClaimed)(client.provider, collection, wallet),
|
|
66
67
|
{ revalidateOnFocus: false, shouldRetryOnError: false }
|
|
67
68
|
);
|
|
68
69
|
return { hasClaimed: data ?? null, isLoading, error, mutate };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/use-pop.ts"],"sourcesContent":["\"use client\";\n\nimport useSWR from \"swr\";\nimport type { ApiCollection, ApiMeta } from \"@medialane/sdk\";\nimport { popHasClaimed, type MedialaneClient } from \"@medialane/sdk/starknet\";\nimport
|
|
1
|
+
{"version":3,"sources":["../../src/utils/use-pop.ts"],"sourcesContent":["\"use client\";\n\nimport useSWR from \"swr\";\nimport type { ApiCollection, ApiMeta } from \"@medialane/sdk\";\nimport { popHasClaimed, type MedialaneClient } from \"@medialane/sdk/starknet\";\nimport { useMedialaneClient } from \"./use-medialane-client.js\";\n\nexport function usePopCollections(getClient: () => MedialaneClient) {\n const client = useMedialaneClient(getClient);\n const { data, error, isLoading, mutate } = useSWR<{ data: ApiCollection[]; meta?: ApiMeta }>(\n \"pop-collections\",\n () => client.api.listCollections({ service: \"pop-protocol\", hideEmpty: false, limit: 50 }),\n { revalidateOnFocus: false }\n );\n return { collections: data?.data ?? [], meta: data?.meta, isLoading, error, mutate };\n}\n\nexport function useMyPopEvents(getClient: () => MedialaneClient, owner: string | null) {\n const client = useMedialaneClient(getClient);\n const { data, error, isLoading, mutate } = useSWR<ApiCollection[]>(\n owner ? `my-pop-events-${owner}` : null,\n async () => (await client.api.listCollections({ service: \"pop-protocol\", owner: owner!, limit: 50 })).data ?? [],\n { revalidateOnFocus: false }\n );\n return { events: data ?? [], isLoading, error, mutate };\n}\n\nexport function popClaimedKey(collection: string | null, wallet: string | null): string | null {\n return collection && wallet ? `pop-claimed-${collection}-${wallet}` : null;\n}\n\n/** Whether `wallet` already holds this collection's credential, read from chain. */\nexport function usePopClaimStatus(\n getClient: () => MedialaneClient,\n collection: string | null,\n wallet: string | null,\n) {\n const client = useMedialaneClient(getClient);\n const { data, error, isLoading, mutate } = useSWR<boolean>(\n popClaimedKey(collection, wallet),\n () => popHasClaimed(client.provider, collection!, wallet!),\n { revalidateOnFocus: false, shouldRetryOnError: false },\n );\n return { hasClaimed: data ?? null, isLoading, error, mutate };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,iBAAmB;AAEnB,sBAAoD;AACpD,kCAAmC;AAE5B,SAAS,kBAAkB,WAAkC;AAClE,QAAM,aAAS,gDAAmB,SAAS;AAC3C,QAAM,EAAE,MAAM,OAAO,WAAW,OAAO,QAAI,WAAAA;AAAA,IACzC;AAAA,IACA,MAAM,OAAO,IAAI,gBAAgB,EAAE,SAAS,gBAAgB,WAAW,OAAO,OAAO,GAAG,CAAC;AAAA,IACzF,EAAE,mBAAmB,MAAM;AAAA,EAC7B;AACA,SAAO,EAAE,aAAa,MAAM,QAAQ,CAAC,GAAG,MAAM,MAAM,MAAM,WAAW,OAAO,OAAO;AACrF;AAEO,SAAS,eAAe,WAAkC,OAAsB;AACrF,QAAM,aAAS,gDAAmB,SAAS;AAC3C,QAAM,EAAE,MAAM,OAAO,WAAW,OAAO,QAAI,WAAAA;AAAA,IACzC,QAAQ,iBAAiB,KAAK,KAAK;AAAA,IACnC,aAAa,MAAM,OAAO,IAAI,gBAAgB,EAAE,SAAS,gBAAgB,OAAe,OAAO,GAAG,CAAC,GAAG,QAAQ,CAAC;AAAA,IAC/G,EAAE,mBAAmB,MAAM;AAAA,EAC7B;AACA,SAAO,EAAE,QAAQ,QAAQ,CAAC,GAAG,WAAW,OAAO,OAAO;AACxD;AAEO,SAAS,cAAc,YAA2B,QAAsC;AAC7F,SAAO,cAAc,SAAS,eAAe,UAAU,IAAI,MAAM,KAAK;AACxE;AAGO,SAAS,kBACd,WACA,YACA,QACA;AACA,QAAM,aAAS,gDAAmB,SAAS;AAC3C,QAAM,EAAE,MAAM,OAAO,WAAW,OAAO,QAAI,WAAAA;AAAA,IACzC,cAAc,YAAY,MAAM;AAAA,IAChC,UAAM,+BAAc,OAAO,UAAU,YAAa,MAAO;AAAA,IACzD,EAAE,mBAAmB,OAAO,oBAAoB,MAAM;AAAA,EACxD;AACA,SAAO,EAAE,YAAY,QAAQ,MAAM,WAAW,OAAO,OAAO;AAC9D;","names":["useSWR"]}
|
package/dist/utils/use-pop.d.cts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as swr from 'swr';
|
|
2
2
|
import { ApiCollection, ApiMeta } from '@medialane/sdk';
|
|
3
3
|
import { MedialaneClient } from '@medialane/sdk/starknet';
|
|
4
|
-
import { ProviderInterface } from 'starknet';
|
|
5
4
|
|
|
6
5
|
declare function usePopCollections(getClient: () => MedialaneClient): {
|
|
7
6
|
collections: ApiCollection[];
|
|
@@ -21,7 +20,7 @@ declare function useMyPopEvents(getClient: () => MedialaneClient, owner: string
|
|
|
21
20
|
};
|
|
22
21
|
declare function popClaimedKey(collection: string | null, wallet: string | null): string | null;
|
|
23
22
|
/** Whether `wallet` already holds this collection's credential, read from chain. */
|
|
24
|
-
declare function usePopClaimStatus(
|
|
23
|
+
declare function usePopClaimStatus(getClient: () => MedialaneClient, collection: string | null, wallet: string | null): {
|
|
25
24
|
hasClaimed: boolean | null;
|
|
26
25
|
isLoading: boolean;
|
|
27
26
|
error: any;
|
package/dist/utils/use-pop.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as swr from 'swr';
|
|
2
2
|
import { ApiCollection, ApiMeta } from '@medialane/sdk';
|
|
3
3
|
import { MedialaneClient } from '@medialane/sdk/starknet';
|
|
4
|
-
import { ProviderInterface } from 'starknet';
|
|
5
4
|
|
|
6
5
|
declare function usePopCollections(getClient: () => MedialaneClient): {
|
|
7
6
|
collections: ApiCollection[];
|
|
@@ -21,7 +20,7 @@ declare function useMyPopEvents(getClient: () => MedialaneClient, owner: string
|
|
|
21
20
|
};
|
|
22
21
|
declare function popClaimedKey(collection: string | null, wallet: string | null): string | null;
|
|
23
22
|
/** Whether `wallet` already holds this collection's credential, read from chain. */
|
|
24
|
-
declare function usePopClaimStatus(
|
|
23
|
+
declare function usePopClaimStatus(getClient: () => MedialaneClient, collection: string | null, wallet: string | null): {
|
|
25
24
|
hasClaimed: boolean | null;
|
|
26
25
|
isLoading: boolean;
|
|
27
26
|
error: any;
|
package/dist/utils/use-pop.js
CHANGED
|
@@ -23,10 +23,11 @@ function useMyPopEvents(getClient, owner) {
|
|
|
23
23
|
function popClaimedKey(collection, wallet) {
|
|
24
24
|
return collection && wallet ? `pop-claimed-${collection}-${wallet}` : null;
|
|
25
25
|
}
|
|
26
|
-
function usePopClaimStatus(
|
|
26
|
+
function usePopClaimStatus(getClient, collection, wallet) {
|
|
27
|
+
const client = useMedialaneClient(getClient);
|
|
27
28
|
const { data, error, isLoading, mutate } = useSWR(
|
|
28
29
|
popClaimedKey(collection, wallet),
|
|
29
|
-
() => popHasClaimed(provider, collection, wallet),
|
|
30
|
+
() => popHasClaimed(client.provider, collection, wallet),
|
|
30
31
|
{ revalidateOnFocus: false, shouldRetryOnError: false }
|
|
31
32
|
);
|
|
32
33
|
return { hasClaimed: data ?? null, isLoading, error, mutate };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/use-pop.ts"],"sourcesContent":["\"use client\";\n\nimport useSWR from \"swr\";\nimport type { ApiCollection, ApiMeta } from \"@medialane/sdk\";\nimport { popHasClaimed, type MedialaneClient } from \"@medialane/sdk/starknet\";\nimport
|
|
1
|
+
{"version":3,"sources":["../../src/utils/use-pop.ts"],"sourcesContent":["\"use client\";\n\nimport useSWR from \"swr\";\nimport type { ApiCollection, ApiMeta } from \"@medialane/sdk\";\nimport { popHasClaimed, type MedialaneClient } from \"@medialane/sdk/starknet\";\nimport { useMedialaneClient } from \"./use-medialane-client.js\";\n\nexport function usePopCollections(getClient: () => MedialaneClient) {\n const client = useMedialaneClient(getClient);\n const { data, error, isLoading, mutate } = useSWR<{ data: ApiCollection[]; meta?: ApiMeta }>(\n \"pop-collections\",\n () => client.api.listCollections({ service: \"pop-protocol\", hideEmpty: false, limit: 50 }),\n { revalidateOnFocus: false }\n );\n return { collections: data?.data ?? [], meta: data?.meta, isLoading, error, mutate };\n}\n\nexport function useMyPopEvents(getClient: () => MedialaneClient, owner: string | null) {\n const client = useMedialaneClient(getClient);\n const { data, error, isLoading, mutate } = useSWR<ApiCollection[]>(\n owner ? `my-pop-events-${owner}` : null,\n async () => (await client.api.listCollections({ service: \"pop-protocol\", owner: owner!, limit: 50 })).data ?? [],\n { revalidateOnFocus: false }\n );\n return { events: data ?? [], isLoading, error, mutate };\n}\n\nexport function popClaimedKey(collection: string | null, wallet: string | null): string | null {\n return collection && wallet ? `pop-claimed-${collection}-${wallet}` : null;\n}\n\n/** Whether `wallet` already holds this collection's credential, read from chain. */\nexport function usePopClaimStatus(\n getClient: () => MedialaneClient,\n collection: string | null,\n wallet: string | null,\n) {\n const client = useMedialaneClient(getClient);\n const { data, error, isLoading, mutate } = useSWR<boolean>(\n popClaimedKey(collection, wallet),\n () => popHasClaimed(client.provider, collection!, wallet!),\n { revalidateOnFocus: false, shouldRetryOnError: false },\n );\n return { hasClaimed: data ?? null, isLoading, error, mutate };\n}\n"],"mappings":";AAEA,OAAO,YAAY;AAEnB,SAAS,qBAA2C;AACpD,SAAS,0BAA0B;AAE5B,SAAS,kBAAkB,WAAkC;AAClE,QAAM,SAAS,mBAAmB,SAAS;AAC3C,QAAM,EAAE,MAAM,OAAO,WAAW,OAAO,IAAI;AAAA,IACzC;AAAA,IACA,MAAM,OAAO,IAAI,gBAAgB,EAAE,SAAS,gBAAgB,WAAW,OAAO,OAAO,GAAG,CAAC;AAAA,IACzF,EAAE,mBAAmB,MAAM;AAAA,EAC7B;AACA,SAAO,EAAE,aAAa,MAAM,QAAQ,CAAC,GAAG,MAAM,MAAM,MAAM,WAAW,OAAO,OAAO;AACrF;AAEO,SAAS,eAAe,WAAkC,OAAsB;AACrF,QAAM,SAAS,mBAAmB,SAAS;AAC3C,QAAM,EAAE,MAAM,OAAO,WAAW,OAAO,IAAI;AAAA,IACzC,QAAQ,iBAAiB,KAAK,KAAK;AAAA,IACnC,aAAa,MAAM,OAAO,IAAI,gBAAgB,EAAE,SAAS,gBAAgB,OAAe,OAAO,GAAG,CAAC,GAAG,QAAQ,CAAC;AAAA,IAC/G,EAAE,mBAAmB,MAAM;AAAA,EAC7B;AACA,SAAO,EAAE,QAAQ,QAAQ,CAAC,GAAG,WAAW,OAAO,OAAO;AACxD;AAEO,SAAS,cAAc,YAA2B,QAAsC;AAC7F,SAAO,cAAc,SAAS,eAAe,UAAU,IAAI,MAAM,KAAK;AACxE;AAGO,SAAS,kBACd,WACA,YACA,QACA;AACA,QAAM,SAAS,mBAAmB,SAAS;AAC3C,QAAM,EAAE,MAAM,OAAO,WAAW,OAAO,IAAI;AAAA,IACzC,cAAc,YAAY,MAAM;AAAA,IAChC,MAAM,cAAc,OAAO,UAAU,YAAa,MAAO;AAAA,IACzD,EAAE,mBAAmB,OAAO,oBAAoB,MAAM;AAAA,EACxD;AACA,SAAO,EAAE,YAAY,QAAQ,MAAM,WAAW,OAAO,OAAO;AAC9D;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medialane/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.189.0",
|
|
4
4
|
"description": "Shared UI components for Medialane apps",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"preview": "vite --config preview/vite.config.ts"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
|
-
"@medialane/sdk": ">=0.
|
|
54
|
+
"@medialane/sdk": ">=0.182.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",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
},
|
|
84
84
|
"devDependencies": {
|
|
85
85
|
"@happy-dom/global-registrator": "^20.14.5",
|
|
86
|
-
"@medialane/sdk": "0.
|
|
86
|
+
"@medialane/sdk": "0.182.0",
|
|
87
87
|
"@radix-ui/react-checkbox": "^1.3.8",
|
|
88
88
|
"@radix-ui/react-collapsible": "^1.1.17",
|
|
89
89
|
"@radix-ui/react-dialog": "^1.1.20",
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var chain_exports = {};
|
|
20
|
-
__export(chain_exports, {
|
|
21
|
-
erc20Balance: () => erc20Balance
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(chain_exports);
|
|
24
|
-
var import_sdk = require("@medialane/sdk");
|
|
25
|
-
async function erc20Balance(provider, token, wallet) {
|
|
26
|
-
const res = await provider.callContract({
|
|
27
|
-
contractAddress: (0, import_sdk.normalizeAddress)("STARKNET", token),
|
|
28
|
-
entrypoint: "balance_of",
|
|
29
|
-
calldata: [(0, import_sdk.normalizeAddress)("STARKNET", wallet)]
|
|
30
|
-
});
|
|
31
|
-
return BigInt(res[0] ?? "0x0") + (BigInt(res[1] ?? "0x0") << 128n);
|
|
32
|
-
}
|
|
33
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
34
|
-
0 && (module.exports = {
|
|
35
|
-
erc20Balance
|
|
36
|
-
});
|
|
37
|
-
//# sourceMappingURL=chain.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/drop/chain.ts"],"sourcesContent":["import { normalizeAddress } from \"@medialane/sdk\";\nimport type { ProviderInterface } from \"starknet\";\n\nexport async function erc20Balance(provider: Pick<ProviderInterface, \"callContract\">, token: string, wallet: string): Promise<bigint> {\n const res = await provider.callContract({\n contractAddress: normalizeAddress(\"STARKNET\", token),\n entrypoint: \"balance_of\",\n calldata: [normalizeAddress(\"STARKNET\", wallet)],\n });\n return BigInt(res[0] ?? \"0x0\") + (BigInt(res[1] ?? \"0x0\") << 128n);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAiC;AAGjC,eAAsB,aAAa,UAAmD,OAAe,QAAiC;AACpI,QAAM,MAAM,MAAM,SAAS,aAAa;AAAA,IACtC,qBAAiB,6BAAiB,YAAY,KAAK;AAAA,IACnD,YAAY;AAAA,IACZ,UAAU,KAAC,6BAAiB,YAAY,MAAM,CAAC;AAAA,EACjD,CAAC;AACD,SAAO,OAAO,IAAI,CAAC,KAAK,KAAK,KAAK,OAAO,IAAI,CAAC,KAAK,KAAK,KAAK;AAC/D;","names":[]}
|
package/dist/utils/drop/chain.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { normalizeAddress } from "@medialane/sdk";
|
|
2
|
-
async function erc20Balance(provider, token, wallet) {
|
|
3
|
-
const res = await provider.callContract({
|
|
4
|
-
contractAddress: normalizeAddress("STARKNET", token),
|
|
5
|
-
entrypoint: "balance_of",
|
|
6
|
-
calldata: [normalizeAddress("STARKNET", wallet)]
|
|
7
|
-
});
|
|
8
|
-
return BigInt(res[0] ?? "0x0") + (BigInt(res[1] ?? "0x0") << 128n);
|
|
9
|
-
}
|
|
10
|
-
export {
|
|
11
|
-
erc20Balance
|
|
12
|
-
};
|
|
13
|
-
//# sourceMappingURL=chain.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/drop/chain.ts"],"sourcesContent":["import { normalizeAddress } from \"@medialane/sdk\";\nimport type { ProviderInterface } from \"starknet\";\n\nexport async function erc20Balance(provider: Pick<ProviderInterface, \"callContract\">, token: string, wallet: string): Promise<bigint> {\n const res = await provider.callContract({\n contractAddress: normalizeAddress(\"STARKNET\", token),\n entrypoint: \"balance_of\",\n calldata: [normalizeAddress(\"STARKNET\", wallet)],\n });\n return BigInt(res[0] ?? \"0x0\") + (BigInt(res[1] ?? \"0x0\") << 128n);\n}\n"],"mappings":"AAAA,SAAS,wBAAwB;AAGjC,eAAsB,aAAa,UAAmD,OAAe,QAAiC;AACpI,QAAM,MAAM,MAAM,SAAS,aAAa;AAAA,IACtC,iBAAiB,iBAAiB,YAAY,KAAK;AAAA,IACnD,YAAY;AAAA,IACZ,UAAU,CAAC,iBAAiB,YAAY,MAAM,CAAC;AAAA,EACjD,CAAC;AACD,SAAO,OAAO,IAAI,CAAC,KAAK,KAAK,KAAK,OAAO,IAAI,CAAC,KAAK,KAAK,KAAK;AAC/D;","names":[]}
|