Skip to content

Commit

Permalink
Update candid for nns package (#681)
Browse files Browse the repository at this point in the history
# Motivation

#676 tried to do this automatically
but there were test failures.

# Changes

1. Ran `scripts/import-candid ../../ic` and `scripts/compile-idl-js`.
2. Reverted everything outside nns package: `git checkout
packages/{ckbtc,cketh,cmc,ledger-icp,ledger-icrc,sns}`
3. Added conversion to and from raw action for `InstallCode` action.

# Tests

Unit tests added for conversion in both directions.

# Todos

- [x] Add entry to changelog (if necessary).
  • Loading branch information
dskloetd authored Jul 22, 2024
1 parent dae8474 commit 70a9b9b
Show file tree
Hide file tree
Showing 16 changed files with 394 additions and 42 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +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.

## 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 a3831c8 (2024-07-11 tags: release-2024-07-10_23-01-base) 'rs/nns/gtc/canister/gtc.did' by import-candid
// Generated from IC repo commit de29a1a55b (2024-07-18 tags: release-2024-07-18_01-30--github-base) 'rs/nns/gtc/canister/gtc.did' by import-candid
type AccountState = record {
authenticated_principal_id : opt principal;
successfully_transferred_neurons : vec TransferredNeuron;
Expand Down
34 changes: 26 additions & 8 deletions packages/nns/candid/governance.certified.idl.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@ export const idlFactory = ({ IDL }) => {
'command' : IDL.Opt(Command),
'neuron_id_or_subaccount' : IDL.Opt(NeuronIdOrSubaccount),
});
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 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 @@ -271,9 +278,7 @@ export const idlFactory = ({ IDL }) => {
'maximum_node_provider_rewards_e8s' : IDL.Nat64,
'neurons_fund_economics' : IDL.Opt(NeuronsFundEconomics),
});
const ApproveGenesisKyc = IDL.Record({
'principals' : IDL.Vec(IDL.Principal),
});
const Principals = IDL.Record({ 'principals' : IDL.Vec(IDL.Principal) });
const Change = IDL.Variant({
'ToRemove' : NodeProvider,
'ToAdd' : NodeProvider,
Expand All @@ -283,6 +288,7 @@ export const idlFactory = ({ IDL }) => {
const Action = IDL.Variant({
'RegisterKnownNeuron' : KnownNeuron,
'ManageNeuron' : ManageNeuron,
'InstallCode' : InstallCode,
'CreateServiceNervousSystem' : CreateServiceNervousSystem,
'ExecuteNnsFunction' : ExecuteNnsFunction,
'RewardNodeProvider' : RewardNodeProvider,
Expand All @@ -291,7 +297,7 @@ export const idlFactory = ({ IDL }) => {
'SetDefaultFollowees' : SetDefaultFollowees,
'RewardNodeProviders' : RewardNodeProviders,
'ManageNetworkEconomics' : NetworkEconomics,
'ApproveGenesisKyc' : ApproveGenesisKyc,
'ApproveGenesisKyc' : Principals,
'AddOrRemoveNodeProvider' : AddOrRemoveNodeProvider,
'Motion' : Motion,
});
Expand Down Expand Up @@ -464,7 +470,9 @@ export const idlFactory = ({ IDL }) => {
'max_direct_participation_icp_e8s' : IDL.Opt(IDL.Nat64),
});
const NeuronsFundNeuronPortion = IDL.Record({
'controller' : IDL.Opt(IDL.Principal),
'hotkey_principal' : IDL.Opt(IDL.Principal),
'hotkeys' : IDL.Vec(IDL.Principal),
'is_capped' : IDL.Opt(IDL.Bool),
'maturity_equivalent_icp_e8s' : IDL.Opt(IDL.Nat64),
'nns_neuron_id' : IDL.Opt(NeuronId),
Expand Down Expand Up @@ -786,7 +794,9 @@ export const idlFactory = ({ IDL }) => {
'nns_proposal_id' : IDL.Opt(IDL.Nat64),
});
const NeuronsFundNeuron = IDL.Record({
'controller' : IDL.Opt(IDL.Principal),
'hotkey_principal' : IDL.Opt(IDL.Text),
'hotkeys' : IDL.Opt(Principals),
'is_capped' : IDL.Opt(IDL.Bool),
'nns_neuron_id' : IDL.Opt(IDL.Nat64),
'amount_icp_e8s' : IDL.Opt(IDL.Nat64),
Expand Down Expand Up @@ -974,6 +984,13 @@ export const init = ({ IDL }) => {
'command' : IDL.Opt(Command),
'neuron_id_or_subaccount' : IDL.Opt(NeuronIdOrSubaccount),
});
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 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 @@ -1144,9 +1161,7 @@ export const init = ({ IDL }) => {
'maximum_node_provider_rewards_e8s' : IDL.Nat64,
'neurons_fund_economics' : IDL.Opt(NeuronsFundEconomics),
});
const ApproveGenesisKyc = IDL.Record({
'principals' : IDL.Vec(IDL.Principal),
});
const Principals = IDL.Record({ 'principals' : IDL.Vec(IDL.Principal) });
const Change = IDL.Variant({
'ToRemove' : NodeProvider,
'ToAdd' : NodeProvider,
Expand All @@ -1156,6 +1171,7 @@ export const init = ({ IDL }) => {
const Action = IDL.Variant({
'RegisterKnownNeuron' : KnownNeuron,
'ManageNeuron' : ManageNeuron,
'InstallCode' : InstallCode,
'CreateServiceNervousSystem' : CreateServiceNervousSystem,
'ExecuteNnsFunction' : ExecuteNnsFunction,
'RewardNodeProvider' : RewardNodeProvider,
Expand All @@ -1164,7 +1180,7 @@ export const init = ({ IDL }) => {
'SetDefaultFollowees' : SetDefaultFollowees,
'RewardNodeProviders' : RewardNodeProviders,
'ManageNetworkEconomics' : NetworkEconomics,
'ApproveGenesisKyc' : ApproveGenesisKyc,
'ApproveGenesisKyc' : Principals,
'AddOrRemoveNodeProvider' : AddOrRemoveNodeProvider,
'Motion' : Motion,
});
Expand Down Expand Up @@ -1337,7 +1353,9 @@ export const init = ({ IDL }) => {
'max_direct_participation_icp_e8s' : IDL.Opt(IDL.Nat64),
});
const NeuronsFundNeuronPortion = IDL.Record({
'controller' : IDL.Opt(IDL.Principal),
'hotkey_principal' : IDL.Opt(IDL.Principal),
'hotkeys' : IDL.Vec(IDL.Principal),
'is_capped' : IDL.Opt(IDL.Bool),
'maturity_equivalent_icp_e8s' : IDL.Opt(IDL.Nat64),
'nns_neuron_id' : IDL.Opt(NeuronId),
Expand Down
17 changes: 16 additions & 1 deletion packages/nns/candid/governance.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export interface AccountIdentifier {
export type Action =
| { RegisterKnownNeuron: KnownNeuron }
| { ManageNeuron: ManageNeuron }
| { InstallCode: InstallCode }
| { CreateServiceNervousSystem: CreateServiceNervousSystem }
| { ExecuteNnsFunction: ExecuteNnsFunction }
| { RewardNodeProvider: RewardNodeProvider }
Expand All @@ -16,7 +17,7 @@ export type Action =
| { SetDefaultFollowees: SetDefaultFollowees }
| { RewardNodeProviders: RewardNodeProviders }
| { ManageNetworkEconomics: NetworkEconomics }
| { ApproveGenesisKyc: ApproveGenesisKyc }
| { ApproveGenesisKyc: Principals }
| { AddOrRemoveNodeProvider: AddOrRemoveNodeProvider }
| { Motion: Motion };
export interface AddHotKey {
Expand Down Expand Up @@ -305,6 +306,13 @@ export interface InitialTokenDistribution {
developer_distribution: [] | [DeveloperDistribution];
swap_distribution: [] | [SwapDistribution];
}
export interface InstallCode {
arg: [] | [Uint8Array | number[]];
wasm_module: [] | [Uint8Array | number[]];
skip_stopping_before_installing: [] | [boolean];
canister_id: [] | [Principal];
install_mode: [] | [number];
}
export interface KnownNeuron {
id: [] | [NeuronId];
known_neuron_data: [] | [KnownNeuronData];
Expand Down Expand Up @@ -517,13 +525,17 @@ export interface NeuronsFundMatchedFundingCurveCoefficients {
full_participation_milestone_xdr: [] | [Decimal];
}
export interface NeuronsFundNeuron {
controller: [] | [Principal];
hotkey_principal: [] | [string];
hotkeys: [] | [Principals];
is_capped: [] | [boolean];
nns_neuron_id: [] | [bigint];
amount_icp_e8s: [] | [bigint];
}
export interface NeuronsFundNeuronPortion {
controller: [] | [Principal];
hotkey_principal: [] | [Principal];
hotkeys: Array<Principal>;
is_capped: [] | [boolean];
maturity_equivalent_icp_e8s: [] | [bigint];
nns_neuron_id: [] | [NeuronId];
Expand Down Expand Up @@ -587,6 +599,9 @@ export interface Params {
export interface Percentage {
basis_points: [] | [bigint];
}
export interface Principals {
principals: Array<Principal>;
}
export type Progress = { LastNeuronId: NeuronId };
export interface Proposal {
url: string;
Expand Down
17 changes: 15 additions & 2 deletions packages/nns/candid/governance.did
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// Generated from IC repo commit a3831c8 (2024-07-11 tags: release-2024-07-10_23-01-base) 'rs/nns/governance/canister/governance.did' by import-candid
// Generated from IC repo commit de29a1a55b (2024-07-18 tags: release-2024-07-18_01-30--github-base) 'rs/nns/governance/canister/governance.did' by import-candid
type AccountIdentifier = record { hash : blob };
type Action = variant {
RegisterKnownNeuron : KnownNeuron;
ManageNeuron : ManageNeuron;
InstallCode : InstallCode;
CreateServiceNervousSystem : CreateServiceNervousSystem;
ExecuteNnsFunction : ExecuteNnsFunction;
RewardNodeProvider : RewardNodeProvider;
Expand All @@ -11,7 +12,7 @@ type Action = variant {
SetDefaultFollowees : SetDefaultFollowees;
RewardNodeProviders : RewardNodeProviders;
ManageNetworkEconomics : NetworkEconomics;
ApproveGenesisKyc : ApproveGenesisKyc;
ApproveGenesisKyc : Principals;
AddOrRemoveNodeProvider : AddOrRemoveNodeProvider;
Motion : Motion;
};
Expand Down Expand Up @@ -251,6 +252,13 @@ type InitialTokenDistribution = record {
developer_distribution : opt DeveloperDistribution;
swap_distribution : opt SwapDistribution;
};
type InstallCode = record {
arg : opt blob;
wasm_module : opt blob;
skip_stopping_before_installing : opt bool;
canister_id : opt principal;
install_mode : opt int32;
};
type KnownNeuron = record {
id : opt NeuronId;
known_neuron_data : opt KnownNeuronData;
Expand Down Expand Up @@ -440,13 +448,17 @@ type NeuronsFundMatchedFundingCurveCoefficients = record {
full_participation_milestone_xdr : opt Decimal;
};
type NeuronsFundNeuron = record {
controller : opt principal;
hotkey_principal : opt text;
hotkeys : opt Principals;
is_capped : opt bool;
nns_neuron_id : opt nat64;
amount_icp_e8s : opt nat64;
};
type NeuronsFundNeuronPortion = record {
controller : opt principal;
hotkey_principal : opt principal;
hotkeys : vec principal;
is_capped : opt bool;
maturity_equivalent_icp_e8s : opt nat64;
nns_neuron_id : opt NeuronId;
Expand Down Expand Up @@ -501,6 +513,7 @@ type Params = record {
max_direct_participation_icp_e8s : opt nat64;
};
type Percentage = record { basis_points : opt nat64 };
type Principals = record { principals : vec principal };
type Progress = variant { LastNeuronId : NeuronId };
type Proposal = record {
url : text;
Expand Down
34 changes: 26 additions & 8 deletions packages/nns/candid/governance.idl.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@ export const idlFactory = ({ IDL }) => {
'command' : IDL.Opt(Command),
'neuron_id_or_subaccount' : IDL.Opt(NeuronIdOrSubaccount),
});
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 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 @@ -271,9 +278,7 @@ export const idlFactory = ({ IDL }) => {
'maximum_node_provider_rewards_e8s' : IDL.Nat64,
'neurons_fund_economics' : IDL.Opt(NeuronsFundEconomics),
});
const ApproveGenesisKyc = IDL.Record({
'principals' : IDL.Vec(IDL.Principal),
});
const Principals = IDL.Record({ 'principals' : IDL.Vec(IDL.Principal) });
const Change = IDL.Variant({
'ToRemove' : NodeProvider,
'ToAdd' : NodeProvider,
Expand All @@ -283,6 +288,7 @@ export const idlFactory = ({ IDL }) => {
const Action = IDL.Variant({
'RegisterKnownNeuron' : KnownNeuron,
'ManageNeuron' : ManageNeuron,
'InstallCode' : InstallCode,
'CreateServiceNervousSystem' : CreateServiceNervousSystem,
'ExecuteNnsFunction' : ExecuteNnsFunction,
'RewardNodeProvider' : RewardNodeProvider,
Expand All @@ -291,7 +297,7 @@ export const idlFactory = ({ IDL }) => {
'SetDefaultFollowees' : SetDefaultFollowees,
'RewardNodeProviders' : RewardNodeProviders,
'ManageNetworkEconomics' : NetworkEconomics,
'ApproveGenesisKyc' : ApproveGenesisKyc,
'ApproveGenesisKyc' : Principals,
'AddOrRemoveNodeProvider' : AddOrRemoveNodeProvider,
'Motion' : Motion,
});
Expand Down Expand Up @@ -464,7 +470,9 @@ export const idlFactory = ({ IDL }) => {
'max_direct_participation_icp_e8s' : IDL.Opt(IDL.Nat64),
});
const NeuronsFundNeuronPortion = IDL.Record({
'controller' : IDL.Opt(IDL.Principal),
'hotkey_principal' : IDL.Opt(IDL.Principal),
'hotkeys' : IDL.Vec(IDL.Principal),
'is_capped' : IDL.Opt(IDL.Bool),
'maturity_equivalent_icp_e8s' : IDL.Opt(IDL.Nat64),
'nns_neuron_id' : IDL.Opt(NeuronId),
Expand Down Expand Up @@ -786,7 +794,9 @@ export const idlFactory = ({ IDL }) => {
'nns_proposal_id' : IDL.Opt(IDL.Nat64),
});
const NeuronsFundNeuron = IDL.Record({
'controller' : IDL.Opt(IDL.Principal),
'hotkey_principal' : IDL.Opt(IDL.Text),
'hotkeys' : IDL.Opt(Principals),
'is_capped' : IDL.Opt(IDL.Bool),
'nns_neuron_id' : IDL.Opt(IDL.Nat64),
'amount_icp_e8s' : IDL.Opt(IDL.Nat64),
Expand Down Expand Up @@ -990,6 +1000,13 @@ export const init = ({ IDL }) => {
'command' : IDL.Opt(Command),
'neuron_id_or_subaccount' : IDL.Opt(NeuronIdOrSubaccount),
});
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 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 @@ -1160,9 +1177,7 @@ export const init = ({ IDL }) => {
'maximum_node_provider_rewards_e8s' : IDL.Nat64,
'neurons_fund_economics' : IDL.Opt(NeuronsFundEconomics),
});
const ApproveGenesisKyc = IDL.Record({
'principals' : IDL.Vec(IDL.Principal),
});
const Principals = IDL.Record({ 'principals' : IDL.Vec(IDL.Principal) });
const Change = IDL.Variant({
'ToRemove' : NodeProvider,
'ToAdd' : NodeProvider,
Expand All @@ -1172,6 +1187,7 @@ export const init = ({ IDL }) => {
const Action = IDL.Variant({
'RegisterKnownNeuron' : KnownNeuron,
'ManageNeuron' : ManageNeuron,
'InstallCode' : InstallCode,
'CreateServiceNervousSystem' : CreateServiceNervousSystem,
'ExecuteNnsFunction' : ExecuteNnsFunction,
'RewardNodeProvider' : RewardNodeProvider,
Expand All @@ -1180,7 +1196,7 @@ export const init = ({ IDL }) => {
'SetDefaultFollowees' : SetDefaultFollowees,
'RewardNodeProviders' : RewardNodeProviders,
'ManageNetworkEconomics' : NetworkEconomics,
'ApproveGenesisKyc' : ApproveGenesisKyc,
'ApproveGenesisKyc' : Principals,
'AddOrRemoveNodeProvider' : AddOrRemoveNodeProvider,
'Motion' : Motion,
});
Expand Down Expand Up @@ -1353,7 +1369,9 @@ export const init = ({ IDL }) => {
'max_direct_participation_icp_e8s' : IDL.Opt(IDL.Nat64),
});
const NeuronsFundNeuronPortion = IDL.Record({
'controller' : IDL.Opt(IDL.Principal),
'hotkey_principal' : IDL.Opt(IDL.Principal),
'hotkeys' : IDL.Vec(IDL.Principal),
'is_capped' : IDL.Opt(IDL.Bool),
'maturity_equivalent_icp_e8s' : IDL.Opt(IDL.Nat64),
'nns_neuron_id' : IDL.Opt(NeuronId),
Expand Down
Loading

0 comments on commit 70a9b9b

Please sign in to comment.