Skip to content

Commit

Permalink
Update IC and add conversions for new NNS Governance types
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonz-dfinity committed Jul 27, 2024
1 parent d0998f5 commit 4384a40
Show file tree
Hide file tree
Showing 22 changed files with 855 additions and 10 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ The current status of the libraries at the time of the release is as follows:
- Extend `eip1559TransactionPrice` for Erc20.
- Add "Protocol Canister Management" and "Service Nervous System Management" topics support.
- Add `asNonNullish` function, like `assertNonNullish` but returns the value.
- Support conversion of `InstallCode` action.
- Support conversion of `InstallCode`, `StopOrStartCanister` and `UpdateCanisterSettings` actions, `SetVisibility` neuron operation, and `Neuron::visibility` attribute.

## Fix

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 de29a1a (2024-07-18 tags: release-2024-07-18_01-30--github-base) 'rs/nns/gtc/canister/gtc.did' by import-candid
// Generated from IC repo commit 2b109fb9ba (2024-07-25) 'rs/nns/gtc/canister/gtc.did' by import-candid
type AccountState = record {
authenticated_principal_id : opt principal;
successfully_transferred_neurons : vec TransferredNeuron;
Expand Down
49 changes: 49 additions & 0 deletions packages/nns/candid/governance.certified.idl.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export const idlFactory = ({ IDL }) => {
const IncreaseDissolveDelay = IDL.Record({
'additional_dissolve_delay_seconds' : IDL.Nat32,
});
const SetVisibility = IDL.Record({ 'visibility' : IDL.Opt(IDL.Int32) });
const SetDissolveTimestamp = IDL.Record({
'dissolve_timestamp_seconds' : IDL.Nat64,
});
Expand All @@ -51,6 +52,7 @@ export const idlFactory = ({ IDL }) => {
'StopDissolving' : IDL.Record({}),
'StartDissolving' : IDL.Record({}),
'IncreaseDissolveDelay' : IncreaseDissolveDelay,
'SetVisibility' : SetVisibility,
'JoinCommunityFund' : IDL.Record({}),
'LeaveCommunityFund' : IDL.Record({}),
'SetDissolveTimestamp' : SetDissolveTimestamp,
Expand Down Expand Up @@ -101,13 +103,30 @@ export const idlFactory = ({ IDL }) => {
'command' : IDL.Opt(Command),
'neuron_id_or_subaccount' : IDL.Opt(NeuronIdOrSubaccount),
});
const Controllers = IDL.Record({ 'controllers' : IDL.Vec(IDL.Principal) });
const CanisterSettings = IDL.Record({
'freezing_threshold' : IDL.Opt(IDL.Nat64),
'controllers' : IDL.Opt(Controllers),
'log_visibility' : IDL.Opt(IDL.Int32),
'wasm_memory_limit' : IDL.Opt(IDL.Nat64),
'memory_allocation' : IDL.Opt(IDL.Nat64),
'compute_allocation' : IDL.Opt(IDL.Nat64),
});
const UpdateCanisterSettings = IDL.Record({
'canister_id' : IDL.Opt(IDL.Principal),
'settings' : IDL.Opt(CanisterSettings),
});
const InstallCode = IDL.Record({
'arg' : IDL.Opt(IDL.Vec(IDL.Nat8)),
'wasm_module' : IDL.Opt(IDL.Vec(IDL.Nat8)),
'skip_stopping_before_installing' : IDL.Opt(IDL.Bool),
'canister_id' : IDL.Opt(IDL.Principal),
'install_mode' : IDL.Opt(IDL.Int32),
});
const StopOrStartCanister = IDL.Record({
'action' : IDL.Opt(IDL.Int32),
'canister_id' : IDL.Opt(IDL.Principal),
});
const Percentage = IDL.Record({ 'basis_points' : IDL.Opt(IDL.Nat64) });
const Duration = IDL.Record({ 'seconds' : IDL.Opt(IDL.Nat64) });
const Tokens = IDL.Record({ 'e8s' : IDL.Opt(IDL.Nat64) });
Expand Down Expand Up @@ -288,7 +307,9 @@ export const idlFactory = ({ IDL }) => {
const Action = IDL.Variant({
'RegisterKnownNeuron' : KnownNeuron,
'ManageNeuron' : ManageNeuron,
'UpdateCanisterSettings' : UpdateCanisterSettings,
'InstallCode' : InstallCode,
'StopOrStartCanister' : StopOrStartCanister,
'CreateServiceNervousSystem' : CreateServiceNervousSystem,
'ExecuteNnsFunction' : ExecuteNnsFunction,
'RewardNodeProvider' : RewardNodeProvider,
Expand Down Expand Up @@ -455,10 +476,12 @@ export const idlFactory = ({ IDL }) => {
});
const CfNeuron = IDL.Record({
'has_created_neuron_recipes' : IDL.Opt(IDL.Bool),
'hotkeys' : IDL.Opt(Principals),
'nns_neuron_id' : IDL.Nat64,
'amount_icp_e8s' : IDL.Nat64,
});
const CfParticipant = IDL.Record({
'controller' : IDL.Opt(IDL.Principal),
'hotkey_principal' : IDL.Text,
'cf_neurons' : IDL.Vec(CfNeuron),
});
Expand Down Expand Up @@ -600,6 +623,7 @@ export const idlFactory = ({ IDL }) => {
'dissolve_state' : IDL.Opt(DissolveState),
'followees' : IDL.Vec(IDL.Tuple(IDL.Int32, Followees)),
'neuron_fees_e8s' : IDL.Nat64,
'visibility' : IDL.Opt(IDL.Int32),
'transfer' : IDL.Opt(NeuronStakeTransfer),
'known_neuron_data' : IDL.Opt(KnownNeuronData),
'spawn_at_timestamp_seconds' : IDL.Opt(IDL.Nat64),
Expand Down Expand Up @@ -658,6 +682,7 @@ export const idlFactory = ({ IDL }) => {
'stake_e8s' : IDL.Nat64,
'joined_community_fund_timestamp_seconds' : IDL.Opt(IDL.Nat64),
'retrieved_at_timestamp_seconds' : IDL.Nat64,
'visibility' : IDL.Opt(IDL.Int32),
'known_neuron_data' : IDL.Opt(KnownNeuronData),
'voting_power' : IDL.Nat64,
'age_seconds' : IDL.Nat64,
Expand Down Expand Up @@ -924,6 +949,7 @@ export const init = ({ IDL }) => {
const IncreaseDissolveDelay = IDL.Record({
'additional_dissolve_delay_seconds' : IDL.Nat32,
});
const SetVisibility = IDL.Record({ 'visibility' : IDL.Opt(IDL.Int32) });
const SetDissolveTimestamp = IDL.Record({
'dissolve_timestamp_seconds' : IDL.Nat64,
});
Expand All @@ -934,6 +960,7 @@ export const init = ({ IDL }) => {
'StopDissolving' : IDL.Record({}),
'StartDissolving' : IDL.Record({}),
'IncreaseDissolveDelay' : IncreaseDissolveDelay,
'SetVisibility' : SetVisibility,
'JoinCommunityFund' : IDL.Record({}),
'LeaveCommunityFund' : IDL.Record({}),
'SetDissolveTimestamp' : SetDissolveTimestamp,
Expand Down Expand Up @@ -984,13 +1011,30 @@ export const init = ({ IDL }) => {
'command' : IDL.Opt(Command),
'neuron_id_or_subaccount' : IDL.Opt(NeuronIdOrSubaccount),
});
const Controllers = IDL.Record({ 'controllers' : IDL.Vec(IDL.Principal) });
const CanisterSettings = IDL.Record({
'freezing_threshold' : IDL.Opt(IDL.Nat64),
'controllers' : IDL.Opt(Controllers),
'log_visibility' : IDL.Opt(IDL.Int32),
'wasm_memory_limit' : IDL.Opt(IDL.Nat64),
'memory_allocation' : IDL.Opt(IDL.Nat64),
'compute_allocation' : IDL.Opt(IDL.Nat64),
});
const UpdateCanisterSettings = IDL.Record({
'canister_id' : IDL.Opt(IDL.Principal),
'settings' : IDL.Opt(CanisterSettings),
});
const InstallCode = IDL.Record({
'arg' : IDL.Opt(IDL.Vec(IDL.Nat8)),
'wasm_module' : IDL.Opt(IDL.Vec(IDL.Nat8)),
'skip_stopping_before_installing' : IDL.Opt(IDL.Bool),
'canister_id' : IDL.Opt(IDL.Principal),
'install_mode' : IDL.Opt(IDL.Int32),
});
const StopOrStartCanister = IDL.Record({
'action' : IDL.Opt(IDL.Int32),
'canister_id' : IDL.Opt(IDL.Principal),
});
const Percentage = IDL.Record({ 'basis_points' : IDL.Opt(IDL.Nat64) });
const Duration = IDL.Record({ 'seconds' : IDL.Opt(IDL.Nat64) });
const Tokens = IDL.Record({ 'e8s' : IDL.Opt(IDL.Nat64) });
Expand Down Expand Up @@ -1171,7 +1215,9 @@ export const init = ({ IDL }) => {
const Action = IDL.Variant({
'RegisterKnownNeuron' : KnownNeuron,
'ManageNeuron' : ManageNeuron,
'UpdateCanisterSettings' : UpdateCanisterSettings,
'InstallCode' : InstallCode,
'StopOrStartCanister' : StopOrStartCanister,
'CreateServiceNervousSystem' : CreateServiceNervousSystem,
'ExecuteNnsFunction' : ExecuteNnsFunction,
'RewardNodeProvider' : RewardNodeProvider,
Expand Down Expand Up @@ -1338,10 +1384,12 @@ export const init = ({ IDL }) => {
});
const CfNeuron = IDL.Record({
'has_created_neuron_recipes' : IDL.Opt(IDL.Bool),
'hotkeys' : IDL.Opt(Principals),
'nns_neuron_id' : IDL.Nat64,
'amount_icp_e8s' : IDL.Nat64,
});
const CfParticipant = IDL.Record({
'controller' : IDL.Opt(IDL.Principal),
'hotkey_principal' : IDL.Text,
'cf_neurons' : IDL.Vec(CfNeuron),
});
Expand Down Expand Up @@ -1483,6 +1531,7 @@ export const init = ({ IDL }) => {
'dissolve_state' : IDL.Opt(DissolveState),
'followees' : IDL.Vec(IDL.Tuple(IDL.Int32, Followees)),
'neuron_fees_e8s' : IDL.Nat64,
'visibility' : IDL.Opt(IDL.Int32),
'transfer' : IDL.Opt(NeuronStakeTransfer),
'known_neuron_data' : IDL.Opt(KnownNeuronData),
'spawn_at_timestamp_seconds' : IDL.Opt(IDL.Nat64),
Expand Down
29 changes: 29 additions & 0 deletions packages/nns/candid/governance.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ export interface AccountIdentifier {
export type Action =
| { RegisterKnownNeuron: KnownNeuron }
| { ManageNeuron: ManageNeuron }
| { UpdateCanisterSettings: UpdateCanisterSettings }
| { InstallCode: InstallCode }
| { StopOrStartCanister: StopOrStartCanister }
| { CreateServiceNervousSystem: CreateServiceNervousSystem }
| { ExecuteNnsFunction: ExecuteNnsFunction }
| { RewardNodeProvider: RewardNodeProvider }
Expand Down Expand Up @@ -47,6 +49,14 @@ export type By =
export interface Canister {
id: [] | [Principal];
}
export interface CanisterSettings {
freezing_threshold: [] | [bigint];
controllers: [] | [Controllers];
log_visibility: [] | [number];
wasm_memory_limit: [] | [bigint];
memory_allocation: [] | [bigint];
compute_allocation: [] | [bigint];
}
export interface CanisterStatusResultV2 {
status: [] | [number];
freezing_threshold: [] | [bigint];
Expand All @@ -62,10 +72,12 @@ export interface CanisterSummary {
}
export interface CfNeuron {
has_created_neuron_recipes: [] | [boolean];
hotkeys: [] | [Principals];
nns_neuron_id: bigint;
amount_icp_e8s: bigint;
}
export interface CfParticipant {
controller: [] | [Principal];
hotkey_principal: string;
cf_neurons: Array<CfNeuron>;
}
Expand Down Expand Up @@ -136,6 +148,9 @@ export interface Committed_1 {
export interface Configure {
operation: [] | [Operation];
}
export interface Controllers {
controllers: Array<Principal>;
}
export interface Countries {
iso_codes: Array<string>;
}
Expand Down Expand Up @@ -438,6 +453,7 @@ export interface Neuron {
dissolve_state: [] | [DissolveState];
followees: Array<[number, Followees]>;
neuron_fees_e8s: bigint;
visibility: [] | [number];
transfer: [] | [NeuronStakeTransfer];
known_neuron_data: [] | [KnownNeuronData];
spawn_at_timestamp_seconds: [] | [bigint];
Expand Down Expand Up @@ -476,6 +492,7 @@ export interface NeuronInfo {
stake_e8s: bigint;
joined_community_fund_timestamp_seconds: [] | [bigint];
retrieved_at_timestamp_seconds: bigint;
visibility: [] | [number];
known_neuron_data: [] | [KnownNeuronData];
voting_power: bigint;
age_seconds: bigint;
Expand Down Expand Up @@ -578,6 +595,7 @@ export type Operation =
| { StopDissolving: {} }
| { StartDissolving: {} }
| { IncreaseDissolveDelay: IncreaseDissolveDelay }
| { SetVisibility: SetVisibility }
| { JoinCommunityFund: {} }
| { LeaveCommunityFund: {} }
| { SetDissolveTimestamp: SetDissolveTimestamp };
Expand Down Expand Up @@ -718,6 +736,9 @@ export interface SetSnsTokenSwapOpenTimeWindow {
request: [] | [SetOpenTimeWindowRequest];
swap_canister_id: [] | [Principal];
}
export interface SetVisibility {
visibility: [] | [number];
}
export interface SettleCommunityFundParticipation {
result: [] | [Result_8];
open_sns_token_swap_proposal_id: [] | [bigint];
Expand Down Expand Up @@ -747,6 +768,10 @@ export interface StakeMaturityResponse {
maturity_e8s: bigint;
staked_maturity_e8s: bigint;
}
export interface StopOrStartCanister {
action: [] | [number];
canister_id: [] | [Principal];
}
export interface SwapBackgroundInformation {
ledger_index_canister_summary: [] | [CanisterSummary];
fallback_controller_principal_ids: Array<Principal>;
Expand Down Expand Up @@ -797,6 +822,10 @@ export interface TimeWindow {
export interface Tokens {
e8s: [] | [bigint];
}
export interface UpdateCanisterSettings {
canister_id: [] | [Principal];
settings: [] | [CanisterSettings];
}
export interface UpdateNodeProvider {
reward_account: [] | [AccountIdentifier];
}
Expand Down
27 changes: 26 additions & 1 deletion packages/nns/candid/governance.did
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// Generated from IC repo commit de29a1a (2024-07-18 tags: release-2024-07-18_01-30--github-base) 'rs/nns/governance/canister/governance.did' by import-candid
// Generated from IC repo commit 2b109fb9ba (2024-07-25) 'rs/nns/governance/canister/governance.did' by import-candid
type AccountIdentifier = record { hash : blob };
type Action = variant {
RegisterKnownNeuron : KnownNeuron;
ManageNeuron : ManageNeuron;
UpdateCanisterSettings : UpdateCanisterSettings;
InstallCode : InstallCode;
StopOrStartCanister : StopOrStartCanister;
CreateServiceNervousSystem : CreateServiceNervousSystem;
ExecuteNnsFunction : ExecuteNnsFunction;
RewardNodeProvider : RewardNodeProvider;
Expand All @@ -28,6 +30,14 @@ type By = variant {
Memo : nat64;
};
type Canister = record { id : opt principal };
type CanisterSettings = record {
freezing_threshold : opt nat64;
controllers : opt Controllers;
log_visibility : opt int32;
wasm_memory_limit : opt nat64;
memory_allocation : opt nat64;
compute_allocation : opt nat64;
};
type CanisterStatusResultV2 = record {
status : opt int32;
freezing_threshold : opt nat64;
Expand All @@ -43,10 +53,12 @@ type CanisterSummary = record {
};
type CfNeuron = record {
has_created_neuron_recipes : opt bool;
hotkeys : opt Principals;
nns_neuron_id : nat64;
amount_icp_e8s : nat64;
};
type CfParticipant = record {
controller : opt principal;
hotkey_principal : text;
cf_neurons : vec CfNeuron;
};
Expand Down Expand Up @@ -112,6 +124,7 @@ type Committed_1 = record {
sns_governance_canister_id : opt principal;
};
type Configure = record { operation : opt Operation };
type Controllers = record { controllers : vec principal };
type Countries = record { iso_codes : vec text };
type CreateServiceNervousSystem = record {
url : opt text;
Expand Down Expand Up @@ -367,6 +380,7 @@ type Neuron = record {
dissolve_state : opt DissolveState;
followees : vec record { int32; Followees };
neuron_fees_e8s : nat64;
visibility : opt int32;
transfer : opt NeuronStakeTransfer;
known_neuron_data : opt KnownNeuronData;
spawn_at_timestamp_seconds : opt nat64;
Expand Down Expand Up @@ -401,6 +415,7 @@ type NeuronInfo = record {
stake_e8s : nat64;
joined_community_fund_timestamp_seconds : opt nat64;
retrieved_at_timestamp_seconds : nat64;
visibility : opt int32;
known_neuron_data : opt KnownNeuronData;
voting_power : nat64;
age_seconds : nat64;
Expand Down Expand Up @@ -495,6 +510,7 @@ type Operation = variant {
StopDissolving : record {};
StartDissolving : record {};
IncreaseDissolveDelay : IncreaseDissolveDelay;
SetVisibility : SetVisibility;
JoinCommunityFund : record {};
LeaveCommunityFund : record {};
SetDissolveTimestamp : SetDissolveTimestamp;
Expand Down Expand Up @@ -616,6 +632,7 @@ type SetSnsTokenSwapOpenTimeWindow = record {
request : opt SetOpenTimeWindowRequest;
swap_canister_id : opt principal;
};
type SetVisibility = record { visibility : opt int32 };
type SettleCommunityFundParticipation = record {
result : opt Result_8;
open_sns_token_swap_proposal_id : opt nat64;
Expand All @@ -637,6 +654,10 @@ type StakeMaturityResponse = record {
maturity_e8s : nat64;
staked_maturity_e8s : nat64;
};
type StopOrStartCanister = record {
action : opt int32;
canister_id : opt principal;
};
type SwapBackgroundInformation = record {
ledger_index_canister_summary : opt CanisterSummary;
fallback_controller_principal_ids : vec principal;
Expand Down Expand Up @@ -681,6 +702,10 @@ type TimeWindow = record {
end_timestamp_seconds : nat64;
};
type Tokens = record { e8s : opt nat64 };
type UpdateCanisterSettings = record {
canister_id : opt principal;
settings : opt CanisterSettings;
};
type UpdateNodeProvider = record { reward_account : opt AccountIdentifier };
type VotingRewardParameters = record {
reward_rate_transition_duration : opt Duration;
Expand Down
Loading

0 comments on commit 4384a40

Please sign in to comment.