From eeb70c900353b58b15e9b764412a8cfdb5fb19d0 Mon Sep 17 00:00:00 2001 From: Yusef Habib Fernandez Date: Wed, 4 Dec 2024 12:09:29 +0100 Subject: [PATCH 01/14] rename sns information at the snsAggregator level --- .../src/lib/stores/sns-aggregator.store.ts | 57 +++++++++++++++++-- .../utils/sns-aggregator-converters.utils.ts | 24 ++++++++ 2 files changed, 75 insertions(+), 6 deletions(-) diff --git a/frontend/src/lib/stores/sns-aggregator.store.ts b/frontend/src/lib/stores/sns-aggregator.store.ts index 70245b6b3be..cb576d94c3e 100644 --- a/frontend/src/lib/stores/sns-aggregator.store.ts +++ b/frontend/src/lib/stores/sns-aggregator.store.ts @@ -1,4 +1,7 @@ -import type { CachedSnsDto } from "$lib/types/sns-aggregator"; +import type { + CachedSnsDto, + CachedSnsTokenMetadataDto, +} from "$lib/types/sns-aggregator"; import { SnsSwapLifecycle } from "@dfinity/sns"; import { nonNullish } from "@dfinity/utils"; import { derived, writable, type Readable } from "svelte/store"; @@ -35,10 +38,52 @@ export const snsAggregatorIncludingAbortedProjectsStore = export const snsAggregatorStore: SnsAggregatorStore = derived( snsAggregatorIncludingAbortedProjectsStore, (store) => ({ - data: store.data?.filter( - (sns) => - nonNullish(sns.lifecycle) && - sns.lifecycle.lifecycle !== SnsSwapLifecycle.Aborted - ), + data: store.data + ?.filter( + (sns) => + nonNullish(sns.lifecycle) && + sns.lifecycle.lifecycle !== SnsSwapLifecycle.Aborted + ) + .map(fixBrokenSnsMetadataBasedOnId), }) ); + +// TODO: Find a better way to fix broken SNS metadata. +const brokenSnsOverrides: Record< + string, + { name: string; tokenSymbol: string } +> = { + "bd3sg-teaaa-aaaaa-qaaba-cai": { + name: "CYCLES_TRANSFER_STATION", + tokenSymbol: "CTS", + }, +}; + +const fixBrokenSnsMetadataBasedOnId = (sns: CachedSnsDto): CachedSnsDto => { + const override = brokenSnsOverrides[sns.list_sns_canisters.root]; + if (!nonNullish(override)) return sns; + const newMeta = { + ...sns.meta, + name: `${sns.meta.name} (formerly ${override.name})`, + }; + + const newIcrc1Metadata = sns.icrc1_metadata.map< + [string, CachedSnsTokenMetadataDto[0][1]] + >(([name, value]) => { + if (name === "icrc1:symbol" && "Text" in value) { + return [ + name, + { + Text: `${value.Text} (${override.tokenSymbol})`, + }, + ]; + } + return [name, value]; + }); + + return { + ...sns, + meta: { ...newMeta }, + icrc1_metadata: [...newIcrc1Metadata], + }; +}; diff --git a/frontend/src/lib/utils/sns-aggregator-converters.utils.ts b/frontend/src/lib/utils/sns-aggregator-converters.utils.ts index 6bbbd931669..98fb6a8160d 100644 --- a/frontend/src/lib/utils/sns-aggregator-converters.utils.ts +++ b/frontend/src/lib/utils/sns-aggregator-converters.utils.ts @@ -504,6 +504,13 @@ const isValidSummary = (entry: PartialSummary): entry is SnsSummary => nonNullish(entry.swapParams) && nonNullish(entry.lifecycle); +const brokenUniverses: Record = { + "bd3sg-teaaa-aaaaa-qaaba-cai": { + name: "CYCLES_TRANSFER_STATION", + tokenSymbol: "CTS", + }, +}; + export const convertDtoToSnsSummary = ({ canister_ids: { root_canister_id, @@ -536,6 +543,23 @@ export const convertDtoToSnsSummary = ({ : undefined, lifecycle: convertDtoToLifecycle(lifecycle), }; + // const override = brokenUniverses[partialSummary.rootCanisterId.toText()]; + // const metadata = partialSummary.metadata; + + // if (!isNullish(metadata) && !isNullish(override)) { + // partialSummary.metadata = { + // ...metadata, + // name: `${metadata.name} (formerly known as ${override.name})`, + // }; + // } + // const token = partialSummary.token; + + // if (!isNullish(token) && !isNullish(override)) { + // partialSummary.token = { + // ...token, + // symbol: `${token.symbol} (${override.tokenSymbol})`, + // }; + // } return isValidSummary(partialSummary) ? new SnsSummaryWrapper(partialSummary) From 3b9002347754852bf36d1dbf0b0ef0fdf5800ac9 Mon Sep 17 00:00:00 2001 From: Yusef Habib Fernandez Date: Wed, 4 Dec 2024 12:48:14 +0100 Subject: [PATCH 02/14] Adds tests --- .../src/lib/stores/sns-aggregator.store.ts | 3 +- .../utils/sns-aggregator-converters.utils.ts | 24 -------------- .../lib/stores/sns-aggregator.store.spec.ts | 31 +++++++++++++++++++ 3 files changed, 33 insertions(+), 25 deletions(-) diff --git a/frontend/src/lib/stores/sns-aggregator.store.ts b/frontend/src/lib/stores/sns-aggregator.store.ts index cb576d94c3e..2f3bb5b9457 100644 --- a/frontend/src/lib/stores/sns-aggregator.store.ts +++ b/frontend/src/lib/stores/sns-aggregator.store.ts @@ -53,7 +53,8 @@ const brokenSnsOverrides: Record< string, { name: string; tokenSymbol: string } > = { - "bd3sg-teaaa-aaaaa-qaaba-cai": { + // Overrided for CYCLES_TRANSFER_STATION as discussed in https://dfinity.slack.com/archives/C039M7YS6F6/p1733302975333649 + "ibahq-taaaa-aaaaq-aadna-cai": { name: "CYCLES_TRANSFER_STATION", tokenSymbol: "CTS", }, diff --git a/frontend/src/lib/utils/sns-aggregator-converters.utils.ts b/frontend/src/lib/utils/sns-aggregator-converters.utils.ts index 98fb6a8160d..6bbbd931669 100644 --- a/frontend/src/lib/utils/sns-aggregator-converters.utils.ts +++ b/frontend/src/lib/utils/sns-aggregator-converters.utils.ts @@ -504,13 +504,6 @@ const isValidSummary = (entry: PartialSummary): entry is SnsSummary => nonNullish(entry.swapParams) && nonNullish(entry.lifecycle); -const brokenUniverses: Record = { - "bd3sg-teaaa-aaaaa-qaaba-cai": { - name: "CYCLES_TRANSFER_STATION", - tokenSymbol: "CTS", - }, -}; - export const convertDtoToSnsSummary = ({ canister_ids: { root_canister_id, @@ -543,23 +536,6 @@ export const convertDtoToSnsSummary = ({ : undefined, lifecycle: convertDtoToLifecycle(lifecycle), }; - // const override = brokenUniverses[partialSummary.rootCanisterId.toText()]; - // const metadata = partialSummary.metadata; - - // if (!isNullish(metadata) && !isNullish(override)) { - // partialSummary.metadata = { - // ...metadata, - // name: `${metadata.name} (formerly known as ${override.name})`, - // }; - // } - // const token = partialSummary.token; - - // if (!isNullish(token) && !isNullish(override)) { - // partialSummary.token = { - // ...token, - // symbol: `${token.symbol} (${override.tokenSymbol})`, - // }; - // } return isValidSummary(partialSummary) ? new SnsSummaryWrapper(partialSummary) diff --git a/frontend/src/tests/lib/stores/sns-aggregator.store.spec.ts b/frontend/src/tests/lib/stores/sns-aggregator.store.spec.ts index 4a7a818adac..777275a42ac 100644 --- a/frontend/src/tests/lib/stores/sns-aggregator.store.spec.ts +++ b/frontend/src/tests/lib/stores/sns-aggregator.store.spec.ts @@ -137,4 +137,35 @@ describe("sns-aggregator store", () => { expect(get(snsAggregatorStore).data).toEqual(nonAbortedData); }); }); + + describe("brokenSnsOverrides", () => { + const withBrokenSns = ({ + sns, + rootCanisterId, + }: { + sns: CachedSnsDto; + rootCanisterId: string; + }) => ({ + ...sns, + list_sns_canisters: { + ...sns.list_sns_canisters, + root: rootCanisterId, + }, + }); + + it("should override information for SNS with universeId ibahq-taaaa-aaaaq-aadna-cai", () => { + const brokenSns = withBrokenSns({ + sns: aggregatorMockSnsesDataDto[0], + rootCanisterId: "ibahq-taaaa-aaaaq-aadna-cai", + }); + + const data = [brokenSns]; + snsAggregatorIncludingAbortedProjectsStore.setData(data); + const result = get(snsAggregatorStore).data[0]; + expect(result.meta.name).toBe( + "Dragginz (formerly CYCLES_TRANSFER_STATION)" + ); + expect(result.icrc1_metadata[3][1]).toEqual({ Text: "DKP (CTS)" }); + }); + }); }); From d339e6d6bb8840f07a5e3cc0f759877f6966f9c4 Mon Sep 17 00:00:00 2001 From: Yusef Habib Fernandez Date: Wed, 4 Dec 2024 12:54:53 +0100 Subject: [PATCH 03/14] rewording --- frontend/src/tests/lib/stores/sns-aggregator.store.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/tests/lib/stores/sns-aggregator.store.spec.ts b/frontend/src/tests/lib/stores/sns-aggregator.store.spec.ts index 777275a42ac..6df493b8423 100644 --- a/frontend/src/tests/lib/stores/sns-aggregator.store.spec.ts +++ b/frontend/src/tests/lib/stores/sns-aggregator.store.spec.ts @@ -153,7 +153,7 @@ describe("sns-aggregator store", () => { }, }); - it("should override information for SNS with universeId ibahq-taaaa-aaaaq-aadna-cai", () => { + it("should override information for SNS with rootCanisterId ibahq-taaaa-aaaaq-aadna-cai", () => { const brokenSns = withBrokenSns({ sns: aggregatorMockSnsesDataDto[0], rootCanisterId: "ibahq-taaaa-aaaaq-aadna-cai", From b46e8ca41bfb113971ba0da3008659c4b2758eff Mon Sep 17 00:00:00 2001 From: Yusef Habib Fernandez Date: Wed, 4 Dec 2024 13:48:53 +0100 Subject: [PATCH 04/14] car --- .../lib/stores/sns-aggregator.store.spec.ts | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/frontend/src/tests/lib/stores/sns-aggregator.store.spec.ts b/frontend/src/tests/lib/stores/sns-aggregator.store.spec.ts index 6df493b8423..9920ea343ab 100644 --- a/frontend/src/tests/lib/stores/sns-aggregator.store.spec.ts +++ b/frontend/src/tests/lib/stores/sns-aggregator.store.spec.ts @@ -154,8 +154,26 @@ describe("sns-aggregator store", () => { }); it("should override information for SNS with rootCanisterId ibahq-taaaa-aaaaq-aadna-cai", () => { + const mockedSns = aggregatorMockSnsesDataDto[0]; const brokenSns = withBrokenSns({ - sns: aggregatorMockSnsesDataDto[0], + sns: { + ...mockedSns, + meta: { + ...mockedSns.meta, + name: "---", + }, + icrc1_metadata: [...mockedSns.icrc1_metadata].map(([name, value]) => { + if (name === "icrc1:symbol" && "Text" in value) { + return [ + name, + { + Text: "---", + }, + ]; + } + return [name, value]; + }), + }, rootCanisterId: "ibahq-taaaa-aaaaq-aadna-cai", }); @@ -163,9 +181,9 @@ describe("sns-aggregator store", () => { snsAggregatorIncludingAbortedProjectsStore.setData(data); const result = get(snsAggregatorStore).data[0]; expect(result.meta.name).toBe( - "Dragginz (formerly CYCLES_TRANSFER_STATION)" + "--- (formerly CYCLES_TRANSFER_STATION)" ); - expect(result.icrc1_metadata[3][1]).toEqual({ Text: "DKP (CTS)" }); + expect(result.icrc1_metadata[3][1]).toEqual({ Text: "--- (CTS)" }); }); }); }); From 530149e1ed966873287c7ef75bb25120c7d3c92e Mon Sep 17 00:00:00 2001 From: Yusef Habib Fernandez Date: Wed, 4 Dec 2024 13:52:08 +0100 Subject: [PATCH 05/14] car --- .../src/tests/lib/stores/sns-aggregator.store.spec.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/frontend/src/tests/lib/stores/sns-aggregator.store.spec.ts b/frontend/src/tests/lib/stores/sns-aggregator.store.spec.ts index 9920ea343ab..836df3b32fe 100644 --- a/frontend/src/tests/lib/stores/sns-aggregator.store.spec.ts +++ b/frontend/src/tests/lib/stores/sns-aggregator.store.spec.ts @@ -179,10 +179,15 @@ describe("sns-aggregator store", () => { const data = [brokenSns]; snsAggregatorIncludingAbortedProjectsStore.setData(data); - const result = get(snsAggregatorStore).data[0]; - expect(result.meta.name).toBe( - "--- (formerly CYCLES_TRANSFER_STATION)" + expect(get(snsAggregatorIncludingAbortedProjectsStore).data[0].meta.name).toBe( + "---" ); + expect( + get(snsAggregatorIncludingAbortedProjectsStore).data[0].icrc1_metadata[3][1] + ).toEqual({ Text: "---" }); + + const result = get(snsAggregatorStore).data[0]; + expect(result.meta.name).toBe("--- (formerly CYCLES_TRANSFER_STATION)"); expect(result.icrc1_metadata[3][1]).toEqual({ Text: "--- (CTS)" }); }); }); From f65619948828ce5fe9149e86ce41a38e09519869 Mon Sep 17 00:00:00 2001 From: Yusef Habib Fernandez Date: Wed, 4 Dec 2024 14:39:17 +0100 Subject: [PATCH 06/14] pushes the abandoned sns to the bottom of the lists" --- .../src/lib/stores/sns-aggregator.store.ts | 53 ++++++++++--- .../lib/stores/sns-aggregator.store.spec.ts | 76 ++++++++++++------- 2 files changed, 90 insertions(+), 39 deletions(-) diff --git a/frontend/src/lib/stores/sns-aggregator.store.ts b/frontend/src/lib/stores/sns-aggregator.store.ts index 2f3bb5b9457..cf399ce9e55 100644 --- a/frontend/src/lib/stores/sns-aggregator.store.ts +++ b/frontend/src/lib/stores/sns-aggregator.store.ts @@ -37,18 +37,29 @@ export const snsAggregatorIncludingAbortedProjectsStore = export const snsAggregatorStore: SnsAggregatorStore = derived( snsAggregatorIncludingAbortedProjectsStore, - (store) => ({ - data: store.data - ?.filter( - (sns) => - nonNullish(sns.lifecycle) && - sns.lifecycle.lifecycle !== SnsSwapLifecycle.Aborted - ) - .map(fixBrokenSnsMetadataBasedOnId), - }) + (store) => { + const data = store.data?.filter( + (sns) => + nonNullish(sns.lifecycle) && + sns.lifecycle.lifecycle !== SnsSwapLifecycle.Aborted + ); + + // TODO: Find a better way to fix broken SNS metadata. These transformations will be remove once we have a better solution. + const handledAbandonedSnsData = + data?.map(fixBrokenSnsMetadataBasedOnId) ?? []; + const sortedAbandonesSnsData = sortedListBasedOnAbandoned( + handledAbandonedSnsData + ); + const cachedSnsData = sortedAbandonesSnsData.map( + ({ isAbandoned: _, ...sns }) => ({ ...sns }) + ); + + return { + data: cachedSnsData, + }; + } ); -// TODO: Find a better way to fix broken SNS metadata. const brokenSnsOverrides: Record< string, { name: string; tokenSymbol: string } @@ -60,12 +71,17 @@ const brokenSnsOverrides: Record< }, }; -const fixBrokenSnsMetadataBasedOnId = (sns: CachedSnsDto): CachedSnsDto => { +const fixBrokenSnsMetadataBasedOnId = ( + sns: CachedSnsDto +): CachedSnsDto & { isAbandoned?: boolean } => { const override = brokenSnsOverrides[sns.list_sns_canisters.root]; + + // Required for the tokens and stakin routes + const hiddenCharacterToPushSnsToEndOfList = "\u200B"; if (!nonNullish(override)) return sns; const newMeta = { ...sns.meta, - name: `${sns.meta.name} (formerly ${override.name})`, + name: `${hiddenCharacterToPushSnsToEndOfList}${sns.meta.name} (formerly ${override.name})`, }; const newIcrc1Metadata = sns.icrc1_metadata.map< @@ -86,5 +102,18 @@ const fixBrokenSnsMetadataBasedOnId = (sns: CachedSnsDto): CachedSnsDto => { ...sns, meta: { ...newMeta }, icrc1_metadata: [...newIcrc1Metadata], + isAbandoned: true, }; }; + +// Required for the proposals route +const sortedListBasedOnAbandoned = ( + list: (CachedSnsDto & { isAbandoned?: boolean })[] +) => [ + ...list.sort((a, b) => { + if (a.isAbandoned && !b.isAbandoned) return 1; + if (!a.isAbandoned && b.isAbandoned) return -1; + + return 0; + }), +]; diff --git a/frontend/src/tests/lib/stores/sns-aggregator.store.spec.ts b/frontend/src/tests/lib/stores/sns-aggregator.store.spec.ts index 836df3b32fe..31b7e4f2743 100644 --- a/frontend/src/tests/lib/stores/sns-aggregator.store.spec.ts +++ b/frontend/src/tests/lib/stores/sns-aggregator.store.spec.ts @@ -153,41 +153,63 @@ describe("sns-aggregator store", () => { }, }); - it("should override information for SNS with rootCanisterId ibahq-taaaa-aaaaq-aadna-cai", () => { - const mockedSns = aggregatorMockSnsesDataDto[0]; - const brokenSns = withBrokenSns({ - sns: { - ...mockedSns, - meta: { - ...mockedSns.meta, - name: "---", - }, - icrc1_metadata: [...mockedSns.icrc1_metadata].map(([name, value]) => { - if (name === "icrc1:symbol" && "Text" in value) { - return [ - name, - { - Text: "---", - }, - ]; - } - return [name, value]; - }), + const mockedSns = aggregatorMockSnsesDataDto[0]; + const brokenSns = withBrokenSns({ + sns: { + ...mockedSns, + meta: { + ...mockedSns.meta, + name: "---", }, - rootCanisterId: "ibahq-taaaa-aaaaq-aadna-cai", - }); + icrc1_metadata: [...mockedSns.icrc1_metadata].map(([name, value]) => { + if (name === "icrc1:symbol" && "Text" in value) { + return [ + name, + { + Text: "---", + }, + ]; + } + return [name, value]; + }), + }, + rootCanisterId: "ibahq-taaaa-aaaaq-aadna-cai", + }); + it("should override information for SNS with rootCanisterId ibahq-taaaa-aaaaq-aadna-cai", () => { const data = [brokenSns]; snsAggregatorIncludingAbortedProjectsStore.setData(data); - expect(get(snsAggregatorIncludingAbortedProjectsStore).data[0].meta.name).toBe( - "---" - ); expect( - get(snsAggregatorIncludingAbortedProjectsStore).data[0].icrc1_metadata[3][1] + get(snsAggregatorIncludingAbortedProjectsStore).data[0].meta.name + ).toBe("---"); + expect( + get(snsAggregatorIncludingAbortedProjectsStore).data[0] + .icrc1_metadata[3][1] ).toEqual({ Text: "---" }); const result = get(snsAggregatorStore).data[0]; - expect(result.meta.name).toBe("--- (formerly CYCLES_TRANSFER_STATION)"); + expect(result.meta.name).toBe( + "\u200B--- (formerly CYCLES_TRANSFER_STATION)" + ); + expect(result.icrc1_metadata[3][1]).toEqual({ Text: "--- (CTS)" }); + }); + + it("should sort sns by temporal isAbandoded property", () => { + const data = [brokenSns, ...aggregatorMockSnsesDataDto]; + snsAggregatorIncludingAbortedProjectsStore.setData(data); + expect( + get(snsAggregatorIncludingAbortedProjectsStore).data[0].meta.name + ).toBe("---"); + expect( + get(snsAggregatorIncludingAbortedProjectsStore).data[0] + .icrc1_metadata[3][1] + ).toEqual({ Text: "---" }); + + const result = + get(snsAggregatorStore).data[get(snsAggregatorStore).data.length - 1]; + expect(result.meta.name).toBe( + "\u200B--- (formerly CYCLES_TRANSFER_STATION)" + ); expect(result.icrc1_metadata[3][1]).toEqual({ Text: "--- (CTS)" }); }); }); From d87cbe7dd1dde03f317b23dce916f1767520154a Mon Sep 17 00:00:00 2001 From: Yusef Habib Fernandez Date: Wed, 4 Dec 2024 14:46:46 +0100 Subject: [PATCH 07/14] add comments --- frontend/src/lib/stores/sns-aggregator.store.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/lib/stores/sns-aggregator.store.ts b/frontend/src/lib/stores/sns-aggregator.store.ts index cf399ce9e55..82f8cf2157c 100644 --- a/frontend/src/lib/stores/sns-aggregator.store.ts +++ b/frontend/src/lib/stores/sns-aggregator.store.ts @@ -76,7 +76,7 @@ const fixBrokenSnsMetadataBasedOnId = ( ): CachedSnsDto & { isAbandoned?: boolean } => { const override = brokenSnsOverrides[sns.list_sns_canisters.root]; - // Required for the tokens and stakin routes + // Required for the tokens and staking routes as they apply their own sort logic const hiddenCharacterToPushSnsToEndOfList = "\u200B"; if (!nonNullish(override)) return sns; const newMeta = { @@ -106,7 +106,7 @@ const fixBrokenSnsMetadataBasedOnId = ( }; }; -// Required for the proposals route +// Required for the proposals route as it doesnt apply sort logic const sortedListBasedOnAbandoned = ( list: (CachedSnsDto & { isAbandoned?: boolean })[] ) => [ From f7c215122912a76172e1d9b30c565e8090cc9e3e Mon Sep 17 00:00:00 2001 From: Yusef Habib Fernandez Date: Wed, 4 Dec 2024 15:00:27 +0100 Subject: [PATCH 08/14] fix test --- frontend/src/lib/stores/sns-aggregator.store.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/frontend/src/lib/stores/sns-aggregator.store.ts b/frontend/src/lib/stores/sns-aggregator.store.ts index 82f8cf2157c..83d2ccb0ee3 100644 --- a/frontend/src/lib/stores/sns-aggregator.store.ts +++ b/frontend/src/lib/stores/sns-aggregator.store.ts @@ -3,7 +3,7 @@ import type { CachedSnsTokenMetadataDto, } from "$lib/types/sns-aggregator"; import { SnsSwapLifecycle } from "@dfinity/sns"; -import { nonNullish } from "@dfinity/utils"; +import { isNullish, nonNullish } from "@dfinity/utils"; import { derived, writable, type Readable } from "svelte/store"; /** @@ -43,10 +43,12 @@ export const snsAggregatorStore: SnsAggregatorStore = derived( nonNullish(sns.lifecycle) && sns.lifecycle.lifecycle !== SnsSwapLifecycle.Aborted ); + + if (isNullish(data)) return { data: undefined }; // TODO: Find a better way to fix broken SNS metadata. These transformations will be remove once we have a better solution. const handledAbandonedSnsData = - data?.map(fixBrokenSnsMetadataBasedOnId) ?? []; + data?.map(fixBrokenSnsMetadataBasedOnId); const sortedAbandonesSnsData = sortedListBasedOnAbandoned( handledAbandonedSnsData ); From e7fc811b93e0ae1647ce18cb6f31d9707768875e Mon Sep 17 00:00:00 2001 From: Yusef Habib Fernandez Date: Wed, 4 Dec 2024 15:44:47 +0100 Subject: [PATCH 09/14] last --- CHANGELOG-Nns-Dapp-unreleased.md | 1 + frontend/src/lib/stores/sns-aggregator.store.ts | 2 +- frontend/src/tests/lib/stores/sns-aggregator.store.spec.ts | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG-Nns-Dapp-unreleased.md b/CHANGELOG-Nns-Dapp-unreleased.md index 598ee07f60a..fdb9310f430 100644 --- a/CHANGELOG-Nns-Dapp-unreleased.md +++ b/CHANGELOG-Nns-Dapp-unreleased.md @@ -23,6 +23,7 @@ proposal is successful, the changes it released will be moved from this file to #### Fixed - Adds an override for the name and token.symbol values for abandoned SNS +- Position of abandoned SNSs #### Security diff --git a/frontend/src/lib/stores/sns-aggregator.store.ts b/frontend/src/lib/stores/sns-aggregator.store.ts index 83d2ccb0ee3..3da80f83c23 100644 --- a/frontend/src/lib/stores/sns-aggregator.store.ts +++ b/frontend/src/lib/stores/sns-aggregator.store.ts @@ -93,7 +93,7 @@ const fixBrokenSnsMetadataBasedOnId = ( return [ name, { - Text: `${value.Text} (${override.tokenSymbol})`, + Text: `${hiddenCharacterToPushSnsToEndOfList}${value.Text} (${override.tokenSymbol})`, }, ]; } diff --git a/frontend/src/tests/lib/stores/sns-aggregator.store.spec.ts b/frontend/src/tests/lib/stores/sns-aggregator.store.spec.ts index 31b7e4f2743..e316455b1de 100644 --- a/frontend/src/tests/lib/stores/sns-aggregator.store.spec.ts +++ b/frontend/src/tests/lib/stores/sns-aggregator.store.spec.ts @@ -191,7 +191,7 @@ describe("sns-aggregator store", () => { expect(result.meta.name).toBe( "\u200B--- (formerly CYCLES_TRANSFER_STATION)" ); - expect(result.icrc1_metadata[3][1]).toEqual({ Text: "--- (CTS)" }); + expect(result.icrc1_metadata[3][1]).toEqual({ Text: "\u200B--- (CTS)" }); }); it("should sort sns by temporal isAbandoded property", () => { From 2b5ee685c0a62d137ab828097d594e2331948784 Mon Sep 17 00:00:00 2001 From: Yusef Habib Fernandez Date: Wed, 4 Dec 2024 15:45:37 +0100 Subject: [PATCH 10/14] fmt --- frontend/src/lib/stores/sns-aggregator.store.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/frontend/src/lib/stores/sns-aggregator.store.ts b/frontend/src/lib/stores/sns-aggregator.store.ts index 3da80f83c23..1c8305f73e1 100644 --- a/frontend/src/lib/stores/sns-aggregator.store.ts +++ b/frontend/src/lib/stores/sns-aggregator.store.ts @@ -43,12 +43,11 @@ export const snsAggregatorStore: SnsAggregatorStore = derived( nonNullish(sns.lifecycle) && sns.lifecycle.lifecycle !== SnsSwapLifecycle.Aborted ); - + if (isNullish(data)) return { data: undefined }; // TODO: Find a better way to fix broken SNS metadata. These transformations will be remove once we have a better solution. - const handledAbandonedSnsData = - data?.map(fixBrokenSnsMetadataBasedOnId); + const handledAbandonedSnsData = data?.map(fixBrokenSnsMetadataBasedOnId); const sortedAbandonesSnsData = sortedListBasedOnAbandoned( handledAbandonedSnsData ); From 1bc6f7ad0631ac05c688d44c6088d4142be919bd Mon Sep 17 00:00:00 2001 From: Yusef Habib Fernandez Date: Wed, 4 Dec 2024 15:50:52 +0100 Subject: [PATCH 11/14] update changelog --- CHANGELOG-Nns-Dapp-unreleased.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG-Nns-Dapp-unreleased.md b/CHANGELOG-Nns-Dapp-unreleased.md index fdb9310f430..e202a6c3362 100644 --- a/CHANGELOG-Nns-Dapp-unreleased.md +++ b/CHANGELOG-Nns-Dapp-unreleased.md @@ -22,8 +22,7 @@ proposal is successful, the changes it released will be moved from this file to #### Fixed -- Adds an override for the name and token.symbol values for abandoned SNS -- Position of abandoned SNSs +- Handles abandoned SNSs by adding an override for the name and token.symbol values as well as sorting them down on the lists. #### Security From a679c54f7e6262518b7c4e9b6248380cad35af10 Mon Sep 17 00:00:00 2001 From: Yusef Habib Fernandez Date: Wed, 4 Dec 2024 15:51:43 +0100 Subject: [PATCH 12/14] changelog and tst --- frontend/src/tests/lib/stores/sns-aggregator.store.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/tests/lib/stores/sns-aggregator.store.spec.ts b/frontend/src/tests/lib/stores/sns-aggregator.store.spec.ts index e316455b1de..88d244bb716 100644 --- a/frontend/src/tests/lib/stores/sns-aggregator.store.spec.ts +++ b/frontend/src/tests/lib/stores/sns-aggregator.store.spec.ts @@ -210,7 +210,7 @@ describe("sns-aggregator store", () => { expect(result.meta.name).toBe( "\u200B--- (formerly CYCLES_TRANSFER_STATION)" ); - expect(result.icrc1_metadata[3][1]).toEqual({ Text: "--- (CTS)" }); + expect(result.icrc1_metadata[3][1]).toEqual({ Text: "\u200B--- (CTS)" }); }); }); }); From b5b82ec32460db540a7e3250a3ec79f24a451374 Mon Sep 17 00:00:00 2001 From: Yusef Habib Fernandez Date: Wed, 4 Dec 2024 18:09:14 +0100 Subject: [PATCH 13/14] fix name --- frontend/src/lib/stores/sns-aggregator.store.ts | 4 ++-- .../src/tests/lib/stores/sns-aggregator.store.spec.ts | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/frontend/src/lib/stores/sns-aggregator.store.ts b/frontend/src/lib/stores/sns-aggregator.store.ts index 1c8305f73e1..209968d3ad6 100644 --- a/frontend/src/lib/stores/sns-aggregator.store.ts +++ b/frontend/src/lib/stores/sns-aggregator.store.ts @@ -67,7 +67,7 @@ const brokenSnsOverrides: Record< > = { // Overrided for CYCLES_TRANSFER_STATION as discussed in https://dfinity.slack.com/archives/C039M7YS6F6/p1733302975333649 "ibahq-taaaa-aaaaq-aadna-cai": { - name: "CYCLES_TRANSFER_STATION", + name: "CYCLES-TRANSFER-STATION", tokenSymbol: "CTS", }, }; @@ -92,7 +92,7 @@ const fixBrokenSnsMetadataBasedOnId = ( return [ name, { - Text: `${hiddenCharacterToPushSnsToEndOfList}${value.Text} (${override.tokenSymbol})`, + Text: `${value.Text} (${override.tokenSymbol})`, }, ]; } diff --git a/frontend/src/tests/lib/stores/sns-aggregator.store.spec.ts b/frontend/src/tests/lib/stores/sns-aggregator.store.spec.ts index 88d244bb716..b4665e5acf6 100644 --- a/frontend/src/tests/lib/stores/sns-aggregator.store.spec.ts +++ b/frontend/src/tests/lib/stores/sns-aggregator.store.spec.ts @@ -189,9 +189,9 @@ describe("sns-aggregator store", () => { const result = get(snsAggregatorStore).data[0]; expect(result.meta.name).toBe( - "\u200B--- (formerly CYCLES_TRANSFER_STATION)" + "\u200B--- (formerly CYCLES-TRANSFER-STATION)" ); - expect(result.icrc1_metadata[3][1]).toEqual({ Text: "\u200B--- (CTS)" }); + expect(result.icrc1_metadata[3][1]).toEqual({ Text: "--- (CTS)" }); }); it("should sort sns by temporal isAbandoded property", () => { @@ -208,9 +208,9 @@ describe("sns-aggregator store", () => { const result = get(snsAggregatorStore).data[get(snsAggregatorStore).data.length - 1]; expect(result.meta.name).toBe( - "\u200B--- (formerly CYCLES_TRANSFER_STATION)" + "\u200B--- (formerly CYCLES-TRANSFER-STATION)" ); - expect(result.icrc1_metadata[3][1]).toEqual({ Text: "\u200B--- (CTS)" }); + expect(result.icrc1_metadata[3][1]).toEqual({ Text: "--- (CTS)" }); }); }); }); From 050843bc8d4794d6ee41881b4bf129aee49f4b3b Mon Sep 17 00:00:00 2001 From: Yusef Habib Fernandez Date: Wed, 4 Dec 2024 18:13:32 +0100 Subject: [PATCH 14/14] fix typo --- frontend/src/tests/lib/stores/sns-aggregator.store.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/tests/lib/stores/sns-aggregator.store.spec.ts b/frontend/src/tests/lib/stores/sns-aggregator.store.spec.ts index b4665e5acf6..12586b5a1ab 100644 --- a/frontend/src/tests/lib/stores/sns-aggregator.store.spec.ts +++ b/frontend/src/tests/lib/stores/sns-aggregator.store.spec.ts @@ -194,7 +194,7 @@ describe("sns-aggregator store", () => { expect(result.icrc1_metadata[3][1]).toEqual({ Text: "--- (CTS)" }); }); - it("should sort sns by temporal isAbandoded property", () => { + it("should sort sns by temporary isAbandoded property", () => { const data = [brokenSns, ...aggregatorMockSnsesDataDto]; snsAggregatorIncludingAbortedProjectsStore.setData(data); expect(