@agoric/vats 0.15.1 → 0.15.2-dev-8690eb0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/decentral-itest-vaults-config.json +1 -1
  2. package/package.json +24 -21
  3. package/scripts/build-bundles.d.ts +3 -0
  4. package/scripts/build-bundles.d.ts.map +1 -0
  5. package/scripts/build-bundles.js +14 -0
  6. package/scripts/init-core.d.ts +5 -0
  7. package/scripts/init-core.d.ts.map +1 -0
  8. package/scripts/init-core.js +31 -0
  9. package/scripts/init-network.d.ts +5 -0
  10. package/scripts/init-network.d.ts.map +1 -0
  11. package/scripts/init-network.js +19 -0
  12. package/scripts/restart-vats.d.ts +5 -0
  13. package/scripts/restart-vats.d.ts.map +1 -0
  14. package/scripts/restart-vats.js +23 -0
  15. package/scripts/set-core-proposal-env.d.ts +3 -0
  16. package/scripts/set-core-proposal-env.d.ts.map +1 -0
  17. package/scripts/set-core-proposal-env.js +37 -0
  18. package/src/core/demoIssuers.d.ts +3 -3
  19. package/src/core/demoIssuers.d.ts.map +1 -1
  20. package/src/core/demoIssuers.js +4 -4
  21. package/src/core/lib-boot.d.ts.map +1 -1
  22. package/src/core/lib-boot.js +0 -1
  23. package/src/core/startWalletFactory.d.ts +113 -1
  24. package/src/core/startWalletFactory.d.ts.map +1 -1
  25. package/src/core/types.d.ts +57 -1
  26. package/src/core/types.d.ts.map +1 -1
  27. package/src/ibc.d.ts.map +1 -1
  28. package/src/ibc.js +1 -0
  29. package/src/proposals/restart-vats-proposal.d.ts.map +1 -1
  30. package/src/proposals/restart-vats-proposal.js +0 -1
  31. package/src/provisionPoolKit.d.ts +18 -2
  32. package/src/provisionPoolKit.d.ts.map +1 -1
  33. package/tools/authorityViz.d.ts +27 -0
  34. package/tools/authorityViz.d.ts.map +1 -0
  35. package/tools/authorityViz.js +272 -0
  36. package/tools/bank-utils.d.ts +6 -0
  37. package/tools/bank-utils.d.ts.map +1 -0
  38. package/tools/bank-utils.js +51 -0
  39. package/tools/board-utils.d.ts +53 -0
  40. package/tools/board-utils.d.ts.map +1 -0
  41. package/tools/board-utils.js +145 -0
  42. package/tools/boot-test-utils.d.ts +163 -0
  43. package/tools/boot-test-utils.d.ts.map +1 -0
  44. package/tools/boot-test-utils.js +166 -0
  45. package/tools/viz.mk +17 -0
