@agoric/vats 0.15.2-dev-cbcea8c.0.cbcea8c → 0.15.2-dev-04baeed.0.04baeed

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/package.json +16 -16
  2. package/source-spec-registry.d.ts +16 -4
  3. package/source-spec-registry.d.ts.map +1 -1
  4. package/source-spec-registry.js +5 -0
  5. package/src/core/boot-chain.d.ts +62 -1
  6. package/src/core/boot-chain.d.ts.map +1 -1
  7. package/src/core/startWalletFactory.d.ts +1 -11
  8. package/src/core/startWalletFactory.d.ts.map +1 -1
  9. package/src/core/startWalletFactory.js +3 -22
  10. package/src/core/utils.d.ts +77 -10
  11. package/src/core/utils.d.ts.map +1 -1
  12. package/src/core/utils.js +11 -0
  13. package/src/proposals/invite-committee.d.ts +88 -0
  14. package/src/proposals/invite-committee.d.ts.map +1 -0
  15. package/src/proposals/invite-committee.js +207 -0
  16. package/src/proposals/reserve-then-deposit.d.ts +6 -0
  17. package/src/proposals/reserve-then-deposit.d.ts.map +1 -0
  18. package/src/proposals/reserve-then-deposit.js +83 -0
  19. package/src/proposals/restart-vats-proposal.d.ts +2 -21
  20. package/src/proposals/restart-vats-proposal.d.ts.map +1 -1
  21. package/src/proposals/restart-vats-proposal.js +5 -27
  22. package/src/proposals/start-econ-committee.d.ts +91 -0
  23. package/src/proposals/start-econ-committee.d.ts.map +1 -0
  24. package/src/proposals/start-econ-committee.js +148 -0
  25. package/src/proposals/upgrade-asset-reserve-proposal.d.ts +0 -40
  26. package/src/proposals/upgrade-asset-reserve-proposal.d.ts.map +0 -1
  27. package/src/proposals/upgrade-asset-reserve-proposal.js +0 -99
  28. package/src/proposals/upgrade-psm-proposal.d.ts +0 -35
  29. package/src/proposals/upgrade-psm-proposal.d.ts.map +0 -1
  30. package/src/proposals/upgrade-psm-proposal.js +0 -80
