diff --git a/packages/ic-management/src/ic-management.canister.ts b/packages/ic-management/src/ic-management.canister.ts index 4cb9f0e3..0247155c 100644 --- a/packages/ic-management/src/ic-management.canister.ts +++ b/packages/ic-management/src/ic-management.canister.ts @@ -79,7 +79,9 @@ export class ICManagementCanister { settings, senderCanisterVersion, }: CreateCanisterParams = {}): Promise => { - const { canister_id } = await this.service.create_canister({ + const { create_canister } = this.service; + + const { canister_id } = await create_canister({ settings: toNullable(toCanisterSettings(settings)), sender_canister_version: toNullable(senderCanisterVersion), }); @@ -100,12 +102,15 @@ export class ICManagementCanister { canisterId, senderCanisterVersion, settings, - }: UpdateSettingsParams): Promise => - this.service.update_settings({ + }: UpdateSettingsParams): Promise => { + const { update_settings } = this.service; + + return update_settings({ canister_id: canisterId, sender_canister_version: toNullable(senderCanisterVersion), settings: toCanisterSettings(settings), }); + }; /** * Install code to a canister @@ -124,14 +129,17 @@ export class ICManagementCanister { wasmModule, arg, senderCanisterVersion, - }: InstallCodeParams): Promise => - this.service.install_code({ + }: InstallCodeParams): Promise => { + const { install_code } = this.service; + + return install_code({ mode: toInstallMode(mode), canister_id: canisterId, wasm_module: wasmModule, arg, sender_canister_version: toNullable(senderCanisterVersion), }); + }; /** * Upload chunks of Wasm modules that are too large to fit in a single message for installation purposes. @@ -243,11 +251,14 @@ export class ICManagementCanister { uninstallCode = ({ canisterId, senderCanisterVersion, - }: UninstallCodeParams): Promise => - this.service.uninstall_code({ + }: UninstallCodeParams): Promise => { + const { uninstall_code } = this.service; + + return uninstall_code({ canister_id: canisterId, sender_canister_version: toNullable(senderCanisterVersion), }); + }; /** * Start a canister @@ -255,8 +266,11 @@ export class ICManagementCanister { * @param {Principal} canisterId * @returns {Promise} */ - startCanister = (canisterId: Principal): Promise => - this.service.start_canister({ canister_id: canisterId }); + startCanister = (canisterId: Principal): Promise => { + const { start_canister } = this.service; + + return start_canister({ canister_id: canisterId }); + }; /** * Stop a canister @@ -264,8 +278,10 @@ export class ICManagementCanister { * @param {Principal} canisterId * @returns {Promise} */ - stopCanister = (canisterId: Principal): Promise => - this.service.stop_canister({ canister_id: canisterId }); + stopCanister = (canisterId: Principal): Promise => { + const { stop_canister } = this.service; + return stop_canister({ canister_id: canisterId }); + }; /** * Get canister details (memory size, status, etc.) @@ -273,10 +289,13 @@ export class ICManagementCanister { * @param {Principal} canisterId * @returns {Promise} */ - canisterStatus = (canisterId: Principal): Promise => - this.service.canister_status({ + canisterStatus = (canisterId: Principal): Promise => { + const { canister_status } = this.service; + + return canister_status({ canister_id: canisterId, }); + }; /** * Deletes a canister @@ -284,8 +303,11 @@ export class ICManagementCanister { * @param {Principal} canisterId * @returns {Promise} */ - deleteCanister = (canisterId: Principal): Promise => - this.service.delete_canister({ canister_id: canisterId }); + deleteCanister = (canisterId: Principal): Promise => { + const { delete_canister } = this.service; + + return delete_canister({ canister_id: canisterId }); + }; /** * Creates a canister. Only available on development instances. @@ -301,13 +323,14 @@ export class ICManagementCanister { amount, canisterId, }: ProvisionalCreateCanisterWithCyclesParams = {}): Promise => { - const { canister_id } = - await this.service.provisional_create_canister_with_cycles({ - settings: toNullable(toCanisterSettings(settings)), - amount: toNullable(amount), - specified_id: toNullable(canisterId), - sender_canister_version: [], - }); + const { provisional_create_canister_with_cycles } = this.service; + + const { canister_id } = await provisional_create_canister_with_cycles({ + settings: toNullable(toCanisterSettings(settings)), + amount: toNullable(amount), + specified_id: toNullable(canisterId), + sender_canister_version: [], + }); return canister_id; }; @@ -320,8 +343,11 @@ export class ICManagementCanister { */ fetchCanisterLogs = ( canisterId: Principal, - ): Promise => - this.service.fetch_canister_logs({ + ): Promise => { + const { fetch_canister_logs } = this.service; + + return fetch_canister_logs({ canister_id: canisterId, }); + }; }