diff --git a/CHANGELOG.md b/CHANGELOG.md index 742dc7971..e8cdcd677 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ # Features - Support `CanisterSettings.wasm_memory_threshold` in `@dfinity/nns`. +- Support `UpgradeSnsControlledCanister.chunked_canister_wasm` in `@dfinity/sns`. # 2025.01.20-1030Z diff --git a/packages/sns/candid/sns_governance.certified.idl.js b/packages/sns/candid/sns_governance.certified.idl.js index f988d4e02..ffdc983d8 100644 --- a/packages/sns/candid/sns_governance.certified.idl.js +++ b/packages/sns/candid/sns_governance.certified.idl.js @@ -242,10 +242,16 @@ export const idlFactory = ({ IDL }) => { 'memo' : IDL.Opt(IDL.Nat64), 'amount_e8s' : IDL.Nat64, }); + const ChunkedCanisterWasm = IDL.Record({ + 'wasm_module_hash' : IDL.Vec(IDL.Nat8), + 'chunk_hashes_list' : IDL.Vec(IDL.Vec(IDL.Nat8)), + 'store_canister_id' : IDL.Opt(IDL.Principal), + }); const UpgradeSnsControlledCanister = IDL.Record({ 'new_canister_wasm' : IDL.Vec(IDL.Nat8), 'mode' : IDL.Opt(IDL.Int32), 'canister_id' : IDL.Opt(IDL.Principal), + 'chunked_canister_wasm' : IDL.Opt(ChunkedCanisterWasm), 'canister_upgrade_arg' : IDL.Opt(IDL.Vec(IDL.Nat8)), }); const DeregisterDappCanisters = IDL.Record({ @@ -947,10 +953,16 @@ export const init = ({ IDL }) => { 'memo' : IDL.Opt(IDL.Nat64), 'amount_e8s' : IDL.Nat64, }); + const ChunkedCanisterWasm = IDL.Record({ + 'wasm_module_hash' : IDL.Vec(IDL.Nat8), + 'chunk_hashes_list' : IDL.Vec(IDL.Vec(IDL.Nat8)), + 'store_canister_id' : IDL.Opt(IDL.Principal), + }); const UpgradeSnsControlledCanister = IDL.Record({ 'new_canister_wasm' : IDL.Vec(IDL.Nat8), 'mode' : IDL.Opt(IDL.Int32), 'canister_id' : IDL.Opt(IDL.Principal), + 'chunked_canister_wasm' : IDL.Opt(ChunkedCanisterWasm), 'canister_upgrade_arg' : IDL.Opt(IDL.Vec(IDL.Nat8)), }); const DeregisterDappCanisters = IDL.Record({ diff --git a/packages/sns/candid/sns_governance.d.ts b/packages/sns/candid/sns_governance.d.ts index 38514d65d..cc9b24cd7 100644 --- a/packages/sns/candid/sns_governance.d.ts +++ b/packages/sns/candid/sns_governance.d.ts @@ -72,6 +72,11 @@ export type CanisterStatusType = export interface ChangeAutoStakeMaturity { requested_setting_for_auto_stake_maturity: boolean; } +export interface ChunkedCanisterWasm { + wasm_module_hash: Uint8Array | number[]; + chunk_hashes_list: Array; + store_canister_id: [] | [Principal]; +} export interface ClaimOrRefresh { by: [] | [By]; } @@ -647,6 +652,7 @@ export interface UpgradeSnsControlledCanister { new_canister_wasm: Uint8Array | number[]; mode: [] | [number]; canister_id: [] | [Principal]; + chunked_canister_wasm: [] | [ChunkedCanisterWasm]; canister_upgrade_arg: [] | [Uint8Array | number[]]; } export interface UpgradeStarted { diff --git a/packages/sns/candid/sns_governance.did b/packages/sns/candid/sns_governance.did index 18be46634..e4b95e5c9 100644 --- a/packages/sns/candid/sns_governance.did +++ b/packages/sns/candid/sns_governance.did @@ -1,4 +1,4 @@ -// Generated from IC repo commit aa705aaa62 (2025-01-08 tags: release-2025-01-09_03-19-base) 'rs/sns/governance/canister/governance.did' by import-candid +// Generated from IC repo commit 233c1ee2ef (2025-01-16 tags: release-2025-01-16_16-18-base) 'rs/sns/governance/canister/governance.did' by import-candid type Account = record { owner : opt principal; subaccount : opt Subaccount; @@ -712,8 +712,15 @@ type PendingVersion = record { target_version : opt Version; }; +type ChunkedCanisterWasm = record { + wasm_module_hash : blob; + store_canister_id : opt principal; + chunk_hashes_list : vec blob; +}; + type UpgradeSnsControlledCanister = record { new_canister_wasm : blob; + chunked_canister_wasm : opt ChunkedCanisterWasm; mode : opt int32; canister_id : opt principal; canister_upgrade_arg : opt blob; diff --git a/packages/sns/candid/sns_governance.idl.js b/packages/sns/candid/sns_governance.idl.js index 8d2124b41..8782ec8ac 100644 --- a/packages/sns/candid/sns_governance.idl.js +++ b/packages/sns/candid/sns_governance.idl.js @@ -242,10 +242,16 @@ export const idlFactory = ({ IDL }) => { 'memo' : IDL.Opt(IDL.Nat64), 'amount_e8s' : IDL.Nat64, }); + const ChunkedCanisterWasm = IDL.Record({ + 'wasm_module_hash' : IDL.Vec(IDL.Nat8), + 'chunk_hashes_list' : IDL.Vec(IDL.Vec(IDL.Nat8)), + 'store_canister_id' : IDL.Opt(IDL.Principal), + }); const UpgradeSnsControlledCanister = IDL.Record({ 'new_canister_wasm' : IDL.Vec(IDL.Nat8), 'mode' : IDL.Opt(IDL.Int32), 'canister_id' : IDL.Opt(IDL.Principal), + 'chunked_canister_wasm' : IDL.Opt(ChunkedCanisterWasm), 'canister_upgrade_arg' : IDL.Opt(IDL.Vec(IDL.Nat8)), }); const DeregisterDappCanisters = IDL.Record({ @@ -955,10 +961,16 @@ export const init = ({ IDL }) => { 'memo' : IDL.Opt(IDL.Nat64), 'amount_e8s' : IDL.Nat64, }); + const ChunkedCanisterWasm = IDL.Record({ + 'wasm_module_hash' : IDL.Vec(IDL.Nat8), + 'chunk_hashes_list' : IDL.Vec(IDL.Vec(IDL.Nat8)), + 'store_canister_id' : IDL.Opt(IDL.Principal), + }); const UpgradeSnsControlledCanister = IDL.Record({ 'new_canister_wasm' : IDL.Vec(IDL.Nat8), 'mode' : IDL.Opt(IDL.Int32), 'canister_id' : IDL.Opt(IDL.Principal), + 'chunked_canister_wasm' : IDL.Opt(ChunkedCanisterWasm), 'canister_upgrade_arg' : IDL.Opt(IDL.Vec(IDL.Nat8)), }); const DeregisterDappCanisters = IDL.Record({ diff --git a/packages/sns/candid/sns_governance_test.certified.idl.js b/packages/sns/candid/sns_governance_test.certified.idl.js index 0f00e44a3..6aa98ea43 100644 --- a/packages/sns/candid/sns_governance_test.certified.idl.js +++ b/packages/sns/candid/sns_governance_test.certified.idl.js @@ -242,10 +242,16 @@ export const idlFactory = ({ IDL }) => { 'memo' : IDL.Opt(IDL.Nat64), 'amount_e8s' : IDL.Nat64, }); + const ChunkedCanisterWasm = IDL.Record({ + 'wasm_module_hash' : IDL.Vec(IDL.Nat8), + 'chunk_hashes_list' : IDL.Vec(IDL.Vec(IDL.Nat8)), + 'store_canister_id' : IDL.Opt(IDL.Principal), + }); const UpgradeSnsControlledCanister = IDL.Record({ 'new_canister_wasm' : IDL.Vec(IDL.Nat8), 'mode' : IDL.Opt(IDL.Int32), 'canister_id' : IDL.Opt(IDL.Principal), + 'chunked_canister_wasm' : IDL.Opt(ChunkedCanisterWasm), 'canister_upgrade_arg' : IDL.Opt(IDL.Vec(IDL.Nat8)), }); const DeregisterDappCanisters = IDL.Record({ @@ -975,10 +981,16 @@ export const init = ({ IDL }) => { 'memo' : IDL.Opt(IDL.Nat64), 'amount_e8s' : IDL.Nat64, }); + const ChunkedCanisterWasm = IDL.Record({ + 'wasm_module_hash' : IDL.Vec(IDL.Nat8), + 'chunk_hashes_list' : IDL.Vec(IDL.Vec(IDL.Nat8)), + 'store_canister_id' : IDL.Opt(IDL.Principal), + }); const UpgradeSnsControlledCanister = IDL.Record({ 'new_canister_wasm' : IDL.Vec(IDL.Nat8), 'mode' : IDL.Opt(IDL.Int32), 'canister_id' : IDL.Opt(IDL.Principal), + 'chunked_canister_wasm' : IDL.Opt(ChunkedCanisterWasm), 'canister_upgrade_arg' : IDL.Opt(IDL.Vec(IDL.Nat8)), }); const DeregisterDappCanisters = IDL.Record({ diff --git a/packages/sns/candid/sns_governance_test.d.ts b/packages/sns/candid/sns_governance_test.d.ts index fd9528554..0f5c7a277 100644 --- a/packages/sns/candid/sns_governance_test.d.ts +++ b/packages/sns/candid/sns_governance_test.d.ts @@ -83,6 +83,11 @@ export type CanisterStatusType = export interface ChangeAutoStakeMaturity { requested_setting_for_auto_stake_maturity: boolean; } +export interface ChunkedCanisterWasm { + wasm_module_hash: Uint8Array | number[]; + chunk_hashes_list: Array; + store_canister_id: [] | [Principal]; +} export interface ClaimOrRefresh { by: [] | [By]; } @@ -662,6 +667,7 @@ export interface UpgradeSnsControlledCanister { new_canister_wasm: Uint8Array | number[]; mode: [] | [number]; canister_id: [] | [Principal]; + chunked_canister_wasm: [] | [ChunkedCanisterWasm]; canister_upgrade_arg: [] | [Uint8Array | number[]]; } export interface UpgradeStarted { diff --git a/packages/sns/candid/sns_governance_test.did b/packages/sns/candid/sns_governance_test.did index 44a79519e..0603c953e 100644 --- a/packages/sns/candid/sns_governance_test.did +++ b/packages/sns/candid/sns_governance_test.did @@ -1,4 +1,4 @@ -// Generated from IC repo commit aa705aaa62 (2025-01-08 tags: release-2025-01-09_03-19-base) 'rs/sns/governance/canister/governance_test.did' by import-candid +// Generated from IC repo commit 233c1ee2ef (2025-01-16 tags: release-2025-01-16_16-18-base) 'rs/sns/governance/canister/governance_test.did' by import-candid type Account = record { owner : opt principal; subaccount : opt Subaccount; @@ -726,8 +726,15 @@ type PendingVersion = record { target_version : opt Version; }; +type ChunkedCanisterWasm = record { + wasm_module_hash : blob; + store_canister_id : opt principal; + chunk_hashes_list : vec blob; +}; + type UpgradeSnsControlledCanister = record { new_canister_wasm : blob; + chunked_canister_wasm : opt ChunkedCanisterWasm; mode : opt int32; canister_id : opt principal; canister_upgrade_arg : opt blob; diff --git a/packages/sns/candid/sns_governance_test.idl.js b/packages/sns/candid/sns_governance_test.idl.js index 743bb6bab..f61fb3b0f 100644 --- a/packages/sns/candid/sns_governance_test.idl.js +++ b/packages/sns/candid/sns_governance_test.idl.js @@ -242,10 +242,16 @@ export const idlFactory = ({ IDL }) => { 'memo' : IDL.Opt(IDL.Nat64), 'amount_e8s' : IDL.Nat64, }); + const ChunkedCanisterWasm = IDL.Record({ + 'wasm_module_hash' : IDL.Vec(IDL.Nat8), + 'chunk_hashes_list' : IDL.Vec(IDL.Vec(IDL.Nat8)), + 'store_canister_id' : IDL.Opt(IDL.Principal), + }); const UpgradeSnsControlledCanister = IDL.Record({ 'new_canister_wasm' : IDL.Vec(IDL.Nat8), 'mode' : IDL.Opt(IDL.Int32), 'canister_id' : IDL.Opt(IDL.Principal), + 'chunked_canister_wasm' : IDL.Opt(ChunkedCanisterWasm), 'canister_upgrade_arg' : IDL.Opt(IDL.Vec(IDL.Nat8)), }); const DeregisterDappCanisters = IDL.Record({ @@ -983,10 +989,16 @@ export const init = ({ IDL }) => { 'memo' : IDL.Opt(IDL.Nat64), 'amount_e8s' : IDL.Nat64, }); + const ChunkedCanisterWasm = IDL.Record({ + 'wasm_module_hash' : IDL.Vec(IDL.Nat8), + 'chunk_hashes_list' : IDL.Vec(IDL.Vec(IDL.Nat8)), + 'store_canister_id' : IDL.Opt(IDL.Principal), + }); const UpgradeSnsControlledCanister = IDL.Record({ 'new_canister_wasm' : IDL.Vec(IDL.Nat8), 'mode' : IDL.Opt(IDL.Int32), 'canister_id' : IDL.Opt(IDL.Principal), + 'chunked_canister_wasm' : IDL.Opt(ChunkedCanisterWasm), 'canister_upgrade_arg' : IDL.Opt(IDL.Vec(IDL.Nat8)), }); const DeregisterDappCanisters = IDL.Record({ diff --git a/packages/sns/candid/sns_root.did b/packages/sns/candid/sns_root.did index 9e0cccf5c..c6f88b7da 100644 --- a/packages/sns/candid/sns_root.did +++ b/packages/sns/candid/sns_root.did @@ -1,4 +1,4 @@ -// Generated from IC repo commit aa705aaa62 (2025-01-08 tags: release-2025-01-09_03-19-base) 'rs/sns/root/canister/root.did' by import-candid +// Generated from IC repo commit 233c1ee2ef (2025-01-16 tags: release-2025-01-16_16-18-base) 'rs/sns/root/canister/root.did' by import-candid type CanisterCallError = record { code : opt int32; description : text; diff --git a/packages/sns/candid/sns_swap.did b/packages/sns/candid/sns_swap.did index 40f37ec1b..34588ef6b 100644 --- a/packages/sns/candid/sns_swap.did +++ b/packages/sns/candid/sns_swap.did @@ -1,4 +1,4 @@ -// Generated from IC repo commit aa705aaa62 (2025-01-08 tags: release-2025-01-09_03-19-base) 'rs/sns/swap/canister/swap.did' by import-candid +// Generated from IC repo commit 233c1ee2ef (2025-01-16 tags: release-2025-01-16_16-18-base) 'rs/sns/swap/canister/swap.did' by import-candid type BuyerState = record { icp : opt TransferableAmount; has_created_neuron_recipes : opt bool; diff --git a/packages/sns/src/converters/governance.converters.spec.ts b/packages/sns/src/converters/governance.converters.spec.ts index 27e01fe83..c9125f835 100644 --- a/packages/sns/src/converters/governance.converters.spec.ts +++ b/packages/sns/src/converters/governance.converters.spec.ts @@ -201,10 +201,23 @@ describe("governance converters", () => { it("converts UpgradeSnsControlledCanister action", () => { const new_canister_wasm = new Uint8Array(); const canister_id = mockPrincipal; + const wasm_module_hash = new Uint8Array([1, 2, 3]); + const store_canister_id = Principal.fromHex("123f"); + const chunk_hashes_list = [ + new Uint8Array([4, 5, 6]), + new Uint8Array([7, 8, 9]), + ]; const mode = 1; const action: ActionCandid = { UpgradeSnsControlledCanister: { new_canister_wasm, + chunked_canister_wasm: [ + { + wasm_module_hash, + store_canister_id: [store_canister_id], + chunk_hashes_list, + }, + ], canister_id: [canister_id], canister_upgrade_arg: [], mode: [mode], @@ -213,6 +226,11 @@ describe("governance converters", () => { const expectedAction: Action = { UpgradeSnsControlledCanister: { new_canister_wasm: new Uint8Array(), + chunked_canister_wasm: { + wasm_module_hash, + store_canister_id, + chunk_hashes_list, + }, canister_id, canister_upgrade_arg: undefined, mode, diff --git a/packages/sns/src/converters/governance.converters.ts b/packages/sns/src/converters/governance.converters.ts index db8bd11df..753274703 100644 --- a/packages/sns/src/converters/governance.converters.ts +++ b/packages/sns/src/converters/governance.converters.ts @@ -3,6 +3,7 @@ import { fromNullable, toNullable } from "@dfinity/utils"; import type { Account, Action as ActionCandid, + ChunkedCanisterWasm as ChunkedCanisterWasmCandid, Command, FunctionType as FunctionTypeCandid, GenericNervousSystemFunction as GenericNervousSystemFunctionCandid, @@ -20,6 +21,7 @@ import type { import { DEFAULT_PROPOSALS_LIMIT } from "../constants/governance.constants"; import type { Action, + ChunkedCanisterWasm, FunctionType, GenericNervousSystemFunction, ManageSnsMetadata, @@ -388,10 +390,26 @@ const convertManageSnsMetadata = ( description: fromNullable(params.description), }); +const convertChunkedCanisterWasm = ( + params: ChunkedCanisterWasmCandid | undefined, +): ChunkedCanisterWasm | undefined => { + if (params === undefined) { + return undefined; + } + return { + wasm_module_hash: params.wasm_module_hash, + store_canister_id: fromNullable(params.store_canister_id), + chunk_hashes_list: params.chunk_hashes_list, + }; +}; + const convertUpgradeSnsControlledCanister = ( params: UpgradeSnsControlledCanisterCandid, ): UpgradeSnsControlledCanister => ({ new_canister_wasm: params.new_canister_wasm, + chunked_canister_wasm: convertChunkedCanisterWasm( + fromNullable(params.chunked_canister_wasm), + ), canister_id: fromNullable(params.canister_id), canister_upgrade_arg: fromNullable(params.canister_upgrade_arg), mode: fromNullable(params.mode), diff --git a/packages/sns/src/types/actions.ts b/packages/sns/src/types/actions.ts index f59cc4321..542a3260e 100644 --- a/packages/sns/src/types/actions.ts +++ b/packages/sns/src/types/actions.ts @@ -83,8 +83,15 @@ export interface TransferSnsTreasuryFunds { amount_e8s: bigint; } +export interface ChunkedCanisterWasm { + wasm_module_hash: Uint8Array | number[]; + store_canister_id: Option; + chunk_hashes_list: Array; +} + export interface UpgradeSnsControlledCanister { new_canister_wasm: Uint8Array | number[]; + chunked_canister_wasm: Option; canister_id: Option; canister_upgrade_arg: Option; mode: Option;