pic-ic
Version:
An Internet Computer Protocol canister testing library for TypeScript and JavaScript.
68 lines • 2.95 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CanisterSettings = exports.MANAGEMENT_CANISTER_ID = void 0;
exports.encodeCreateCanisterRequest = encodeCreateCanisterRequest;
exports.decodeCreateCanisterResponse = decodeCreateCanisterResponse;
exports.encodeStartCanisterRequest = encodeStartCanisterRequest;
exports.encodeStopCanisterRequest = encodeStopCanisterRequest;
exports.encodeInstallCodeRequest = encodeInstallCodeRequest;
exports.encodeUpdateCanisterSettingsRequest = encodeUpdateCanisterSettingsRequest;
const candid_1 = require("@dfinity/candid");
const principal_1 = require("@dfinity/principal");
exports.MANAGEMENT_CANISTER_ID = principal_1.Principal.fromText('aaaaa-aa');
exports.CanisterSettings = candid_1.IDL.Record({
controllers: candid_1.IDL.Opt(candid_1.IDL.Vec(candid_1.IDL.Principal)),
compute_allocation: candid_1.IDL.Opt(candid_1.IDL.Nat),
memory_allocation: candid_1.IDL.Opt(candid_1.IDL.Nat),
freezing_threshold: candid_1.IDL.Opt(candid_1.IDL.Nat),
reserved_cycles_limit: candid_1.IDL.Opt(candid_1.IDL.Nat),
});
const CreateCanisterRequest = candid_1.IDL.Record({
settings: candid_1.IDL.Opt(exports.CanisterSettings),
amount: candid_1.IDL.Opt(candid_1.IDL.Nat),
specified_id: candid_1.IDL.Opt(candid_1.IDL.Principal),
});
function encodeCreateCanisterRequest(arg) {
return new Uint8Array(candid_1.IDL.encode([CreateCanisterRequest], [arg]));
}
const CreateCanisterResponse = candid_1.IDL.Record({
canister_id: candid_1.IDL.Principal,
});
function decodeCreateCanisterResponse(arg) {
const [payload] = candid_1.IDL.decode([CreateCanisterResponse], arg);
// [TODO] - type check?
return payload;
}
const StartCanisterRequest = candid_1.IDL.Record({
canister_id: candid_1.IDL.Principal,
});
function encodeStartCanisterRequest(arg) {
return new Uint8Array(candid_1.IDL.encode([StartCanisterRequest], [arg]));
}
const StopCanisterRequest = candid_1.IDL.Record({
canister_id: candid_1.IDL.Principal,
});
function encodeStopCanisterRequest(arg) {
return new Uint8Array(candid_1.IDL.encode([StopCanisterRequest], [arg]));
}
const InstallCodeRequest = candid_1.IDL.Record({
arg: candid_1.IDL.Vec(candid_1.IDL.Nat8),
wasm_module: candid_1.IDL.Vec(candid_1.IDL.Nat8),
mode: candid_1.IDL.Variant({
reinstall: candid_1.IDL.Null,
upgrade: candid_1.IDL.Null,
install: candid_1.IDL.Null,
}),
canister_id: candid_1.IDL.Principal,
});
function encodeInstallCodeRequest(arg) {
return new Uint8Array(candid_1.IDL.encode([InstallCodeRequest], [arg]));
}
const UpdateCanisterSettingsRequest = candid_1.IDL.Record({
canister_id: candid_1.IDL.Principal,
settings: exports.CanisterSettings,
});
function encodeUpdateCanisterSettingsRequest(arg) {
return new Uint8Array(candid_1.IDL.encode([UpdateCanisterSettingsRequest], [arg]));
}
//# sourceMappingURL=management-canister.js.map