@agoric/vats 0.15.1-dev-69236fd.0 → 0.15.1
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 +8 -0
- package/decentral-itest-vaults-config.json +1 -1
- package/package.json +20 -23
- package/src/core/demoIssuers.d.ts +3 -3
- package/src/core/demoIssuers.d.ts.map +1 -1
- package/src/core/demoIssuers.js +4 -4
- package/src/core/lib-boot.d.ts.map +1 -1
- package/src/core/lib-boot.js +1 -0
- package/src/core/startWalletFactory.d.ts +1 -113
- package/src/core/startWalletFactory.d.ts.map +1 -1
- package/src/core/types.d.ts +1 -57
- package/src/core/types.d.ts.map +1 -1
- package/src/ibc.d.ts.map +1 -1
- package/src/ibc.js +0 -1
- package/src/proposals/restart-vats-proposal.d.ts.map +1 -1
- package/src/proposals/restart-vats-proposal.js +1 -0
- package/src/provisionPoolKit.d.ts +2 -18
- package/src/provisionPoolKit.d.ts.map +1 -1
- package/scripts/build-bundles.d.ts +0 -3
- package/scripts/build-bundles.d.ts.map +0 -1
- package/scripts/build-bundles.js +0 -14
- package/scripts/init-core.d.ts +0 -5
- package/scripts/init-core.d.ts.map +0 -1
- package/scripts/init-core.js +0 -31
- package/scripts/init-network.d.ts +0 -5
- package/scripts/init-network.d.ts.map +0 -1
- package/scripts/init-network.js +0 -19
- package/scripts/restart-vats.d.ts +0 -5
- package/scripts/restart-vats.d.ts.map +0 -1
- package/scripts/restart-vats.js +0 -23
- package/scripts/set-core-proposal-env.d.ts +0 -3
- package/scripts/set-core-proposal-env.d.ts.map +0 -1
- package/scripts/set-core-proposal-env.js +0 -37
- package/tools/authorityViz.d.ts +0 -27
- package/tools/authorityViz.d.ts.map +0 -1
- package/tools/authorityViz.js +0 -272
- package/tools/bank-utils.d.ts +0 -6
- package/tools/bank-utils.d.ts.map +0 -1
- package/tools/bank-utils.js +0 -51
- package/tools/board-utils.d.ts +0 -53
- package/tools/board-utils.d.ts.map +0 -1
- package/tools/board-utils.js +0 -145
- package/tools/boot-test-utils.d.ts +0 -163
- package/tools/boot-test-utils.d.ts.map +0 -1
- package/tools/boot-test-utils.js +0 -166
- package/tools/viz.mk +0 -17
package/scripts/restart-vats.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"set-core-proposal-env.d.ts","sourceRoot":"","sources":["set-core-proposal-env.js"],"names":[],"mappings":""}
|
|
@@ -1,37 +0,0 @@
|
|
|
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
|
-
}
|
package/tools/authorityViz.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/tools/authorityViz.js
DELETED
|
@@ -1,272 +0,0 @@
|
|
|
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);
|
package/tools/bank-utils.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/tools/bank-utils.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
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
|
-
};
|
package/tools/board-utils.d.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/tools/board-utils.js
DELETED
|
@@ -1,145 +0,0 @@
|
|
|
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
|
-
};
|