diff --git a/common/src/common/networks.ts b/common/src/common/networks.ts index 989b2387..1d3ea6e3 100644 --- a/common/src/common/networks.ts +++ b/common/src/common/networks.ts @@ -20,12 +20,20 @@ const networks = (() => { const getAllSameType = (chainId: chainIdish): NetworkType[] => getAllActive().filter((nw: NetworkType) => isMainnet(nw.chainId) === isMainnet(chainId)); - const getAllMainnets = (): NetworkType[] => getAllActive().filter((nw: NetworkType) => isMainnet(nw.chainId)); + const getAllMainnetIds = (): number[] => + getAllActive() + .filter((nw: NetworkType) => isMainnet(nw.chainId)) + .map((nw) => nw.chainId); - const getAllTestnets = (): NetworkType[] => getAllActive().filter((nw: NetworkType) => isTestnet(nw.chainId)); + const getAllTestnetIds = (): number[] => + getAllActive() + .filter((nw: NetworkType) => isTestnet(nw.chainId)) + .map((nw) => nw.chainId); - const getAllOpMainnets = (): NetworkType[] => - getAllActive().filter((nw: NetworkType) => isOpStack(nw.chainId) && isMainnet(nw.chainId)); + const getAllOpMainnetIds = (): number[] => + getAllActive() + .filter((nw: NetworkType) => isOpStack(nw.chainId) && isMainnet(nw.chainId)) + .map((nw) => nw.chainId); const get = (chainId: chainIdish): NetworkType | undefined => _networksMap?.get(Number(chainId)); @@ -74,9 +82,9 @@ const networks = (() => { getAllActive, getAllInactive, getAllSameType, - getAllMainnets, - getAllTestnets, - getAllOpMainnets, + getAllMainnetIds, + getAllTestnetIds, + getAllOpMainnetIds, getBlur, getBlurUrl, diff --git a/config/src/testnets.handlebars.json b/config/src/testnets.handlebars.json index 576e7e4e..2b07ae9b 100644 --- a/config/src/testnets.handlebars.json +++ b/config/src/testnets.handlebars.json @@ -193,7 +193,7 @@ "linkedMainnet": 59144, "linkedLayer1": 5, "create": true, - "active": true + "active": false }, { "chainId": 59141, @@ -533,6 +533,7 @@ "http://localhost/explorer" ], "linkedMainnet": 31337, - "create": true + "create": true, + "active": false } ] \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7f1d0857..6a8cd7b6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -327,12 +327,6 @@ importers: '@kredeum/common': specifier: workspace:^ version: link:../common - '@kredeum/contracts': - specifier: workspace:^ - version: link:../contracts - '@kredeum/providers': - specifier: workspace:^ - version: link:../providers '@kredeum/svelte': specifier: workspace:^ version: link:../svelte diff --git a/sveltekit/package.json b/sveltekit/package.json index 4aaccd67..df12f10f 100644 --- a/sveltekit/package.json +++ b/sveltekit/package.json @@ -32,8 +32,6 @@ "type": "module", "dependencies": { "@kredeum/common": "workspace:^", - "@kredeum/contracts": "workspace:^", - "@kredeum/providers": "workspace:^", "@kredeum/svelte": "workspace:^" } } \ No newline at end of file diff --git a/sveltekit/src/lib/components/Stats.svelte b/sveltekit/src/lib/components/Stats.svelte index c98f7b4a..7c8cae6f 100644 --- a/sveltekit/src/lib/components/Stats.svelte +++ b/sveltekit/src/lib/components/Stats.svelte @@ -16,16 +16,14 @@ let tabsMounted: TabsMounted = { Mainnets: true, OPnets: false, - Testnets: false, - Inactives: false + Testnets: false }; let tabActive = "Mainnets"; - const getNetworks = (tab: string): NetworkType[] => { - if (tab === "OPnets") return networks.getAllOpMainnets(); - if (tab === "Testnets") return networks.getAllTestnets(); - if (tab === "Inactives") return networks.getAllInactive(); - return networks.getAllMainnets(); + const getChainIds = (tab: string): number[] => { + if (tab === "OPnets") return networks.getAllOpMainnetIds(); + if (tab === "Testnets") return networks.getAllTestnetIds(); + return networks.getAllMainnetIds(); }; $: console.log(tabsMounted); @@ -58,7 +56,7 @@ {#each Object.entries(tabsMounted) as [tabKey, tabMounted]} {#if tabMounted} - + {/if} {/each} diff --git a/sveltekit/src/lib/components/StatsNetwork.svelte b/sveltekit/src/lib/components/StatsNetwork.svelte new file mode 100644 index 00000000..1dff93ea --- /dev/null +++ b/sveltekit/src/lib/components/StatsNetwork.svelte @@ -0,0 +1,28 @@ + + + + + + + + +

Kredeum NFTs Factory - Statistics {networks.getChainName(chainId)}

+
+ + +

+ {chainId} +

+
+
diff --git a/sveltekit/src/lib/components/StatsNetworkLine.svelte b/sveltekit/src/lib/components/StatsNetworkLine.svelte new file mode 100644 index 00000000..6918533f --- /dev/null +++ b/sveltekit/src/lib/components/StatsNetworkLine.svelte @@ -0,0 +1,105 @@ + + +{#if chainId} + + {chainId} + {networks.getChainName(chainId)} + + {#await countCollections(chainId)} + ... + {:then value} + {value} + {:catch} + --- + {/await} + + + + + {getShortAddress(factoryGetAddress(chainId))} + + + + + {getShortAddress(resolverGetAddress(chainId))} + + + + + {getShortAddress(getAddressOpenNFTsTemplate(chainId))} + + + + + {getShortAddress(getAddressOpenAutoMarket(chainId))} + + + +{/if} + + diff --git a/sveltekit/src/lib/components/StatsNetworks.svelte b/sveltekit/src/lib/components/StatsNetworks.svelte index 0d63b5f2..a2443398 100644 --- a/sveltekit/src/lib/components/StatsNetworks.svelte +++ b/sveltekit/src/lib/components/StatsNetworks.svelte @@ -1,63 +1,32 @@ - + @@ -66,41 +35,8 @@ - {#each networksSorted || networks as network} - - - - - - - - - - + {#each chainIds as chainId, index} + {/each}
Chain IDChain
Name
{done}/{networks.length}
Chain
Name
{done}/{chainIds.length}
Collections
Count
{total}
OpenNFTs
Factory
OpenNFTs
Resolver
{network.chainId}{network.chainName} - {#await countCollections(network.chainId)} - ... - {:then count} - {count} - {:catch} - --- - {/await} - - - {getShortAddress(factoryGetAddress(network.chainId))} - - - - {getShortAddress(resolverGetAddress(network.chainId))} - - - - {getShortAddress(getAddressOpenNFTsTemplate(network.chainId))} - - - - {getShortAddress(getAddressOpenAutoMarket(network.chainId))} - -
@@ -110,8 +46,7 @@ border-collapse: collapse; } - th, - td { + th { padding: 8px; text-align: right; border-bottom: 1px solid #ddd; @@ -125,18 +60,4 @@ tr:hover { background-color: #f5f5f5; } - - .addr { - font-family: "Courier New", monospace; - } - .addr a { - color: #007bff; - text-decoration: none; - transition: color 0.2s; - } - - .addr a:hover { - color: #0056b3; - text-decoration: underline; - } diff --git a/sveltekit/src/lib/ts/statsCounts.ts b/sveltekit/src/lib/ts/statsCounts.ts new file mode 100644 index 00000000..47770b41 --- /dev/null +++ b/sveltekit/src/lib/ts/statsCounts.ts @@ -0,0 +1,38 @@ +import type { Writable } from "svelte/store"; +import { get, writable } from "svelte/store"; + +// STORES // + +// number of collection counts updates +const stats: Writable = writable(0); + +// collection count per chainId +const statsCounts: Writable> = writable(new Map()); + +// total collection count of all chainIds +const statsTotal: Writable = writable(0); + + +// FUNCTIONS // + +// chainIds with collection counts +const statsChainIds = (): number[] => [...get(statsCounts).keys()]; + +// subtotal collection count of specific set of chainIds +const statsSubTotal = (chainIds: number[]): number => + chainIds.reduce((sum, chainId) => sum + (get(statsCounts).get(chainId) || 0), 0); + +// update stats +const statsUpdate = (chainId: number, value: number) => { + statsCounts.update((map) => { + statsTotal.update((sum) => sum + value - (map.get(chainId) || 0)); + map.set(chainId, value); + stats.update((n) => n + 1); + + + console.log("statsCounts.update ~ map:", map); + return map; + }); +}; + +export { stats, statsCounts, statsTotal, statsChainIds, statsSubTotal, statsUpdate }; diff --git a/sveltekit/src/routes/stats/+layout.ts b/sveltekit/src/routes/stats/+layout.ts new file mode 100644 index 00000000..94a25ecf --- /dev/null +++ b/sveltekit/src/routes/stats/+layout.ts @@ -0,0 +1,10 @@ +import type { Load } from "@sveltejs/kit"; + +const prerender = false; +const ssr = false; + +const load: Load = async () => { + return {}; +}; + +export { prerender, ssr, load }; diff --git a/sveltekit/src/routes/stats/[chainId]/+page.svelte b/sveltekit/src/routes/stats/[chainId]/+page.svelte new file mode 100644 index 00000000..054a216d --- /dev/null +++ b/sveltekit/src/routes/stats/[chainId]/+page.svelte @@ -0,0 +1,6 @@ + + + diff --git a/sveltekit/svelte.config.js b/sveltekit/svelte.config.js index 208167b5..a9571a5b 100644 --- a/sveltekit/svelte.config.js +++ b/sveltekit/svelte.config.js @@ -14,6 +14,7 @@ const config = { adapter: adapter({ pages: "web/dapp", assets: "web/dapp", + fallback: "200.html", precompress: false, strict: true })