Skip to content

Commit

Permalink
feat: expose upgrade module
Browse files Browse the repository at this point in the history
  • Loading branch information
peterpeterparker committed Nov 27, 2024
1 parent 7ca5427 commit 983bf9d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/admin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export * from './errors/upgrade.errors';
export * from './services/mission-control.controllers.services';
export * from './services/mission-control.upgrade.services';
export * from './services/mission-control.version.services';
export * from './services/module.upgrade.services';
export * from './services/orbiter.controllers.services';
export * from './services/orbiter.memory.services';
export * from './services/orbiter.upgrade.services';
Expand Down
28 changes: 28 additions & 0 deletions packages/admin/src/services/module.upgrade.services.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import {upgrade} from '../handlers/upgrade.handlers';
import type {ActorParameters} from '../types/actor.types';
import type {UpgradeCodeParams} from '../types/upgrade.types';

/**
* Upgrades a module with the provided WASM code and arguments. This generic is notably useful for Juno Docker.
*
* @param {Object} params - Parameters for upgrading the module.
* @param {ActorParameters} params.actor - The actor parameters associated with the module.
* @param {Principal} params.canisterId - The ID of the canister being upgraded.
* @param {Principal} [params.missionControlId] - Optional. An ID to store and reuse WASM chunks across installations.
* @param {Uint8Array} params.wasmModule - The WASM code to be installed during the upgrade.
* @param {Uint8Array} params.arg - The initialization argument for the module upgrade.
* @param {canister_install_mode} params.mode - The installation mode, e.g., `upgrade` or `reinstall`.
* @param {boolean} [params.preClearChunks] - Optional. Forces clearing existing chunks before uploading a chunked WASM module. Recommended for WASM modules larger than 2MB.
* @param {function} [params.onProgress] - Optional. Callback function to track progress during the upgrade process.
* @param {boolean} [params.reset=false] - Optional. Specifies whether to reset the module (reinstall) instead of performing an upgrade. Defaults to `false`.
* @throws {Error} Will throw an error if the parameters are invalid or if the upgrade process fails.
* @returns {Promise<void>} Resolves when the upgrade process is complete.
*/
export const upgradeModule = async (
params: {
actor: ActorParameters;
reset?: boolean;
} & UpgradeCodeParams
): Promise<void> => {
await upgrade(params);
};

0 comments on commit 983bf9d

Please sign in to comment.