@agoric/governance 0.10.4-upgrade-14-dev-0169c7e.0 → 0.10.4-upgrade-16-dev-8879538.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.
Files changed (80) hide show
  1. package/exported.d.ts +32 -0
  2. package/exported.js +1 -1
  3. package/package.json +35 -29
  4. package/src/binaryVoteCounter.d.ts +6 -3
  5. package/src/binaryVoteCounter.d.ts.map +1 -1
  6. package/src/binaryVoteCounter.js +6 -2
  7. package/src/breakTie.d.ts +1 -0
  8. package/src/breakTie.d.ts.map +1 -1
  9. package/src/breakTie.js +4 -0
  10. package/src/closingRule.d.ts +4 -0
  11. package/src/closingRule.d.ts.map +1 -1
  12. package/src/closingRule.js +4 -0
  13. package/src/committee.d.ts +12 -8
  14. package/src/committee.d.ts.map +1 -1
  15. package/src/committee.js +24 -11
  16. package/src/constants.d.ts +12 -12
  17. package/src/constants.d.ts.map +1 -1
  18. package/src/contractGovernance/governApi.d.ts +11 -8
  19. package/src/contractGovernance/governApi.d.ts.map +1 -1
  20. package/src/contractGovernance/governApi.js +8 -3
  21. package/src/contractGovernance/governFilter.d.ts +8 -2
  22. package/src/contractGovernance/governFilter.d.ts.map +1 -1
  23. package/src/contractGovernance/governFilter.js +5 -1
  24. package/src/contractGovernance/governParam.d.ts +9 -2
  25. package/src/contractGovernance/governParam.d.ts.map +1 -1
  26. package/src/contractGovernance/governParam.js +6 -1
  27. package/src/contractGovernance/paramManager.d.ts +13 -9
  28. package/src/contractGovernance/paramManager.d.ts.map +1 -1
  29. package/src/contractGovernance/paramManager.js +18 -14
  30. package/src/contractGovernance/typedParamManager.d.ts +19 -10
  31. package/src/contractGovernance/typedParamManager.d.ts.map +1 -1
  32. package/src/contractGovernance/typedParamManager.js +5 -0
  33. package/src/contractGovernor.d.ts +11 -5
  34. package/src/contractGovernor.d.ts.map +1 -1
  35. package/src/contractGovernor.js +19 -9
  36. package/src/contractGovernorKit.d.ts +14 -48
  37. package/src/contractGovernorKit.d.ts.map +1 -1
  38. package/src/contractGovernorKit.js +56 -10
  39. package/src/contractHelper.d.ts +68 -78
  40. package/src/contractHelper.d.ts.map +1 -1
  41. package/src/contractHelper.js +21 -21
  42. package/src/electorateTools.d.ts +21 -17
  43. package/src/electorateTools.d.ts.map +1 -1
  44. package/src/electorateTools.js +20 -12
  45. package/src/index.js +3 -6
  46. package/src/multiCandidateVoteCounter.d.ts +6 -3
  47. package/src/multiCandidateVoteCounter.d.ts.map +1 -1
  48. package/src/multiCandidateVoteCounter.js +8 -4
  49. package/src/noActionElectorate.d.ts +6 -1
  50. package/src/noActionElectorate.d.ts.map +1 -1
  51. package/src/noActionElectorate.js +11 -2
  52. package/src/question.d.ts +15 -11
  53. package/src/question.d.ts.map +1 -1
  54. package/src/question.js +5 -0
  55. package/src/quorumCounter.d.ts +1 -1
  56. package/src/quorumCounter.d.ts.map +1 -1
  57. package/src/quorumCounter.js +4 -0
  58. package/src/typeGuards.d.ts +91 -54
  59. package/src/typeGuards.d.ts.map +1 -1
  60. package/src/types.d.ts +59 -62
  61. package/src/types.d.ts.map +1 -1
  62. package/src/types.js +35 -27
  63. package/src/validators.d.ts +5 -0
  64. package/src/validators.d.ts.map +1 -1
  65. package/src/validators.js +6 -3
  66. package/src/voterKit.d.ts +6 -11
  67. package/src/voterKit.d.ts.map +1 -1
  68. package/src/voterKit.js +4 -0
  69. package/tools/puppetContractGovernor.d.ts +15 -11
  70. package/tools/puppetContractGovernor.d.ts.map +1 -1
  71. package/tools/puppetContractGovernor.js +7 -5
  72. package/tools/puppetGovernance.d.ts +31 -30
  73. package/tools/puppetGovernance.d.ts.map +1 -1
  74. package/tools/puppetGovernance.js +6 -4
  75. package/tools/storageDoc.d.ts +3 -3
  76. package/tools/storageDoc.d.ts.map +1 -1
  77. package/CHANGELOG.md +0 -456
  78. package/src/types-ambient.d.ts +0 -1047
  79. package/src/types-ambient.d.ts.map +0 -1
  80. package/src/types-ambient.js +0 -731
