From 24053f30060b3eaecc064cbf5fc637425a46c387 Mon Sep 17 00:00:00 2001 From: Jason Zhu Date: Wed, 17 Jul 2024 22:42:59 +0000 Subject: [PATCH] Formatting --- CHANGELOG-Nns-Dapp-unreleased.md | 4 +-- .../src/lib/constants/neurons.constants.ts | 5 ++- frontend/src/lib/i18n/en.governance.json | 2 +- frontend/src/lib/i18n/en.json | 2 +- frontend/src/lib/utils/neuron.utils.ts | 36 ++++++++++--------- .../src/tests/lib/utils/neuron.utils.spec.ts | 16 ++++++--- 6 files changed, 40 insertions(+), 25 deletions(-) diff --git a/CHANGELOG-Nns-Dapp-unreleased.md b/CHANGELOG-Nns-Dapp-unreleased.md index e9dd7f389b5..791194d0d23 100644 --- a/CHANGELOG-Nns-Dapp-unreleased.md +++ b/CHANGELOG-Nns-Dapp-unreleased.md @@ -16,8 +16,8 @@ proposal is successful, the changes it released will be moved from this file to #### Added * A short delay before closing the mobile table sorting modal. -* Add 2 new topics ProtocolCanisterMangement and ServiceNervousSystemManagement - while not allowing following to be set. +* Add 2 new topics `ProtocolCanisterMangement` and + `ServiceNervousSystemManagement` while not allowing following to be set. #### Changed diff --git a/frontend/src/lib/constants/neurons.constants.ts b/frontend/src/lib/constants/neurons.constants.ts index 7787215ae33..d72b98b30d3 100644 --- a/frontend/src/lib/constants/neurons.constants.ts +++ b/frontend/src/lib/constants/neurons.constants.ts @@ -23,7 +23,10 @@ const LAST_TOPICS = [Topic.ExchangeRate]; // Topics that neurons cannot yet set following for. // TODO: Remove this list when the NNS Governance supports following on those topics. -export const TOPICS_WITH_FOLLOWING_DISABLED = [Topic.ProtocolCanisterManagement, Topic.ServiceNervousSystemManagement]; +export const TOPICS_WITH_FOLLOWING_DISABLED = [ + Topic.ProtocolCanisterManagement, + Topic.ServiceNervousSystemManagement, +]; // This list should include ALL topics ordered as we want. // Filtering out topics is done in the utils. diff --git a/frontend/src/lib/i18n/en.governance.json b/frontend/src/lib/i18n/en.governance.json index 7131f34f45e..b70791295bb 100644 --- a/frontend/src/lib/i18n/en.governance.json +++ b/frontend/src/lib/i18n/en.governance.json @@ -212,4 +212,4 @@ "DeployHostosToSomeNodes": "Deploy a HostOS version to a given set of nodes. The proposal changes the HostOS version that is used on the specified nodes.", "SubnetRentalRequest": "A proposal to rent a subnet on the Internet Computer.

