Skip to content

Commit

Permalink
Proof of concept: Use empty optionals
Browse files Browse the repository at this point in the history
  • Loading branch information
dskloetd committed Mar 6, 2024
1 parent defe796 commit 4cc3d05
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 71 deletions.
118 changes: 55 additions & 63 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/lib/utils/sns-aggregator-converters.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -93,6 +94,7 @@ export const convertNervousFunction = ({
const convertNeuronsFundParticipationConstraints = (
constraints: CachedNeuronsFundParticipationConstraints
): SnsNeuronsFundParticipationConstraints => ({
...emptyOptionalsForSnsNeuronsFundParticipationConstraints,
coefficient_intervals: constraints.coefficient_intervals.map(
({
slope_numerator,
Expand Down Expand Up @@ -126,7 +128,6 @@ const convertNeuronsFundParticipationConstraints = (
constraints.min_direct_participation_threshold_icp_e8s
)
),
ideal_matched_participation_function: [],
});

const convertSwapInitParams = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand Down Expand Up @@ -563,6 +564,7 @@ describe("sns aggregator converters utils", () => {
...summaryMockData.swap.init[0],
neurons_fund_participation_constraints: [
{
...emptyOptionalsForSnsNeuronsFundParticipationConstraints,
coefficient_intervals: [
{
slope_numerator: [2n],
Expand All @@ -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],
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/tests/mocks/sns-projects.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
import { Principal } from "@dfinity/principal";
import {
SnsSwapLifecycle,
emptyOptionalsForSnsNeuronsFundParticipationConstraints,
type SnsGetDerivedStateResponse,
type SnsGetLifecycleResponse,
type SnsGetMetadataResponse,
Expand Down Expand Up @@ -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: [],
},
]
: [],
Expand Down

0 comments on commit 4cc3d05

Please sign in to comment.