Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vite with SSL and not committed SNS #2981

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
512 changes: 511 additions & 1 deletion frontend/package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@
"svelte2tsx": "^0.6.14",
"ts-jest": "^29.1.0",
"typescript": "^5.0.4",
"vite": "^4.3.8"
"vite": "^4.3.8",
"vite-plugin-mkcert": "^1.10.1"
},
"type": "module",
"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/lib/derived/selectable-universes.derived.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { OWN_CANISTER_ID_TEXT } from "$lib/constants/canister-ids.constants";
import { ckBTCUniversesStore } from "$lib/derived/ckbtc-universes.derived";
import { pageStore, type Page } from "$lib/derived/page.derived";
import {
snsProjectsCommittedStore,
snsProjectsStore,
type SnsFullProject,
} from "$lib/derived/sns/sns-projects.derived";
import type { Universe } from "$lib/types/universe";
Expand All @@ -17,7 +17,7 @@ const universesStore = derived<
[Readable<SnsFullProject[]>, Readable<Universe[]>],
Universe[]
>(
[snsProjectsCommittedStore, ckBTCUniversesStore],
[snsProjectsStore, ckBTCUniversesStore],
([projects, ckBTCUniverses]: [SnsFullProject[], Universe[]]) => [
NNS_UNIVERSE,
...ckBTCUniverses,
Expand Down
8 changes: 5 additions & 3 deletions frontend/src/lib/derived/sns/sns-projects.derived.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ export const snsProjectsStore = derived<
SnsFullProject[]
>(
[snsSummariesStore, snsSwapCommitmentsStore],
([summaries, $snsSwapStatesStore]): SnsFullProject[] =>
summaries.map((summary) => {
([summaries, $snsSwapStatesStore]): SnsFullProject[] => {
console.log('dskloetx summaries', summaries.map(s => s.token.name));
return summaries.map((summary) => {
const { rootCanisterId } = summary;
const summaryPrincipalAsText = rootCanisterId.toText();
const swapCommitmentStoreEntry = $snsSwapStatesStore?.find(
Expand All @@ -46,7 +47,8 @@ export const snsProjectsStore = derived<
summary,
swapCommitment: swapCommitmentStoreEntry?.swapCommitment,
};
})
});
}
);

export const snsProjectsActivePadStore = derived<
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/lib/pages/NnsAccounts.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
});
</script>

<div>My local dev server</div>

<div class="card-grid" data-tid="accounts-body">
{#if nonNullish($icpAccountsStore?.main)}
<!-- Workaround: Type checker does not get $accountsStore.main is defined here -->
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/lib/routes/Neurons.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import { isNnsUniverseStore } from "$lib/derived/selected-universe.derived";
import SummaryUniverse from "$lib/components/summary/SummaryUniverse.svelte";
import { nonNullish } from "@dfinity/utils";
import { snsCommittedProjectSelectedStore } from "$lib/derived/sns/sns-selected-project.derived";
import { snsProjectSelectedStore } from "$lib/derived/sns/sns-selected-project.derived";
</script>

<TestIdWrapper testId="neurons-component">
Expand All @@ -16,15 +16,15 @@

{#if $isNnsUniverseStore}
<NnsNeurons />
{:else if nonNullish($snsCommittedProjectSelectedStore)}
{:else if nonNullish($snsProjectSelectedStore)}
<SnsNeurons />
{/if}
</main>

{#if $isNnsUniverseStore}
<NnsNeuronsFooter />
<!-- Staking SNS Neurons has not yet been reviewed by security -->
{:else if nonNullish($snsCommittedProjectSelectedStore)}
{:else if nonNullish($snsProjectSelectedStore)}
<SnsNeuronsFooter />
{/if}
</TestIdWrapper>
Expand Down
8 changes: 5 additions & 3 deletions frontend/src/lib/stores/sns.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,11 +271,13 @@ export const snsQueryStoreIsLoading = derived<SnsQueryStore, boolean>(
*/
export const snsSummariesStore = derived<SnsQueryStore, SnsSummary[]>(
snsQueryStore,
(data: SnsQueryStoreData) =>
mapAndSortSnsQueryToSummaries({
(data: SnsQueryStoreData) => {
console.log('dskloetx snsSummariesStore data', data);
return mapAndSortSnsQueryToSummaries({
metadata: data?.metadata ?? [],
swaps: data?.swaps ?? [],
})
});
}
);

// ************** Sns commitment **************
Expand Down
10 changes: 10 additions & 0 deletions frontend/src/lib/utils/sns.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,11 @@ export const mapAndSortSnsQueryToSummaries = ({
);

// Only those that have valid metadata, toke, sale and derived information are - and can be - considered as valid
console.log('dskloetx allSummaries', allSummaries.map(s => [s.token.symbol,
s]));
const validSwapSummaries: ValidSummary[] = allSummaries.filter(
(entry: OptionalSummary): entry is ValidSummary =>
entry.token.symbol === 'CAT' ||
entry.swap !== undefined &&
entry.swap.params !== undefined &&
entry.swapCanisterId !== undefined &&
Expand All @@ -173,13 +176,20 @@ export const mapAndSortSnsQueryToSummaries = ({
entry.metadata !== undefined &&
entry.token !== undefined
);
console.log('dskloetx validSwapSummaries', validSwapSummaries);

return validSwapSummaries.map(({ rootCanisterId, ...rest }) => ({
rootCanisterId: Principal.fromText(rootCanisterId),
...rest,
}));
/*
return sortSnsSummaries(
validSwapSummaries.map(({ rootCanisterId, ...rest }) => ({
rootCanisterId: Principal.fromText(rootCanisterId),
...rest,
}))
);
*/
};

export const getSwapCanisterAccount = ({
Expand Down
4 changes: 3 additions & 1 deletion frontend/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import mkcert from 'vite-plugin-mkcert'
import inject from "@rollup/plugin-inject";
import { sveltekit } from "@sveltejs/kit/vite";
import { readFileSync } from "fs";
Expand All @@ -10,7 +11,8 @@ const json = readFileSync(file, "utf8");
const { version } = JSON.parse(json);

const config: UserConfig = {
plugins: [sveltekit()],
plugins: [sveltekit(), mkcert()],
server: { https: true },
build: {
target: "es2020",
sourcemap: "hidden",
Expand Down