The Subnet Rental Canister is called when this proposal is executed, and the rental request is stored there. The user specified in the proposal needs to make a sufficient upfront payment in ICP in order for the proposal to be valid, and the subnet must be available for rent. The available rental conditions can be checked by calling the Subnet Rental Canister." } -} \ No newline at end of file +} diff --git a/frontend/src/lib/i18n/en.json b/frontend/src/lib/i18n/en.json index b05c3df7721..6e1381140da 100644 --- a/frontend/src/lib/i18n/en.json +++ b/frontend/src/lib/i18n/en.json @@ -1032,4 +1032,4 @@ "show_all": "Show all", "import_token": "Import Token" } -} \ No newline at end of file +} diff --git a/frontend/src/lib/utils/neuron.utils.ts b/frontend/src/lib/utils/neuron.utils.ts index 3876b351a1e..30b3a825699 100644 --- a/frontend/src/lib/utils/neuron.utils.ts +++ b/frontend/src/lib/utils/neuron.utils.ts @@ -208,9 +208,9 @@ export const bonusMultiplier = ({ }): number => 1 + multiplier * - (Math.min(Number(amount), max) / - // to avoid NaN - (max === 0 ? 1 : max)); + (Math.min(Number(amount), max) / + // to avoid NaN + (max === 0 ? 1 : max)); // TODO: Do we need this? What does it mean to have a valid stake? // TODO: https://dfinity.atlassian.net/browse/L2-507 @@ -218,16 +218,16 @@ export const hasValidStake = (neuron: NeuronInfo): boolean => // Ignore if we can't validate the stake nonNullish(neuron.fullNeuron) ? neuron.fullNeuron.cachedNeuronStake + - neuron.fullNeuron.maturityE8sEquivalent > - BigInt(DEFAULT_TRANSACTION_FEE_E8S) + neuron.fullNeuron.maturityE8sEquivalent > + BigInt(DEFAULT_TRANSACTION_FEE_E8S) : false; export const getDissolvingTimestampSeconds = ( neuron: NeuronInfo ): bigint | undefined => neuron.state === NeuronState.Dissolving && - neuron.fullNeuron?.dissolveState !== undefined && - "WhenDissolvedTimestampSeconds" in neuron.fullNeuron.dissolveState + neuron.fullNeuron?.dissolveState !== undefined && + "WhenDissolvedTimestampSeconds" in neuron.fullNeuron.dissolveState ? neuron.fullNeuron.dissolveState.WhenDissolvedTimestampSeconds : undefined; @@ -283,7 +283,7 @@ export const formattedMaturity = ({ fullNeuron }: NeuronInfo): string => export const formattedTotalMaturity = ({ fullNeuron }: NeuronInfo): string => formatMaturity( (fullNeuron?.maturityE8sEquivalent ?? 0n) + - (fullNeuron?.stakedMaturityE8sEquivalent ?? 0n) + (fullNeuron?.stakedMaturityE8sEquivalent ?? 0n) ); /** @@ -369,7 +369,7 @@ export const isNeuronControllable = ({ fullNeuron?.controller !== undefined && (fullNeuron.controller === identity?.getPrincipal().toText() || getAccountByPrincipal({ principal: fullNeuron.controller, accounts }) !== - undefined); + undefined); export const isNeuronControlledByHardwareWallet = ({ neuron, @@ -735,12 +735,12 @@ export const canBeMerged = ( } return sameManageNeuronFollowees(neurons) ? { - isValid: true, - } + isValid: true, + } : { - isValid: false, - messageKey: "error.merge_neurons_not_same_manage_neuron_followees", - }; + isValid: false, + messageKey: "error.merge_neurons_not_same_manage_neuron_followees", + }; }; export const mapNeuronIds = ({ @@ -815,7 +815,11 @@ export const topicsToFollow = (neuron: NeuronInfo): Topic[] => (followeesByTopic({ neuron, topic: Topic.ManageNeuron }) === undefined ? TOPICS_TO_FOLLOW_NNS.filter((topic) => topic !== Topic.ManageNeuron) : TOPICS_TO_FOLLOW_NNS - ).filter((topic) => !DEPRECATED_TOPICS.includes(topic) && !TOPICS_WITH_FOLLOWING_DISABLED.includes(topic)); + ).filter( + (topic) => + !DEPRECATED_TOPICS.includes(topic) && + !TOPICS_WITH_FOLLOWING_DISABLED.includes(topic) + ); // NeuronInfo is public info. // fullNeuron is only for users with access. @@ -973,7 +977,7 @@ export const maturityLastDistribution = ({ return ( actual_timestamp_seconds - (fromNullable(rounds_since_last_distribution) ?? 1n) * - BigInt(SECONDS_IN_DAY) + BigInt(SECONDS_IN_DAY) ); }; diff --git a/frontend/src/tests/lib/utils/neuron.utils.spec.ts b/frontend/src/tests/lib/utils/neuron.utils.spec.ts index 0fcb40b3090..833c604531d 100644 --- a/frontend/src/tests/lib/utils/neuron.utils.spec.ts +++ b/frontend/src/tests/lib/utils/neuron.utils.spec.ts @@ -2171,18 +2171,24 @@ describe("neuron-utils", () => { expect(topicsToFollow(neuronWithoutManageNeuron)).toEqual( TOPICS_TO_FOLLOW_NNS.filter( (topic) => - topic !== Topic.ManageNeuron && !DEPRECATED_TOPICS.includes(topic) && !TOPICS_WITH_FOLLOWING_DISABLED.includes(topic) + topic !== Topic.ManageNeuron && + !DEPRECATED_TOPICS.includes(topic) && + !TOPICS_WITH_FOLLOWING_DISABLED.includes(topic) ) ); expect(topicsToFollow(neuronWithoutFollowees)).toEqual( TOPICS_TO_FOLLOW_NNS.filter( (topic) => - topic !== Topic.ManageNeuron && !DEPRECATED_TOPICS.includes(topic) && !TOPICS_WITH_FOLLOWING_DISABLED.includes(topic) + topic !== Topic.ManageNeuron && + !DEPRECATED_TOPICS.includes(topic) && + !TOPICS_WITH_FOLLOWING_DISABLED.includes(topic) ) ); expect(topicsToFollow(neuronWithManageNeuron)).toEqual( TOPICS_TO_FOLLOW_NNS.filter( - (topic) => !DEPRECATED_TOPICS.includes(topic) && !TOPICS_WITH_FOLLOWING_DISABLED.includes(topic) + (topic) => + !DEPRECATED_TOPICS.includes(topic) && + !TOPICS_WITH_FOLLOWING_DISABLED.includes(topic) ) ); }); @@ -2190,7 +2196,9 @@ describe("neuron-utils", () => { it("should return topics with ManageNeuron if neuron follows some neuron on the ManageNeuron topic", () => { expect(topicsToFollow(neuronWithManageNeuron)).toEqual( TOPICS_TO_FOLLOW_NNS.filter( - (topic) => !DEPRECATED_TOPICS.includes(topic) && !TOPICS_WITH_FOLLOWING_DISABLED.includes(topic) + (topic) => + !DEPRECATED_TOPICS.includes(topic) && + !TOPICS_WITH_FOLLOWING_DISABLED.includes(topic) ) ); });