From a09503924aa8f4fa6a51a7777d0369ecd310b9dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lloren=C3=A7=20Muntaner?= Date: Thu, 9 Nov 2023 10:11:48 +0100 Subject: [PATCH] Fix: Add missing swap parameters to SNS proposal action (#461) # Motivation There were some fields not appearing in the proposal to open an SNS. The problem was that the fields were considered optional, and the types didn't catch when they were missing from the converters. Instead, I used the `Option` utility, to ensure that fields are present, but can be `undefined`. # Changes * Change optional fields to use `Option` in `SwapParameters` of the `CreateServiceNervousSystem`. * Add missing fields in the converter of the `SwapParameters` of the `CreateServiceNervousSystem`. # Tests After changing the type to `Option`, I run the tests and they were failing to compile because the types didn't match. After adding the fields, the tests pass again. # Todos - [ ] Add entry to changelog (if necessary). It was already in the changelog. But the feature was incomplete. --- .../governance/response.converters.ts | 9 ++++++ .../nns/src/types/governance_converters.ts | 28 +++++++++---------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/packages/nns/src/canisters/governance/response.converters.ts b/packages/nns/src/canisters/governance/response.converters.ts index 4d803e905..3926f4727 100644 --- a/packages/nns/src/canisters/governance/response.converters.ts +++ b/packages/nns/src/canisters/governance/response.converters.ts @@ -1213,6 +1213,15 @@ const toSwapParameters = ( restrictedCountries: toCountries( fromNullable(swapParameters.restricted_countries), ), + maxDirectParticipationIcp: toTokens( + fromNullable(swapParameters.maximum_direct_participation_icp), + ), + minDirectParticipationIcp: toTokens( + fromNullable(swapParameters.minimum_direct_participation_icp), + ), + neuronsFundParticipation: fromNullable( + swapParameters.neurons_fund_participation, + ), }; }; diff --git a/packages/nns/src/types/governance_converters.ts b/packages/nns/src/types/governance_converters.ts index 2f2d2c2f5..2dd6dd935 100644 --- a/packages/nns/src/types/governance_converters.ts +++ b/packages/nns/src/types/governance_converters.ts @@ -557,20 +557,20 @@ export interface NeuronBasketConstructionParameters { count?: bigint; } export interface SwapParameters { - minimumParticipants?: bigint; - duration?: Duration; - neuronBasketConstructionParameters?: NeuronBasketConstructionParameters; - confirmationText?: string; - maximumParticipantIcp?: Tokens; - neuronsFundInvestmentIcp?: Tokens; - minimumIcp?: Tokens; - minimumParticipantIcp?: Tokens; - startTime?: GlobalTimeOfDay; - maximumIcp?: Tokens; - restrictedCountries?: Countries; - maxDirectParticipationIcp?: Tokens; - minDirectParticipationIcp?: Tokens; - neuronsFundParticipation?: boolean; + minimumParticipants: Option; + duration: Option; + neuronBasketConstructionParameters: Option; + confirmationText: Option; + maximumParticipantIcp: Option; + neuronsFundInvestmentIcp: Option; + minimumIcp: Option; + minimumParticipantIcp: Option; + startTime: Option; + maximumIcp: Option; + restrictedCountries: Option; + maxDirectParticipationIcp: Option; + minDirectParticipationIcp: Option; + neuronsFundParticipation: Option; } export interface SwapDistribution {