Skip to content

Commit

Permalink
chore: linter
Browse files Browse the repository at this point in the history
  • Loading branch information
mstrasinskis committed Dec 7, 2023
1 parent 49312b4 commit 6b624b6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
20 changes: 17 additions & 3 deletions packages/nns/src/canisters/governance/response.converters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ import type {
Tokens as RawTokens,
VotingRewardParameters as RawVotingRewardParameters,
} from "../../../candid/governance";
import { NeuronState, type NeuronType } from "../../enums/governance.enums";
import { NeuronState, NeuronType } from "../../enums/governance.enums";
import { UnsupportedValueError } from "../../errors/governance.errors";
import type {
AccountIdentifier as AccountIdentifierString,
Expand Down Expand Up @@ -125,7 +125,11 @@ export const toNeuronInfo = ({
neuronId: neuronId,
dissolveDelaySeconds: neuronInfo.dissolve_delay_seconds,
recentBallots: neuronInfo.recent_ballots.map(toBallotInfo),
neuronType: fromNullable(neuronInfo.neuron_type) as NeuronType | undefined,

// TODO: replace the mock
neuronType: mockNeuronType(toNeuronId({ id: neuronId ?? 0n })),
// neuronType: fromNullable(neuronInfo.neuron_type) as NeuronType | undefined,

createdTimestampSeconds: neuronInfo.created_timestamp_seconds,
state: neuronInfo.state,
joinedCommunityFundTimestampSeconds: neuronInfo
Expand All @@ -139,6 +143,12 @@ export const toNeuronInfo = ({
};
};

const mockNeuronType = (neuronId: bigint): NeuronType | undefined => {
const id = Number(neuronId.toString().substring(0, 8));
if (id % 3 === 0) return NeuronType.Seed;
if (id % 5 === 0) return NeuronType.Ect;
};

const toNeuron = ({
neuron,
canisterId,
Expand All @@ -154,7 +164,11 @@ const toNeuron = ({
? neuron.controller[0].toString()
: undefined,
recentBallots: neuron.recent_ballots.map(toBallotInfo),
neuronType: fromNullable(neuron.neuron_type) as NeuronType | undefined,

// TODO: replace the mock
neuronType: mockNeuronType(toNeuronId(neuron?.id[0] ?? { id: 0n })),
// neuronType: fromNullable(neuron.neuron_type) as NeuronType | undefined,

kycVerified: neuron.kyc_verified,
notForProfit: neuron.not_for_profit,
cachedNeuronStake: neuron.cached_neuron_stake_e8s,
Expand Down
2 changes: 1 addition & 1 deletion packages/nns/src/types/governance_converters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type {
Topic,
Vote,
} from "../enums/governance.enums";
import { NeuronType } from "../enums/governance.enums";
import type { NeuronType } from "../enums/governance.enums";
import type {
AccountIdentifier,
CanisterIdString,
Expand Down

0 comments on commit 6b624b6

Please sign in to comment.