@@ -1,731 +0,0 @@
1
- /**
2
- * @typedef { 'unranked' | 'order' | 'plurality' } ChoiceMethod
3
- * * UNRANKED: "unranked voting" means that the voter specifies some number of
4
- * positions, and is endorsing them equally.
5
- * * ORDER: The voter assigns ordinal numbers to some of the positions. The
6
- * positions will be treated as an ordered list with no gaps.
7
- *
8
- * When voters are limited to choosing a single candidate, either UNRANKED or
9
- * ORDER would work. UNRANKED has a simpler representation so we use that.
10
- */
11
-
12
- /**
13
- * @typedef { 'param_change' | 'election' | 'survey' | 'api_invocation' |
14
- * 'offer_filter' } ElectionType
15
- * param_change is very specific. Survey means multiple answers are possible,
16
- * Election means some candidates are going to "win". It's not clear these are
17
- * orthogonal. The important distinction is that param_change has a structured
18
- * issue, while the others have a issue presented as a string.
19
- */
20
-
21
- /** @typedef {import('./constants.js').ParamType} ParamType */
22
-
23
- /**
24
- * @typedef { 'majority' | 'all' | 'no_quorum' } QuorumRule
25
- */
26
-
27
- /**
28
- * @typedef {object} SimpleIssue
29
- * @property {string} text
30
- */
31
-
32
- /**
33
- * @typedef { Amount | Brand | Installation | Instance | bigint |
34
- * Ratio | string | import('@agoric/time/src/types').TimestampRecord |
35
- * import('@agoric/time/src/types').RelativeTimeRecord | unknown } ParamValue
36
- */
37
-
38
- // XXX better to use the manifest constant ParamTypes
39
- // but importing that here turns this file into a module,
40
- // breaking the ambient typing
41
- /**
42
- * @template {ParamType} T
43
- * @typedef {T extends 'amount' ? Amount<any> :
44
- * T extends 'brand' ? Brand :
45
- * T extends 'installation' ? Installation:
46
- * T extends 'instance' ? Instance :
47
- * T extends 'invitation' ? Amount<'set'> : // XXX this is the getter value but not the setter
48
- * T extends 'nat' ? bigint :
49
- * T extends 'ratio' ? Ratio :
50
- * T extends 'string' ? string :
51
- * T extends 'timestamp' ? import('@agoric/time').Timestamp :
52
- * T extends 'relativeTime' ? import('@agoric/time').RelativeTime :
53
- * T extends 'unknown' ? unknown :
54
- * never
55
- * } ParamValueForType
56
- */
57
-
58
- /**
59
- * @template {ParamType} [T=ParamType]
60
- * @typedef {{ type: T, value: ParamValueForType<T> }} ParamValueTyped<T>
61
- */
62
-
63
- /**
64
- * Terms a contract must provide in order to be governed.
65
- *
66
- * @template {import('./contractGovernance/typedParamManager.js').ParamTypesMap} T Governed parameters of contract
67
- * @typedef {{
68
- * electionManager: import('@agoric/zoe/src/zoeService/utils.js').Instance<import('./contractGovernor.js')['prepare']>,
69
- * governedParams: import('./contractGovernance/typedParamManager.js').ParamRecordsFromTypes<T & {
70
- * Electorate: 'invitation'
71
- * }>
72
- * }} GovernanceTerms<T>
73
- */
74
-
75
- /**
76
- * @typedef { SimpleIssue | ParamChangeIssue<unknown> | ApiInvocationIssue |
77
- * OfferFilterIssue } Issue
78
- */
79
-
80
- /**
81
- * @typedef {object} QuestionTerms - QuestionSpec plus the Electorate Instance and
82
- * a numerical threshold for the quorum. (The voteCounter doesn't know the
83
- * size of the electorate, so the Electorate has to say what limit to enforce.)
84
- * @property {QuestionSpec} questionSpec
85
- * @property {number} quorumThreshold
86
- * @property {Instance} electorate
87
- */
88
-
89
- /**
90
- * @typedef {object} TextPosition
91
- * @property {string} text
92
- */
93
-
94
- /**
95
- * @typedef { TextPosition | ChangeParamsPosition | NoChangeParamsPosition | InvokeApiPosition | DontInvokeApiPosition |
96
- * OfferFilterPosition | NoChangeOfferFilterPosition | InvokeApiPosition } Position
97
- */
98
-
99
- /**
100
- * @typedef {{ question: Handle<'Question'> } & (
101
- * { outcome: 'win', position: Position } |
102
- * { outcome: 'fail', reason: 'No quorum' }
103
- * )} OutcomeRecord
104
- */
105
-
106
- /**
107
- * @typedef {{ question: Handle<'Question'> } & (
108
- * { outcome: 'win', positions: Position[] } |
109
- * { outcome: 'fail', reason: 'No quorum' }
110
- * )} MultiOutcomeRecord
111
- */
112
-
113
- /**
114
- * Specification when requesting creation of a Question
115
- *
116
- * @template {Issue} [I=Issue]
117
- * @typedef {object} QuestionSpec
118
- * @property {ChoiceMethod} method
119
- * @property {I} issue
120
- * @property {Position[]} positions
121
- * @property {ElectionType} electionType
122
- * @property {number} maxChoices
123
- * @property {number} maxWinners
124
- * @property {ClosingRule} closingRule
125
- * @property {QuorumRule} quorumRule
126
- * @property {Position} tieOutcome
127
- */
128
-
129
- /**
130
- * @typedef {object} QuestionDetailsExtraProperties
131
- * @property {Instance} counterInstance - instance of the VoteCounter
132
- * @property {Handle<'Question'>} questionHandle
133
- */
134
-
135
- /**
136
- * @typedef {QuestionSpec & QuestionDetailsExtraProperties} QuestionDetails
137
- * complete question details: questionSpec plus counter and questionHandle
138
- */
139
-
140
- /**
141
- * @typedef {object} GovernancePair
142
- * @property {Instance} governor
143
- * @property {Instance} governed
144
- */
145
-
146
- /**
147
- * @typedef {object} Question
148
- * @property {() => Instance} getVoteCounter
149
- * @property {() => QuestionDetails} getDetails
150
- */
151
-
152
- /**
153
- * @typedef {object} CompleteUnrankedQuestion
154
- * @property {Handle<'Question'>} questionHandle
155
- * @property {Position[]} chosen - a list of equal-weight preferred positions
156
- */
157
-
158
- // not yet in use
159
- /**
160
- * @typedef {object} CompleteWeightedBallot
161
- * @property {Handle<'Question'>} questionHandle
162
- * @property {[Position,bigint][]} weighted - list of positions with
163
- * weights. VoteCounter may limit weights to a range or require uniqueness.
164
- */
165
-
166
- // not yet in use
167
- /**
168
- * @typedef {object} CompleteOrderedBallot
169
- * @property {Handle<'Question'>} questionHandle
170
- * @property {Position[]} ordered - ordered list of position from most preferred
171
- * to least preferred
172
- */
173
-
174
- /**
175
- * @typedef {object} PositionCount
176
- * @property {Position} position
177
- * @property {bigint} total
178
- */
179
-
180
- /**
181
- * @typedef {object} VoteStatistics
182
- * @property {bigint} spoiled
183
- * @property {number} votes
184
- * @property {PositionCount[]} results
185
- */
186
-
187
- /**
188
- * @typedef {object} QuorumCounter
189
- * @property {(stats: VoteStatistics) => boolean} check
190
- */
191
-
192
- /**
193
- * @callback BuildQuestion
194
- * @param {QuestionSpec} questionSpec
195
- * @param {Instance} instance - voteCounter instance
196
- * @returns {Question}
197
- */
198
-
199
- /**
200
- * @typedef {object} VoteCounterCreatorFacet - a facet that the Electorate should
201
- * hold tightly. submitVote() is the core capability that allows the holder to
202
- * specify the identity and choice of a voter. The voteCounter is making that
203
- * available to the Electorate, which should wrap and attenuate it so each
204
- * voter gets only the ability to cast their own vote at a weight specified by
205
- * the electorate.
206
- * @property {SubmitVote} submitVote
207
- */
208
-
209
- /**
210
- * @typedef {object} VoteCounterPublicFacet
211
- * @property {() => boolean} isOpen
212
- * @property {() => Question} getQuestion
213
- * @property {() => Promise<Position>} getOutcome
214
- * @property {() => QuestionDetails} getDetails
215
- * @property {() => Promise<VoteStatistics>} getStats
216
- */
217
-
218
- /**
219
- * @typedef {object} MultiVoteCounterPublicFacet
220
- * @property {() => boolean} isOpen
221
- * @property {() => Question} getQuestion
222
- * @property {() => Promise<Position[]>} getOutcome
223
- * @property {() => QuestionDetails} getDetails
224
- * @property {() => Promise<VoteStatistics>} getStats
225
- */
226
-
227
- /**
228
- * @typedef {object} VoteCounterCloseFacet
229
- * TEST ONLY: Should not be allowed to escape from contracts
230
- * @property {() => void} closeVoting
231
- */
232
-
233
- /**
234
- * @typedef {object} VoteCounterFacets
235
- * @property {VoteCounterPublicFacet} publicFacet
236
- * @property {VoteCounterCreatorFacet} creatorFacet
237
- * @property {VoteCounterCloseFacet} closeFacet
238
- */
239
-
240
- /**
241
- * @typedef {object} MultiVoteCounterFacets
242
- * @property {MultiVoteCounterPublicFacet} publicFacet
243
- * @property {VoteCounterCreatorFacet} creatorFacet
244
- * @property {VoteCounterCloseFacet} closeFacet
245
- */
246
-
247
- /**
248
- * @callback BuildVoteCounter
249
- * @param {QuestionSpec} questionSpec
250
- * @param {bigint} threshold - questionSpec includes quorumRule; the electorate
251
- * converts that to a number that the counter can enforce.
252
- * @param {Instance} instance
253
- * @param {ERef<Publisher<OutcomeRecord>>} publisher
254
- * @returns {VoteCounterFacets}
255
- */
256
-
257
- /**
258
- * @callback BuildMultiVoteCounter
259
- * @param {QuestionSpec} questionSpec
260
- * @param {bigint} threshold - questionSpec includes quorumRule; the electorate
261
- * converts that to a number that the counter can enforce.
262
- * @param {Instance} instance
263
- * @param {ERef<Publisher<MultiOutcomeRecord>>} publisher
264
- * @returns {MultiVoteCounterFacets}
265
- */
266
-
267
- /**
268
- * @typedef {object} CompletedBallet
269
- * @property {Position} chosen
270
- * @property {bigint} shares
271
- */
272
-
273
- /**
274
- * @callback SubmitVote
275
- * @param {Handle<'Voter'>} voterHandle
276
- * @param {Position[]} chosenPositions
277
- * @param {bigint} [weight]
278
- * @returns {CompletedBallet}
279
- */
280
-
281
- /**
282
- * @callback GetOpenQuestions
283
- * @returns {Promise<Handle<'Question'>[]>}
284
- */
285
-
286
- /**
287
- * @callback GetQuestion
288
- * @param {Handle<'Question'>} h
289
- * @returns {Promise<Question>}
290
- */
291
-
292
- /**
293
- * @typedef {object} ElectoratePublic
294
- * @property {() => Subscriber<QuestionDetails>} getQuestionSubscriber
295
- * @property {GetOpenQuestions} getOpenQuestions,
296
- * @property {() => Instance} getInstance
297
- * @property {GetQuestion} getQuestion
298
- */
299
-
300
- /**
301
- * @typedef { ElectoratePublic & {makeVoterInvitation: () => ERef<Invitation>} } ClaimsElectoratePublic
302
- * @typedef { ElectoratePublic & {getName: () => string} } CommitteeElectoratePublic
303
- */
304
-
305
- /**
306
- * @typedef {object} PoserFacet
307
- * @property {AddQuestion} addQuestion
308
- */
309
-
310
- /**
311
- * @typedef {object} ElectorateCreatorFacet
312
- * @property {AddQuestion} addQuestion can be used directly when the creator doesn't need any
313
- * reassurance. When someone needs to connect addQuestion to the Electorate
314
- * instance, getPoserInvitation() lets them get addQuestion with assurance.
315
- * @property {() => Promise<Invitation>} getPoserInvitation
316
- * @property {() => Subscriber<QuestionDetails>} getQuestionSubscriber
317
- * @property {() => ElectoratePublic} getPublicFacet
318
- */
319
-
320
- /**
321
- * @typedef {object} GetVoterInvitations
322
- * @property {() => Invitation[]} getVoterInvitations
323
- */
324
-
325
- /**
326
- * @typedef {object} VoterFacet - a facet that the Electorate should hold
327
- * tightly. It allows specification of the vote's weight, so the Electorate
328
- * should distribute an attenuated wrapper that doesn't make that available!
329
- * @property {SubmitVote} submitVote
330
- */
331
-
332
- /**
333
- * @typedef {object} ClosingRule
334
- * @property {ERef<Timer>} timer
335
- * @property {import('@agoric/time/src/types').Timestamp} deadline
336
- */
337
-
338
- /**
339
- * @callback CloseVoting
340
- * @param {ClosingRule} closingRule
341
- * @param {() => void} closeVoting
342
- */
343
-
344
- /**
345
- * @typedef {object} AddQuestionReturn
346
- * @property {VoteCounterPublicFacet} publicFacet
347
- * @property {VoteCounterCreatorFacet} creatorFacet
348
- * @property {import('@agoric/zoe/src/zoeService/utils.js').Instance<typeof import('./binaryVoteCounter.js').start>} instance
349
- * @property {import('@agoric/time/src/types').Timestamp} deadline
350
- * @property {Handle<'Question'>} questionHandle
351
- */
352
-
353
- /**
354
- * @callback AddQuestion
355
- * @param {ERef<Installation>} voteCounter
356
- * @param {QuestionSpec} questionSpec
357
- * @returns {Promise<AddQuestionReturn>}
358
- */
359
-
360
- /**
361
- * @callback CreateQuestion
362
- *
363
- * @param {string} name - The name of the parameter to change
364
- * @param {ParamValue} proposedValue - the proposed value for the named
365
- * parameter
366
- * @param {Installation} voteCounterInstallation - the voteCounter to
367
- * instantiate to count votes. Expected to be a binaryVoteCounter. Other
368
- * voteCounters might be added here, or might require separate governors.
369
- * under management so users can trace it back and see that it would use
370
- * this electionManager to manage parameters
371
- * @param {Instance} contractInstance - include the instance of the contract
372
- * @param {ClosingRule} closingRule - deadline and timer for closing voting
373
- * @returns {Promise<QuestionDetails>}
374
- */
375
-
376
- /**
377
- * @template [P=StandardParamPath] path for a paramManagerRetriever
378
- * @typedef {object} ParamChangeIssue
379
- * @property {ParamChangesSpec<P>} spec
380
- * @property {import('@agoric/zoe/src/zoeService/utils.js').Instance<(zcf: ZCF<GovernanceTerms<{}>>) => {}>} contract
381
- */
382
-
383
- /**
384
- * @typedef {object} ApiInvocationIssue
385
- * @property {string} apiMethodName
386
- * @property {unknown[]} methodArgs
387
- */
388
-
389
- /**
390
- * @typedef {object} OfferFilterIssue
391
- * @property {string[]} strings
392
- */
393
-
394
- /**
395
- * @typedef {object} ParamChangePositions
396
- * @property {ChangeParamsPosition} positive
397
- * @property {NoChangeParamsPosition} negative
398
- */
399
-
400
- /**
401
- * @typedef {object} ParamChangeIssueDetails
402
- * details for a question that can change a contract parameter
403
- * @property {ChoiceMethod} method
404
- * @property {ParamChangeIssue<unknown>} issue
405
- * @property {ParamChangePositions} positions
406
- * @property {ElectionType} electionType
407
- * @property {number} maxChoices
408
- * @property {ClosingRule} closingRule
409
- * @property {QuorumRule} quorumRule
410
- * @property {NoChangeParamsPosition} tieOutcome
411
- * @property {Instance} counterInstance - instance of the VoteCounter
412
- * @property {Handle<'Question'>} questionHandle
413
- */
414
-
415
- /**
416
- * @typedef {Record<Keyword, ParamValueTyped>} ParamStateRecord a Record containing
417
- * keyword pairs with descriptions of parameters under governance.
418
- */
419
-
420
- /** @typedef {{current: ParamStateRecord}} GovernanceSubscriptionState */
421
-
422
- /**
423
- * @typedef {object} ParamManagerBase The base paramManager with typed getters
424
- * @property {() => ERef<ParamStateRecord>} getParams
425
- * @property {(name: string) => Amount} getAmount
426
- * @property {(name: string) => Brand} getBrand
427
- * @property {(name: string) => Instance} getInstance
428
- * @property {(name: string) => Installation} getInstallation
429
- * @property {(name: string) => Amount<'set'>} getInvitationAmount
430
- * @property {(name: string) => bigint} getNat
431
- * @property {(name: string) => Ratio} getRatio
432
- * @property {(name: string) => string} getString
433
- * @property {(name: string) => import('@agoric/time/src/types').TimestampRecord} getTimestamp
434
- * @property {(name: string) => import('@agoric/time/src/types').RelativeTimeRecord} getRelativeTime
435
- * @property {(name: string) => any} getUnknown
436
- * @property {(name: string, proposedValue: ParamValue) => ParamValue} getVisibleValue - for
437
- * most types, the visible value is the same as proposedValue. For Invitations
438
- * the visible value is the amount of the invitation.
439
- * @property {(name: string) => Promise<Invitation>} getInternalParamValue
440
- * @property {() => StoredSubscription<GovernanceSubscriptionState>} getSubscription
441
- */
442
-
443
- /**
444
- * @callback UpdateParams
445
- * @param {Record<string,ParamValue>} paramChanges
446
- * @returns {Promise<void>}
447
- */
448
-
449
- /**
450
- * These are typed `any` because the builder pattern of paramManager makes it very
451
- * complicated for the type system to know the set of param-specific functions
452
- * returned by `.build()`. Instead we let paramManager create the desired methods
453
- * and use typedParamManager to create a version that includes the static types.
454
- *
455
- * @typedef {Record<string, any>} ParamManagerGettersAndUpdaters
456
- * @typedef {ParamManagerBase & ParamManagerGettersAndUpdaters & {updateParams: UpdateParams}} AnyParamManager
457
- */
458
-
459
- /**
460
- * @typedef {Record<string, string[]>} ParameterNameList
461
- */
462
-
463
- /**
464
- * @callback AssertParamManagerType
465
- * @param {ParamType} type
466
- * @param {ParamValue} value
467
- * @param {string} name
468
- */
469
-
470
- /**
471
- * @callback BuildParamManager - ParamManager is a facility that governed
472
- * contracts can use to manage their visible state in a way that allows the
473
- * ContractGovernor to update values using governance. When paramManager is
474
- * instantiated inside the contract, the contract has synchronous access to
475
- * the values, and clients of the contract can verify that a ContractGovernor
476
- * can change the values in a legible way.
477
- * @param {Iterable<ParamValueTyped>} paramDescriptions
478
- * @returns {AnyParamManager}
479
- */
480
-
481
- /**
482
- * @typedef {object} ChangeParamsPosition
483
- * @property {Record<string,ParamValue>} changes one or more changes to parameters
484
- */
485
-
486
- /**
487
- * @typedef {object} OfferFilterPosition
488
- * @property {string[]} strings
489
- */
490
-
491
- /**
492
- * @typedef {object} NoChangeOfferFilterPosition
493
- * @property {string[]} dontUpdate
494
- */
495
-
496
- /**
497
- * @typedef {object} InvokeApiPosition
498
- * @property {string} apiMethodName
499
- * @property {unknown[]} methodArgs
500
- */
501
-
502
- /**
503
- * @typedef {object} DontInvokeApiPosition
504
- * @property {string} dontInvoke
505
- */
506
-
507
- /**
508
- * @typedef {object} NoChangeParamsPosition
509
- * @property {string[]} noChange Parameters in the proposal that this position
510
- * is opposed to
511
- */
512
-
513
- /**
514
- * @typedef {object} Governor
515
- * @property {CreateQuestion} createQuestion
516
- */
517
-
518
- /** @typedef {{ [methodName: string]: (...args: any) => unknown }} GovernedApis */
519
-
520
- /**
521
- * @typedef {object} GovernorPublic
522
- * @property {() => Promise<Instance>} getElectorate
523
- * @property {() => Instance} getGovernedContract
524
- * @property {(voteCounter: Instance) => Promise<void>} validateVoteCounter
525
- * @property {(regP: ERef<Instance>) => Promise<void>} validateElectorate
526
- * @property {(closingRule: ClosingRule) => void} validateTimer
527
- */
528
-
529
- /**
530
- * @typedef {object} ParamKey identifier for a paramManager within a contract
531
- * @property {unknown} key
532
- */
533
-
534
- /**
535
- * Description of a set of coordinated changes for a ParamManager
536
- *
537
- * @template P path for a paramManagerRetriever
538
- * @typedef {object} ParamChangesSpec<P>
539
- * @property {P} paramPath
540
- * @property {Record<string, ParamValue>} changes one or more changes to parameters
541
- */
542
-
543
- /**
544
- * @typedef {object} ContractGovernanceVoteResult
545
- * @property {Instance} instance - instance of the VoteCounter
546
- * @property {ERef<QuestionDetails>} details
547
- * @property {Promise<ParamValue>} outcomeOfUpdate - A promise for the result
548
- * of updating the parameter value. Primarily useful for its behavior on
549
- * rejection.
550
- */
551
-
552
- /**
553
- * @template {GovernableStartFn} SF Start function of governed contract
554
- * @typedef {object} GovernorCreatorFacet
555
- * @property {VoteOnParamChanges} voteOnParamChanges
556
- * @property {VoteOnApiInvocation} voteOnApiInvocation
557
- * @property {VoteOnOfferFilter} voteOnOfferFilter
558
- * @property {() => LimitedCF<SF>} getCreatorFacet facet of the governed contract,
559
- * with creator-like powers but without the tightly held ability to change
560
- * param values.
561
- * @property {(poserInvitation: Invitation) => Promise<void>} replaceElectorate
562
- * @property {() => AdminFacet} getAdminFacet
563
- * @property {() => GovernedPublicFacet<Awaited<ReturnType<SF>>['publicFacet']>} getPublicFacet - public facet of the governed contract
564
- * @property {() => Instance} getInstance - instance of the governed
565
- * contract
566
- */
567
-
568
- /**
569
- * @typedef GovernedPublicFacetMethods
570
- * @property {(key?: any) => StoredSubscription<GovernanceSubscriptionState>} getSubscription
571
- * @property {(key?: any) => ERef<ParamStateRecord>} getGovernedParams - get descriptions of
572
- * all the governed parameters
573
- * @property {(name: string) => Amount} getInvitationAmount
574
- */
575
-
576
- /**
577
- * @template {{}} PF Public facet
578
- * @typedef {PF & GovernedPublicFacetMethods} GovernedPublicFacet
579
- */
580
-
581
- /**
582
- * @template {GovernableStartFn} SF
583
- * @typedef {ReturnType<Awaited<ReturnType<SF>>['creatorFacet']['getLimitedCreatorFacet']>} LimitedCF
584
- */
585
-
586
- /**
587
- * @template {{}} CF creator facet
588
- * @typedef GovernedCreatorFacet
589
- * What a governed contract must return as its creatorFacet in order to be governed
590
- * @property {() => ParamManagerRetriever} getParamMgrRetriever - allows accessing
591
- * and updating governed parameters. Should only be directly accessible to the
592
- * contractGovernor
593
- * @property {() => ERef<CF>} getLimitedCreatorFacet - the creator
594
- * facet of the governed contract. Doesn't provide access to any governance
595
- * functionality
596
- * @property {(name: string) => Promise<Invitation>} getInvitation
597
- * @property {() => ERef<GovernedApis>} getGovernedApis
598
- * @property {() => (string | symbol)[]} getGovernedApiNames
599
- * @property {(strings: string[]) => void} setOfferFilter
600
- */
601
-
602
- /**
603
- * @typedef {{key: string}} StandardParamPath
604
- */
605
-
606
- /**
607
- * @typedef {object} ParamManagerRetriever
608
- * @property {(paramKey?: ParamKey) => AnyParamManager} get
609
- */
610
-
611
- /**
612
- * @template [P=StandardParamPath]
613
- *
614
- * @callback VoteOnParamChanges
615
- * @param {Installation} voteCounterInstallation
616
- * @param {import('@agoric/time/src/types').Timestamp} deadline
617
- * @param {ParamChangesSpec<P>} paramSpec
618
- * @returns {ContractGovernanceVoteResult}
619
- */
620
-
621
- /**
622
- * @callback VoteOnApiInvocation
623
- * @param {string} apiMethodName
624
- * @param {unknown[]} methodArgs
625
- * @param {Installation} voteCounterInstallation
626
- * @param {import('@agoric/time/src/types').Timestamp} deadline
627
- * @returns {Promise<ContractGovernanceVoteResult>}
628
- */
629
-
630
- /**
631
- * @callback VoteOnOfferFilter
632
- * @param {Installation} voteCounterInstallation
633
- * @param {import('@agoric/time/src/types').Timestamp} deadline
634
- * @param {string[]} strings
635
- * @returns {ContractGovernanceVoteResult}
636
- */
637
-
638
- /**
639
- * @typedef {object} ParamGovernor
640
- * @property {VoteOnParamChanges} voteOnParamChanges
641
- * @property {CreatedQuestion} createdQuestion
642
- */
643
-
644
- /**
645
- * @typedef {object} ApiGovernor
646
- * @property {VoteOnApiInvocation} voteOnApiInvocation
647
- * @property {CreatedQuestion} createdQuestion
648
- */
649
-
650
- /**
651
- * @typedef {object} FilterGovernor
652
- * @property {VoteOnOfferFilter} voteOnFilter
653
- * @property {CreatedQuestion} createdQuestion
654
- */
655
-
656
- /**
657
- * @callback CreatedQuestion
658
- * Was this question created by this ContractGovernor?
659
- * @param {Instance} questionInstance
660
- * @returns {boolean}
661
- */
662
-
663
- /**
664
- * @callback PositionIncluded
665
- * @param {Position[]} positions
666
- * @param {Position} position
667
- * @returns {boolean}
668
- */
669
-
670
- /**
671
- * @typedef {object} GovernedContractTerms
672
- * @property {import('@agoric/time/src/types').TimerService} timer
673
- * @property {IssuerKeywordRecord} issuerKeywordRecord
674
- * @property {object} privateArgs
675
- */
676
-
677
- /**
678
- * @callback AssertContractGovernance
679
- *
680
- * @param {ERef<ZoeService>} zoe
681
- * @param {import('@agoric/zoe/src/zoeService/utils.js').Instance<(zcf: ZCF<GovernanceTerms<{}>>) => {}>} allegedGoverned
682
- * @param {Instance} allegedGovernor
683
- * @param {Installation<import('@agoric/governance/src/contractGovernor.js').prepare>} contractGovernorInstallation
684
- * @returns {Promise<GovernancePair>}
685
- */
686
-
687
- /**
688
- * @callback AssertContractElectorate - assert that the contract uses the
689
- * electorate
690
- *
691
- * @param {ERef<ZoeService>} zoe
692
- * @param {Instance} allegedGovernor
693
- * @param {Instance} allegedElectorate
694
- */
695
-
696
- /**
697
- * @typedef {import('@agoric/zoe/src/zoeService/utils.js').ContractStartFunction
698
- * & ((zcf?: any, pa?: any, baggage?: any) => ERef<{creatorFacet: GovernedCreatorFacet<{}>, publicFacet: GovernedPublicFacet<{}>}>)} GovernableStartFn
699
- */
700
-
701
- /**
702
- * @typedef {import('./contractGovernor.js')['prepare']} GovernorSF
703
- */
704
-
705
- // TODO find a way to parameterize the startInstance so the governed contract types flow
706
- /**
707
- * @see {StartedInstanceKit}
708
- * @template {ERef<Installation<GovernableStartFn>>} I
709
- * @typedef GovernorStartedInstallationKit
710
- * Same result as StartedInstanceKit but:
711
- * - typed for contractGovernor installation being started by Zoe. (It in turn starts the governed contract.)
712
- * - parameterized by Installation instead of StartFunction
713
- * @property {import('@agoric/zoe/src/zoeService/utils.js').Instance<GovernorSF>} instance
714
- * @property {AdminFacet} adminFacet
715
- * @property {GovernorCreatorFacet<InstallationStart<Awaited<I>>>} creatorFacet
716
- * @property {GovernorPublic} publicFacet
717
- */
718
-
719
- /**
720
- * @see {StartedInstanceKit}
721
- * @template {GovernableStartFn} SF
722
- * @typedef GovernanceFacetKit
723
- * Akin to StartedInstanceKit but designed for the results of starting governed contracts. Used in bootstrap space.
724
- * @property {AdminFacet} adminFacet of the governed contract
725
- * @property {LimitedCF<SF>} creatorFacet creator-like facet within the governed contract (without the powers the governor needs)
726
- * @property {GovernorCreatorFacet<SF>} governorCreatorFacet of the governing contract
727
- * @property {AdminFacet} governorAdminFacet of the governing contract
728
- * @property {Awaited<ReturnType<SF>>['publicFacet']} publicFacet
729
- * @property {Instance} instance
730
- * @property {Instance} governor
731
- */