@@ -0,0 +1,207 @@
1
+ import { deeplyFulfilledObject } from '@agoric/internal';
2
+ import { E } from '@endo/far';
3
+ import { reserveThenDeposit } from './reserve-then-deposit.js';
4
+
5
+ /**
6
+ * @import {Installation, Instance, Invitation} from '@agoric/zoe';
7
+ * @import {StartedInstanceKit} from '@agoric/zoe/src/zoeService/utils.js';
8
+ * @import {CommitteeElectorateCreatorFacet} from '@agoric/governance/src/committee.js';
9
+ * @import {start as CharterStart} from '@agoric/governance/src/econCommitteeCharter.js';
10
+ * @import {BootstrapPowers, Producer} from '../core/types.js';
11
+ */
12
+
13
+ /**
14
+ * Relocated from `inter-protocol` (refs #12719). Invites the economic
15
+ * committee members and stands up the (generic) charter through which they pose
16
+ * governance questions. The only governed contract that remains is provisionPool
17
+ * (in this package), so addGovernorsToEconCharter registers it instead of the
18
+ * former Inter Protocol contracts.
19
+ *
20
+ * @typedef {StartedInstanceKit<typeof CharterStart>} EconCharterStartResult
21
+ */
22
+
23
+ /**
24
+ * @typedef {BootstrapPowers & {
25
+ * consume: {
26
+ * economicCommitteeCreatorFacet: Promise<CommitteeElectorateCreatorFacet>;
27
+ * econCharterKit: Promise<EconCharterStartResult>;
28
+ * };
29
+ * produce: { econCharterKit: Producer<EconCharterStartResult> };
30
+ * }} EconCommitteePowers
31
+ */
32
+
33
+ const { values } = Object;
34
+
35
+ /** @type {<X, Y>(xs: X[], ys: Y[]) => [X, Y][]} */
36
+ const zip = (xs, ys) => xs.map((x, i) => [x, ys[i]]);
37
+
38
+ const EC_HIGH_PRIORITY_SENDERS_NAMESPACE = 'economicCommittee';
39
+
40
+ /**
41
+ * @param {EconCommitteePowers} powers
42
+ * @param {{ options: { voterAddresses: Record<string, string> } }} param1
43
+ */
44
+ export const inviteCommitteeMembers = async (
45
+ {
46
+ consume: { namesByAddressAdmin, economicCommitteeCreatorFacet, ...consume },
47
+ },
48
+ { options: { voterAddresses } },
49
+ ) => {
50
+ const invitations = await E(
51
+ economicCommitteeCreatorFacet,
52
+ ).getVoterInvitations();
53
+ assert.equal(invitations.length, values(voterAddresses).length);
54
+
55
+ const highPrioritySendersManager = await consume.highPrioritySendersManager;
56
+
57
+ /** @param {[string, Promise<Invitation>][]} addrInvitations */
58
+ const distributeInvitations = async addrInvitations => {
59
+ await Promise.all(
60
+ addrInvitations.map(async ([addr, invitationP]) => {
61
+ const debugName = `econ committee member ${addr}`;
62
+ await reserveThenDeposit(debugName, namesByAddressAdmin, addr, [
63
+ invitationP,
64
+ ]).catch(err => console.error(`failed deposit to ${debugName}`, err));
65
+ if (highPrioritySendersManager) {
66
+ await E(highPrioritySendersManager).add(
67
+ EC_HIGH_PRIORITY_SENDERS_NAMESPACE,
68
+ addr,
69
+ );
70
+ }
71
+ }),
72
+ );
73
+ };
74
+
75
+ // This doesn't resolve until the committee members create their smart wallets.
76
+ // Don't block bootstrap on it.
77
+ void distributeInvitations(zip(values(voterAddresses), invitations));
78
+ };
79
+
80
+ harden(inviteCommitteeMembers);
81
+
82
+ /** @param {EconCommitteePowers} powers */
83
+ export const startEconCharter = async ({
84
+ consume: { zoe },
85
+ produce: { econCharterKit },
86
+ installation: {
87
+ consume: { binaryVoteCounter: counterP, econCommitteeCharter: installP },
88
+ },
89
+ instance: {
90
+ produce: { econCommitteeCharter: instanceP },
91
+ },
92
+ }) => {
93
+ const [charterInstall0, counterInstall] = await Promise.all([
94
+ installP,
95
+ counterP,
96
+ ]);
97
+ // vats types the econCommitteeCharter installation generically (by name);
98
+ // narrow it to the governance charter contract.
99
+ const charterInstall = /** @type {Installation<typeof CharterStart>} */ (
100
+ charterInstall0
101
+ );
102
+ const terms = await deeplyFulfilledObject(
103
+ harden({
104
+ binaryVoteCounterInstallation: counterInstall,
105
+ }),
106
+ );
107
+
108
+ /** @type {Promise<EconCharterStartResult>} */
109
+ const startResult = E(zoe).startInstance(
110
+ charterInstall,
111
+ undefined,
112
+ terms,
113
+ undefined,
114
+ 'econCommitteeCharter',
115
+ );
116
+ instanceP.resolve(E.get(startResult).instance);
117
+ econCharterKit.resolve(startResult);
118
+ };
119
+ harden(startEconCharter);
120
+
121
+ /**
122
+ * Introduce the (only remaining) governed contract, provisionPool, to the
123
+ * charter so the committee can vote on its parameters.
124
+ *
125
+ * @param {EconCommitteePowers} powers
126
+ */
127
+ export const addGovernorsToEconCharter = async ({
128
+ consume: { econCharterKit, provisionPoolStartResult },
129
+ }) => {
130
+ const { creatorFacet } = E.get(econCharterKit);
131
+
132
+ const ppKit = await provisionPoolStartResult;
133
+ await E(creatorFacet).addInstance(
134
+ ppKit.instance,
135
+ ppKit.governorCreatorFacet,
136
+ 'provisionPool',
137
+ );
138
+ };
139
+
140
+ harden(addGovernorsToEconCharter);
141
+
142
+ /**
143
+ * @param {EconCommitteePowers} powers
144
+ * @param {{ options: { voterAddresses: Record<string, string> } }} param1
145
+ */
146
+ export const inviteToEconCharter = async (
147
+ { consume: { namesByAddressAdmin, econCharterKit } },
148
+ { options: { voterAddresses } },
149
+ ) => {
150
+ const { creatorFacet } = E.get(econCharterKit);
151
+
152
+ // This doesn't resolve until the committee members create their smart wallets.
153
+ // Don't block bootstrap on it.
154
+ void Promise.all(
155
+ values(voterAddresses).map(async addr => {
156
+ const debugName = `econ charter member ${addr}`;
157
+ reserveThenDeposit(debugName, namesByAddressAdmin, addr, [
158
+ E(creatorFacet).makeCharterMemberInvitation(),
159
+ ]).catch(err => console.error(`failed deposit to ${debugName}`, err));
160
+ }),
161
+ );
162
+ };
163
+
164
+ harden(inviteToEconCharter);
165
+
166
+ export const getManifestForInviteCommittee = async (
167
+ { restoreRef },
168
+ { voterAddresses, econCommitteeCharterRef },
169
+ ) => {
170
+ const t = true;
171
+ return {
172
+ manifest: {
173
+ [inviteCommitteeMembers.name]: {
174
+ consume: {
175
+ namesByAddressAdmin: t,
176
+ economicCommitteeCreatorFacet: t,
177
+ highPrioritySendersManager: t,
178
+ },
179
+ },
180
+ [startEconCharter.name]: {
181
+ consume: { zoe: t },
182
+ produce: { econCharterKit: t },
183
+ installation: {
184
+ consume: { binaryVoteCounter: t, econCommitteeCharter: t },
185
+ },
186
+ instance: {
187
+ produce: { econCommitteeCharter: t },
188
+ },
189
+ },
190
+ [addGovernorsToEconCharter.name]: {
191
+ consume: {
192
+ econCharterKit: t,
193
+ provisionPoolStartResult: t,
194
+ },
195
+ },
196
+ [inviteToEconCharter.name]: {
197
+ consume: { namesByAddressAdmin: t, econCharterKit: t },
198
+ },
199
+ },
200
+ installations: {
201
+ econCommitteeCharter: restoreRef(econCommitteeCharterRef),
202
+ },
203
+ options: {
204
+ voterAddresses,
205
+ },
206
+ };
207
+ };
@@ -0,0 +1,6 @@
1
+ export function reserveThenGetNamePaths(nameAdmin: ERef<NameAdmin>, paths: string[][]): Promise<unknown[]>;
2
+ export function reserveThenDeposit(debugName: string, namesByAddressAdmin: ERef<NameAdmin>, addr: string, payments: ERef<Payment>[]): Promise<void>;
3
+ import type { NameAdmin } from '@agoric/vats';
4
+ import type { ERef } from '@endo/far';
5
+ import type { Payment } from '@agoric/ertp';
6
+ //# sourceMappingURL=reserve-then-deposit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reserve-then-deposit.d.ts","sourceRoot":"","sources":["reserve-then-deposit.js"],"names":[],"mappings":"AAmBO,mDAJI,KAAK,SAAS,CAAC,SACf,MAAM,EAAE,EAAE,GACR,OAAO,CAAC,OAAO,EAAE,CAAC,CAgC9B;AAWM,8CALI,MAAM,uBACN,KAAK,SAAS,CAAC,QACf,MAAM,YACN,KAAK,OAAO,CAAC,EAAE,iBAwBzB;+BA5E2B,cAAc;0BADnB,WAAW;6BAER,cAAc"}
@@ -0,0 +1,83 @@
1
+ import { Fail } from '@endo/errors';
2
+ import { E } from '@endo/far';
3
+ import { WalletName } from '@agoric/internal';
4
+
5
+ /**
6
+ * @import {ERef} from '@endo/far';
7
+ * @import {NameAdmin} from '@agoric/vats';
8
+ * @import {Payment} from '@agoric/ertp';
9
+ */
10
+
11
+ /**
12
+ * Reserve and look up a list of name paths, waiting for each path segment to be
13
+ * reserved before resolving. Relocated from `inter-protocol` (refs
14
+ * #12719); used by the economicCommittee/charter bootstrap proposals.
15
+ *
16
+ * @param {ERef<NameAdmin>} nameAdmin
17
+ * @param {string[][]} paths
18
+ * @returns {Promise<unknown[]>}
19
+ */
20
+ export const reserveThenGetNamePaths = async (nameAdmin, paths) => {
21
+ /**
22
+ * @param {ERef<NameAdmin>} nextAdmin
23
+ * @param {string[]} path
24
+ * @returns {Promise<unknown>}
25
+ */
26
+ const nextPath = async (nextAdmin, path) => {
27
+ const [nextName, ...rest] = path;
28
+ assert.typeof(nextName, 'string');
29
+
30
+ // Ensure we wait for the next name until it exists.
31
+ await E(nextAdmin).reserve(nextName);
32
+
33
+ if (rest.length === 0) {
34
+ // Now return the readonly lookup of the name.
35
+ const nameHub = E(nextAdmin).readonly();
36
+ return E(nameHub).lookup(nextName);
37
+ }
38
+
39
+ // Wait until the next admin is resolved.
40
+ const restAdmin = await E(nextAdmin).lookupAdmin(nextName);
41
+ return nextPath(restAdmin, rest);
42
+ };
43
+
44
+ return Promise.all(
45
+ paths.map(async path => {
46
+ Array.isArray(path) || Fail`path ${path} is not an array`;
47
+ return nextPath(nameAdmin, path);
48
+ }),
49
+ );
50
+ };
51
+
52
+ /**
53
+ * Deposit payments (e.g. invitations) to an address's deposit facet, reserving
54
+ * the name path first so it resolves once the recipient provisions a wallet.
55
+ *
56
+ * @param {string} debugName
57
+ * @param {ERef<NameAdmin>} namesByAddressAdmin
58
+ * @param {string} addr
59
+ * @param {ERef<Payment>[]} payments
60
+ */
61
+ export const reserveThenDeposit = async (
62
+ debugName,
63
+ namesByAddressAdmin,
64
+ addr,
65
+ payments,
66
+ ) => {
67
+ console.info('awaiting depositFacet for', debugName);
68
+ /** @type {any} */
69
+ const [depositFacet] = await reserveThenGetNamePaths(namesByAddressAdmin, [
70
+ [addr, WalletName.depositFacet],
71
+ ]);
72
+ console.info('depositing to', debugName);
73
+ await Promise.allSettled(
74
+ payments.map(async (paymentP, i) => {
75
+ const payment = await paymentP;
76
+ await E(depositFacet).receive(payment);
77
+ console.info(
78
+ `confirmed deposit ${i + 1}/${payments.length} for`,
79
+ debugName,
80
+ );
81
+ }),
82
+ );
83
+ };
@@ -1,4 +1,4 @@
1
- export function restartVats({ consume }: BootstrapPowers & EconomyKitSpace, { options }: {
1
+ export function restartVats({ consume }: BootstrapPowers, { options }: {
2
2
  options: {
3
3
  skip: string[];
4
4
  };
@@ -11,36 +11,17 @@ export function getManifestForRestart(_powers: any, options: any): {
11
11
  governedContractKits: boolean;
12
12
  instancePrivateArgs: boolean;
13
13
  loadCriticalVat: boolean;
14
- psmKit: boolean;
15
14
  vatStore: boolean;
16
15
  vatAdminSvc: boolean;
17
16
  vatUpgradeInfo: boolean;
18
17
  zoe: string;
19
18
  provisioning: string;
20
- vaultFactoryKit: boolean;
19
+ provisionPoolStartResult: boolean;
21
20
  };
22
21
  produce: {};
23
22
  };
24
23
  };
25
24
  options: any;
26
25
  };
27
- /**
28
- * The subset of EconomyBootstrapSpace (from
29
- * inter-protocol/src/proposals/econ-behaviors.js) that this proposal reads,
30
- * declared structurally so this package doesn't depend on inter-protocol.
31
- */
32
- export type EconomyKitSpace = PromiseSpaceOf<{
33
- psmKit: MapStore<Brand, {
34
- label: string;
35
- psm: Instance<any>;
36
- psmAdminFacet: AdminFacet;
37
- }>;
38
- vaultFactoryKit: unknown;
39
- }>;
40
26
  import type { BootstrapPowers } from '../core/types.js';
41
- import type { Brand } from '@agoric/ertp';
42
- import type { Instance } from '@agoric/zoe/src/zoeService/utils.js';
43
- import type { AdminFacet } from '@agoric/zoe';
44
- import type { MapStore } from '@agoric/store';
45
- import type { PromiseSpaceOf } from '../core/types.js';
46
27
  //# sourceMappingURL=restart-vats-proposal.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"restart-vats-proposal.d.ts","sourceRoot":"","sources":["restart-vats-proposal.js"],"names":[],"mappings":"AAuDO,yCAJI,eAAe,GAAG,eAAe,eAEzC;IAAmC,OAAO,EAAlC;QAAE,IAAI,EAAE,MAAM,EAAE,CAAA;KAAE;CAC5B,iBAmHA;AAGM;;QAEH,CAAC,WAAW,CAAC,IAAI,CAAC;;;;;;;;;;;;;;;UAejB;;;EAGH;;;;;;8BA7KW,eAAe;IACvB,MAAM,EAAE,SACZ,KAAW,EACX;QAAQ,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,SAAS,GAAG,CAAC,CAAC;QAAC,aAAa,EAAE,UAAU,CAAA;KAAE,CACjE,CAAC;IACF,eAAe,EAAE,OAAO,CAAC;CAC1B,CAAC;qCAd6C,kBAAkB;2BAL5C,cAAc;8BAGX,qCAAqC;gCAD1B,aAAa;8BADxB,eAAe;oCAIQ,kBAAkB"}
1
+ {"version":3,"file":"restart-vats-proposal.d.ts","sourceRoot":"","sources":["restart-vats-proposal.js"],"names":[],"mappings":"AAyCO,yCAJI,eAAe,eAEvB;IAAmC,OAAO,EAAlC;QAAE,IAAI,EAAE,MAAM,EAAE,CAAA;KAAE;CAC5B,iBA4GA;AAGM;;QAEH,CAAC,WAAW,CAAC,IAAI,CAAC;;;;;;;;;;;;;;UAcjB;;;EAGH;qCA/JgD,kBAAkB"}
@@ -12,20 +12,6 @@ import { E, getInterfaceOf } from '@endo/far';
12
12
  * @import {BootstrapPowers, PromiseSpaceOf} from '../core/types.js';
13
13
  */
14
14
 
15
- /**
16
- * The subset of EconomyBootstrapSpace (from
17
- * inter-protocol/src/proposals/econ-behaviors.js) that this proposal reads,
18
- * declared structurally so this package doesn't depend on inter-protocol.
19
- *
20
- * @typedef {PromiseSpaceOf<{
21
- * psmKit: MapStore<
22
- * Brand,
23
- * { label: string; psm: Instance<any>; psmAdminFacet: AdminFacet }
24
- * >;
25
- * vaultFactoryKit: unknown;
26
- * }>} EconomyKitSpace
27
- */
28
-
29
15
  const trace = makeTracer('RV');
30
16
 
31
17
  const HR = '----------------';
@@ -49,7 +35,7 @@ const vatUpgradeStatus = {
49
35
  };
50
36
 
51
37
  /**
52
- * @param {BootstrapPowers & EconomyKitSpace} space
38
+ * @param {BootstrapPowers} space
53
39
  * @param {object} config
54
40
  * @param {{ skip: string[] }} config.options
55
41
  */
@@ -59,16 +45,15 @@ export const restartVats = async ({ consume }, { options }) => {
59
45
  trace('restartVats start', options);
60
46
  mustMatch(options, harden({ skip: M.arrayOf(M.string()) }));
61
47
 
62
- trace('awaiting VaultFactorKit as a proxy for "bootstrap done"');
63
- await consume.vaultFactoryKit;
48
+ trace('awaiting provisionPoolStartResult as a proxy for "bootstrap done"');
49
+ await consume.provisionPoolStartResult;
64
50
 
65
51
  trace('testing restarts');
66
- const { contractKits, governedContractKits, psmKit, vatStore } =
52
+ const { contractKits, governedContractKits, vatStore } =
67
53
  await deeplyFulfilledObject(
68
54
  harden({
69
55
  contractKits: consume.contractKits,
70
56
  governedContractKits: consume.governedContractKits,
71
- psmKit: consume.psmKit,
72
57
  vatStore: consume.vatStore,
73
58
  }),
74
59
  );
@@ -136,12 +121,6 @@ export const restartVats = async ({ consume }, { options }) => {
136
121
  );
137
122
  }
138
123
 
139
- trace('iterating over psmKit');
140
- for (const kit of psmKit.values()) {
141
- console.log('restarting PSM', kit.label);
142
- await tryRestartContract(kit.label, kit.psm, kit.psmAdminFacet);
143
- }
144
-
145
124
  trace('iterating over vatStore');
146
125
  for (const [name, { adminNode }] of vatStore.entries()) {
147
126
  const status = vatUpgradeStatus[name];
@@ -178,13 +157,12 @@ export const getManifestForRestart = (_powers, options) => ({
178
157
  governedContractKits: true,
179
158
  instancePrivateArgs: true,
180
159
  loadCriticalVat: true,
181
- psmKit: true,
182
160
  vatStore: true,
183
161
  vatAdminSvc: true,
184
162
  vatUpgradeInfo: true,
185
163
  zoe: 'zoe',
186
164
  provisioning: 'provisioning',
187
- vaultFactoryKit: true,
165
+ provisionPoolStartResult: true,
188
166
  },
189
167
  produce: {},
190
168
  },
@@ -0,0 +1,91 @@
1
+ export function startEconomicCommittee({ consume: { board, chainStorage, diagnostics, zoe }, produce: { economicCommitteeKit, economicCommitteeCreatorFacet }, installation: { consume: { committee }, }, instance: { produce: { economicCommittee }, }, }: BootstrapPowers & {
2
+ produce: {
3
+ economicCommitteeKit: Producer<StartedInstanceKit<typeof CommitteeStart> & {
4
+ label: string;
5
+ }>;
6
+ economicCommitteeCreatorFacet: Producer<CommitteeElectorateCreatorFacet>;
7
+ };
8
+ instance: {
9
+ produce: {
10
+ economicCommittee: Producer<Instance<typeof CommitteeStart>>;
11
+ };
12
+ };
13
+ }, { options: { econCommitteeOptions } }: {
14
+ options?: {
15
+ econCommitteeOptions?: EconCommitteeOptions | undefined;
16
+ } | undefined;
17
+ }): Promise<void>;
18
+ export const ECON_COMMITTEE_MANIFEST: {
19
+ [startEconomicCommittee.name]: {
20
+ consume: {
21
+ board: true;
22
+ chainStorage: true;
23
+ diagnostics: true;
24
+ zoe: true;
25
+ };
26
+ produce: {
27
+ economicCommitteeKit: true;
28
+ economicCommitteeCreatorFacet: string;
29
+ };
30
+ installation: {
31
+ consume: {
32
+ committee: string;
33
+ };
34
+ };
35
+ instance: {
36
+ produce: {
37
+ economicCommittee: string;
38
+ };
39
+ };
40
+ };
41
+ };
42
+ export function getManifestForEconCommittee({ restoreRef }: {
43
+ restoreRef: any;
44
+ }, { installKeys, econCommitteeOptions }: {
45
+ installKeys: any;
46
+ econCommitteeOptions: any;
47
+ }): {
48
+ manifest: {
49
+ [startEconomicCommittee.name]: {
50
+ consume: {
51
+ board: true;
52
+ chainStorage: true;
53
+ diagnostics: true;
54
+ zoe: true;
55
+ };
56
+ produce: {
57
+ economicCommitteeKit: true;
58
+ economicCommitteeCreatorFacet: string;
59
+ };
60
+ installation: {
61
+ consume: {
62
+ committee: string;
63
+ };
64
+ };
65
+ instance: {
66
+ produce: {
67
+ economicCommittee: string;
68
+ };
69
+ };
70
+ };
71
+ };
72
+ installations: {
73
+ contractGovernor: any;
74
+ committee: any;
75
+ binaryVoteCounter: any;
76
+ };
77
+ options: {
78
+ econCommitteeOptions: any;
79
+ };
80
+ };
81
+ export type EconCommitteeOptions = {
82
+ committeeName?: string | undefined;
83
+ committeeSize?: number | undefined;
84
+ };
85
+ import type { BootstrapPowers } from '../core/types.js';
86
+ import type { start as CommitteeStart } from '@agoric/governance/src/committee.js';
87
+ import type { StartedInstanceKit } from '@agoric/zoe/src/zoeService/utils.js';
88
+ import type { Producer } from '../core/types.js';
89
+ import type { CommitteeElectorateCreatorFacet } from '@agoric/governance/src/committee.js';
90
+ import type { Instance } from '@agoric/zoe';
91
+ //# sourceMappingURL=start-econ-committee.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"start-econ-committee.d.ts","sourceRoot":"","sources":["start-econ-committee.js"],"names":[],"mappings":"AAkDO,4PAfI,eAAe,GAAG;IACxB,OAAO,EAAE;QACP,oBAAoB,EAAE,SAC5B,mBAA2B,qBAAqB,CAAC,GAAG;YAAE,KAAK,EAAE,MAAM,CAAA;SAAE,CAC9D,CAAC;QACF,6BAA6B,EAAE,SAAS,+BAA+B,CAAC,CAAC;KAC1E,CAAC;IACF,QAAQ,EAAE;QACR,OAAO,EAAE;YAAE,iBAAiB,EAAE,SAAS,SAAS,qBAAqB,CAAC,CAAC,CAAA;SAAE,CAAC;KAC3E,CAAC;CACH,yCAED;IAAwB,OAAO;;;CACoC,iBAyDrE;AAGD;IACE,CAAC,sBAAsB,CAAC,IAAI,CAAC;;;;;;;;;;;;;;;;;;;;;MAiB5B;EACA;AAKI;;;;;;;QAvBL,CAAC,sBAAsB,CAAC,IAAI,CAAC;;;;;;;;;;;;;;;;;;;;;UAiB5B;;;;;;;;;;EAqBF;;;;;qCAxI2C,kBAAkB;6CADa,qCAAqC;wCAD3E,qCAAqC;8BAE9B,kBAAkB;qDADa,qCAAqC;8BAFrF,aAAa"}
@@ -0,0 +1,148 @@
1
+ import { makeTracer } from '@agoric/internal';
2
+ import {
3
+ assertPathSegment,
4
+ makeStorageNodeChild,
5
+ } from '@agoric/internal/src/lib-chainStorage.js';
6
+ import { E } from '@endo/far';
7
+
8
+ /**
9
+ * @import {Instance} from '@agoric/zoe';
10
+ * @import {StartedInstanceKit} from '@agoric/zoe/src/zoeService/utils.js';
11
+ * @import {CommitteeElectorateCreatorFacet, start as CommitteeStart} from '@agoric/governance/src/committee.js';
12
+ * @import {BootstrapPowers, Producer} from '../core/types.js';
13
+ */
14
+
15
+ const trace = makeTracer('RunEconCommittee', true);
16
+
17
+ /** @type {(name: string) => string} */
18
+ const sanitizePathSegment = name => {
19
+ const candidate = name.replace(/[ ,]/g, '_');
20
+ assertPathSegment(candidate);
21
+ return candidate;
22
+ };
23
+
24
+ /**
25
+ * @typedef {object} EconCommitteeOptions
26
+ * @property {string} [committeeName]
27
+ * @property {number} [committeeSize]
28
+ */
29
+
30
+ /**
31
+ * Start the Economic Committee electorate. Formerly part of
32
+ * `inter-protocol`; relocated to `@agoric/vats` because it outlives
33
+ * Inter Protocol — provisionPool (in this package) is governed and needs this
34
+ * electorate. The committee contract itself remains in `@agoric/governance`.
35
+ *
36
+ * @param {BootstrapPowers & {
37
+ * produce: {
38
+ * economicCommitteeKit: Producer<
39
+ * StartedInstanceKit<typeof CommitteeStart> & { label: string }
40
+ * >;
41
+ * economicCommitteeCreatorFacet: Producer<CommitteeElectorateCreatorFacet>;
42
+ * };
43
+ * instance: {
44
+ * produce: { economicCommittee: Producer<Instance<typeof CommitteeStart>> };
45
+ * };
46
+ * }} powers
47
+ * @param {object} config
48
+ * @param {object} [config.options]
49
+ * @param {EconCommitteeOptions} [config.options.econCommitteeOptions]
50
+ */
51
+ export const startEconomicCommittee = async (
52
+ {
53
+ consume: { board, chainStorage, diagnostics, zoe },
54
+ produce: { economicCommitteeKit, economicCommitteeCreatorFacet },
55
+ installation: {
56
+ consume: { committee },
57
+ },
58
+ instance: {
59
+ produce: { economicCommittee },
60
+ },
61
+ },
62
+ { options: { econCommitteeOptions = {} } = {} },
63
+ ) => {
64
+ const COMMITTEES_ROOT = 'committees';
65
+ trace('startEconomicCommittee');
66
+ const {
67
+ // NB: the electorate (and size) of the committee may change, but the name must not
68
+ committeeName = 'Economic Committee',
69
+ committeeSize = 3,
70
+ ...rest
71
+ } = econCommitteeOptions;
72
+
73
+ const committeesNode = await makeStorageNodeChild(
74
+ chainStorage,
75
+ COMMITTEES_ROOT,
76
+ );
77
+ const storageNode = await E(committeesNode).makeChildNode(
78
+ sanitizePathSegment(committeeName),
79
+ );
80
+
81
+ // NB: committee must only publish what it intended to be public
82
+ const marshaller = await E(board).getPublishingMarshaller();
83
+
84
+ const privateArgs = {
85
+ storageNode,
86
+ marshaller,
87
+ };
88
+ const startResult = await E(zoe).startInstance(
89
+ committee,
90
+ {},
91
+ { committeeName, committeeSize, ...rest },
92
+ privateArgs,
93
+ 'economicCommittee',
94
+ );
95
+ const { creatorFacet, instance } = startResult;
96
+
97
+ economicCommitteeKit.resolve(
98
+ // XXX should startInstance return its label?
99
+ harden({ ...startResult, label: 'economicCommittee' }),
100
+ );
101
+
102
+ await E(diagnostics).savePrivateArgs(startResult.instance, privateArgs);
103
+
104
+ economicCommitteeCreatorFacet.resolve(creatorFacet);
105
+ economicCommittee.resolve(instance);
106
+ };
107
+ harden(startEconomicCommittee);
108
+
109
+ export const ECON_COMMITTEE_MANIFEST = harden({
110
+ [startEconomicCommittee.name]: {
111
+ consume: {
112
+ board: true,
113
+ chainStorage: true,
114
+ diagnostics: true,
115
+ zoe: true,
116
+ },
117
+ produce: {
118
+ economicCommitteeKit: true,
119
+ economicCommitteeCreatorFacet: 'economicCommittee',
120
+ },
121
+ installation: {
122
+ consume: { committee: 'zoe' },
123
+ },
124
+ instance: {
125
+ produce: { economicCommittee: 'economicCommittee' },
126
+ },
127
+ },
128
+ });
129
+
130
+ // Core-eval manifest for the Economic Committee. Also publishes the governance
131
+ // installations (contractGovernor, committee, binaryVoteCounter) that governed
132
+ // contracts such as provisionPool depend on.
133
+ export const getManifestForEconCommittee = (
134
+ { restoreRef },
135
+ { installKeys, econCommitteeOptions },
136
+ ) => {
137
+ return {
138
+ manifest: ECON_COMMITTEE_MANIFEST,
139
+ installations: {
140
+ contractGovernor: restoreRef(installKeys.contractGovernor),
141
+ committee: restoreRef(installKeys.committee),
142
+ binaryVoteCounter: restoreRef(installKeys.binaryVoteCounter),
143
+ },
144
+ options: {
145
+ econCommitteeOptions,
146
+ },
147
+ };
148
+ };