@agoric/inter-protocol 0.13.2-dev-e61a41e.0 → 0.13.2-dev-d092592.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.
@@ -1,135 +0,0 @@
1
- import '@agoric/governance/exported.js';
2
- import { makeScalarMapStore, M, makeHeapFarInstance, fit } from '@agoric/store';
3
- import '@agoric/zoe/exported.js';
4
- import '@agoric/zoe/src/contracts/exported.js';
5
- import { InstanceHandleShape } from '@agoric/zoe/src/typeGuards.js';
6
- import { BrandShape } from '@agoric/ertp';
7
- import { TimestampShape } from '@agoric/swingset-vat/src/vats/timer/typeGuards.js';
8
- import { E } from '@endo/far';
9
-
10
- /**
11
- * @file
12
- *
13
- * This contract makes it possible for those who govern the PSM to call for
14
- * votes on changes. A more complete implementation would validate parameters,
15
- * constrain deadlines and possibly split the ability to call for votes into
16
- * separate capabilities for finer grain encapsulation.
17
- */
18
-
19
- /**
20
- * @typedef {object} ParamChangesOfferArgs
21
- * @property {bigint} deadline
22
- * @property {Instance} instance
23
- * @property {Record<string, unknown>} params
24
- * @property {{paramPath: { key: string }}} [path]
25
- */
26
- const ParamChangesOfferArgsShape = M.splitRecord(
27
- {
28
- deadline: TimestampShape,
29
- instance: InstanceHandleShape,
30
- params: M.recordOf(M.string(), M.any()),
31
- },
32
- {
33
- path: { paramPath: { key: M.string() } },
34
- },
35
- );
36
-
37
- /**
38
- * @param {ZCF<{binaryVoteCounterInstallation:Installation}>} zcf
39
- */
40
- export const start = async zcf => {
41
- const { binaryVoteCounterInstallation: counter } = zcf.getTerms();
42
- /** @type {MapStore<Instance,GovernedContractFacetAccess<{},{}>>} */
43
- const instanceToGovernor = makeScalarMapStore();
44
-
45
- const makeParamInvitation = () => {
46
- /**
47
- * @param {ZCFSeat} seat
48
- * @param {ParamChangesOfferArgs} args
49
- */
50
- const voteOnParamChanges = (seat, args) => {
51
- fit(args, ParamChangesOfferArgsShape);
52
- seat.exit();
53
-
54
- const {
55
- params,
56
- instance,
57
- deadline,
58
- path = { paramPath: { key: 'governedApi' } },
59
- } = args;
60
- const psmGovernor = instanceToGovernor.get(instance);
61
- return E(psmGovernor).voteOnParamChanges(counter, deadline, {
62
- ...path,
63
- changes: params,
64
- });
65
- };
66
-
67
- return zcf.makeInvitation(voteOnParamChanges, 'vote on param changes');
68
- };
69
-
70
- const makeOfferFilterInvitation = (instance, strings, deadline) => {
71
- const voteOnOfferFilterHandler = seat => {
72
- seat.exit();
73
-
74
- const psmGovernor = instanceToGovernor.get(instance);
75
- return E(psmGovernor).voteOnOfferFilter(counter, deadline, strings);
76
- };
77
-
78
- return zcf.makeInvitation(voteOnOfferFilterHandler, 'vote on offer filter');
79
- };
80
-
81
- const MakerShape = M.interface('PSM Charter InvitationMakers', {
82
- VoteOnParamChange: M.call().returns(M.promise()),
83
- VoteOnPauseOffers: M.call(
84
- InstanceHandleShape,
85
- M.arrayOf(M.string()),
86
- TimestampShape,
87
- ).returns(M.promise()),
88
- });
89
- const invitationMakers = makeHeapFarInstance(
90
- 'PSM Invitation Makers',
91
- MakerShape,
92
- {
93
- VoteOnParamChange: makeParamInvitation,
94
- VoteOnPauseOffers: makeOfferFilterInvitation,
95
- },
96
- );
97
-
98
- const charterMemberHandler = seat => {
99
- seat.exit();
100
- return harden({ invitationMakers });
101
- };
102
-
103
- const psmCharterCreatorI = M.interface('PSM Charter creatorFacet', {
104
- addInstance: M.call(InstanceHandleShape, M.any())
105
- .optional(BrandShape, BrandShape)
106
- .returns(),
107
- makeCharterMemberInvitation: M.call().returns(M.promise()),
108
- });
109
-
110
- const creatorFacet = makeHeapFarInstance(
111
- 'PSM Charter creatorFacet',
112
- psmCharterCreatorI,
113
- {
114
- /**
115
- * @param {Instance} psmInstance
116
- * @param {GovernedContractFacetAccess<{},{}>} psmGovernorFacet
117
- * @param {Brand} [anchor] for diagnostic use only
118
- * @param {Brand} [minted] for diagnostic use only
119
- */
120
- addInstance: (psmInstance, psmGovernorFacet, anchor, minted) => {
121
- console.log('psmCharter: adding instance', { minted, anchor });
122
- instanceToGovernor.init(psmInstance, psmGovernorFacet);
123
- },
124
- makeCharterMemberInvitation: () =>
125
- zcf.makeInvitation(
126
- charterMemberHandler,
127
- 'PSM charter member invitation',
128
- ),
129
- },
130
- );
131
-
132
- return harden({ creatorFacet });
133
- };
134
-
135
- export const INVITATION_MAKERS_DESC = 'PSM charter member invitation';