Skip to content

Commit

Permalink
Merge branch 'NNS1-3349-add-neuron-details-spec' into NNS1-3349-add-n…
Browse files Browse the repository at this point in the history
…euron-visibility-toggle
  • Loading branch information
coskucinkilic committed Sep 27, 2024
2 parents 5dfccf1 + 420c388 commit 24ea802
Show file tree
Hide file tree
Showing 16 changed files with 583 additions and 110 deletions.
2 changes: 1 addition & 1 deletion dfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@
"DIDC_VERSION": "2024-05-14",
"POCKETIC_VERSION": "3.0.1",
"CARGO_SORT_VERSION": "1.0.9",
"SNSDEMO_RELEASE": "release-2024-09-18",
"SNSDEMO_RELEASE": "release-2024-09-25",
"IC_COMMIT_FOR_PROPOSALS": "release-2024-09-19_01-31-base",
"IC_COMMIT_FOR_SNS_AGGREGATOR": "release-2024-09-19_01-31-base"
},
Expand Down
8 changes: 7 additions & 1 deletion frontend/src/lib/components/accounts/IcrcWalletPage.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
hasAccounts,
} from "$lib/utils/accounts.utils";
import { replacePlaceholders } from "$lib/utils/i18n.utils";
import { IconDots, Island, Spinner } from "@dfinity/gix-components";
import { IconDots, Island, Spinner, Tag } from "@dfinity/gix-components";
import type { Principal } from "@dfinity/principal";
import { TokenAmountV2, isNullish, nonNullish } from "@dfinity/utils";
import type { Writable } from "svelte/store";
Expand Down Expand Up @@ -221,6 +221,12 @@
>
<slot name="header-actions" />
<SignInGuard />

