@agoric/vats 0.15.2-u11.0 → 0.15.2-u12.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.
- package/CHANGELOG.md +17 -0
- package/package.json +31 -29
- package/scripts/build-bundles.d.ts +3 -0
- package/scripts/build-bundles.d.ts.map +1 -0
- package/scripts/build-bundles.js +14 -0
- package/scripts/build-game1-start.d.ts +5 -0
- package/scripts/build-game1-start.d.ts.map +1 -0
- package/scripts/build-game1-start.js +34 -0
- package/scripts/build-walletFactory-upgrade.d.ts +5 -0
- package/scripts/build-walletFactory-upgrade.d.ts.map +1 -0
- package/scripts/build-walletFactory-upgrade.js +35 -0
- package/scripts/init-core.d.ts +5 -0
- package/scripts/init-core.d.ts.map +1 -0
- package/scripts/init-core.js +31 -0
- package/scripts/init-network.d.ts +5 -0
- package/scripts/init-network.d.ts.map +1 -0
- package/scripts/init-network.js +19 -0
- package/scripts/restart-vats.d.ts +5 -0
- package/scripts/restart-vats.d.ts.map +1 -0
- package/scripts/restart-vats.js +23 -0
- package/scripts/set-core-proposal-env.d.ts +3 -0
- package/scripts/set-core-proposal-env.d.ts.map +1 -0
- package/scripts/set-core-proposal-env.js +37 -0
- package/src/core/startWalletFactory.d.ts +113 -1
- package/src/core/startWalletFactory.d.ts.map +1 -1
- package/src/core/types.d.ts +57 -1
- package/src/core/types.d.ts.map +1 -1
- package/src/provisionPool.d.ts +2 -2
- package/src/provisionPoolKit.d.ts +22 -6
- package/src/provisionPoolKit.d.ts.map +1 -1
- package/tools/authorityViz.d.ts +27 -0
- package/tools/authorityViz.d.ts.map +1 -0
- package/tools/authorityViz.js +272 -0
- package/tools/bank-utils.d.ts +6 -0
- package/tools/bank-utils.d.ts.map +1 -0
- package/tools/bank-utils.js +51 -0
- package/tools/board-utils.d.ts +53 -0
- package/tools/board-utils.d.ts.map +1 -0
- package/tools/board-utils.js +145 -0
- package/tools/boot-test-utils.d.ts +163 -0
- package/tools/boot-test-utils.d.ts.map +1 -0
- package/tools/boot-test-utils.js +166 -0
- package/tools/viz.mk +17 -0
package/src/provisionPool.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ export function prepare(zcf: ZCF<ProvisionTerms>, privateArgs: {
|
|
|
27
27
|
reviveWallet(address: string): Promise<{
|
|
28
28
|
handleBridgeAction(actionCapData: import("@endo/marshal").CapData<string>, canSpend?: boolean | undefined): Promise<void>;
|
|
29
29
|
getDepositFacet(): {
|
|
30
|
-
receive(payment:
|
|
30
|
+
receive(payment: Payment<AssetKind>): Promise<Amount<AssetKind>>;
|
|
31
31
|
};
|
|
32
32
|
getOffersFacet(): {
|
|
33
33
|
executeOffer(offerSpec: import("@agoric/smart-wallet/src/offers.js").OfferSpec): Promise<void>;
|
|
@@ -82,7 +82,7 @@ export function prepare(zcf: ZCF<ProvisionTerms>, privateArgs: {
|
|
|
82
82
|
reviveWallet(address: string): Promise<{
|
|
83
83
|
handleBridgeAction(actionCapData: import("@endo/marshal").CapData<string>, canSpend?: boolean | undefined): Promise<void>;
|
|
84
84
|
getDepositFacet(): {
|
|
85
|
-
receive(payment:
|
|
85
|
+
receive(payment: Payment<AssetKind>): Promise<Amount<AssetKind>>;
|
|
86
86
|
};
|
|
87
87
|
getOffersFacet(): {
|
|
88
88
|
executeOffer(offerSpec: import("@agoric/smart-wallet/src/offers.js").OfferSpec): Promise<void>;
|
|
@@ -22,7 +22,7 @@ export function prepareProvisionPoolKit(baggage: MapStore<string, unknown>, { ma
|
|
|
22
22
|
reviveWallet(address: string): Promise<{
|
|
23
23
|
handleBridgeAction(actionCapData: import("@endo/marshal").CapData<string>, canSpend?: boolean | undefined): Promise<void>;
|
|
24
24
|
getDepositFacet(): {
|
|
25
|
-
receive(payment:
|
|
25
|
+
receive(payment: Payment<AssetKind>): Promise<Amount<AssetKind>>;
|
|
26
26
|
};
|
|
27
27
|
getOffersFacet(): {
|
|
28
28
|
executeOffer(offerSpec: import("@agoric/smart-wallet/src/offers.js").OfferSpec): Promise<void>;
|
|
@@ -69,7 +69,7 @@ export function prepareProvisionPoolKit(baggage: MapStore<string, unknown>, { ma
|
|
|
69
69
|
reviveWallet(address: string): Promise<{
|
|
70
70
|
handleBridgeAction(actionCapData: import("@endo/marshal").CapData<string>, canSpend?: boolean | undefined): Promise<void>;
|
|
71
71
|
getDepositFacet(): {
|
|
72
|
-
receive(payment:
|
|
72
|
+
receive(payment: Payment<AssetKind>): Promise<Amount<AssetKind>>;
|
|
73
73
|
};
|
|
74
74
|
getOffersFacet(): {
|
|
75
75
|
executeOffer(offerSpec: import("@agoric/smart-wallet/src/offers.js").OfferSpec): Promise<void>;
|
|
@@ -136,7 +136,7 @@ export function prepareProvisionPoolKit(baggage: MapStore<string, unknown>, { ma
|
|
|
136
136
|
reviveWallet(address: string): Promise<{
|
|
137
137
|
handleBridgeAction(actionCapData: import("@endo/marshal").CapData<string>, canSpend?: boolean | undefined): Promise<void>;
|
|
138
138
|
getDepositFacet(): {
|
|
139
|
-
receive(payment:
|
|
139
|
+
receive(payment: Payment<AssetKind>): Promise<Amount<AssetKind>>;
|
|
140
140
|
};
|
|
141
141
|
getOffersFacet(): {
|
|
142
142
|
executeOffer(offerSpec: import("@agoric/smart-wallet/src/offers.js").OfferSpec): Promise<void>;
|
|
@@ -183,7 +183,7 @@ export function prepareProvisionPoolKit(baggage: MapStore<string, unknown>, { ma
|
|
|
183
183
|
reviveWallet(address: string): Promise<{
|
|
184
184
|
handleBridgeAction(actionCapData: import("@endo/marshal").CapData<string>, canSpend?: boolean | undefined): Promise<void>;
|
|
185
185
|
getDepositFacet(): {
|
|
186
|
-
receive(payment:
|
|
186
|
+
receive(payment: Payment<AssetKind>): Promise<Amount<AssetKind>>;
|
|
187
187
|
};
|
|
188
188
|
getOffersFacet(): {
|
|
189
189
|
executeOffer(offerSpec: import("@agoric/smart-wallet/src/offers.js").OfferSpec): Promise<void>;
|
|
@@ -324,7 +324,15 @@ export type PsmInstance = import('@agoric/zoe/src/zoeService/utils').Instance<(z
|
|
|
324
324
|
getInvitationAmount: (name: string) => Amount<"set">;
|
|
325
325
|
getNat: (name: string) => bigint;
|
|
326
326
|
getRatio: (name: string) => Ratio;
|
|
327
|
-
getString: (name: string) => string;
|
|
327
|
+
getString: (name: string) => string; /**
|
|
328
|
+
* @param {import('@agoric/vat-data').Baggage} baggage
|
|
329
|
+
* @param {{
|
|
330
|
+
* makeRecorderKit: import('@agoric/zoe/src/contractSupport/recorder.js').MakeRecorderKit,
|
|
331
|
+
* params: *,
|
|
332
|
+
* poolBank: import('@endo/far').ERef<Bank>,
|
|
333
|
+
* zcf: ZCF,
|
|
334
|
+
* }} powers
|
|
335
|
+
*/
|
|
328
336
|
getTimestamp: (name: string) => import("@agoric/time/src/types.js").TimestampRecord;
|
|
329
337
|
getRelativeTime: (name: string) => import("@agoric/time/src/types.js").RelativeTimeRecord;
|
|
330
338
|
getUnknown: (name: string) => any;
|
|
@@ -345,7 +353,15 @@ export type PsmInstance = import('@agoric/zoe/src/zoeService/utils').Instance<(z
|
|
|
345
353
|
getInvitationAmount: (name: string) => Amount<"set">;
|
|
346
354
|
getNat: (name: string) => bigint;
|
|
347
355
|
getRatio: (name: string) => Ratio;
|
|
348
|
-
getString: (name: string) => string;
|
|
356
|
+
getString: (name: string) => string; /**
|
|
357
|
+
* @param {import('@agoric/vat-data').Baggage} baggage
|
|
358
|
+
* @param {{
|
|
359
|
+
* makeRecorderKit: import('@agoric/zoe/src/contractSupport/recorder.js').MakeRecorderKit,
|
|
360
|
+
* params: *,
|
|
361
|
+
* poolBank: import('@endo/far').ERef<Bank>,
|
|
362
|
+
* zcf: ZCF,
|
|
363
|
+
* }} powers
|
|
364
|
+
*/
|
|
349
365
|
getTimestamp: (name: string) => import("@agoric/time/src/types.js").TimestampRecord;
|
|
350
366
|
getRelativeTime: (name: string) => import("@agoric/time/src/types.js").RelativeTimeRecord;
|
|
351
367
|
getUnknown: (name: string) => any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provisionPoolKit.d.ts","sourceRoot":"","sources":["provisionPoolKit.js"],"names":[],"mappings":"AAqDO,0EAJkB,KAAK,IAAI,CAAC,KAAK,QAAQ,IAAI,CAAC,iBAC1C,MAAM,IAAI,0DAKR,0BAA0B;;;;GAgCtC;AAWM,wHAPI;IACV,eAAmB,EAAE,OAAO,6CAA6C,EAAE,eAAe,CAAC;IAC3F,MAAU,MAAI;IACd,QAAY,EAAE,OAAO,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7C,GAAO,EAAE,GAAG,CAAC;CACV;IA8VqB,SAAS,EAArB,KAAK;IACmB,WAAW,EAAnC,KAAK,WAAW,CAAC;;;QAhRtB;;WAEG;4CADQ,MAAM,EAAE;;YAkDnB,8BAA8B;kCAAlB,MAAM;;;;;;;;;;;;;;;;;;;;;;;;YAqBlB;;;eAGG;+BAFQ,MAAM,GACJ,OAAO;;QAhEpB;;WAEG;6BADQ,0BAA0B;;;;;;QA8BrC;;;WAGG;uBAFQ,KAAK,YACL,WAAW;;;QAQtB,8BAA8B;8BAAlB,MAAM;;;;;;;;;;;;;;;;;;;;;;;;QAqBlB;;;WAGG;2BAFQ,MAAM,GACJ,OAAO;;;;;;;QAgDpB;;;WAGG;qCADQ,KAAK,IAAI,CAAC;QA2BrB;;;WAGG;;;;QA2EH;;;;WAIG;oBAHQ,KAAK,OAAO,CAAC,UACb,MAAM,YACN,WAAW;;;;;;;;;QAxOtB;;WAEG;4CADQ,MAAM,EAAE;;YAkDnB,8BAA8B;kCAAlB,MAAM;;;;;;;;;;;;;;;;;;;;;;;;YAqBlB;;;eAGG;+BAFQ,MAAM,GACJ,OAAO;;QAhEpB;;WAEG;6BADQ,0BAA0B;;;;;;QA8BrC;;;WAGG;uBAFQ,KAAK,YACL,WAAW;;;QAQtB,8BAA8B;8BAAlB,MAAM;;;;;;;;;;;;;;;;;;;;;;;;QAqBlB;;;WAGG;2BAFQ,MAAM,GACJ,OAAO;;;;;;;QAgDpB;;;WAGG;qCADQ,KAAK,IAAI,CAAC;QA2BrB;;;WAGG;;;;QA2EH;;;;WAIG;oBAHQ,KAAK,OAAO,CAAC,UACb,MAAM,YACN,WAAW;;;;;;;IAwD7B;0BAtba,OAAO,kCAAkC,EAAE,QAAQ
|
|
1
|
+
{"version":3,"file":"provisionPoolKit.d.ts","sourceRoot":"","sources":["provisionPoolKit.js"],"names":[],"mappings":"AAqDO,0EAJkB,KAAK,IAAI,CAAC,KAAK,QAAQ,IAAI,CAAC,iBAC1C,MAAM,IAAI,0DAKR,0BAA0B;;;;GAgCtC;AAWM,wHAPI;IACV,eAAmB,EAAE,OAAO,6CAA6C,EAAE,eAAe,CAAC;IAC3F,MAAU,MAAI;IACd,QAAY,EAAE,OAAO,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7C,GAAO,EAAE,GAAG,CAAC;CACV;IA8VqB,SAAS,EAArB,KAAK;IACmB,WAAW,EAAnC,KAAK,WAAW,CAAC;;;QAhRtB;;WAEG;4CADQ,MAAM,EAAE;;YAkDnB,8BAA8B;kCAAlB,MAAM;;;;;;;;;;;;;;;;;;;;;;;;YAqBlB;;;eAGG;+BAFQ,MAAM,GACJ,OAAO;;QAhEpB;;WAEG;6BADQ,0BAA0B;;;;;;QA8BrC;;;WAGG;uBAFQ,KAAK,YACL,WAAW;;;QAQtB,8BAA8B;8BAAlB,MAAM;;;;;;;;;;;;;;;;;;;;;;;;QAqBlB;;;WAGG;2BAFQ,MAAM,GACJ,OAAO;;;;;;;QAgDpB;;;WAGG;qCADQ,KAAK,IAAI,CAAC;QA2BrB;;;WAGG;;;;QA2EH;;;;WAIG;oBAHQ,KAAK,OAAO,CAAC,UACb,MAAM,YACN,WAAW;;;;;;;;;QAxOtB;;WAEG;4CADQ,MAAM,EAAE;;YAkDnB,8BAA8B;kCAAlB,MAAM;;;;;;;;;;;;;;;;;;;;;;;;YAqBlB;;;eAGG;+BAFQ,MAAM,GACJ,OAAO;;QAhEpB;;WAEG;6BADQ,0BAA0B;;;;;;QA8BrC;;;WAGG;uBAFQ,KAAK,YACL,WAAW;;;QAQtB,8BAA8B;8BAAlB,MAAM;;;;;;;;;;;;;;;;;;;;;;;;QAqBlB;;;WAGG;2BAFQ,MAAM,GACJ,OAAO;;;;;;;QAgDpB;;;WAGG;qCADQ,KAAK,IAAI,CAAC;QA2BrB;;;WAGG;;;;QA2EH;;;;WAIG;oBAHQ,KAAK,OAAO,CAAC,UACb,MAAM,YACN,WAAW;;;;;;;IAwD7B;0BAtba,OAAO,kCAAkC,EAAE,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6CAgEjE;;;;;;;;WAQG;;;;;;;;;;;;;;;;;;;;;6CARH;;;;;;;;WAQG;;;;;;;;;;;;;;GAxEuH;;iBAI5G,KAAK,WAAW,CAAC;yBACjB,KAAK,OAAO,cAAc,EAAE,SAAS,CAAC;mBACtC,KAAK,OAAO,0CAA0C,EAAE,wBAAwB,CAAC,cAAc,CAAC,CAAC;;;;;;;;;;wBAQjG,MAAM;;;;yBACN,OAAO,KAAK,CAAC;;;;;0BACb,OAAO,KAAK,CAAC;;;;;;mBAUd,OAAO,eAAe,EAAE,IAAI"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
export type GraphNode = {
|
|
3
|
+
id: string;
|
|
4
|
+
cluster?: string;
|
|
5
|
+
label: string;
|
|
6
|
+
style?: string;
|
|
7
|
+
};
|
|
8
|
+
export type Permit = true | ({
|
|
9
|
+
vatParameters?: Record<string, Permit>;
|
|
10
|
+
vatPowers?: Record<string, true>;
|
|
11
|
+
vats?: Record<string, Status>;
|
|
12
|
+
devices?: Record<string, true>;
|
|
13
|
+
home?: PowerSpace;
|
|
14
|
+
issuer?: PowerSpace;
|
|
15
|
+
brand?: PowerSpace;
|
|
16
|
+
oracleBrand?: PowerSpace;
|
|
17
|
+
installation?: PowerSpace;
|
|
18
|
+
instance?: PowerSpace;
|
|
19
|
+
} & PowerSpace);
|
|
20
|
+
export type PowerSpace = {
|
|
21
|
+
produce?: Record<string, Status>;
|
|
22
|
+
consume?: Record<string, Status>;
|
|
23
|
+
};
|
|
24
|
+
export type Status = boolean | VatName;
|
|
25
|
+
export type VatName = string;
|
|
26
|
+
export type Resolver = (specifier: string, parent: string) => Promise<string>;
|
|
27
|
+
//# sourceMappingURL=authorityViz.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authorityViz.d.ts","sourceRoot":"","sources":["authorityViz.js"],"names":[],"mappings":";wBA6Ba;IACZ,EAAM,EAAE,MAAM,CAAC;IACf,OAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAS,EAAE,MAAM,CAAC;IAClB,KAAS,CAAC,EAAE,MAAM,CAAC;CAChB;qBAiCU,IAAI,IAAG;IACpB,aAAiB,CAAC,EAAE,OAAO,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3C,SAAa,CAAC,EAAE,OAAO,MAAM,EAAE,IAAI,CAAC,CAAA;IACpC,IAAQ,CAAC,EAAE,OAAO,MAAM,EAAE,MAAM,CAAC,CAAA;IACjC,OAAW,CAAC,EAAE,OAAO,MAAM,EAAE,IAAI,CAAC,CAAA;IAClC,IAAQ,CAAC,EAAE,UAAU,CAAC;IACtB,MAAU,CAAC,EAAE,UAAU,CAAC;IACxB,KAAS,CAAC,EAAE,UAAU,CAAC;IACvB,WAAe,CAAC,EAAE,UAAU,CAAC;IAC7B,YAAgB,CAAC,EAAE,UAAU,CAAC;IAC9B,QAAY,CAAC,EAAE,UAAU,CAAC;CACvB,GAAG,UAAU,CAAA;yBACJ;IAAC,OAAO,CAAC,EAAE,OAAO,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,MAAM,EAAE,MAAM,CAAC,CAAA;CAAC;qBACnE,OAAO,GAAG,OAAO;sBACjB,MAAM;mCA0IK,MAAM,UAAU,MAAM,KAAK,QAAQ,MAAM,CAAC"}
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// @ts-check
|
|
3
|
+
import '@endo/init';
|
|
4
|
+
import process from 'process';
|
|
5
|
+
|
|
6
|
+
const { entries, keys, values } = Object;
|
|
7
|
+
|
|
8
|
+
const logged = label => x => {
|
|
9
|
+
console.error(label, x);
|
|
10
|
+
return x;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const styles = {
|
|
14
|
+
vatPowers: 'shape=star, style=filled, fillcolor=aqua',
|
|
15
|
+
vats: 'shape=doubleoctagon, style=filled, fillcolor=tomato',
|
|
16
|
+
vat: 'shape=doubleoctagon, style=filled, fillcolor=tomato3',
|
|
17
|
+
devices: 'shape=box, style=filled, fillcolor=gold',
|
|
18
|
+
space: 'shape=house, style=filled, fillcolor=khaki',
|
|
19
|
+
issuer: 'shape=trapezium, style=filled, fillcolor=chocolate',
|
|
20
|
+
brand: 'shape=Mcircle, style=filled, fillcolor=chocolate2',
|
|
21
|
+
installation: 'shape=cylinder',
|
|
22
|
+
instance: 'shape=component',
|
|
23
|
+
home: 'shape=folder',
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @param {Set<GraphNode>} nodes
|
|
28
|
+
* @param {Map<string, Set<{ id: string, style?: string }>>} neighbors
|
|
29
|
+
* @yields { string }
|
|
30
|
+
* @typedef {{
|
|
31
|
+
* id: string,
|
|
32
|
+
* cluster?: string,
|
|
33
|
+
* label: string,
|
|
34
|
+
* style?: string,
|
|
35
|
+
* }} GraphNode
|
|
36
|
+
*/
|
|
37
|
+
function* fmtGraph(nodes, neighbors) {
|
|
38
|
+
const q = txt => JSON.stringify(txt.replace(/\./g, '_'));
|
|
39
|
+
yield 'digraph G {\n';
|
|
40
|
+
yield 'rankdir = LR;\n';
|
|
41
|
+
const clusters = new Set(
|
|
42
|
+
[...nodes].map(({ cluster }) => cluster).filter(c => !!c),
|
|
43
|
+
);
|
|
44
|
+
for (const subgraph of [...clusters, undefined]) {
|
|
45
|
+
if (subgraph) {
|
|
46
|
+
assert.typeof(subgraph, 'string');
|
|
47
|
+
yield `subgraph cluster_${subgraph} {\n`;
|
|
48
|
+
yield `label = "${subgraph}"\n`;
|
|
49
|
+
}
|
|
50
|
+
for (const { id, cluster, label, style } of nodes) {
|
|
51
|
+
if (subgraph && cluster !== subgraph) continue;
|
|
52
|
+
yield `${q(id)} [label=${q(label)}${style ? `, ${style}` : ''}];\n`;
|
|
53
|
+
}
|
|
54
|
+
if (subgraph) {
|
|
55
|
+
yield `}\n`;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
for (const [src, arcs] of neighbors.entries()) {
|
|
59
|
+
for (const { id, style } of arcs) {
|
|
60
|
+
yield `${q(src)} -> ${q(id)} [${style}]\n`;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
yield '}\n';
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* @param {Record<string, Permit>} manifest
|
|
68
|
+
* @typedef { true | {
|
|
69
|
+
* vatParameters?: Record<string, Permit>,
|
|
70
|
+
* vatPowers?: Record<string, true>
|
|
71
|
+
* vats?: Record<string, Status>
|
|
72
|
+
* devices?: Record<string, true>
|
|
73
|
+
* home?: PowerSpace,
|
|
74
|
+
* issuer?: PowerSpace,
|
|
75
|
+
* brand?: PowerSpace,
|
|
76
|
+
* oracleBrand?: PowerSpace,
|
|
77
|
+
* installation?: PowerSpace,
|
|
78
|
+
* instance?: PowerSpace,
|
|
79
|
+
* } & PowerSpace } Permit
|
|
80
|
+
* @typedef {{produce?: Record<string, Status>, consume?: Record<string, Status>}} PowerSpace
|
|
81
|
+
* @typedef { boolean | VatName } Status
|
|
82
|
+
* @typedef { string } VatName
|
|
83
|
+
*/
|
|
84
|
+
const manifest2graph = manifest => {
|
|
85
|
+
/** @type { Set<GraphNode> } */
|
|
86
|
+
const nodes = new Set();
|
|
87
|
+
const neighbors = new Map();
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* @param {string} src
|
|
91
|
+
* @param {string} dest
|
|
92
|
+
* @param {string} [style]
|
|
93
|
+
*/
|
|
94
|
+
const addEdge = (src, dest, style = '') => {
|
|
95
|
+
logged('addEdge')({ src, dest });
|
|
96
|
+
if (!neighbors.has(src)) {
|
|
97
|
+
neighbors.set(src, new Set());
|
|
98
|
+
}
|
|
99
|
+
neighbors.get(src).add({ id: dest, style });
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* @param {string} src
|
|
104
|
+
* @param {string} ty
|
|
105
|
+
* @param {Permit} item
|
|
106
|
+
* @param {boolean} [reverse=false]
|
|
107
|
+
*/
|
|
108
|
+
const level1 = (src, ty, item, reverse = false) => {
|
|
109
|
+
if (!item) return;
|
|
110
|
+
for (const [powerName, status] of entries(item)) {
|
|
111
|
+
// subsumed by permits for vat:, home:, ...
|
|
112
|
+
if (
|
|
113
|
+
[
|
|
114
|
+
'loadVat',
|
|
115
|
+
'loadCriticalVat',
|
|
116
|
+
'client',
|
|
117
|
+
'agoricNames',
|
|
118
|
+
'nameHubs',
|
|
119
|
+
'nameAdmins',
|
|
120
|
+
].includes(powerName) &&
|
|
121
|
+
reverse
|
|
122
|
+
)
|
|
123
|
+
continue;
|
|
124
|
+
if (status) {
|
|
125
|
+
let cluster = {};
|
|
126
|
+
if (typeof status !== 'boolean') {
|
|
127
|
+
cluster = { cluster: status };
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
nodes.add({
|
|
131
|
+
id: `${ty}.${powerName}`,
|
|
132
|
+
label: powerName,
|
|
133
|
+
style: styles[ty],
|
|
134
|
+
...cluster,
|
|
135
|
+
});
|
|
136
|
+
addEdge(src, `${ty}.${powerName}`, reverse ? 'dir=back' : '');
|
|
137
|
+
if (ty === 'home') {
|
|
138
|
+
nodes.add({ id: 'home', label: 'home', cluster: 'provisioning' });
|
|
139
|
+
addEdge('home', `${ty}.${powerName}`);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
/** @type {<X>(xs: X[]) => X[]} */
|
|
146
|
+
const uniq = xs => [...new Set(xs)];
|
|
147
|
+
const spaces = uniq(
|
|
148
|
+
logged('vals')(values(manifest)).flatMap(permit =>
|
|
149
|
+
logged('keys?')(keys(permit)).flatMap(name => {
|
|
150
|
+
logged('name?')(name);
|
|
151
|
+
|
|
152
|
+
if (['produce', 'consume'].includes(name)) return [];
|
|
153
|
+
return [name];
|
|
154
|
+
}),
|
|
155
|
+
),
|
|
156
|
+
);
|
|
157
|
+
console.error('@@@', { spaces });
|
|
158
|
+
|
|
159
|
+
for (const [fnName, permit] of entries(manifest)) {
|
|
160
|
+
if (permit === true) {
|
|
161
|
+
console.error('skipping wildcard permit:', fnName);
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
nodes.add({ id: logged('fn')(fnName), label: fnName });
|
|
165
|
+
|
|
166
|
+
permit.vatPowers && level1(fnName, 'vatPowers', permit.vatPowers, true);
|
|
167
|
+
permit.vats && level1(fnName, 'vats', permit.vats, true);
|
|
168
|
+
permit.devices && level1(fnName, 'devices', permit.devices, true);
|
|
169
|
+
|
|
170
|
+
const doPart = (name, part) => {
|
|
171
|
+
if (!part) return;
|
|
172
|
+
level1(fnName, name, part.produce || {});
|
|
173
|
+
level1(fnName, name, part.consume || {}, true);
|
|
174
|
+
};
|
|
175
|
+
doPart('space', permit);
|
|
176
|
+
spaces.forEach(s => doPart(s, permit[s]));
|
|
177
|
+
|
|
178
|
+
if ('runBehaviors' in permit) {
|
|
179
|
+
throw Error('not impl');
|
|
180
|
+
// nodes.add({
|
|
181
|
+
// id: `runBehaviors`,
|
|
182
|
+
// label: `runBehaviors`,
|
|
183
|
+
// style: '',
|
|
184
|
+
// });
|
|
185
|
+
// addEdge(fnName, `runBehaviors`);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return { nodes, neighbors };
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
const { Fail, quote: q } = assert;
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* @param {string} specifier
|
|
195
|
+
* @param {object} io
|
|
196
|
+
* @param {Resolver} io.resolve
|
|
197
|
+
* @param {typeof import('fs/promises').readFile} io.readFile
|
|
198
|
+
*/
|
|
199
|
+
const loadConfig = async (specifier, { resolve, readFile }) => {
|
|
200
|
+
const fullPath = await resolve(specifier, import.meta.url).then(
|
|
201
|
+
u => new URL(u).pathname,
|
|
202
|
+
);
|
|
203
|
+
typeof fullPath === 'string' || Fail`${q(specifier)}`;
|
|
204
|
+
const txt = await readFile(fullPath, 'utf-8');
|
|
205
|
+
typeof txt === 'string' || Fail`readFile ${q(fullPath)}`;
|
|
206
|
+
return JSON.parse(txt);
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* @param {string[]} args
|
|
211
|
+
* @param {object} io
|
|
212
|
+
* @param {typeof import('process').stdout} io.stdout
|
|
213
|
+
* @param {typeof import('fs/promises')} io.fsp
|
|
214
|
+
* @param {{
|
|
215
|
+
* resolve: Resolver,
|
|
216
|
+
* url: string,
|
|
217
|
+
* load: (specifier: string) => Promise<Record<string, any>>,
|
|
218
|
+
* }} io.meta
|
|
219
|
+
*
|
|
220
|
+
* @typedef {(specifier: string, parent: string) => Promise<string>} Resolver
|
|
221
|
+
*/
|
|
222
|
+
const main = async (args, { stdout, fsp, meta }) => {
|
|
223
|
+
const [specifier, ...opts] = args;
|
|
224
|
+
specifier || Fail`Usage: $0 @agoric/vats/decentral-...json`;
|
|
225
|
+
|
|
226
|
+
const config = await loadConfig(specifier, {
|
|
227
|
+
resolve: meta.resolve,
|
|
228
|
+
readFile: fsp.readFile,
|
|
229
|
+
});
|
|
230
|
+
// console.log(config);
|
|
231
|
+
const { bootstrap } = config.vats;
|
|
232
|
+
|
|
233
|
+
const { MANIFEST } = await meta
|
|
234
|
+
.resolve(bootstrap.sourceSpec, meta.url)
|
|
235
|
+
.then(p => meta.load(p));
|
|
236
|
+
// console.log('manifest keys:', Object.keys(MANIFEST));
|
|
237
|
+
|
|
238
|
+
const [gov] = ['--gov'].map(opt => opts.includes(opt));
|
|
239
|
+
|
|
240
|
+
if (gov) {
|
|
241
|
+
throw Error('not impl');
|
|
242
|
+
/*
|
|
243
|
+
const postBoot = sim
|
|
244
|
+
? manifests.SIM_CHAIN_POST_BOOT_MANIFEST
|
|
245
|
+
: manifests.CHAIN_POST_BOOT_MANIFEST;
|
|
246
|
+
manifest = { ...postBoot, ...manifest };
|
|
247
|
+
*/
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
const g = manifest2graph(MANIFEST);
|
|
251
|
+
for (const chunk of fmtGraph(g.nodes, g.neighbors)) {
|
|
252
|
+
stdout.write(chunk);
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
(async () => {
|
|
257
|
+
await Promise.all([
|
|
258
|
+
import('fs/promises'),
|
|
259
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
260
|
+
import('import-meta-resolve'),
|
|
261
|
+
]).then(([fsp, metaResolve]) => {
|
|
262
|
+
return main(process.argv.slice(2), {
|
|
263
|
+
stdout: process.stdout,
|
|
264
|
+
fsp,
|
|
265
|
+
meta: {
|
|
266
|
+
resolve: metaResolve.resolve,
|
|
267
|
+
url: import.meta.url,
|
|
268
|
+
load: specifier => import(specifier),
|
|
269
|
+
},
|
|
270
|
+
});
|
|
271
|
+
});
|
|
272
|
+
})().catch(console.error);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export function makeFakeBankKit(issuerKits: Array<Pick<IssuerKit, 'brand' | 'issuer'>>): {
|
|
2
|
+
addAsset: (denom: string, issuerName: string, proposedName: string, kit: import('../src/vat-bank.js').AssetIssuerKit) => void;
|
|
3
|
+
assetPublication: IterationObserver<import("../src/vat-bank.js").AssetDescriptor>;
|
|
4
|
+
bank: import("../src/vat-bank.js").Bank;
|
|
5
|
+
};
|
|
6
|
+
//# sourceMappingURL=bank-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bank-utils.d.ts","sourceRoot":"","sources":["bank-utils.js"],"names":[],"mappings":"AASO,4CAFI,MAAM,KAAK,SAAS,EAAE,OAAO,GAAG,QAAQ,CAAC,CAAC;sBAmBxC,MAAM,cACN,MAAM,gBACN,MAAM,OACN,OAAO,oBAAoB,EAAE,cAAc;;;EAqBvD"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
import { makeSubscriptionKit } from '@agoric/notifier';
|
|
3
|
+
import { makeScalarMapStore } from '@agoric/vat-data';
|
|
4
|
+
import { E } from '@endo/far';
|
|
5
|
+
import { Far } from '@endo/marshal';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @param {Array<Pick<IssuerKit, 'brand' | 'issuer'>>} issuerKits
|
|
9
|
+
*/
|
|
10
|
+
export const makeFakeBankKit = issuerKits => {
|
|
11
|
+
/** @type {MapStore<Brand, ERef<Issuer>>} */
|
|
12
|
+
const issuers = makeScalarMapStore();
|
|
13
|
+
/** @type {MapStore<Brand, ERef<import('../src/vat-bank.js').VirtualPurse>>} */
|
|
14
|
+
const purses = makeScalarMapStore();
|
|
15
|
+
|
|
16
|
+
// XXX setup purses without publishing
|
|
17
|
+
issuerKits.forEach(kit => issuers.init(kit.brand, kit.issuer));
|
|
18
|
+
issuerKits.forEach(kit => {
|
|
19
|
+
assert(kit.issuer);
|
|
20
|
+
purses.init(kit.brand, E(kit.issuer).makeEmptyPurse());
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
/** @type {SubscriptionRecord<import('../src/vat-bank.js').AssetDescriptor>} */
|
|
24
|
+
const { subscription, publication } = makeSubscriptionKit();
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @param {string} denom lower-level denomination string
|
|
28
|
+
* @param {string} issuerName
|
|
29
|
+
* @param {string} proposedName
|
|
30
|
+
* @param {import('../src/vat-bank.js').AssetIssuerKit} kit ERTP issuer kit
|
|
31
|
+
*/
|
|
32
|
+
const addAsset = (denom, issuerName, proposedName, kit) => {
|
|
33
|
+
issuers.init(kit.brand, kit.issuer);
|
|
34
|
+
purses.init(kit.brand, E(kit.issuer).makeEmptyPurse());
|
|
35
|
+
publication.updateState({
|
|
36
|
+
...kit,
|
|
37
|
+
denom,
|
|
38
|
+
issuerName,
|
|
39
|
+
proposedName,
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/** @type {import('../src/vat-bank.js').Bank} */
|
|
44
|
+
const bank = Far('mock bank', {
|
|
45
|
+
/** @param {Brand} brand */
|
|
46
|
+
getPurse: async brand => purses.get(brand),
|
|
47
|
+
getAssetSubscription: () => subscription,
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
return { addAsset, assetPublication: publication, bank };
|
|
51
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export function makeBoardRemote({ boardId, iface }: any): BoardRemote;
|
|
2
|
+
export function slotToBoardRemote(boardId: any, iface: any): BoardRemote;
|
|
3
|
+
export function boardValToSlot(val: any): any;
|
|
4
|
+
export function makeAgoricNamesRemotesFromFakeStorage(fakeStorageKit: import("@agoric/internal/src/storage-test-utils.js").FakeStorageKit): AgoricNamesRemotes;
|
|
5
|
+
export function boardSlottingMarshaller(slotToVal?: ((slot: string, iface: string) => any) | undefined): Omit<import('@endo/marshal').Marshal<string>, 'serialize' | 'unserialize'>;
|
|
6
|
+
export function makeHistoryReviver(entries: Array<[string, string]>, slotToVal?: ((slot: string, iface?: string) => any) | undefined): {
|
|
7
|
+
getItem: (key: any) => any;
|
|
8
|
+
children: (prefix: any) => string[];
|
|
9
|
+
has: (k: any) => boolean;
|
|
10
|
+
};
|
|
11
|
+
export function makeFakeBoard(initSequence?: number | bigint | undefined, options?: {
|
|
12
|
+
prefix?: string | undefined;
|
|
13
|
+
crcDigits?: number | undefined;
|
|
14
|
+
} | undefined): {
|
|
15
|
+
getId(value: any): string;
|
|
16
|
+
getValue(id: string): any;
|
|
17
|
+
lookup(...path: string[]): Promise<any>;
|
|
18
|
+
has(val: any): boolean;
|
|
19
|
+
ids(): string[];
|
|
20
|
+
getPublishingMarshaller(): {
|
|
21
|
+
toCapData(val: any): import("@endo/marshal").CapData<string>;
|
|
22
|
+
fromCapData(data: any): any;
|
|
23
|
+
serialize(data: any): import("@endo/marshal").CapData<string>;
|
|
24
|
+
unserialize(data: any): any;
|
|
25
|
+
};
|
|
26
|
+
getReadonlyMarshaller(): {
|
|
27
|
+
toCapData(val: any): import("@endo/marshal").CapData<string | null>;
|
|
28
|
+
fromCapData(data: any): any;
|
|
29
|
+
serialize(data: any): import("@endo/marshal").CapData<string | null>;
|
|
30
|
+
unserialize(data: any): any;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Should be a union with Remotable, but that's `any`, making this type meaningless
|
|
35
|
+
*/
|
|
36
|
+
export type BoardRemote = {
|
|
37
|
+
getBoardId: () => string;
|
|
38
|
+
};
|
|
39
|
+
export type VBankAssetDetail = {
|
|
40
|
+
brand: BoardRemote & Brand;
|
|
41
|
+
denom: string;
|
|
42
|
+
displayInfo: DisplayInfo;
|
|
43
|
+
issuer: BoardRemote & Issuer;
|
|
44
|
+
issuerName: string;
|
|
45
|
+
proposedName: string;
|
|
46
|
+
};
|
|
47
|
+
export type AgoricNamesRemotes = {
|
|
48
|
+
brand: Record<string, Brand>;
|
|
49
|
+
instance: Record<string, Instance>;
|
|
50
|
+
vbankAsset: Record<string, VBankAssetDetail>;
|
|
51
|
+
reverse: Record<string, string>;
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=board-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"board-utils.d.ts","sourceRoot":"","sources":["board-utils.js"],"names":[],"mappings":"AAoCO,0DAFM,WAAW,CAKvB;AAEM,yEAC8B;AAE9B,8CAKN;AAMM,sEAHI,OAAO,4CAA4C,EAAE,cAAc,GACjE,kBAAkB,CAmC9B;AAYM,4DAHW,MAAM,SAAS,MAAM,KAAK,GAAG,gBAClC,KAAK,OAAO,eAAe,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,aAAa,CAAC,CAMtF;AAQM,4CAHI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,sBAChB,MAAM,UAAU,MAAM,KAAK,GAAG;;;;EAoB/C;AAWM;;;;;;;;;;;;;;;;;;;;;EAGN;;;;0BA5IY;IAAE,UAAU,EAAE,MAAM,MAAM,CAAA;CAAE;+BAG5B;IACZ,KAAS,EAAE,WAAW,GAAG,KAAK,CAAC;IAC/B,KAAS,EAAE,MAAM,CAAC;IAClB,WAAe,EAAE,WAAW,CAAC;IAC7B,MAAU,EAAE,WAAW,GAAG,MAAM,CAAC;IACjC,UAAc,EAAE,MAAM,CAAC;IACvB,YAAgB,EAAE,MAAM,CAAC;CACtB;iCAGS;IACZ,KAAS,EAAE,OAAO,MAAM,EAAE,KAAK,CAAC,CAAC;IACjC,QAAY,EAAE,OAAO,MAAM,EAAE,QAAQ,CAAC,CAAC;IACvC,UAAc,EAAE,OAAO,MAAM,EAAE,gBAAgB,CAAC,CAAC;IACjD,OAAW,EAAE,OAAO,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC"}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
/**
|
|
3
|
+
* Should be a union with Remotable, but that's `any`, making this type meaningless
|
|
4
|
+
*
|
|
5
|
+
* @typedef {{ getBoardId: () => string }} BoardRemote
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* @typedef {{
|
|
9
|
+
* brand: BoardRemote & Brand,
|
|
10
|
+
* denom: string,
|
|
11
|
+
* displayInfo: DisplayInfo,
|
|
12
|
+
* issuer: BoardRemote & Issuer,
|
|
13
|
+
* issuerName: string,
|
|
14
|
+
* proposedName: string,
|
|
15
|
+
* }} VBankAssetDetail
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* @typedef {{
|
|
19
|
+
* brand: Record<string, Brand>,
|
|
20
|
+
* instance: Record<string, Instance>,
|
|
21
|
+
* vbankAsset: Record<string, VBankAssetDetail>,
|
|
22
|
+
* reverse: Record<string, string>,
|
|
23
|
+
* }} AgoricNamesRemotes
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import { Fail } from '@agoric/assert';
|
|
27
|
+
import { unmarshalFromVstorage } from '@agoric/internal/src/lib-chainStorage.js';
|
|
28
|
+
import { makeScalarBigMapStore } from '@agoric/vat-data';
|
|
29
|
+
import { Far } from '@endo/far';
|
|
30
|
+
import { makeMarshal } from '@endo/marshal';
|
|
31
|
+
import { prepareBoardKit } from '../src/lib-board.js';
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @param {*} slotInfo
|
|
35
|
+
* @returns {BoardRemote}
|
|
36
|
+
*/
|
|
37
|
+
export const makeBoardRemote = ({ boardId, iface }) => {
|
|
38
|
+
const nonalleged = iface ? iface.replace(/^Alleged: /, '') : '';
|
|
39
|
+
return Far(`BoardRemote${nonalleged}`, { getBoardId: () => boardId });
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const slotToBoardRemote = (boardId, iface) =>
|
|
43
|
+
makeBoardRemote({ boardId, iface });
|
|
44
|
+
|
|
45
|
+
export const boardValToSlot = val => {
|
|
46
|
+
if ('getBoardId' in val) {
|
|
47
|
+
return val.getBoardId();
|
|
48
|
+
}
|
|
49
|
+
Fail`unknown obj in boardSlottingMarshaller.valToSlot ${val}`;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @param {import("@agoric/internal/src/storage-test-utils.js").FakeStorageKit} fakeStorageKit
|
|
54
|
+
* @returns {AgoricNamesRemotes}
|
|
55
|
+
*/
|
|
56
|
+
export const makeAgoricNamesRemotesFromFakeStorage = fakeStorageKit => {
|
|
57
|
+
const { data } = fakeStorageKit;
|
|
58
|
+
|
|
59
|
+
// this produces Remotables that can roundtrip through a
|
|
60
|
+
// boardValToSlot-using marshaller
|
|
61
|
+
|
|
62
|
+
const { fromCapData } = makeMarshal(undefined, slotToBoardRemote);
|
|
63
|
+
const reverse = {};
|
|
64
|
+
const entries = ['brand', 'instance'].map(kind => {
|
|
65
|
+
/** @type {Array<[string, import('@agoric/vats/tools/board-utils.js').BoardRemote]>} */
|
|
66
|
+
const parts = unmarshalFromVstorage(
|
|
67
|
+
data,
|
|
68
|
+
`published.agoricNames.${kind}`,
|
|
69
|
+
fromCapData,
|
|
70
|
+
);
|
|
71
|
+
for (const [name, remote] of parts) {
|
|
72
|
+
reverse[remote.getBoardId()] = name;
|
|
73
|
+
}
|
|
74
|
+
return [kind, Object.fromEntries(parts)];
|
|
75
|
+
});
|
|
76
|
+
const tables = Object.fromEntries(entries);
|
|
77
|
+
// XXX not part of reverse[]
|
|
78
|
+
const vbankAsset = Object.fromEntries(
|
|
79
|
+
unmarshalFromVstorage(
|
|
80
|
+
data,
|
|
81
|
+
`published.agoricNames.vbankAsset`,
|
|
82
|
+
fromCapData,
|
|
83
|
+
).map(([_denom, info]) => [
|
|
84
|
+
info.issuerName,
|
|
85
|
+
{ ...info, brand: tables.brand[info.issuerName] },
|
|
86
|
+
]),
|
|
87
|
+
);
|
|
88
|
+
return { ...tables, reverse, vbankAsset };
|
|
89
|
+
};
|
|
90
|
+
harden(makeAgoricNamesRemotesFromFakeStorage);
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* A marshaller which can serialize getBoardId() -bearing
|
|
94
|
+
* Remotables. This allows the caller to pick their slots. The
|
|
95
|
+
* deserializer is configurable: the default cannot handle
|
|
96
|
+
* Remotable-bearing data.
|
|
97
|
+
*
|
|
98
|
+
* @param {(slot: string, iface: string) => any} [slotToVal]
|
|
99
|
+
* @returns {Omit<import('@endo/marshal').Marshal<string>, 'serialize' | 'unserialize'>}
|
|
100
|
+
*/
|
|
101
|
+
export const boardSlottingMarshaller = (slotToVal = undefined) => {
|
|
102
|
+
return makeMarshal(boardValToSlot, slotToVal, {
|
|
103
|
+
serializeBodyFormat: 'smallcaps',
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Provide access to object graphs serialized in vstorage.
|
|
109
|
+
*
|
|
110
|
+
* @param {Array<[string, string]>} entries
|
|
111
|
+
* @param {(slot: string, iface?: string) => any} [slotToVal]
|
|
112
|
+
*/
|
|
113
|
+
export const makeHistoryReviver = (entries, slotToVal = undefined) => {
|
|
114
|
+
const board = boardSlottingMarshaller(slotToVal);
|
|
115
|
+
const vsMap = new Map(entries);
|
|
116
|
+
const fromCapData = (...args) =>
|
|
117
|
+
Reflect.apply(board.fromCapData, board, args);
|
|
118
|
+
const getItem = key => unmarshalFromVstorage(vsMap, key, fromCapData, -1);
|
|
119
|
+
const children = prefix => {
|
|
120
|
+
prefix.endsWith('.') || Fail`prefix must end with '.'`;
|
|
121
|
+
return harden([
|
|
122
|
+
...new Set(
|
|
123
|
+
entries
|
|
124
|
+
.map(([k, _]) => k)
|
|
125
|
+
.filter(k => k.startsWith(prefix))
|
|
126
|
+
.map(k => k.slice(prefix.length).split('.')[0]),
|
|
127
|
+
),
|
|
128
|
+
]);
|
|
129
|
+
};
|
|
130
|
+
return harden({ getItem, children, has: k => vsMap.get(k) !== undefined });
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Make a board that uses durable storage, but with fake baggage which will fail upgrade.
|
|
135
|
+
* Suitable only for use in tests.
|
|
136
|
+
*
|
|
137
|
+
* @param {bigint | number} [initSequence]
|
|
138
|
+
* @param {object} [options]
|
|
139
|
+
* @param {string} [options.prefix]
|
|
140
|
+
* @param {number} [options.crcDigits]
|
|
141
|
+
*/
|
|
142
|
+
export const makeFakeBoard = (initSequence = 0, options = {}) => {
|
|
143
|
+
const make = prepareBoardKit(makeScalarBigMapStore('baggage'));
|
|
144
|
+
return make(initSequence, options).board;
|
|
145
|
+
};
|