@agoric/vats 0.15.1-dev-779b73d.0 → 0.15.1-dev-3353509.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/package.json +22 -20
- 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/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/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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/vats",
|
|
3
|
-
"version": "0.15.1-dev-
|
|
3
|
+
"version": "0.15.1-dev-3353509.0+3353509",
|
|
4
4
|
"description": "Agoric's Vat library",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.js",
|
|
@@ -28,19 +28,19 @@
|
|
|
28
28
|
"author": "Agoric",
|
|
29
29
|
"license": "Apache-2.0",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@agoric/assert": "0.6.1-dev-
|
|
32
|
-
"@agoric/ertp": "0.16.3-dev-
|
|
33
|
-
"@agoric/governance": "0.10.3-dev-
|
|
34
|
-
"@agoric/inter-protocol": "0.16.1-dev-
|
|
35
|
-
"@agoric/internal": "0.3.3-dev-
|
|
36
|
-
"@agoric/notifier": "0.6.3-dev-
|
|
37
|
-
"@agoric/sharing-service": "0.2.12-dev-
|
|
38
|
-
"@agoric/store": "0.9.3-dev-
|
|
39
|
-
"@agoric/swingset-vat": "0.32.3-dev-
|
|
40
|
-
"@agoric/time": "0.3.3-dev-
|
|
41
|
-
"@agoric/vat-data": "0.5.3-dev-
|
|
42
|
-
"@agoric/zoe": "0.26.3-dev-
|
|
43
|
-
"@agoric/zone": "0.2.3-dev-
|
|
31
|
+
"@agoric/assert": "0.6.1-dev-3353509.0+3353509",
|
|
32
|
+
"@agoric/ertp": "0.16.3-dev-3353509.0+3353509",
|
|
33
|
+
"@agoric/governance": "0.10.3-dev-3353509.0+3353509",
|
|
34
|
+
"@agoric/inter-protocol": "0.16.1-dev-3353509.0+3353509",
|
|
35
|
+
"@agoric/internal": "0.3.3-dev-3353509.0+3353509",
|
|
36
|
+
"@agoric/notifier": "0.6.3-dev-3353509.0+3353509",
|
|
37
|
+
"@agoric/sharing-service": "0.2.12-dev-3353509.0+3353509",
|
|
38
|
+
"@agoric/store": "0.9.3-dev-3353509.0+3353509",
|
|
39
|
+
"@agoric/swingset-vat": "0.32.3-dev-3353509.0+3353509",
|
|
40
|
+
"@agoric/time": "0.3.3-dev-3353509.0+3353509",
|
|
41
|
+
"@agoric/vat-data": "0.5.3-dev-3353509.0+3353509",
|
|
42
|
+
"@agoric/zoe": "0.26.3-dev-3353509.0+3353509",
|
|
43
|
+
"@agoric/zone": "0.2.3-dev-3353509.0+3353509",
|
|
44
44
|
"@endo/far": "^0.2.18",
|
|
45
45
|
"@endo/import-bundle": "^0.3.4",
|
|
46
46
|
"@endo/init": "^0.5.56",
|
|
@@ -50,11 +50,11 @@
|
|
|
50
50
|
"jessie.js": "^0.3.2"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@agoric/cosmic-swingset": "0.41.3-dev-
|
|
54
|
-
"@agoric/deploy-script-support": "0.10.3-dev-
|
|
55
|
-
"@agoric/smart-wallet": "0.5.3-dev-
|
|
56
|
-
"@agoric/swing-store": "0.9.2-dev-
|
|
57
|
-
"@agoric/swingset-liveslots": "0.10.3-dev-
|
|
53
|
+
"@agoric/cosmic-swingset": "0.41.3-dev-3353509.0+3353509",
|
|
54
|
+
"@agoric/deploy-script-support": "0.10.3-dev-3353509.0+3353509",
|
|
55
|
+
"@agoric/smart-wallet": "0.5.3-dev-3353509.0+3353509",
|
|
56
|
+
"@agoric/swing-store": "0.9.2-dev-3353509.0+3353509",
|
|
57
|
+
"@agoric/swingset-liveslots": "0.10.3-dev-3353509.0+3353509",
|
|
58
58
|
"@endo/bundle-source": "^2.5.1",
|
|
59
59
|
"@endo/captp": "^3.1.1",
|
|
60
60
|
"@endo/stream": "^0.3.25",
|
|
@@ -65,6 +65,8 @@
|
|
|
65
65
|
"files": [
|
|
66
66
|
"CHANGELOG.md",
|
|
67
67
|
"src/",
|
|
68
|
+
"scripts/",
|
|
69
|
+
"tools/",
|
|
68
70
|
"*.json",
|
|
69
71
|
"globals.d.ts",
|
|
70
72
|
"exported.js"
|
|
@@ -83,5 +85,5 @@
|
|
|
83
85
|
"timeout": "20m",
|
|
84
86
|
"workerThreads": false
|
|
85
87
|
},
|
|
86
|
-
"gitHead": "
|
|
88
|
+
"gitHead": "33535095a838565aa9ae7aa1234669ed68b4bb9d"
|
|
87
89
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-bundles.d.ts","sourceRoot":"","sources":["build-bundles.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#! /usr/bin/env node
|
|
2
|
+
import '@endo/init';
|
|
3
|
+
import { createBundles } from '@agoric/internal/src/node/createBundles.js';
|
|
4
|
+
import url from 'url';
|
|
5
|
+
|
|
6
|
+
const dirname = url.fileURLToPath(new URL('.', import.meta.url));
|
|
7
|
+
|
|
8
|
+
const sourceToBundle = [
|
|
9
|
+
[`../src/centralSupply.js`, `../bundles/bundle-centralSupply.js`],
|
|
10
|
+
[`../src/mintHolder.js`, `../bundles/bundle-mintHolder.js`],
|
|
11
|
+
[`../src/provisionPool.js`, `../bundles/bundle-provisionPool.js`],
|
|
12
|
+
];
|
|
13
|
+
|
|
14
|
+
await createBundles(sourceToBundle, dirname);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').ProposalBuilder} */
|
|
2
|
+
export const defaultProposalBuilder: import('@agoric/deploy-script-support/src/externalTypes.js').ProposalBuilder;
|
|
3
|
+
declare function _default(homeP: any, endowments: any): Promise<void>;
|
|
4
|
+
export default _default;
|
|
5
|
+
//# sourceMappingURL=init-core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init-core.d.ts","sourceRoot":"","sources":["init-core.js"],"names":[],"mappings":"AAEA,2FAA2F;AAC3F,qCADW,OAAO,oDAAoD,EAAE,eAAe,CAuBlF;AAEU,sEAGd"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { makeHelpers } from '@agoric/deploy-script-support';
|
|
2
|
+
|
|
3
|
+
/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').ProposalBuilder} */
|
|
4
|
+
export const defaultProposalBuilder = async ({ publishRef, install }) =>
|
|
5
|
+
harden({
|
|
6
|
+
sourceSpec: '../src/core/startWalletFactory.js',
|
|
7
|
+
getManifestCall: [
|
|
8
|
+
'getManifestForWalletFactory',
|
|
9
|
+
{
|
|
10
|
+
installKeys: {
|
|
11
|
+
provisionPool: publishRef(
|
|
12
|
+
install(
|
|
13
|
+
'../src/provisionPool.js',
|
|
14
|
+
'../bundles/bundle-provisionPool.js',
|
|
15
|
+
),
|
|
16
|
+
),
|
|
17
|
+
walletFactory: publishRef(
|
|
18
|
+
install(
|
|
19
|
+
'@agoric/smart-wallet/src/walletFactory.js',
|
|
20
|
+
'../../smart-wallet/bundles/bundle-walletFactory.js',
|
|
21
|
+
),
|
|
22
|
+
),
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
export default async (homeP, endowments) => {
|
|
29
|
+
const { writeCoreProposal } = await makeHelpers(homeP, endowments);
|
|
30
|
+
await writeCoreProposal('gov-vats', defaultProposalBuilder);
|
|
31
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').ProposalBuilder} */
|
|
2
|
+
export const defaultProposalBuilder: import('@agoric/deploy-script-support/src/externalTypes.js').ProposalBuilder;
|
|
3
|
+
declare function _default(homeP: any, endowments: any): Promise<void>;
|
|
4
|
+
export default _default;
|
|
5
|
+
//# sourceMappingURL=init-network.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init-network.d.ts","sourceRoot":"","sources":["init-network.js"],"names":[],"mappings":"AAEA,2FAA2F;AAC3F,qCADW,OAAO,oDAAoD,EAAE,eAAe,CAWlF;AAEU,sEAGd"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { makeHelpers } from '@agoric/deploy-script-support';
|
|
2
|
+
|
|
3
|
+
/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').ProposalBuilder} */
|
|
4
|
+
export const defaultProposalBuilder = async ({ publishRef, install }) =>
|
|
5
|
+
harden({
|
|
6
|
+
sourceSpec: '../src/proposals/network-proposal.js',
|
|
7
|
+
getManifestCall: [
|
|
8
|
+
'getManifestForNetwork',
|
|
9
|
+
{
|
|
10
|
+
networkRef: publishRef(install('../src/vat-network.js')),
|
|
11
|
+
ibcRef: publishRef(install('../src/vat-ibc.js')),
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export default async (homeP, endowments) => {
|
|
17
|
+
const { writeCoreProposal } = await makeHelpers(homeP, endowments);
|
|
18
|
+
await writeCoreProposal('gov-network', defaultProposalBuilder);
|
|
19
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').ProposalBuilder} */
|
|
2
|
+
export const defaultProposalBuilder: import('@agoric/deploy-script-support/src/externalTypes.js').ProposalBuilder;
|
|
3
|
+
declare function _default(homeP: any, endowments: any): Promise<void>;
|
|
4
|
+
export default _default;
|
|
5
|
+
//# sourceMappingURL=restart-vats.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"restart-vats.d.ts","sourceRoot":"","sources":["restart-vats.js"],"names":[],"mappings":"AAEA,2FAA2F;AAC3F,qCADW,OAAO,oDAAoD,EAAE,eAAe,CAerF;AAEa,sEAGd"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { makeHelpers } from '@agoric/deploy-script-support';
|
|
2
|
+
|
|
3
|
+
/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').ProposalBuilder} */
|
|
4
|
+
export const defaultProposalBuilder = async () => {
|
|
5
|
+
// An includelist isn't necessary because the collections are known to be complete (tested in test-vaults-upgrade.js)
|
|
6
|
+
const skip = [
|
|
7
|
+
// can be replaced instead of upgraded
|
|
8
|
+
'auctioneer',
|
|
9
|
+
'feeDistributor',
|
|
10
|
+
// skip so vaultManager can have prices upon restart; these have been tested as restartable
|
|
11
|
+
'scaledPriceAuthority-ATOM',
|
|
12
|
+
];
|
|
13
|
+
|
|
14
|
+
return harden({
|
|
15
|
+
sourceSpec: '../src/proposals/restart-vats-proposal.js',
|
|
16
|
+
getManifestCall: ['getManifestForRestart', harden({ skip })],
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export default async (homeP, endowments) => {
|
|
21
|
+
const { writeCoreProposal } = await makeHelpers(homeP, endowments);
|
|
22
|
+
await writeCoreProposal('restart-vats', defaultProposalBuilder);
|
|
23
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set-core-proposal-env.d.ts","sourceRoot":"","sources":["set-core-proposal-env.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#! /usr/bin/env node
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import process from 'process';
|
|
4
|
+
import { createRequire } from 'module';
|
|
5
|
+
|
|
6
|
+
const require = createRequire(import.meta.url);
|
|
7
|
+
const spec = process.argv[2];
|
|
8
|
+
if (!spec) {
|
|
9
|
+
process.exit(0);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const vatConfigFile = require.resolve(spec);
|
|
13
|
+
const configJson = fs.readFileSync(vatConfigFile);
|
|
14
|
+
const config = JSON.parse(configJson);
|
|
15
|
+
|
|
16
|
+
const envs = new Map();
|
|
17
|
+
if (Array.isArray(config?.coreProposals)) {
|
|
18
|
+
config.coreProposals.forEach(
|
|
19
|
+
({ env }) =>
|
|
20
|
+
env &&
|
|
21
|
+
Object.entries(env).forEach(([key, val]) => {
|
|
22
|
+
const oldVal = envs.get(key);
|
|
23
|
+
if (envs.has(key) && oldVal !== val) {
|
|
24
|
+
throw Error(
|
|
25
|
+
`Duplicate env key: ${key}, but value is ${val} not ${oldVal}`,
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
envs.set(key, val);
|
|
29
|
+
}),
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
for (const [key, val] of envs.entries()) {
|
|
34
|
+
process.stdout.write(
|
|
35
|
+
`${key}="${val.replace(/(\\)/g, '\\$1').replace(/(")/g, '\\$1')}"\n`,
|
|
36
|
+
);
|
|
37
|
+
}
|
|
@@ -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);
|
|
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
|
+
};
|
|
@@ -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
|
+
|