Skip to content

Commit

Permalink
feat: use admin with ic-management (#152)
Browse files Browse the repository at this point in the history
  • Loading branch information
peterpeterparker authored Nov 22, 2024
1 parent 040a197 commit b417919
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 49 deletions.
57 changes: 29 additions & 28 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
"@dfinity/agent": "^2.1.3",
"@dfinity/auth-client": "^2.1.3",
"@dfinity/candid": "^2.1.3",
"@dfinity/ic-management": "^5.2.3",
"@dfinity/ic-management": "^5.3.0-next-2024-11-22",
"@dfinity/identity": "^2.1.3",
"@dfinity/principal": "^2.1.3",
"@junobuild/admin": "^0.0.58",
"@junobuild/admin": "^0.0.58-next-2024-11-22",
"@junobuild/cli-tools": "^0.0.16",
"@junobuild/config-loader": "^0.0.7",
"@junobuild/core-peer": "^0.0.29",
Expand Down
8 changes: 4 additions & 4 deletions src/services/upgrade/upgrade-assert.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {cyan, yellow} from 'kleur';
import {type UpgradeWasm, type UpgradeWasmModule} from '../../types/upgrade';
import {NEW_CMD_LINE, confirmAndExit} from '../../utils/prompt.utils';

const wasmBuildType = async ({wasm_module}: UpgradeWasmModule): Promise<BuildType | undefined> => {
const buffer = Buffer.from(wasm_module);
const wasmBuildType = async ({wasmModule}: UpgradeWasmModule): Promise<BuildType | undefined> => {
const buffer = Buffer.from(wasmModule);

const wasm = isGzip(buffer)
? await gunzipFile({
Expand All @@ -28,7 +28,7 @@ const wasmBuildType = async ({wasm_module}: UpgradeWasmModule): Promise<BuildTyp

export const assertSatelliteBuildType = async ({
satellite,
wasm_module
wasmModule
}: {satellite: SatelliteParameters} & UpgradeWasmModule) => {
// TODO: Workaround for agent-js. Disable console.warn.
// See https://github.com/dfinity/agent-js/issues/843
Expand All @@ -37,7 +37,7 @@ export const assertSatelliteBuildType = async ({
globalThis.console.warn = (): null => null;

const [wasmTypeResult, satelliteTypeResult] = await Promise.allSettled([
wasmBuildType({wasm_module}),
wasmBuildType({wasmModule}),
satelliteBuildType({
satellite
})
Expand Down
9 changes: 5 additions & 4 deletions src/services/upgrade/upgrade.mission-control.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {isNullish} from '@junobuild/utils';
import {cyan, red} from 'kleur';
import {getCliMissionControl} from '../../configs/cli.config';
import {MISSION_CONTROL_WASM_NAME} from '../../constants/constants';
import type {UpgradeWasmModule} from '../../types/upgrade';
import {actorParameters} from '../../utils/actor.utils';
import {NEW_CMD_LINE} from '../../utils/prompt.utils';
import {selectVersion, upgradeWasmCdn, upgradeWasmLocal} from './upgrade.services';
Expand Down Expand Up @@ -73,10 +74,10 @@ const updateMissionControlRelease = async ({

const nocheck = hasArgs({args, options: ['-n', '--nocheck']});

const upgradeMissionControlWasm = async ({wasm_module}: {wasm_module: Uint8Array}) => {
const upgradeMissionControlWasm = async (params: UpgradeWasmModule) => {
await upgradeMissionControlAdmin({
missionControl: missionControlParameters,
wasm_module
...params
});
};

Expand Down Expand Up @@ -104,10 +105,10 @@ const upgradeMissionControlCustom = async ({

const nocheck = hasArgs({args, options: ['-n', '--nocheck']});

const upgradeMissionControlWasm = async ({wasm_module}: {wasm_module: Uint8Array}) => {
const upgradeMissionControlWasm = async (params: UpgradeWasmModule) => {
await upgradeMissionControlAdmin({
missionControl: missionControlParameters,
wasm_module
...params
});
};

Expand Down
9 changes: 5 additions & 4 deletions src/services/upgrade/upgrade.orbiter.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {hasArgs, nextArg} from '@junobuild/cli-tools';
import {cyan, red} from 'kleur';
import {getCliOrbiters} from '../../configs/cli.config';
import {ORBITER_WASM_NAME} from '../../constants/constants';
import type {UpgradeWasmModule} from '../../types/upgrade';
import {actorParameters} from '../../utils/actor.utils';
import {NEW_CMD_LINE} from '../../utils/prompt.utils';
import {orbiterKey} from '../../utils/satellite.utils';
Expand Down Expand Up @@ -66,10 +67,10 @@ const upgradeOrbiterCustom = async ({

const nocheck = hasArgs({args, options: ['-n', '--nocheck']});

const upgradeOrbiterWasm = async ({wasm_module}: {wasm_module: Uint8Array}) => {
const upgradeOrbiterWasm = async (params: UpgradeWasmModule) => {
await upgradeOrbiterAdmin({
orbiter: orbiterParameters,
wasm_module,
...params,
...(reset && {reset})
});
};
Expand Down Expand Up @@ -100,10 +101,10 @@ const updateOrbiterRelease = async ({
const reset = await confirmReset({args, assetKey: 'orbiter'});
const nocheck = hasArgs({args, options: ['-n', '--nocheck']});

const upgradeOrbiterWasm = async ({wasm_module}: {wasm_module: Uint8Array}) => {
const upgradeOrbiterWasm = async (params: UpgradeWasmModule) => {
await upgradeOrbiterAdmin({
orbiter: orbiterParameters,
wasm_module,
...params,
...(reset && {reset})
});
};
Expand Down
4 changes: 2 additions & 2 deletions src/services/upgrade/upgrade.satellite.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ const executeUpgradeSatellite = async ({
// Information we want to try to redo once the satellite has been updated and resetted
const customDomains = reset ? await listCustomDomains({satellite}) : [];

const upgradeSatelliteWasm = async ({wasm_module}: UpgradeWasmModule) => {
const upgradeSatelliteWasm = async (params: UpgradeWasmModule) => {
await upgradeSatelliteAdmin({
satellite,
wasm_module,
...params,
// TODO: option to be removed
deprecated: compare(currentVersion, '0.0.7') < 0,
deprecatedNoScope: compare(currentVersion, '0.0.9') < 0,
Expand Down
4 changes: 2 additions & 2 deletions src/services/upgrade/upgrade.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ const executeUpgradeWasm = async ({
nocheck
}: UpgradeWasm) => {
if (!nocheck) {
await assert?.({wasm_module: wasm});
await assert?.({wasmModule: wasm});
await assertUpgradeHash({hash, reset});
}

const spinner = ora(`Upgrading Wasm${reset ? ' and resetting state' : ''}...`).start();

try {
await upgrade({
wasm_module: wasm
wasmModule: wasm
});
} finally {
spinner.stop();
Expand Down
6 changes: 3 additions & 3 deletions src/types/upgrade.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export interface UpgradeWasmModule {
wasm_module: Uint8Array;
}
import type {InstallCodeParams} from '@dfinity/ic-management';

export type UpgradeWasmModule = Pick<InstallCodeParams, 'wasmModule'>;

export interface UpgradeWasm {
wasm: Buffer;
Expand Down

0 comments on commit b417919

Please sign in to comment.