-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathrevocation-provider.js
More file actions
32 lines (31 loc) · 1.01 KB
/
revocation-provider.js
File metadata and controls
32 lines (31 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { Far } from '@endo/marshal';
/**
* Build function for vats that will run various tests.
*
* @param {object} vatPowers - The vat powers.
* @param {object} vatPowers.logger - The logger for this vat.
* @returns {*} The root object for the new vat.
*/
export function buildRootObject({ logger }) {
const { log } = logger.subLogger({ tags: ['test'] });
const platform = { foo: () => `foo`, bar: () => `bar` };
let revokerCount = 0;
const revocable = (obj) => {
const gate = Far('gate', { ...obj });
// XXX makeRevoker is defined as an endowment (in VatSupervisor.ts), but
// the linter has no way to know that it is defined.
// eslint-disable-next-line no-undef
const revoker = makeRevoker(gate);
const id = revokerCount;
revokerCount += 1;
const slam = () => {
revoker();
log(`slam:${id}`);
};
return [gate, Far(`slam:${id}`, { slam })];
};
return Far('root', {
requestPlatform: () => revocable(platform),
revokerCount: () => revokerCount,
});
}