{#if isImportedToken}
<Tag testId="imported-token-tag"
>{$i18n.import_token.imported_token}</Tag
>
{/if}
</WalletPageHeading>

{#if $$slots["info-card"]}
Expand Down
9 changes: 8 additions & 1 deletion frontend/src/lib/pages/NnsProposals.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,14 @@
// Show spinner right away avoiding debounce
loading = true;
proposalsStore.setProposals({ proposals: [], certified: undefined });
const mutableProposalsStore =
proposalsStore.getSingleMutationProposalsStore();
mutableProposalsStore.set({
// This `certified` is what the subscriber of the store sees.
data: { proposals: [], certified: undefined },
// This `certified` indicates that the store mutation is final.
certified: true,
});
debounceFindProposals?.();
};
Expand Down
19 changes: 19 additions & 0 deletions frontend/src/lib/routes/Wallet.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,31 @@
import { i18n } from "$lib/stores/i18n";
import { layoutTitleStore } from "$lib/stores/layout.store";
import { nonNullish } from "@dfinity/utils";
import { AppPath } from "$lib/constants/routes.constants";
import { goto } from "$app/navigation";
import { snsAggregatorStore } from "$lib/stores/sns-aggregator.store";
export let accountIdentifier: string | undefined | null = undefined;
layoutTitleStore.set({
title: $i18n.wallet.title,
});
let isUnknownToken = false;
$: isUnknownToken =
!$isNnsUniverseStore &&
!$isCkBTCUniverseStore &&
!$isIcrcTokenUniverseStore &&
// We can't be sure that the token is unknown
// before we have the list of Sns projects.
nonNullish($snsAggregatorStore.data) &&
!nonNullish($snsProjectSelectedStore);
$: if (isUnknownToken) {
// This will also cover the case when the user was logged out
// being on the wallet page of an imported token
// (imported tokens are not available when signed out).
goto(AppPath.Tokens);
}
</script>

<TestIdWrapper testId="wallet-component">
Expand Down
7 changes: 6 additions & 1 deletion frontend/src/lib/services/nns-vote-registration.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,12 @@ export const registerNnsVotes = async ({
);

// the one that was called
proposalsStore.replaceProposals([updatedProposalInfo]);
const mutableProposalsStore =
proposalsStore.getSingleMutationProposalsStore();
mutableProposalsStore.replaceProposals({
proposals: [updatedProposalInfo],
certified: true,
});
updateProposalContext(updatedProposalInfo);

// Reset and reload actionable nns proposals.
Expand Down
65 changes: 52 additions & 13 deletions frontend/src/lib/services/public/proposals.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
proposalsFiltersStore,
proposalsStore,
type ProposalsFiltersStore,
type SingleMutationProposalsStore,
} from "$lib/stores/proposals.store";
import { toastsError, toastsShow } from "$lib/stores/toasts.store";
import { hashCode } from "$lib/utils/dev.utils";
Expand All @@ -38,18 +39,20 @@ const handleFindProposalsError = ({
error: err,
certified,
identity,
mutableProposalsStore,
}: {
error: unknown;
certified: boolean;
identity: Identity;
mutableProposalsStore: SingleMutationProposalsStore;
}) => {
console.error(err);
if (
certified ||
identity.getPrincipal().isAnonymous() ||
isForceCallStrategy()
) {
proposalsStore.setProposals({ proposals: [], certified });
mutableProposalsStore.setProposals({ proposals: [], certified });

const resultsTooLarge = isPayloadSizeError(err);

Expand All @@ -70,17 +73,29 @@ export const listProposals = async ({
certified: boolean | undefined;
}) => void;
}): Promise<void> => {
const mutableProposalsStore =
proposalsStore.getSingleMutationProposalsStore();
return findProposals({
beforeProposal: undefined,
onLoad: ({ response: proposals, certified }) => {
proposalsStore.setProposals({ proposals, certified });
mutableProposalsStore.setProposals({ proposals, certified });

loadFinished({
paginationOver: proposals.length < DEFAULT_LIST_PAGINATION_LIMIT,
certified,
});
},
onError: handleFindProposalsError,
onError: (onErrorParams: {
error: unknown;
certified: boolean;
identity: Identity;
}) => {
handleFindProposalsError({
...onErrorParams,
mutableProposalsStore,
});
},
mutableProposalsStore,
});
};

Expand All @@ -99,8 +114,10 @@ export const listNextProposals = async ({
paginationOver: boolean;
certified: boolean | undefined;
}) => void;
}): Promise<void> =>
findProposals({
}): Promise<void> => {
const mutableProposalsStore =
proposalsStore.getSingleMutationProposalsStore();
return findProposals({
beforeProposal,
onLoad: ({ response: proposals, certified }) => {
if (proposals.length === 0) {
Expand All @@ -110,30 +127,46 @@ export const listNextProposals = async ({
return;
}

proposalsStore.pushProposals({ proposals, certified });
mutableProposalsStore.pushProposals({ proposals, certified });
loadFinished({
paginationOver: proposals.length < DEFAULT_LIST_PAGINATION_LIMIT,
certified,
});
},
onError: handleFindProposalsError,
onError: (onErrorParams: {
error: unknown;
certified: boolean;
identity: Identity;
}) => {
handleFindProposalsError({
...onErrorParams,
mutableProposalsStore,
});
},
mutableProposalsStore,
});
};

const findProposals = async ({
beforeProposal,
onLoad,
onError,
mutableProposalsStore,
}: {
beforeProposal: ProposalId | undefined;
onLoad: QueryAndUpdateOnResponse<ProposalInfo[]>;
onError: QueryAndUpdateOnError<unknown>;
mutableProposalsStore: SingleMutationProposalsStore;
}): Promise<void> => {
const filters: ProposalsFiltersStore = get(proposalsFiltersStore);

const validateResponses = (
trustedProposals: ProposalInfo[],
untrustedProposals: ProposalInfo[]
) => {
const validateResponses = ({
trustedProposals,
untrustedProposals,
}:{
trustedProposals: ProposalInfo[];
untrustedProposals: ProposalInfo[];
}) => {
if (
proposalsHaveSameIds({
proposalsA: untrustedProposals,
Expand All @@ -151,7 +184,10 @@ const findProposals = async ({
exclusion: trustedProposals,
});
if (proposalsToRemove.length > 0) {
proposalsStore.removeProposals(proposalsToRemove);
mutableProposalsStore.removeProposals({
proposalsToRemove,
certified: true,
});
}
};
let uncertifiedProposals: ProposalInfo[] | undefined;
Expand All @@ -175,7 +211,10 @@ const findProposals = async ({
}

if (uncertifiedProposals) {
validateResponses(proposals, uncertifiedProposals);
validateResponses({
trustedProposals: proposals,
untrustedProposals: uncertifiedProposals,
});
}

onLoad({ response: proposals, certified });
Expand Down
Loading

0 comments on commit 24ea802

Please sign in to comment.