Skip to content

Commit

Permalink
Fix: Update nns-js candid types (#455)
Browse files Browse the repository at this point in the history
# Motivation

The field `is_genesis` has been reverted. Therefore, I updated the
candid files to the latest commit for nns-js.

# Changes

## Automatic changes

* `.did` files with `./scripts/import-candid`.
* Candid related js and type files with `./scripts/compile-idl-js`.

## Manual changes

* Fix converters.

# Tests

* Remove field from neuron mock

# Todos

- [ ] Add entry to changelog (if necessary).
I removed a previous entry.
  • Loading branch information
lmuntaner authored Oct 18, 2023
1 parent 234c232 commit 90bae93
Show file tree
Hide file tree
Showing 13 changed files with 391 additions and 196 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
- support new fields from swap canister response types: `min_direct_participation_icp_e8s` and `max_direct_participation_icp_e8s`
- support new fields in the `CreateServiceNervousSystem` proposal action `maximum_direct_participation_icp`, `minimum_direct_participation_icp` and `neurons_fund_participation`.
- support new filter field `omit_large_fields` in `list_proposals`.
- support new field `is_genesis` in `Neuron` and `NeuronInfo`.
- add support for `retrieve_btc_with_approval` in `@dfinity/ckbtc`.

# 2023.10.02-1515Z
Expand Down
2 changes: 1 addition & 1 deletion packages/nns/candid/genesis_token.did
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Generated from IC repo commit 15e69667ae983fa92c33794a3954d9ca87518af6 'rs/nns/gtc/canister/gtc.did' by import-candid
// Generated from IC repo commit 1a01f85fc1994e69dd5ba72b4d87fe9f9c4093ee 'rs/nns/gtc/canister/gtc.did' by import-candid
type AccountState = record {
authenticated_principal_id : opt principal;
successfully_transferred_neurons : vec TransferredNeuron;
Expand Down
109 changes: 71 additions & 38 deletions packages/nns/candid/governance.certified.idl.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,37 +364,55 @@ export const idlFactory = ({ IDL }) => {
'neuron_indexes_migration' : IDL.Opt(Migration),
'copy_inactive_neurons_to_stable_memory_migration' : IDL.Opt(Migration),
});
const NeuronsFundNeuron_1 = IDL.Record({
const GovernanceError = IDL.Record({
'error_message' : IDL.Text,
'error_type' : IDL.Int32,
});
const CfNeuron = IDL.Record({
'has_created_neuron_recipes' : IDL.Opt(IDL.Bool),
'nns_neuron_id' : IDL.Nat64,
'amount_icp_e8s' : IDL.Nat64,
});
const CfParticipant = IDL.Record({
'hotkey_principal' : IDL.Text,
'cf_neurons' : IDL.Vec(CfNeuron),
});
const Ballot = IDL.Record({ 'vote' : IDL.Int32, 'voting_power' : IDL.Nat64 });
const SwapParticipationLimits = IDL.Record({
'min_participant_icp_e8s' : IDL.Opt(IDL.Nat64),
'max_participant_icp_e8s' : IDL.Opt(IDL.Nat64),
'min_direct_participation_icp_e8s' : IDL.Opt(IDL.Nat64),
'max_direct_participation_icp_e8s' : IDL.Opt(IDL.Nat64),
});
const NeuronsFundNeuronPortion = IDL.Record({
'hotkey_principal' : IDL.Opt(IDL.Principal),
'is_capped' : IDL.Opt(IDL.Bool),
'nns_neuron_id' : IDL.Opt(IDL.Nat64),
'maturity_equivalent_icp_e8s' : IDL.Opt(IDL.Nat64),
'nns_neuron_id' : IDL.Opt(NeuronId),
'amount_icp_e8s' : IDL.Opt(IDL.Nat64),
});
const NeuronsFundSnapshot = IDL.Record({
'neurons_fund_neurons' : IDL.Vec(NeuronsFundNeuron_1),
'neurons_fund_neuron_portions' : IDL.Vec(NeuronsFundNeuronPortion),
});
const IdealMatchedParticipationFunction = IDL.Record({
'serialized_representation' : IDL.Opt(IDL.Text),
});
const NeuronsFundParticipation = IDL.Record({
'neurons_fund_snapshot' : IDL.Opt(NeuronsFundSnapshot),
'total_maturity_equivalent_icp_e8s' : IDL.Opt(IDL.Nat64),
'intended_neurons_fund_participation_icp_e8s' : IDL.Opt(IDL.Nat64),
'direct_participation_icp_e8s' : IDL.Opt(IDL.Nat64),
'swap_participation_limits' : IDL.Opt(SwapParticipationLimits),
'max_neurons_fund_swap_participation_icp_e8s' : IDL.Opt(IDL.Nat64),
'neurons_fund_reserves' : IDL.Opt(NeuronsFundSnapshot),
'ideal_matched_participation_function' : IDL.Opt(
IdealMatchedParticipationFunction
),
});
const GovernanceError = IDL.Record({
'error_message' : IDL.Text,
'error_type' : IDL.Int32,
});
const CfNeuron = IDL.Record({
'nns_neuron_id' : IDL.Nat64,
'amount_icp_e8s' : IDL.Nat64,
});
const CfParticipant = IDL.Record({
'hotkey_principal' : IDL.Text,
'cf_neurons' : IDL.Vec(CfNeuron),
const NeuronsFundData = IDL.Record({
'final_neurons_fund_participation' : IDL.Opt(NeuronsFundParticipation),
'initial_neurons_fund_participation' : IDL.Opt(NeuronsFundParticipation),
'neurons_fund_refunds' : IDL.Opt(NeuronsFundSnapshot),
});
const Ballot = IDL.Record({ 'vote' : IDL.Int32, 'voting_power' : IDL.Nat64 });
const CanisterStatusResultV2 = IDL.Record({
'status' : IDL.Opt(IDL.Int32),
'freezing_threshold' : IDL.Opt(IDL.Nat64),
Expand Down Expand Up @@ -432,13 +450,13 @@ export const idlFactory = ({ IDL }) => {
});
const ProposalData = IDL.Record({
'id' : IDL.Opt(NeuronId),
'neurons_fund_participation' : IDL.Opt(NeuronsFundParticipation),
'failure_reason' : IDL.Opt(GovernanceError),
'cf_participants' : IDL.Vec(CfParticipant),
'ballots' : IDL.Vec(IDL.Tuple(IDL.Nat64, Ballot)),
'proposal_timestamp_seconds' : IDL.Nat64,
'reward_event_round' : IDL.Nat64,
'failed_timestamp_seconds' : IDL.Nat64,
'neurons_fund_data' : IDL.Opt(NeuronsFundData),
'reject_cost_e8s' : IDL.Nat64,
'derived_proposal_information' : IDL.Opt(DerivedProposalInformation),
'latest_tally' : IDL.Opt(Tally),
Expand Down Expand Up @@ -487,7 +505,6 @@ export const idlFactory = ({ IDL }) => {
'created_timestamp_seconds' : IDL.Nat64,
'auto_stake_maturity' : IDL.Opt(IDL.Bool),
'aging_since_timestamp_seconds' : IDL.Nat64,
'is_genesis' : IDL.Opt(IDL.Bool),
'hot_keys' : IDL.Vec(IDL.Principal),
'account' : IDL.Vec(IDL.Nat8),
'joined_community_fund_timestamp_seconds' : IDL.Opt(IDL.Nat64),
Expand Down Expand Up @@ -545,7 +562,6 @@ export const idlFactory = ({ IDL }) => {
'recent_ballots' : IDL.Vec(BallotInfo),
'created_timestamp_seconds' : IDL.Nat64,
'state' : IDL.Int32,
'is_genesis' : IDL.Opt(IDL.Bool),
'stake_e8s' : IDL.Nat64,
'joined_community_fund_timestamp_seconds' : IDL.Opt(IDL.Nat64),
'retrieved_at_timestamp_seconds' : IDL.Nat64,
Expand Down Expand Up @@ -674,7 +690,7 @@ export const idlFactory = ({ IDL }) => {
'amount_icp_e8s' : IDL.Opt(IDL.Nat64),
});
const Ok = IDL.Record({
'neurons_fund_neurons' : IDL.Vec(NeuronsFundNeuron),
'neurons_fund_neuron_portions' : IDL.Vec(NeuronsFundNeuron),
});
const Result_9 = IDL.Variant({ 'Ok' : Ok, 'Err' : GovernanceError });
const SettleNeuronsFundParticipationResponse = IDL.Record({
Expand Down Expand Up @@ -1113,37 +1129,55 @@ export const init = ({ IDL }) => {
'neuron_indexes_migration' : IDL.Opt(Migration),
'copy_inactive_neurons_to_stable_memory_migration' : IDL.Opt(Migration),
});
const NeuronsFundNeuron_1 = IDL.Record({
const GovernanceError = IDL.Record({
'error_message' : IDL.Text,
'error_type' : IDL.Int32,
});
const CfNeuron = IDL.Record({
'has_created_neuron_recipes' : IDL.Opt(IDL.Bool),
'nns_neuron_id' : IDL.Nat64,
'amount_icp_e8s' : IDL.Nat64,
});
const CfParticipant = IDL.Record({
'hotkey_principal' : IDL.Text,
'cf_neurons' : IDL.Vec(CfNeuron),
});
const Ballot = IDL.Record({ 'vote' : IDL.Int32, 'voting_power' : IDL.Nat64 });
const SwapParticipationLimits = IDL.Record({
'min_participant_icp_e8s' : IDL.Opt(IDL.Nat64),
'max_participant_icp_e8s' : IDL.Opt(IDL.Nat64),
'min_direct_participation_icp_e8s' : IDL.Opt(IDL.Nat64),
'max_direct_participation_icp_e8s' : IDL.Opt(IDL.Nat64),
});
const NeuronsFundNeuronPortion = IDL.Record({
'hotkey_principal' : IDL.Opt(IDL.Principal),
'is_capped' : IDL.Opt(IDL.Bool),
'nns_neuron_id' : IDL.Opt(IDL.Nat64),
'maturity_equivalent_icp_e8s' : IDL.Opt(IDL.Nat64),
'nns_neuron_id' : IDL.Opt(NeuronId),
'amount_icp_e8s' : IDL.Opt(IDL.Nat64),
});
const NeuronsFundSnapshot = IDL.Record({
'neurons_fund_neurons' : IDL.Vec(NeuronsFundNeuron_1),
'neurons_fund_neuron_portions' : IDL.Vec(NeuronsFundNeuronPortion),
});
const IdealMatchedParticipationFunction = IDL.Record({
'serialized_representation' : IDL.Opt(IDL.Text),
});
const NeuronsFundParticipation = IDL.Record({
'neurons_fund_snapshot' : IDL.Opt(NeuronsFundSnapshot),
'total_maturity_equivalent_icp_e8s' : IDL.Opt(IDL.Nat64),
'intended_neurons_fund_participation_icp_e8s' : IDL.Opt(IDL.Nat64),
'direct_participation_icp_e8s' : IDL.Opt(IDL.Nat64),
'swap_participation_limits' : IDL.Opt(SwapParticipationLimits),
'max_neurons_fund_swap_participation_icp_e8s' : IDL.Opt(IDL.Nat64),
'neurons_fund_reserves' : IDL.Opt(NeuronsFundSnapshot),
'ideal_matched_participation_function' : IDL.Opt(
IdealMatchedParticipationFunction
),
});
const GovernanceError = IDL.Record({
'error_message' : IDL.Text,
'error_type' : IDL.Int32,
});
const CfNeuron = IDL.Record({
'nns_neuron_id' : IDL.Nat64,
'amount_icp_e8s' : IDL.Nat64,
});
const CfParticipant = IDL.Record({
'hotkey_principal' : IDL.Text,
'cf_neurons' : IDL.Vec(CfNeuron),
const NeuronsFundData = IDL.Record({
'final_neurons_fund_participation' : IDL.Opt(NeuronsFundParticipation),
'initial_neurons_fund_participation' : IDL.Opt(NeuronsFundParticipation),
'neurons_fund_refunds' : IDL.Opt(NeuronsFundSnapshot),
});
const Ballot = IDL.Record({ 'vote' : IDL.Int32, 'voting_power' : IDL.Nat64 });
const CanisterStatusResultV2 = IDL.Record({
'status' : IDL.Opt(IDL.Int32),
'freezing_threshold' : IDL.Opt(IDL.Nat64),
Expand Down Expand Up @@ -1181,13 +1215,13 @@ export const init = ({ IDL }) => {
});
const ProposalData = IDL.Record({
'id' : IDL.Opt(NeuronId),
'neurons_fund_participation' : IDL.Opt(NeuronsFundParticipation),
'failure_reason' : IDL.Opt(GovernanceError),
'cf_participants' : IDL.Vec(CfParticipant),
'ballots' : IDL.Vec(IDL.Tuple(IDL.Nat64, Ballot)),
'proposal_timestamp_seconds' : IDL.Nat64,
'reward_event_round' : IDL.Nat64,
'failed_timestamp_seconds' : IDL.Nat64,
'neurons_fund_data' : IDL.Opt(NeuronsFundData),
'reject_cost_e8s' : IDL.Nat64,
'derived_proposal_information' : IDL.Opt(DerivedProposalInformation),
'latest_tally' : IDL.Opt(Tally),
Expand Down Expand Up @@ -1236,7 +1270,6 @@ export const init = ({ IDL }) => {
'created_timestamp_seconds' : IDL.Nat64,
'auto_stake_maturity' : IDL.Opt(IDL.Bool),
'aging_since_timestamp_seconds' : IDL.Nat64,
'is_genesis' : IDL.Opt(IDL.Bool),
'hot_keys' : IDL.Vec(IDL.Principal),
'account' : IDL.Vec(IDL.Nat8),
'joined_community_fund_timestamp_seconds' : IDL.Opt(IDL.Nat64),
Expand Down
32 changes: 24 additions & 8 deletions packages/nns/candid/governance.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export interface CanisterSummary {
canister_id: [] | [Principal];
}
export interface CfNeuron {
has_created_neuron_recipes: [] | [boolean];
nns_neuron_id: bigint;
amount_icp_e8s: bigint;
}
Expand Down Expand Up @@ -382,7 +383,6 @@ export interface Neuron {
created_timestamp_seconds: bigint;
auto_stake_maturity: [] | [boolean];
aging_since_timestamp_seconds: bigint;
is_genesis: [] | [boolean];
hot_keys: Array<Principal>;
account: Uint8Array;
joined_community_fund_timestamp_seconds: [] | [bigint];
Expand Down Expand Up @@ -423,7 +423,6 @@ export interface NeuronInfo {
recent_ballots: Array<BallotInfo>;
created_timestamp_seconds: bigint;
state: number;
is_genesis: [] | [boolean];
stake_e8s: bigint;
joined_community_fund_timestamp_seconds: [] | [bigint];
retrieved_at_timestamp_seconds: bigint;
Expand All @@ -440,33 +439,44 @@ export interface NeuronStakeTransfer {
transfer_timestamp: bigint;
block_height: bigint;
}
export interface NeuronsFundData {
final_neurons_fund_participation: [] | [NeuronsFundParticipation];
initial_neurons_fund_participation: [] | [NeuronsFundParticipation];
neurons_fund_refunds: [] | [NeuronsFundSnapshot];
}
export interface NeuronsFundNeuron {
hotkey_principal: [] | [string];
is_capped: [] | [boolean];
nns_neuron_id: [] | [bigint];
amount_icp_e8s: [] | [bigint];
}
export interface NeuronsFundNeuron_1 {
export interface NeuronsFundNeuronPortion {
hotkey_principal: [] | [Principal];
is_capped: [] | [boolean];
nns_neuron_id: [] | [bigint];
maturity_equivalent_icp_e8s: [] | [bigint];
nns_neuron_id: [] | [NeuronId];
amount_icp_e8s: [] | [bigint];
}
export interface NeuronsFundParticipation {
neurons_fund_snapshot: [] | [NeuronsFundSnapshot];
total_maturity_equivalent_icp_e8s: [] | [bigint];
intended_neurons_fund_participation_icp_e8s: [] | [bigint];
direct_participation_icp_e8s: [] | [bigint];
swap_participation_limits: [] | [SwapParticipationLimits];
max_neurons_fund_swap_participation_icp_e8s: [] | [bigint];
neurons_fund_reserves: [] | [NeuronsFundSnapshot];
ideal_matched_participation_function:
| []
| [IdealMatchedParticipationFunction];
}
export interface NeuronsFundSnapshot {
neurons_fund_neurons: Array<NeuronsFundNeuron_1>;
neurons_fund_neuron_portions: Array<NeuronsFundNeuronPortion>;
}
export interface NodeProvider {
id: [] | [Principal];
reward_account: [] | [AccountIdentifier];
}
export interface Ok {
neurons_fund_neurons: Array<NeuronsFundNeuron>;
neurons_fund_neuron_portions: Array<NeuronsFundNeuron>;
}
export interface OpenSnsTokenSwap {
community_fund_investment_e8s: [] | [bigint];
Expand Down Expand Up @@ -510,13 +520,13 @@ export interface Proposal {
}
export interface ProposalData {
id: [] | [NeuronId];
neurons_fund_participation: [] | [NeuronsFundParticipation];
failure_reason: [] | [GovernanceError];
cf_participants: Array<CfParticipant>;
ballots: Array<[bigint, Ballot]>;
proposal_timestamp_seconds: bigint;
reward_event_round: bigint;
failed_timestamp_seconds: bigint;
neurons_fund_data: [] | [NeuronsFundData];
reject_cost_e8s: bigint;
derived_proposal_information: [] | [DerivedProposalInformation];
latest_tally: [] | [Tally];
Expand Down Expand Up @@ -666,6 +676,12 @@ export interface SwapParameters {
neurons_fund_investment_icp: [] | [Tokens];
restricted_countries: [] | [Countries];
}
export interface SwapParticipationLimits {
min_participant_icp_e8s: [] | [bigint];
max_participant_icp_e8s: [] | [bigint];
min_direct_participation_icp_e8s: [] | [bigint];
max_direct_participation_icp_e8s: [] | [bigint];
}
export interface Tally {
no: bigint;
yes: bigint;
Expand Down
Loading

0 comments on commit 90bae93

Please sign in to comment.