UNPKG

pic-js-mops

Version:

An Internet Computer Protocol canister testing library for TypeScript and JavaScript.

62 lines 2.17 kB
import { IDL } from '@icp-sdk/core/candid'; import { Principal } from '@icp-sdk/core/principal'; import { decodeCandid, isNil } from './util/index.js'; export const MANAGEMENT_CANISTER_ID = Principal.fromText('aaaaa-aa'); export const CanisterSettings = IDL.Record({ controllers: IDL.Opt(IDL.Vec(IDL.Principal)), compute_allocation: IDL.Opt(IDL.Nat), memory_allocation: IDL.Opt(IDL.Nat), freezing_threshold: IDL.Opt(IDL.Nat), reserved_cycles_limit: IDL.Opt(IDL.Nat), }); const CreateCanisterRequest = IDL.Record({ settings: IDL.Opt(CanisterSettings), amount: IDL.Opt(IDL.Nat), specified_id: IDL.Opt(IDL.Principal), }); export function encodeCreateCanisterRequest(arg) { return new Uint8Array(IDL.encode([CreateCanisterRequest], [arg])); } const CreateCanisterResponse = IDL.Record({ canister_id: IDL.Principal, }); export function decodeCreateCanisterResponse(arg) { const payload = decodeCandid([CreateCanisterResponse], arg); if (isNil(payload)) { throw new Error('Failed to decode CreateCanisterResponse'); } return payload; } const StartCanisterRequest = IDL.Record({ canister_id: IDL.Principal, }); export function encodeStartCanisterRequest(arg) { return new Uint8Array(IDL.encode([StartCanisterRequest], [arg])); } const StopCanisterRequest = IDL.Record({ canister_id: IDL.Principal, }); export function encodeStopCanisterRequest(arg) { return new Uint8Array(IDL.encode([StopCanisterRequest], [arg])); } const InstallCodeRequest = IDL.Record({ arg: IDL.Vec(IDL.Nat8), wasm_module: IDL.Vec(IDL.Nat8), mode: IDL.Variant({ reinstall: IDL.Null, upgrade: IDL.Null, install: IDL.Null, }), canister_id: IDL.Principal, }); export function encodeInstallCodeRequest(arg) { return new Uint8Array(IDL.encode([InstallCodeRequest], [arg])); } const UpdateCanisterSettingsRequest = IDL.Record({ canister_id: IDL.Principal, settings: CanisterSettings, }); export function encodeUpdateCanisterSettingsRequest(arg) { return new Uint8Array(IDL.encode([UpdateCanisterSettingsRequest], [arg])); } //# sourceMappingURL=management-canister.js.map