@metamask/ocap-kernel
Version:
OCap kernel core components
61 lines • 2.99 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.vatSyscallHandler = exports.vatSyscallSpec = void 0;
const superstruct_1 = require("@metamask/superstruct");
const types_ts_1 = require("../../types.cjs");
const SendStruct = (0, superstruct_1.tuple)([(0, superstruct_1.literal)('send'), (0, superstruct_1.string)(), types_ts_1.MessageStruct]);
const SubscribeStruct = (0, superstruct_1.tuple)([(0, superstruct_1.literal)('subscribe'), (0, superstruct_1.string)()]);
const ResolveStruct = (0, superstruct_1.tuple)([
(0, superstruct_1.literal)('resolve'),
(0, superstruct_1.array)(types_ts_1.VatOneResolutionStruct),
]);
const ExitStruct = (0, superstruct_1.tuple)([(0, superstruct_1.literal)('exit'), (0, superstruct_1.boolean)(), types_ts_1.CapDataStruct]);
const DropImportsStruct = (0, superstruct_1.tuple)([(0, superstruct_1.literal)('dropImports'), (0, superstruct_1.array)((0, superstruct_1.string)())]);
const RetireImportsStruct = (0, superstruct_1.tuple)([(0, superstruct_1.literal)('retireImports'), (0, superstruct_1.array)((0, superstruct_1.string)())]);
const RetireExportsStruct = (0, superstruct_1.tuple)([(0, superstruct_1.literal)('retireExports'), (0, superstruct_1.array)((0, superstruct_1.string)())]);
const AbandonExportsStruct = (0, superstruct_1.tuple)([
(0, superstruct_1.literal)('abandonExports'),
(0, superstruct_1.array)((0, superstruct_1.string)()),
]);
// These are bogus, but are needed to keep TypeScript happy
const CallNowStruct = (0, superstruct_1.tuple)([
(0, superstruct_1.literal)('callNow'),
(0, superstruct_1.string)(),
(0, superstruct_1.string)(),
types_ts_1.CapDataStruct,
]);
const VatstoreGetStruct = (0, superstruct_1.tuple)([(0, superstruct_1.literal)('vatstoreGet'), (0, superstruct_1.string)()]);
const VatstoreGetNextKeyStruct = (0, superstruct_1.tuple)([
(0, superstruct_1.literal)('vatstoreGetNextKey'),
(0, superstruct_1.string)(),
]);
const VatstoreSetStruct = (0, superstruct_1.tuple)([(0, superstruct_1.literal)('vatstoreSet'), (0, superstruct_1.string)(), (0, superstruct_1.string)()]);
const VatstoreDeleteStruct = (0, superstruct_1.tuple)([(0, superstruct_1.literal)('vatstoreDelete'), (0, superstruct_1.string)()]);
const VatSyscallParamsStruct = (0, superstruct_1.union)([
SendStruct,
SubscribeStruct,
ResolveStruct,
ExitStruct,
DropImportsStruct,
RetireImportsStruct,
RetireExportsStruct,
AbandonExportsStruct,
// These are bogus, but are needed to keep TypeScript happy
CallNowStruct,
VatstoreGetStruct,
VatstoreGetNextKeyStruct,
VatstoreSetStruct,
VatstoreDeleteStruct,
]);
exports.vatSyscallSpec = {
method: 'syscall',
params: VatSyscallParamsStruct,
};
exports.vatSyscallHandler = {
...exports.vatSyscallSpec,
hooks: { handleSyscall: true },
implementation: ({ handleSyscall }, params) => {
handleSyscall(params);
},
};
//# sourceMappingURL=vat-syscall.cjs.map