Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proof of concept: provide empty optionals #569

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/sns/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export * from "./errors/governance.errors";
export * from "./errors/swap.errors";
export { SnsGovernanceCanister } from "./governance.canister";
export { SnsGovernanceTestCanister } from "./governance_test.canister";
export * from "./optionals/optionals";
export { SnsRootCanister } from "./root.canister";
export * from "./sns";
export * from "./sns.wrapper";
Expand Down
17 changes: 17 additions & 0 deletions packages/sns/src/optionals/optionals.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import type { NeuronsFundParticipationConstraints as SnsNeuronsFundParticipationConstraints } from "../../candid/sns_swap";
import { emptyOptionalsForSnsNeuronsFundParticipationConstraints } from "./optionals";

// If this file has a compilation error because new optional fields were added
// to a Candid type, add the the empty optional field values to the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// to a Candid type, add the the empty optional field values to the
// to a Candid type, add the empty optional field values to the

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Done.

// corresponding `emptyOptionalsFor...` value in `./optionals.ts`.

const testValueForSnsNeuronsFundParticipationConstraints: SnsNeuronsFundParticipationConstraints =
{
...emptyOptionalsForSnsNeuronsFundParticipationConstraints,
coefficient_intervals: [],
};

// The real test is whether the types above are accepted by the compiler.
it("should have at least one test", () => {
expect(true).toBe(true);
});
14 changes: 14 additions & 0 deletions packages/sns/src/optionals/optionals.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type { NeuronsFundParticipationConstraints as SnsNeuronsFundParticipationConstraints } from "../../candid/sns_swap";

export interface NeuronsFundParticipationConstraints {}

export const emptyOptionalsForSnsNeuronsFundParticipationConstraints: Pick<
SnsNeuronsFundParticipationConstraints,
| "max_neurons_fund_participation_icp_e8s"
| "min_direct_participation_threshold_icp_e8s"
| "ideal_matched_participation_function"
> = {
max_neurons_fund_participation_icp_e8s: [],
min_direct_participation_threshold_icp_e8s: [],
ideal_matched_participation_function: [],
};
Loading