@@ -0,0 +1,163 @@
1
+ export namespace vatRoots {
2
+ export { agoricNamesRoot as agoricNames };
3
+ export { bankRoot as bank };
4
+ export { boardRoot as board };
5
+ export { ibcRoot as ibc };
6
+ export { mintsRoot as mints };
7
+ export { networkRoot as network };
8
+ export { priceAuthorityRoot as priceAuthority };
9
+ export { provisioningRoot as provisioning };
10
+ export { zoeRoot as zoe };
11
+ }
12
+ export function noop(): void;
13
+ /** @type {DProxy} */
14
+ export const mockDProxy: DProxy;
15
+ export function makeMock(log: any): {
16
+ devices: {
17
+ vatAdmin: {
18
+ getNamedBundleCap: (name: any) => {
19
+ getBundle: () => any;
20
+ };
21
+ };
22
+ command: any;
23
+ mailbox: any;
24
+ timer: any;
25
+ plugin: any;
26
+ };
27
+ vats: {
28
+ vattp: any;
29
+ comms: {
30
+ addRemote: () => void;
31
+ addEgress: () => void;
32
+ addIngress: () => Promise<{
33
+ getConfiguration: () => {
34
+ _: string;
35
+ };
36
+ }>;
37
+ } & import("@endo/eventual-send").RemotableBrand<{}, {
38
+ addRemote: () => void;
39
+ addEgress: () => void;
40
+ addIngress: () => Promise<{
41
+ getConfiguration: () => {
42
+ _: string;
43
+ };
44
+ }>;
45
+ }>;
46
+ http: {
47
+ setPresences: () => void;
48
+ setCommandDevice: () => void;
49
+ };
50
+ spawner: {
51
+ buildSpawner: () => {
52
+ _: string;
53
+ };
54
+ };
55
+ timer: {
56
+ createTimerService: () => Promise<ManualTimer>;
57
+ } & import("@endo/eventual-send").RemotableBrand<{}, {
58
+ createTimerService: () => Promise<ManualTimer>;
59
+ }>;
60
+ uploads: {
61
+ getUploads: () => {
62
+ _: string;
63
+ };
64
+ };
65
+ network: {
66
+ registerProtocolHandler: () => void;
67
+ bind: () => {
68
+ addListener: () => void;
69
+ };
70
+ } & import("@endo/eventual-send").RemotableBrand<{}, {
71
+ registerProtocolHandler: () => void;
72
+ bind: () => {
73
+ addListener: () => void;
74
+ };
75
+ }>;
76
+ };
77
+ };
78
+ export function makePopulatedFakeVatAdmin(): {
79
+ vatAdminService: {
80
+ createVat: (bundleCap: any, options: any) => Promise<{
81
+ root: unknown;
82
+ adminNode: {
83
+ done: () => Promise<any>;
84
+ terminateWithFailure: () => void;
85
+ upgrade: (_bundleCap: any, _options: any) => never;
86
+ } & import("@endo/eventual-send").RemotableBrand<{}, {
87
+ done: () => Promise<any>;
88
+ terminateWithFailure: () => void;
89
+ upgrade: (_bundleCap: any, _options: any) => never;
90
+ }>;
91
+ }> | {
92
+ root: any;
93
+ adminNode: import("@agoric/swingset-vat").VatAdminFacet;
94
+ };
95
+ createVatByName: (name: any) => Promise<{
96
+ root: unknown;
97
+ adminNode: {
98
+ done: () => Promise<any>;
99
+ terminateWithFailure: () => void;
100
+ upgrade: (_bundleCap: any, _options: any) => never;
101
+ } & import("@endo/eventual-send").RemotableBrand<{}, {
102
+ done: () => Promise<any>;
103
+ terminateWithFailure: () => void;
104
+ upgrade: (_bundleCap: any, _options: any) => never;
105
+ }>;
106
+ } | {
107
+ root: any;
108
+ adminNode: import("@agoric/swingset-vat").VatAdminFacet;
109
+ }>;
110
+ getBundleCap: (bundleID: any) => Promise<any>;
111
+ waitForBundleCap: (bundleID: any) => Promise<any>;
112
+ getNamedBundleCap: (name: any) => Promise<any>;
113
+ getBundleIDByName: (name: any) => Promise<string>;
114
+ } & import("@endo/eventual-send").RemotableBrand<{}, {
115
+ createVat: (bundleCap: any, options: any) => Promise<{
116
+ root: unknown;
117
+ adminNode: {
118
+ done: () => Promise<any>;
119
+ terminateWithFailure: () => void;
120
+ upgrade: (_bundleCap: any, _options: any) => never;
121
+ } & import("@endo/eventual-send").RemotableBrand<{}, {
122
+ done: () => Promise<any>;
123
+ terminateWithFailure: () => void;
124
+ upgrade: (_bundleCap: any, _options: any) => never;
125
+ }>;
126
+ }> | {
127
+ root: any;
128
+ adminNode: import("@agoric/swingset-vat").VatAdminFacet;
129
+ };
130
+ createVatByName: (name: any) => Promise<{
131
+ root: unknown;
132
+ adminNode: {
133
+ done: () => Promise<any>;
134
+ terminateWithFailure: () => void;
135
+ upgrade: (_bundleCap: any, _options: any) => never;
136
+ } & import("@endo/eventual-send").RemotableBrand<{}, {
137
+ done: () => Promise<any>;
138
+ terminateWithFailure: () => void;
139
+ upgrade: (_bundleCap: any, _options: any) => never;
140
+ }>;
141
+ } | {
142
+ root: any;
143
+ adminNode: import("@agoric/swingset-vat").VatAdminFacet;
144
+ }>;
145
+ getBundleCap: (bundleID: any) => Promise<any>;
146
+ waitForBundleCap: (bundleID: any) => Promise<any>;
147
+ getNamedBundleCap: (name: any) => Promise<any>;
148
+ getBundleIDByName: (name: any) => Promise<string>;
149
+ }>;
150
+ vatAdminRoot: any;
151
+ };
152
+ export function mockSwingsetVats(mock: any): any;
153
+ export function mockPsmBootstrapArgs(log: (msg: string) => void): any[];
154
+ import { buildRootObject as agoricNamesRoot } from "../src/vat-agoricNames.js";
155
+ import { buildRootObject as bankRoot } from "../src/vat-bank.js";
156
+ import { buildRootObject as boardRoot } from "../src/vat-board.js";
157
+ import { buildRootObject as ibcRoot } from "../src/vat-ibc.js";
158
+ import { buildRootObject as mintsRoot } from "../src/vat-mints.js";
159
+ import { buildRootObject as networkRoot } from "../src/vat-network.js";
160
+ import { buildRootObject as priceAuthorityRoot } from "../src/vat-priceAuthority.js";
161
+ import { buildRootObject as provisioningRoot } from "../src/vat-provisioning.js";
162
+ import { buildRootObject as zoeRoot } from "../src/vat-zoe.js";
163
+ //# sourceMappingURL=boot-test-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"boot-test-utils.d.ts","sourceRoot":"","sources":["boot-test-utils.js"],"names":[],"mappings":";;;;;;;;;;;AAkCO,6BAAqB;AAE5B,qBAAqB;AAErB,yBAFW,MAAM,CAEgB;AAE1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwCH;AAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiEN;AAEM,iDAON;AAKM,gDAFU,MAAM,KAAK,IAAI,SAM/B"}
@@ -0,0 +1,166 @@
1
+ // @ts-check
2
+ import {
3
+ makeFakeVatAdmin,
4
+ zcfBundleCap,
5
+ } from '@agoric/zoe/tools/fakeVatAdmin.js';
6
+ import buildManualTimer from '@agoric/zoe/tools/manualTimer.js';
7
+ import { Far } from '@endo/marshal';
8
+ import { makeScalarBigMapStore } from '@agoric/vat-data';
9
+ import { bundles, devices } from '../test/devices.js';
10
+
11
+ import { buildRootObject as agoricNamesRoot } from '../src/vat-agoricNames.js';
12
+ import { buildRootObject as bankRoot } from '../src/vat-bank.js';
13
+ import { buildRootObject as boardRoot } from '../src/vat-board.js';
14
+ import { buildRootObject as ibcRoot } from '../src/vat-ibc.js';
15
+ import { buildRootObject as mintsRoot } from '../src/vat-mints.js';
16
+ import { buildRootObject as networkRoot } from '../src/vat-network.js';
17
+ import { buildRootObject as priceAuthorityRoot } from '../src/vat-priceAuthority.js';
18
+ import { buildRootObject as provisioningRoot } from '../src/vat-provisioning.js';
19
+ import { buildRootObject as zoeRoot } from '../src/vat-zoe.js';
20
+
21
+ const { Fail } = assert;
22
+
23
+ export const vatRoots = {
24
+ agoricNames: agoricNamesRoot,
25
+ bank: bankRoot,
26
+ board: boardRoot,
27
+ ibc: ibcRoot,
28
+ mints: mintsRoot,
29
+ network: networkRoot,
30
+ priceAuthority: priceAuthorityRoot,
31
+ provisioning: provisioningRoot,
32
+ zoe: zoeRoot,
33
+ };
34
+
35
+ export const noop = () => {};
36
+
37
+ /** @type {DProxy} */
38
+ // @ts-expect-error cast
39
+ export const mockDProxy = d => d;
40
+
41
+ export const makeMock = log =>
42
+ harden({
43
+ devices: {
44
+ command: /** @type { any } */ ({ registerInboundHandler: noop }),
45
+ mailbox: /** @type { any } */ ({
46
+ registerInboundHandler: noop,
47
+ }),
48
+ timer: /** @type { any } */ ({}),
49
+ plugin: /** @type { any } */ ({ registerReceiver: noop }),
50
+ ...devices,
51
+ },
52
+ vats: {
53
+ vattp: /** @type { any } */ (
54
+ Far('vattp', {
55
+ registerMailboxDevice: noop,
56
+ addRemote: () => harden({}),
57
+ })
58
+ ),
59
+ comms: Far('comms', {
60
+ addRemote: noop,
61
+ addEgress: noop,
62
+ addIngress: async () =>
63
+ harden({
64
+ getConfiguration: () => harden({ _: 'client configuration' }),
65
+ }),
66
+ }),
67
+ http: { setPresences: noop, setCommandDevice: noop },
68
+ spawner: {
69
+ buildSpawner: () => harden({ _: 'spawner' }),
70
+ },
71
+ timer: Far('TimerVat', {
72
+ createTimerService: async () => buildManualTimer(log),
73
+ }),
74
+ uploads: { getUploads: () => harden({ _: 'uploads' }) },
75
+
76
+ network: Far('network', {
77
+ registerProtocolHandler: noop,
78
+ bind: () => harden({ addListener: noop }),
79
+ }),
80
+ },
81
+ });
82
+
83
+ export const makePopulatedFakeVatAdmin = () => {
84
+ // The .createVat() from zoe/tools/fakeVatAdmin.js only knows how to
85
+ // make ZCF vats, so wrap it in a form that can create the other
86
+ // vats too. We have two types.
87
+
88
+ const fakeCapToName = new Map(); // cap -> name
89
+ const fakeNameToCap = new Map(); // name -> cap
90
+ const { admin: fakeVatAdmin, vatAdminState } = makeFakeVatAdmin();
91
+ for (const name of Object.getOwnPropertyNames(vatRoots)) {
92
+ // These don't have real bundles (just a buildRootObject
93
+ // function), but fakeVatAdmin wants to see a bundle.endoZipBase64
94
+ // hash, so make some fake ones.
95
+ const id = `id-${name}`; // fake bundleID
96
+ const bundle = { endoZipBase64: id };
97
+ const cap = vatAdminState.installNamedBundle(name, id, bundle);
98
+ fakeCapToName.set(cap, name);
99
+ fakeNameToCap.set(name, cap);
100
+ }
101
+
102
+ for (const [name, bundle] of Object.entries(bundles)) {
103
+ // These *do* have real bundles, with an ID and everything.
104
+ const id = bundle.endoZipBase64Sha512;
105
+ const cap = vatAdminState.installNamedBundle(name, id, bundle);
106
+ fakeCapToName.set(cap, name);
107
+ fakeNameToCap.set(name, cap);
108
+ }
109
+
110
+ const createVat = (bundleCap, options) => {
111
+ assert(bundleCap);
112
+ if (bundleCap === zcfBundleCap) {
113
+ return fakeVatAdmin.createVat(zcfBundleCap, options);
114
+ }
115
+ const name = fakeCapToName.get(bundleCap);
116
+ assert(name);
117
+ const buildRoot = vatRoots[name];
118
+ if (!buildRoot) {
119
+ throw Error(`TODO: load vat ${name}`);
120
+ }
121
+ const vatParameters = { ...options?.vatParameters };
122
+ if (name === 'zoe') {
123
+ // basic-behaviors.js:buildZoe() provides hard-coded zcf BundleName
124
+ // and vat-zoe.js ignores vatParameters, but this would be the
125
+ // preferred way to pass the name.
126
+ vatParameters.zcfBundleName = 'zcf';
127
+ }
128
+ const baggage = makeScalarBigMapStore('baggage');
129
+ const adminNode =
130
+ /** @type {import('@agoric/swingset-vat').VatAdminFacet} */ ({});
131
+ return { root: buildRoot({}, vatParameters, baggage), adminNode };
132
+ };
133
+ const createVatByName = async name => {
134
+ return createVat(fakeNameToCap.get(name) || Fail`unknown vat ${name}`);
135
+ };
136
+
137
+ const vatAdminService = Far('vatAdminSvc', {
138
+ ...fakeVatAdmin,
139
+ createVat,
140
+ createVatByName,
141
+ });
142
+ const criticalVatKey = vatAdminState.getCriticalVatKey();
143
+ const getCriticalVatKey = () => criticalVatKey;
144
+ const createVatAdminService = () => vatAdminService;
145
+ /** @type { any } */
146
+ const vatAdminRoot = { getCriticalVatKey, createVatAdminService };
147
+ return { vatAdminService, vatAdminRoot };
148
+ };
149
+
150
+ export const mockSwingsetVats = mock => {
151
+ const { vatAdminRoot } = makePopulatedFakeVatAdmin();
152
+ const vats = {
153
+ ...mock.vats,
154
+ vatAdmin: vatAdminRoot,
155
+ };
156
+ return vats;
157
+ };
158
+
159
+ /**
160
+ * @param {(msg: string) => void} log
161
+ */
162
+ export const mockPsmBootstrapArgs = log => {
163
+ const mock = makeMock(log);
164
+ const vats = mockSwingsetVats(mock);
165
+ return [vats, mock.devices];
166
+ };
package/tools/viz.mk ADDED
@@ -0,0 +1,17 @@
1
+ # config: tools outsidet the source tree
2
+ VIEWER=firefox
3
+ DOT=dot
4
+
5
+ CONFIG=decentral-test-vaults-config
6
+
7
+ SRC=../src/core/chain-behaviors.js ../src/core/basic-behaviors.js
8
+
9
+ $(CONFIG).svg: $(CONFIG).dot
10
+ $(DOT) -Tsvg $< >$@ || rm $@
11
+
12
+ view: $(CONFIG).svg
13
+ $(VIEWER) $<
14
+
15
+ $(CONFIG).dot: ../$(CONFIG).json $(SRC) authorityViz.js
16
+ node authorityViz.js ../$(CONFIG).json >$@ || rm $@
17
+