From 4cc3d05538bde4e323b52f77e12dba1eb99495a1 Mon Sep 17 00:00:00 2001 From: David de Kloet Date: Wed, 6 Mar 2024 11:30:21 +0100 Subject: [PATCH] Proof of concept: Use empty optionals --- frontend/package-lock.json | 118 ++++++++---------- frontend/package.json | 8 +- .../utils/sns-aggregator-converters.utils.ts | 3 +- .../sns-aggregator-converters.utils.spec.ts | 3 +- frontend/src/tests/mocks/sns-projects.mock.ts | 4 +- 5 files changed, 65 insertions(+), 71 deletions(-) diff --git a/frontend/package-lock.json b/frontend/package-lock.json index c7f9f4e140b..c24e2f92ae3 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -18,12 +18,12 @@ "@dfinity/ic-management": "next", "@dfinity/identity": "^1.0.1", "@dfinity/ledger-icp": "next", - "@dfinity/ledger-icrc": "next", - "@dfinity/nns": "next", + "@dfinity/ledger-icrc": "file:../../../ic-js/tree1/packages/ledger-icrc", + "@dfinity/nns": "file:../../../ic-js/tree1/packages/nns", "@dfinity/nns-proto": "next", "@dfinity/principal": "^1.0.1", - "@dfinity/sns": "next", - "@dfinity/utils": "next", + "@dfinity/sns": "file:../../../ic-js/tree1/packages/sns", + "@dfinity/utils": "file:../../../ic-js/tree1/packages/utils", "@ledgerhq/hw-transport-node-hid-noevents": "^6.27.8", "@ledgerhq/hw-transport-webhid": "^6.27.8", "@zondax/ledger-icp": "^0.6.1", @@ -318,49 +318,49 @@ } }, "node_modules/@dfinity/ledger-icp": { - "version": "2.2.1-next-2024-03-04.3", - "resolved": "https://registry.npmjs.org/@dfinity/ledger-icp/-/ledger-icp-2.2.1-next-2024-03-04.3.tgz", - "integrity": "sha512-HmGZX0UYCBx66DJsISGIAJ+AORvlzIJmUtuW/Tj2ZFxgleb6MUlm2dCjjS94wDd9ubPAlZpDXw/Tn85zYDqyIA==", + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/@dfinity/ledger-icp/-/ledger-icp-2.2.1.tgz", + "integrity": "sha512-0+muT7oPhrvSHQevX3XAMbyfwghYzFlEjLeiNQSsH/3Y1lBuY0GVn0UufR/5iBHkuDkCMmWGGLdHLyr55Qn44g==", "peerDependencies": { - "@dfinity/agent": "*", - "@dfinity/candid": "*", - "@dfinity/nns-proto": "*", - "@dfinity/principal": "*", - "@dfinity/utils": "*" + "@dfinity/agent": "^1.0.1", + "@dfinity/candid": "^1.0.1", + "@dfinity/nns-proto": "^1.0.1", + "@dfinity/principal": "^1.0.1", + "@dfinity/utils": "^2.1.2" } }, "node_modules/@dfinity/ledger-icrc": { - "version": "2.1.3-next-2024-03-04.3", - "resolved": "https://registry.npmjs.org/@dfinity/ledger-icrc/-/ledger-icrc-2.1.3-next-2024-03-04.3.tgz", - "integrity": "sha512-BR6EiEYx0560Z5P9HDJ4iMcVW+q7hPtQnHYMyAq761q412gnnIee9PDmPcD0SwavHQ39YmdHlXdLNo3Fs0uAIQ==", + "version": "2.2.0", + "resolved": "file:../../../ic-js/tree1/packages/ledger-icrc", + "license": "Apache-2.0", "peerDependencies": { - "@dfinity/agent": "*", - "@dfinity/candid": "*", - "@dfinity/principal": "*", - "@dfinity/utils": "*" + "@dfinity/agent": "^1.0.1", + "@dfinity/candid": "^1.0.1", + "@dfinity/principal": "^1.0.1", + "@dfinity/utils": "^2.1.2" } }, "node_modules/@dfinity/nns": { - "version": "4.0.1-next-2024-03-04.3", - "resolved": "https://registry.npmjs.org/@dfinity/nns/-/nns-4.0.1-next-2024-03-04.3.tgz", - "integrity": "sha512-fmZGII7uAJWN05QBLrnlNM0qyb1YptdWQqphpEaGn0wuWUPHAyuW9v9Spa3w8Z3Qo16BUc4tT5CUOwQDKtn2TQ==", + "version": "4.0.1", + "resolved": "file:../../../ic-js/tree1/packages/nns", + "license": "Apache-2.0", "dependencies": { "@noble/hashes": "^1.3.2", "randombytes": "^2.1.0" }, "peerDependencies": { - "@dfinity/agent": "*", - "@dfinity/candid": "*", - "@dfinity/ledger-icp": "*", - "@dfinity/nns-proto": "*", - "@dfinity/principal": "*", - "@dfinity/utils": "*" + "@dfinity/agent": "^1.0.1", + "@dfinity/candid": "^1.0.1", + "@dfinity/ledger-icp": "^2.2.1", + "@dfinity/nns-proto": "^1.0.1", + "@dfinity/principal": "^1.0.1", + "@dfinity/utils": "^2.1.2" } }, "node_modules/@dfinity/nns-proto": { - "version": "1.0.1-next-2024-03-04.3", - "resolved": "https://registry.npmjs.org/@dfinity/nns-proto/-/nns-proto-1.0.1-next-2024-03-04.3.tgz", - "integrity": "sha512-eX2VANw17Gv4Y15ECOmQU92SNilbycM7Xxl+6pBcJjYqbN7Buas1tt0noPJ8prrjUBDfPviHhcpj1T/+zaP2vA==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@dfinity/nns-proto/-/nns-proto-1.0.1.tgz", + "integrity": "sha512-zMtlERvmE3X9vlx13rMPghWJNiTAzEU8R6CA5EScnK3EnDFUMdFhBPeW06/BmqG3ngVqES+AM58u9v/SB4ECDQ==", "dependencies": { "google-protobuf": "^3.21.2" } @@ -374,28 +374,28 @@ } }, "node_modules/@dfinity/sns": { - "version": "3.0.0-next-2024-03-04.3", - "resolved": "https://registry.npmjs.org/@dfinity/sns/-/sns-3.0.0-next-2024-03-04.3.tgz", - "integrity": "sha512-ZaxqkHaXGtJjdhHvJYp4yZiD9OOtFUigNKd+ewQPuI/E4nRQnOqbZFAeHVkc2mKQOl7iz/PAU+7hSPgV+UiuAA==", + "version": "3.0.1", + "resolved": "file:../../../ic-js/tree1/packages/sns", + "license": "Apache-2.0", "dependencies": { "@noble/hashes": "^1.3.2" }, "peerDependencies": { - "@dfinity/agent": "*", - "@dfinity/candid": "*", - "@dfinity/ledger-icrc": "*", - "@dfinity/principal": "*", - "@dfinity/utils": "*" + "@dfinity/agent": "^1.0.1", + "@dfinity/candid": "^1.0.1", + "@dfinity/ledger-icrc": "^2.2.0", + "@dfinity/principal": "^1.0.1", + "@dfinity/utils": "^2.1.2" } }, "node_modules/@dfinity/utils": { - "version": "2.1.2-next-2024-03-04.3", - "resolved": "https://registry.npmjs.org/@dfinity/utils/-/utils-2.1.2-next-2024-03-04.3.tgz", - "integrity": "sha512-5+sIBv7XoMD7ui4Cvx7SHYmlE0MR5PAM8Seul1WotMEEe3JIys7pqSavZ/YA/ubpFPa+q0RiYvOEP+7GIEsa9g==", + "version": "2.1.2", + "resolved": "file:../../../ic-js/tree1/packages/utils", + "license": "Apache-2.0", "peerDependencies": { - "@dfinity/agent": "*", - "@dfinity/candid": "*", - "@dfinity/principal": "*" + "@dfinity/agent": "^1.0.1", + "@dfinity/candid": "^1.0.1", + "@dfinity/principal": "^1.0.1" } }, "node_modules/@esbuild/android-arm": { @@ -7089,30 +7089,26 @@ } }, "@dfinity/ledger-icp": { - "version": "2.2.1-next-2024-03-04.3", - "resolved": "https://registry.npmjs.org/@dfinity/ledger-icp/-/ledger-icp-2.2.1-next-2024-03-04.3.tgz", - "integrity": "sha512-HmGZX0UYCBx66DJsISGIAJ+AORvlzIJmUtuW/Tj2ZFxgleb6MUlm2dCjjS94wDd9ubPAlZpDXw/Tn85zYDqyIA==", + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/@dfinity/ledger-icp/-/ledger-icp-2.2.1.tgz", + "integrity": "sha512-0+muT7oPhrvSHQevX3XAMbyfwghYzFlEjLeiNQSsH/3Y1lBuY0GVn0UufR/5iBHkuDkCMmWGGLdHLyr55Qn44g==", "requires": {} }, "@dfinity/ledger-icrc": { - "version": "2.1.3-next-2024-03-04.3", - "resolved": "https://registry.npmjs.org/@dfinity/ledger-icrc/-/ledger-icrc-2.1.3-next-2024-03-04.3.tgz", - "integrity": "sha512-BR6EiEYx0560Z5P9HDJ4iMcVW+q7hPtQnHYMyAq761q412gnnIee9PDmPcD0SwavHQ39YmdHlXdLNo3Fs0uAIQ==", + "version": "2.2.0", "requires": {} }, "@dfinity/nns": { - "version": "4.0.1-next-2024-03-04.3", - "resolved": "https://registry.npmjs.org/@dfinity/nns/-/nns-4.0.1-next-2024-03-04.3.tgz", - "integrity": "sha512-fmZGII7uAJWN05QBLrnlNM0qyb1YptdWQqphpEaGn0wuWUPHAyuW9v9Spa3w8Z3Qo16BUc4tT5CUOwQDKtn2TQ==", + "version": "4.0.1", "requires": { "@noble/hashes": "^1.3.2", "randombytes": "^2.1.0" } }, "@dfinity/nns-proto": { - "version": "1.0.1-next-2024-03-04.3", - "resolved": "https://registry.npmjs.org/@dfinity/nns-proto/-/nns-proto-1.0.1-next-2024-03-04.3.tgz", - "integrity": "sha512-eX2VANw17Gv4Y15ECOmQU92SNilbycM7Xxl+6pBcJjYqbN7Buas1tt0noPJ8prrjUBDfPviHhcpj1T/+zaP2vA==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@dfinity/nns-proto/-/nns-proto-1.0.1.tgz", + "integrity": "sha512-zMtlERvmE3X9vlx13rMPghWJNiTAzEU8R6CA5EScnK3EnDFUMdFhBPeW06/BmqG3ngVqES+AM58u9v/SB4ECDQ==", "requires": { "google-protobuf": "^3.21.2" } @@ -7126,17 +7122,13 @@ } }, "@dfinity/sns": { - "version": "3.0.0-next-2024-03-04.3", - "resolved": "https://registry.npmjs.org/@dfinity/sns/-/sns-3.0.0-next-2024-03-04.3.tgz", - "integrity": "sha512-ZaxqkHaXGtJjdhHvJYp4yZiD9OOtFUigNKd+ewQPuI/E4nRQnOqbZFAeHVkc2mKQOl7iz/PAU+7hSPgV+UiuAA==", + "version": "3.0.1", "requires": { "@noble/hashes": "^1.3.2" } }, "@dfinity/utils": { - "version": "2.1.2-next-2024-03-04.3", - "resolved": "https://registry.npmjs.org/@dfinity/utils/-/utils-2.1.2-next-2024-03-04.3.tgz", - "integrity": "sha512-5+sIBv7XoMD7ui4Cvx7SHYmlE0MR5PAM8Seul1WotMEEe3JIys7pqSavZ/YA/ubpFPa+q0RiYvOEP+7GIEsa9g==", + "version": "2.1.2", "requires": {} }, "@esbuild/android-arm": { diff --git a/frontend/package.json b/frontend/package.json index 76e84aad641..ad392427720 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -71,12 +71,12 @@ "@dfinity/ic-management": "next", "@dfinity/identity": "^1.0.1", "@dfinity/ledger-icp": "next", - "@dfinity/ledger-icrc": "next", - "@dfinity/nns": "next", + "@dfinity/ledger-icrc": "file:../../../ic-js/tree1/packages/ledger-icrc", + "@dfinity/nns": "file:../../../ic-js/tree1/packages/nns", "@dfinity/nns-proto": "next", "@dfinity/principal": "^1.0.1", - "@dfinity/sns": "next", - "@dfinity/utils": "next", + "@dfinity/sns": "file:../../../ic-js/tree1/packages/sns", + "@dfinity/utils": "file:../../../ic-js/tree1/packages/utils", "@ledgerhq/hw-transport-node-hid-noevents": "^6.27.8", "@ledgerhq/hw-transport-webhid": "^6.27.8", "@zondax/ledger-icp": "^0.6.1", diff --git a/frontend/src/lib/utils/sns-aggregator-converters.utils.ts b/frontend/src/lib/utils/sns-aggregator-converters.utils.ts index cc7b41f83da..39c3dad5cac 100644 --- a/frontend/src/lib/utils/sns-aggregator-converters.utils.ts +++ b/frontend/src/lib/utils/sns-aggregator-converters.utils.ts @@ -32,6 +32,7 @@ import type { SnsSwapDerivedState, SnsSwapInit, } from "@dfinity/sns"; +import { emptyOptionalsForSnsNeuronsFundParticipationConstraints } from "@dfinity/sns"; import { isNullish, nonNullish, toNullable } from "@dfinity/utils"; import { mapOptionalToken } from "./icrc-tokens.utils"; import { isPngAsset } from "./utils"; @@ -93,6 +94,7 @@ export const convertNervousFunction = ({ const convertNeuronsFundParticipationConstraints = ( constraints: CachedNeuronsFundParticipationConstraints ): SnsNeuronsFundParticipationConstraints => ({ + ...emptyOptionalsForSnsNeuronsFundParticipationConstraints, coefficient_intervals: constraints.coefficient_intervals.map( ({ slope_numerator, @@ -126,7 +128,6 @@ const convertNeuronsFundParticipationConstraints = ( constraints.min_direct_participation_threshold_icp_e8s ) ), - ideal_matched_participation_function: [], }); const convertSwapInitParams = ( diff --git a/frontend/src/tests/lib/utils/sns-aggregator-converters.utils.spec.ts b/frontend/src/tests/lib/utils/sns-aggregator-converters.utils.spec.ts index 7bfdef8296d..c0380385069 100644 --- a/frontend/src/tests/lib/utils/sns-aggregator-converters.utils.spec.ts +++ b/frontend/src/tests/lib/utils/sns-aggregator-converters.utils.spec.ts @@ -7,6 +7,7 @@ import { } from "$lib/utils/sns-aggregator-converters.utils"; import { aggregatorSnsMockDto } from "$tests/mocks/sns-aggregator.mock"; import { Principal } from "@dfinity/principal"; +import { emptyOptionalsForSnsNeuronsFundParticipationConstraints } from "@dfinity/sns"; describe("sns aggregator converters utils", () => { describe("convertDtoData", () => { @@ -563,6 +564,7 @@ describe("sns aggregator converters utils", () => { ...summaryMockData.swap.init[0], neurons_fund_participation_constraints: [ { + ...emptyOptionalsForSnsNeuronsFundParticipationConstraints, coefficient_intervals: [ { slope_numerator: [2n], @@ -574,7 +576,6 @@ describe("sns aggregator converters utils", () => { ], max_neurons_fund_participation_icp_e8s: [300000000000n], min_direct_participation_threshold_icp_e8s: [10000000000n], - ideal_matched_participation_function: [], }, ], min_direct_participation_icp_e8s: [300000000000n], diff --git a/frontend/src/tests/mocks/sns-projects.mock.ts b/frontend/src/tests/mocks/sns-projects.mock.ts index f9f6bac6ad7..78753df020c 100644 --- a/frontend/src/tests/mocks/sns-projects.mock.ts +++ b/frontend/src/tests/mocks/sns-projects.mock.ts @@ -15,6 +15,7 @@ import { import { Principal } from "@dfinity/principal"; import { SnsSwapLifecycle, + emptyOptionalsForSnsNeuronsFundParticipationConstraints, type SnsGetDerivedStateResponse, type SnsGetLifecycleResponse, type SnsGetMetadataResponse, @@ -394,11 +395,10 @@ export const createSummary = ({ neurons_fund_participation_constraints: nonNullish(maxNFParticipation) ? [ { + ...emptyOptionalsForSnsNeuronsFundParticipationConstraints, max_neurons_fund_participation_icp_e8s: toNullable(maxNFParticipation), coefficient_intervals: [], - min_direct_participation_threshold_icp_e8s: [], - ideal_matched_participation_function: [], }, ] : [],