@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.
- package/exported.d.ts +32 -0
- package/exported.js +1 -1
- package/package.json +35 -29
- package/src/binaryVoteCounter.d.ts +6 -3
- package/src/binaryVoteCounter.d.ts.map +1 -1
- package/src/binaryVoteCounter.js +6 -2
- package/src/breakTie.d.ts +1 -0
- package/src/breakTie.d.ts.map +1 -1
- package/src/breakTie.js +4 -0
- package/src/closingRule.d.ts +4 -0
- package/src/closingRule.d.ts.map +1 -1
- package/src/closingRule.js +4 -0
- package/src/committee.d.ts +12 -8
- package/src/committee.d.ts.map +1 -1
- package/src/committee.js +24 -11
- package/src/constants.d.ts +12 -12
- package/src/constants.d.ts.map +1 -1
- package/src/contractGovernance/governApi.d.ts +11 -8
- package/src/contractGovernance/governApi.d.ts.map +1 -1
- package/src/contractGovernance/governApi.js +8 -3
- package/src/contractGovernance/governFilter.d.ts +8 -2
- package/src/contractGovernance/governFilter.d.ts.map +1 -1
- package/src/contractGovernance/governFilter.js +5 -1
- package/src/contractGovernance/governParam.d.ts +9 -2
- package/src/contractGovernance/governParam.d.ts.map +1 -1
- package/src/contractGovernance/governParam.js +6 -1
- package/src/contractGovernance/paramManager.d.ts +13 -9
- package/src/contractGovernance/paramManager.d.ts.map +1 -1
- package/src/contractGovernance/paramManager.js +18 -14
- package/src/contractGovernance/typedParamManager.d.ts +19 -10
- package/src/contractGovernance/typedParamManager.d.ts.map +1 -1
- package/src/contractGovernance/typedParamManager.js +5 -0
- package/src/contractGovernor.d.ts +11 -5
- package/src/contractGovernor.d.ts.map +1 -1
- package/src/contractGovernor.js +19 -9
- package/src/contractGovernorKit.d.ts +14 -48
- package/src/contractGovernorKit.d.ts.map +1 -1
- package/src/contractGovernorKit.js +56 -10
- package/src/contractHelper.d.ts +68 -78
- package/src/contractHelper.d.ts.map +1 -1
- package/src/contractHelper.js +21 -21
- package/src/electorateTools.d.ts +21 -17
- package/src/electorateTools.d.ts.map +1 -1
- package/src/electorateTools.js +20 -12
- package/src/index.js +3 -6
- package/src/multiCandidateVoteCounter.d.ts +6 -3
- package/src/multiCandidateVoteCounter.d.ts.map +1 -1
- package/src/multiCandidateVoteCounter.js +8 -4
- package/src/noActionElectorate.d.ts +6 -1
- package/src/noActionElectorate.d.ts.map +1 -1
- package/src/noActionElectorate.js +11 -2
- package/src/question.d.ts +15 -11
- package/src/question.d.ts.map +1 -1
- package/src/question.js +5 -0
- package/src/quorumCounter.d.ts +1 -1
- package/src/quorumCounter.d.ts.map +1 -1
- package/src/quorumCounter.js +4 -0
- package/src/typeGuards.d.ts +91 -54
- package/src/typeGuards.d.ts.map +1 -1
- package/src/types.d.ts +59 -62
- package/src/types.d.ts.map +1 -1
- package/src/types.js +35 -27
- package/src/validators.d.ts +5 -0
- package/src/validators.d.ts.map +1 -1
- package/src/validators.js +6 -3
- package/src/voterKit.d.ts +6 -11
- package/src/voterKit.d.ts.map +1 -1
- package/src/voterKit.js +4 -0
- package/tools/puppetContractGovernor.d.ts +15 -11
- package/tools/puppetContractGovernor.d.ts.map +1 -1
- package/tools/puppetContractGovernor.js +7 -5
- package/tools/puppetGovernance.d.ts +31 -30
- package/tools/puppetGovernance.d.ts.map +1 -1
- package/tools/puppetGovernance.js +6 -4
- package/tools/storageDoc.d.ts +3 -3
- package/tools/storageDoc.d.ts.map +1 -1
- package/CHANGELOG.md +0 -456
- package/src/types-ambient.d.ts +0 -1047
- package/src/types-ambient.d.ts.map +0 -1
- package/src/types-ambient.js +0 -731
package/src/types-ambient.d.ts
DELETED
|
@@ -1,1047 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* * UNRANKED: "unranked voting" means that the voter specifies some number of
|
|
3
|
-
* positions, and is endorsing them equally.
|
|
4
|
-
* * ORDER: The voter assigns ordinal numbers to some of the positions. The
|
|
5
|
-
* positions will be treated as an ordered list with no gaps.
|
|
6
|
-
*
|
|
7
|
-
* When voters are limited to choosing a single candidate, either UNRANKED or
|
|
8
|
-
* ORDER would work. UNRANKED has a simpler representation so we use that.
|
|
9
|
-
*/
|
|
10
|
-
type ChoiceMethod = 'unranked' | 'order' | 'plurality';
|
|
11
|
-
/**
|
|
12
|
-
* param_change is very specific. Survey means multiple answers are possible,
|
|
13
|
-
* Election means some candidates are going to "win". It's not clear these are
|
|
14
|
-
* orthogonal. The important distinction is that param_change has a structured
|
|
15
|
-
* issue, while the others have a issue presented as a string.
|
|
16
|
-
*/
|
|
17
|
-
type ElectionType = 'param_change' | 'election' | 'survey' | 'api_invocation' | 'offer_filter';
|
|
18
|
-
type ParamType = import('./constants.js').ParamType;
|
|
19
|
-
type QuorumRule = 'majority' | 'all' | 'no_quorum';
|
|
20
|
-
type SimpleIssue = {
|
|
21
|
-
text: string;
|
|
22
|
-
};
|
|
23
|
-
type ParamValue = Amount | Brand | Installation | Instance | bigint | Ratio | string | import('@agoric/time/src/types').TimestampRecord | import('@agoric/time/src/types').RelativeTimeRecord | unknown;
|
|
24
|
-
type ParamValueForType<T extends import("./constants.js").ParamType> = T extends 'amount' ? Amount<any> : T extends 'brand' ? Brand : T extends 'installation' ? Installation : T extends 'instance' ? Instance : T extends 'invitation' ? Amount<'set'> : T extends 'nat' ? bigint : T extends 'ratio' ? Ratio : T extends 'string' ? string : T extends 'timestamp' ? import('@agoric/time').Timestamp : T extends 'relativeTime' ? import('@agoric/time').RelativeTime : T extends 'unknown' ? unknown : never;
|
|
25
|
-
/**
|
|
26
|
-
* <T>
|
|
27
|
-
*/
|
|
28
|
-
type ParamValueTyped<T extends import("./constants.js").ParamType = import("./constants.js").ParamType> = {
|
|
29
|
-
type: T;
|
|
30
|
-
value: ParamValueForType<T>;
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* <T>
|
|
34
|
-
*/
|
|
35
|
-
type GovernanceTerms<T extends import("./contractGovernance/typedParamManager.js").ParamTypesMap> = {
|
|
36
|
-
electionManager: import('@agoric/zoe/src/zoeService/utils.js').Instance<typeof import("./contractGovernor.js")['prepare']>;
|
|
37
|
-
governedParams: import('./contractGovernance/typedParamManager.js').ParamRecordsFromTypes<T & {
|
|
38
|
-
Electorate: 'invitation';
|
|
39
|
-
}>;
|
|
40
|
-
};
|
|
41
|
-
type Issue = SimpleIssue | ParamChangeIssue<unknown> | ApiInvocationIssue | OfferFilterIssue;
|
|
42
|
-
/**
|
|
43
|
-
* - QuestionSpec plus the Electorate Instance and
|
|
44
|
-
* a numerical threshold for the quorum. (The voteCounter doesn't know the
|
|
45
|
-
* size of the electorate, so the Electorate has to say what limit to enforce.)
|
|
46
|
-
*/
|
|
47
|
-
type QuestionTerms = {
|
|
48
|
-
questionSpec: QuestionSpec;
|
|
49
|
-
quorumThreshold: number;
|
|
50
|
-
electorate: Instance;
|
|
51
|
-
};
|
|
52
|
-
type TextPosition = {
|
|
53
|
-
text: string;
|
|
54
|
-
};
|
|
55
|
-
type Position = TextPosition | ChangeParamsPosition | NoChangeParamsPosition | InvokeApiPosition | DontInvokeApiPosition | OfferFilterPosition | NoChangeOfferFilterPosition | InvokeApiPosition;
|
|
56
|
-
type OutcomeRecord = {
|
|
57
|
-
question: Handle<'Question'>;
|
|
58
|
-
} & ({
|
|
59
|
-
outcome: 'win';
|
|
60
|
-
position: Position;
|
|
61
|
-
} | {
|
|
62
|
-
outcome: 'fail';
|
|
63
|
-
reason: 'No quorum';
|
|
64
|
-
});
|
|
65
|
-
type MultiOutcomeRecord = {
|
|
66
|
-
question: Handle<'Question'>;
|
|
67
|
-
} & ({
|
|
68
|
-
outcome: 'win';
|
|
69
|
-
positions: Position[];
|
|
70
|
-
} | {
|
|
71
|
-
outcome: 'fail';
|
|
72
|
-
reason: 'No quorum';
|
|
73
|
-
});
|
|
74
|
-
/**
|
|
75
|
-
* Specification when requesting creation of a Question
|
|
76
|
-
*/
|
|
77
|
-
type QuestionSpec<I extends Issue = Issue> = {
|
|
78
|
-
method: ChoiceMethod;
|
|
79
|
-
issue: I;
|
|
80
|
-
positions: Position[];
|
|
81
|
-
electionType: ElectionType;
|
|
82
|
-
maxChoices: number;
|
|
83
|
-
maxWinners: number;
|
|
84
|
-
closingRule: ClosingRule;
|
|
85
|
-
quorumRule: QuorumRule;
|
|
86
|
-
tieOutcome: Position;
|
|
87
|
-
};
|
|
88
|
-
type QuestionDetailsExtraProperties = {
|
|
89
|
-
/**
|
|
90
|
-
* - instance of the VoteCounter
|
|
91
|
-
*/
|
|
92
|
-
counterInstance: Instance;
|
|
93
|
-
questionHandle: Handle<'Question'>;
|
|
94
|
-
};
|
|
95
|
-
/**
|
|
96
|
-
* complete question details: questionSpec plus counter and questionHandle
|
|
97
|
-
*/
|
|
98
|
-
type QuestionDetails = QuestionSpec & QuestionDetailsExtraProperties;
|
|
99
|
-
type GovernancePair = {
|
|
100
|
-
governor: Instance;
|
|
101
|
-
governed: Instance;
|
|
102
|
-
};
|
|
103
|
-
type Question = {
|
|
104
|
-
getVoteCounter: () => Instance;
|
|
105
|
-
getDetails: () => QuestionDetails;
|
|
106
|
-
};
|
|
107
|
-
type CompleteUnrankedQuestion = {
|
|
108
|
-
questionHandle: Handle<'Question'>;
|
|
109
|
-
/**
|
|
110
|
-
* - a list of equal-weight preferred positions
|
|
111
|
-
*/
|
|
112
|
-
chosen: Position[];
|
|
113
|
-
};
|
|
114
|
-
type CompleteWeightedBallot = {
|
|
115
|
-
questionHandle: Handle<'Question'>;
|
|
116
|
-
/**
|
|
117
|
-
* - list of positions with
|
|
118
|
-
* weights. VoteCounter may limit weights to a range or require uniqueness.
|
|
119
|
-
*/
|
|
120
|
-
weighted: [Position, bigint][];
|
|
121
|
-
};
|
|
122
|
-
type CompleteOrderedBallot = {
|
|
123
|
-
questionHandle: Handle<'Question'>;
|
|
124
|
-
/**
|
|
125
|
-
* - ordered list of position from most preferred
|
|
126
|
-
* to least preferred
|
|
127
|
-
*/
|
|
128
|
-
ordered: Position[];
|
|
129
|
-
};
|
|
130
|
-
type PositionCount = {
|
|
131
|
-
position: Position;
|
|
132
|
-
total: bigint;
|
|
133
|
-
};
|
|
134
|
-
type VoteStatistics = {
|
|
135
|
-
spoiled: bigint;
|
|
136
|
-
votes: number;
|
|
137
|
-
results: PositionCount[];
|
|
138
|
-
};
|
|
139
|
-
type QuorumCounter = {
|
|
140
|
-
check: (stats: VoteStatistics) => boolean;
|
|
141
|
-
};
|
|
142
|
-
type BuildQuestion = (questionSpec: QuestionSpec, instance: Instance) => Question;
|
|
143
|
-
/**
|
|
144
|
-
* - a facet that the Electorate should
|
|
145
|
-
* hold tightly. submitVote() is the core capability that allows the holder to
|
|
146
|
-
* specify the identity and choice of a voter. The voteCounter is making that
|
|
147
|
-
* available to the Electorate, which should wrap and attenuate it so each
|
|
148
|
-
* voter gets only the ability to cast their own vote at a weight specified by
|
|
149
|
-
* the electorate.
|
|
150
|
-
*/
|
|
151
|
-
type VoteCounterCreatorFacet = {
|
|
152
|
-
submitVote: SubmitVote;
|
|
153
|
-
};
|
|
154
|
-
type VoteCounterPublicFacet = {
|
|
155
|
-
isOpen: () => boolean;
|
|
156
|
-
getQuestion: () => Question;
|
|
157
|
-
getOutcome: () => Promise<Position>;
|
|
158
|
-
getDetails: () => QuestionDetails;
|
|
159
|
-
getStats: () => Promise<VoteStatistics>;
|
|
160
|
-
};
|
|
161
|
-
type MultiVoteCounterPublicFacet = {
|
|
162
|
-
isOpen: () => boolean;
|
|
163
|
-
getQuestion: () => Question;
|
|
164
|
-
getOutcome: () => Promise<Position[]>;
|
|
165
|
-
getDetails: () => QuestionDetails;
|
|
166
|
-
getStats: () => Promise<VoteStatistics>;
|
|
167
|
-
};
|
|
168
|
-
/**
|
|
169
|
-
* TEST ONLY: Should not be allowed to escape from contracts
|
|
170
|
-
*/
|
|
171
|
-
type VoteCounterCloseFacet = {
|
|
172
|
-
closeVoting: () => void;
|
|
173
|
-
};
|
|
174
|
-
type VoteCounterFacets = {
|
|
175
|
-
publicFacet: VoteCounterPublicFacet;
|
|
176
|
-
creatorFacet: VoteCounterCreatorFacet;
|
|
177
|
-
closeFacet: VoteCounterCloseFacet;
|
|
178
|
-
};
|
|
179
|
-
type MultiVoteCounterFacets = {
|
|
180
|
-
publicFacet: MultiVoteCounterPublicFacet;
|
|
181
|
-
creatorFacet: VoteCounterCreatorFacet;
|
|
182
|
-
closeFacet: VoteCounterCloseFacet;
|
|
183
|
-
};
|
|
184
|
-
type BuildVoteCounter = (questionSpec: QuestionSpec, threshold: bigint, instance: Instance, publisher: ERef<Publisher<OutcomeRecord>>) => VoteCounterFacets;
|
|
185
|
-
type BuildMultiVoteCounter = (questionSpec: QuestionSpec, threshold: bigint, instance: Instance, publisher: ERef<Publisher<MultiOutcomeRecord>>) => MultiVoteCounterFacets;
|
|
186
|
-
type CompletedBallet = {
|
|
187
|
-
chosen: Position;
|
|
188
|
-
shares: bigint;
|
|
189
|
-
};
|
|
190
|
-
type SubmitVote = (voterHandle: Handle<'Voter'>, chosenPositions: Position[], weight?: bigint | undefined) => CompletedBallet;
|
|
191
|
-
type GetOpenQuestions = () => Promise<Handle<'Question'>[]>;
|
|
192
|
-
type GetQuestion = (h: Handle<'Question'>) => Promise<Question>;
|
|
193
|
-
type ElectoratePublic = {
|
|
194
|
-
getQuestionSubscriber: () => Subscriber<QuestionDetails>;
|
|
195
|
-
/**
|
|
196
|
-
* ,
|
|
197
|
-
*/
|
|
198
|
-
getOpenQuestions: GetOpenQuestions;
|
|
199
|
-
getInstance: () => Instance;
|
|
200
|
-
getQuestion: GetQuestion;
|
|
201
|
-
};
|
|
202
|
-
type ClaimsElectoratePublic = ElectoratePublic & {
|
|
203
|
-
makeVoterInvitation: () => ERef<Invitation>;
|
|
204
|
-
};
|
|
205
|
-
type CommitteeElectoratePublic = ElectoratePublic & {
|
|
206
|
-
getName: () => string;
|
|
207
|
-
};
|
|
208
|
-
type PoserFacet = {
|
|
209
|
-
addQuestion: AddQuestion;
|
|
210
|
-
};
|
|
211
|
-
type ElectorateCreatorFacet = {
|
|
212
|
-
/**
|
|
213
|
-
* can be used directly when the creator doesn't need any
|
|
214
|
-
* reassurance. When someone needs to connect addQuestion to the Electorate
|
|
215
|
-
* instance, getPoserInvitation() lets them get addQuestion with assurance.
|
|
216
|
-
*/
|
|
217
|
-
addQuestion: AddQuestion;
|
|
218
|
-
getPoserInvitation: () => Promise<Invitation>;
|
|
219
|
-
getQuestionSubscriber: () => Subscriber<QuestionDetails>;
|
|
220
|
-
getPublicFacet: () => ElectoratePublic;
|
|
221
|
-
};
|
|
222
|
-
type GetVoterInvitations = {
|
|
223
|
-
getVoterInvitations: () => Invitation[];
|
|
224
|
-
};
|
|
225
|
-
/**
|
|
226
|
-
* - a facet that the Electorate should hold
|
|
227
|
-
* tightly. It allows specification of the vote's weight, so the Electorate
|
|
228
|
-
* should distribute an attenuated wrapper that doesn't make that available!
|
|
229
|
-
*/
|
|
230
|
-
type VoterFacet = {
|
|
231
|
-
submitVote: SubmitVote;
|
|
232
|
-
};
|
|
233
|
-
type ClosingRule = {
|
|
234
|
-
timer: ERef<Timer>;
|
|
235
|
-
deadline: import('@agoric/time/src/types').Timestamp;
|
|
236
|
-
};
|
|
237
|
-
type CloseVoting = (closingRule: ClosingRule, closeVoting: () => void) => any;
|
|
238
|
-
type AddQuestionReturn = {
|
|
239
|
-
publicFacet: VoteCounterPublicFacet;
|
|
240
|
-
creatorFacet: VoteCounterCreatorFacet;
|
|
241
|
-
instance: import('@agoric/zoe/src/zoeService/utils.js').Instance<typeof import('./binaryVoteCounter.js').start>;
|
|
242
|
-
deadline: import('@agoric/time/src/types').Timestamp;
|
|
243
|
-
questionHandle: Handle<'Question'>;
|
|
244
|
-
};
|
|
245
|
-
type AddQuestion = (voteCounter: ERef<Installation>, questionSpec: QuestionSpec) => Promise<AddQuestionReturn>;
|
|
246
|
-
type CreateQuestion = (name: string, proposedValue: ParamValue, voteCounterInstallation: Installation, contractInstance: Instance, closingRule: ClosingRule) => Promise<QuestionDetails>;
|
|
247
|
-
type ParamChangeIssue<P = StandardParamPath> = {
|
|
248
|
-
spec: ParamChangesSpec<P>;
|
|
249
|
-
contract: import("@agoric/zoe/src/zoeService/utils.js").Instance<(zcf: ZCF<GovernanceTerms<{}>>) => {}>;
|
|
250
|
-
};
|
|
251
|
-
type ApiInvocationIssue = {
|
|
252
|
-
apiMethodName: string;
|
|
253
|
-
methodArgs: unknown[];
|
|
254
|
-
};
|
|
255
|
-
type OfferFilterIssue = {
|
|
256
|
-
strings: string[];
|
|
257
|
-
};
|
|
258
|
-
type ParamChangePositions = {
|
|
259
|
-
positive: ChangeParamsPosition;
|
|
260
|
-
negative: NoChangeParamsPosition;
|
|
261
|
-
};
|
|
262
|
-
/**
|
|
263
|
-
* details for a question that can change a contract parameter
|
|
264
|
-
*/
|
|
265
|
-
type ParamChangeIssueDetails = {
|
|
266
|
-
method: ChoiceMethod;
|
|
267
|
-
issue: ParamChangeIssue<unknown>;
|
|
268
|
-
positions: ParamChangePositions;
|
|
269
|
-
electionType: ElectionType;
|
|
270
|
-
maxChoices: number;
|
|
271
|
-
closingRule: ClosingRule;
|
|
272
|
-
quorumRule: QuorumRule;
|
|
273
|
-
tieOutcome: NoChangeParamsPosition;
|
|
274
|
-
/**
|
|
275
|
-
* - instance of the VoteCounter
|
|
276
|
-
*/
|
|
277
|
-
counterInstance: Instance;
|
|
278
|
-
questionHandle: Handle<'Question'>;
|
|
279
|
-
};
|
|
280
|
-
/**
|
|
281
|
-
* a Record containing
|
|
282
|
-
* keyword pairs with descriptions of parameters under governance.
|
|
283
|
-
*/
|
|
284
|
-
type ParamStateRecord = Record<Keyword, ParamValueTyped>;
|
|
285
|
-
type GovernanceSubscriptionState = {
|
|
286
|
-
current: ParamStateRecord;
|
|
287
|
-
};
|
|
288
|
-
/**
|
|
289
|
-
* The base paramManager with typed getters
|
|
290
|
-
*/
|
|
291
|
-
type ParamManagerBase = {
|
|
292
|
-
getParams: () => ERef<ParamStateRecord>;
|
|
293
|
-
getAmount: (name: string) => Amount;
|
|
294
|
-
getBrand: (name: string) => Brand;
|
|
295
|
-
getInstance: (name: string) => Instance;
|
|
296
|
-
getInstallation: (name: string) => Installation;
|
|
297
|
-
getInvitationAmount: (name: string) => Amount<'set'>;
|
|
298
|
-
getNat: (name: string) => bigint;
|
|
299
|
-
getRatio: (name: string) => Ratio;
|
|
300
|
-
getString: (name: string) => string;
|
|
301
|
-
getTimestamp: (name: string) => import('@agoric/time/src/types').TimestampRecord;
|
|
302
|
-
getRelativeTime: (name: string) => import('@agoric/time/src/types').RelativeTimeRecord;
|
|
303
|
-
getUnknown: (name: string) => any;
|
|
304
|
-
/**
|
|
305
|
-
* - for
|
|
306
|
-
* most types, the visible value is the same as proposedValue. For Invitations
|
|
307
|
-
* the visible value is the amount of the invitation.
|
|
308
|
-
*/
|
|
309
|
-
getVisibleValue: (name: string, proposedValue: ParamValue) => ParamValue;
|
|
310
|
-
getInternalParamValue: (name: string) => Promise<Invitation>;
|
|
311
|
-
getSubscription: () => StoredSubscription<GovernanceSubscriptionState>;
|
|
312
|
-
};
|
|
313
|
-
type UpdateParams = (paramChanges: Record<string, ParamValue>) => Promise<void>;
|
|
314
|
-
/**
|
|
315
|
-
* These are typed `any` because the builder pattern of paramManager makes it very
|
|
316
|
-
* complicated for the type system to know the set of param-specific functions
|
|
317
|
-
* returned by `.build()`. Instead we let paramManager create the desired methods
|
|
318
|
-
* and use typedParamManager to create a version that includes the static types.
|
|
319
|
-
*/
|
|
320
|
-
type ParamManagerGettersAndUpdaters = Record<string, any>;
|
|
321
|
-
/**
|
|
322
|
-
* These are typed `any` because the builder pattern of paramManager makes it very
|
|
323
|
-
* complicated for the type system to know the set of param-specific functions
|
|
324
|
-
* returned by `.build()`. Instead we let paramManager create the desired methods
|
|
325
|
-
* and use typedParamManager to create a version that includes the static types.
|
|
326
|
-
*/
|
|
327
|
-
type AnyParamManager = ParamManagerBase & ParamManagerGettersAndUpdaters & {
|
|
328
|
-
updateParams: UpdateParams;
|
|
329
|
-
};
|
|
330
|
-
type ParameterNameList = Record<string, string[]>;
|
|
331
|
-
type AssertParamManagerType = (type: ParamType, value: ParamValue, name: string) => any;
|
|
332
|
-
/**
|
|
333
|
-
* - ParamManager is a facility that governed
|
|
334
|
-
* contracts can use to manage their visible state in a way that allows the
|
|
335
|
-
* ContractGovernor to update values using governance. When paramManager is
|
|
336
|
-
* instantiated inside the contract, the contract has synchronous access to
|
|
337
|
-
* the values, and clients of the contract can verify that a ContractGovernor
|
|
338
|
-
* can change the values in a legible way.
|
|
339
|
-
*/
|
|
340
|
-
type BuildParamManager = (paramDescriptions: Iterable<ParamValueTyped>) => AnyParamManager;
|
|
341
|
-
type ChangeParamsPosition = {
|
|
342
|
-
/**
|
|
343
|
-
* one or more changes to parameters
|
|
344
|
-
*/
|
|
345
|
-
changes: Record<string, ParamValue>;
|
|
346
|
-
};
|
|
347
|
-
type OfferFilterPosition = {
|
|
348
|
-
strings: string[];
|
|
349
|
-
};
|
|
350
|
-
type NoChangeOfferFilterPosition = {
|
|
351
|
-
dontUpdate: string[];
|
|
352
|
-
};
|
|
353
|
-
type InvokeApiPosition = {
|
|
354
|
-
apiMethodName: string;
|
|
355
|
-
methodArgs: unknown[];
|
|
356
|
-
};
|
|
357
|
-
type DontInvokeApiPosition = {
|
|
358
|
-
dontInvoke: string;
|
|
359
|
-
};
|
|
360
|
-
type NoChangeParamsPosition = {
|
|
361
|
-
/**
|
|
362
|
-
* Parameters in the proposal that this position
|
|
363
|
-
* is opposed to
|
|
364
|
-
*/
|
|
365
|
-
noChange: string[];
|
|
366
|
-
};
|
|
367
|
-
type Governor = {
|
|
368
|
-
createQuestion: CreateQuestion;
|
|
369
|
-
};
|
|
370
|
-
type GovernedApis = {
|
|
371
|
-
[methodName: string]: (...args: any) => unknown;
|
|
372
|
-
};
|
|
373
|
-
type GovernorPublic = {
|
|
374
|
-
getElectorate: () => Promise<Instance>;
|
|
375
|
-
getGovernedContract: () => Instance;
|
|
376
|
-
validateVoteCounter: (voteCounter: Instance) => Promise<void>;
|
|
377
|
-
validateElectorate: (regP: ERef<Instance>) => Promise<void>;
|
|
378
|
-
validateTimer: (closingRule: ClosingRule) => void;
|
|
379
|
-
};
|
|
380
|
-
/**
|
|
381
|
-
* identifier for a paramManager within a contract
|
|
382
|
-
*/
|
|
383
|
-
type ParamKey = {
|
|
384
|
-
key: unknown;
|
|
385
|
-
};
|
|
386
|
-
/**
|
|
387
|
-
* <P>
|
|
388
|
-
*/
|
|
389
|
-
type ParamChangesSpec<P> = {
|
|
390
|
-
paramPath: P;
|
|
391
|
-
/**
|
|
392
|
-
* one or more changes to parameters
|
|
393
|
-
*/
|
|
394
|
-
changes: Record<string, ParamValue>;
|
|
395
|
-
};
|
|
396
|
-
type ContractGovernanceVoteResult = {
|
|
397
|
-
/**
|
|
398
|
-
* - instance of the VoteCounter
|
|
399
|
-
*/
|
|
400
|
-
instance: Instance;
|
|
401
|
-
details: ERef<QuestionDetails>;
|
|
402
|
-
/**
|
|
403
|
-
* - A promise for the result
|
|
404
|
-
* of updating the parameter value. Primarily useful for its behavior on
|
|
405
|
-
* rejection.
|
|
406
|
-
*/
|
|
407
|
-
outcomeOfUpdate: Promise<ParamValue>;
|
|
408
|
-
};
|
|
409
|
-
type GovernorCreatorFacet<SF extends GovernableStartFn> = {
|
|
410
|
-
voteOnParamChanges: VoteOnParamChanges;
|
|
411
|
-
voteOnApiInvocation: VoteOnApiInvocation;
|
|
412
|
-
voteOnOfferFilter: VoteOnOfferFilter;
|
|
413
|
-
/**
|
|
414
|
-
* facet of the governed contract,
|
|
415
|
-
* with creator-like powers but without the tightly held ability to change
|
|
416
|
-
* param values.
|
|
417
|
-
*/
|
|
418
|
-
getCreatorFacet: () => LimitedCF<SF>;
|
|
419
|
-
replaceElectorate: (poserInvitation: Invitation) => Promise<void>;
|
|
420
|
-
getAdminFacet: () => AdminFacet;
|
|
421
|
-
/**
|
|
422
|
-
* - public facet of the governed contract
|
|
423
|
-
*/
|
|
424
|
-
getPublicFacet: () => GovernedPublicFacet<Awaited<ReturnType<SF>>['publicFacet']>;
|
|
425
|
-
/**
|
|
426
|
-
* - instance of the governed
|
|
427
|
-
* contract
|
|
428
|
-
*/
|
|
429
|
-
getInstance: () => Instance;
|
|
430
|
-
};
|
|
431
|
-
type GovernedPublicFacetMethods = {
|
|
432
|
-
getSubscription: (key?: any) => StoredSubscription<GovernanceSubscriptionState>;
|
|
433
|
-
/**
|
|
434
|
-
* - get descriptions of
|
|
435
|
-
* all the governed parameters
|
|
436
|
-
*/
|
|
437
|
-
getGovernedParams: (key?: any) => ERef<ParamStateRecord>;
|
|
438
|
-
getInvitationAmount: (name: string) => Amount;
|
|
439
|
-
};
|
|
440
|
-
type GovernedPublicFacet<PF extends {}> = PF & GovernedPublicFacetMethods;
|
|
441
|
-
type LimitedCF<SF extends GovernableStartFn> = ReturnType<Awaited<ReturnType<SF>>['creatorFacet']['getLimitedCreatorFacet']>;
|
|
442
|
-
/**
|
|
443
|
-
* What a governed contract must return as its creatorFacet in order to be governed
|
|
444
|
-
*/
|
|
445
|
-
type GovernedCreatorFacet<CF extends {}> = {
|
|
446
|
-
/**
|
|
447
|
-
* - allows accessing
|
|
448
|
-
* and updating governed parameters. Should only be directly accessible to the
|
|
449
|
-
* contractGovernor
|
|
450
|
-
*/
|
|
451
|
-
getParamMgrRetriever: () => ParamManagerRetriever;
|
|
452
|
-
/**
|
|
453
|
-
* - the creator
|
|
454
|
-
* facet of the governed contract. Doesn't provide access to any governance
|
|
455
|
-
* functionality
|
|
456
|
-
*/
|
|
457
|
-
getLimitedCreatorFacet: () => ERef<CF>;
|
|
458
|
-
getInvitation: (name: string) => Promise<Invitation>;
|
|
459
|
-
getGovernedApis: () => ERef<GovernedApis>;
|
|
460
|
-
getGovernedApiNames: () => (string | symbol)[];
|
|
461
|
-
setOfferFilter: (strings: string[]) => void;
|
|
462
|
-
};
|
|
463
|
-
type StandardParamPath = {
|
|
464
|
-
key: string;
|
|
465
|
-
};
|
|
466
|
-
type ParamManagerRetriever = {
|
|
467
|
-
get: (paramKey?: ParamKey) => AnyParamManager;
|
|
468
|
-
};
|
|
469
|
-
type VoteOnParamChanges<P = StandardParamPath> = (voteCounterInstallation: Installation, deadline: import('@agoric/time/src/types').Timestamp, paramSpec: ParamChangesSpec<P>) => ContractGovernanceVoteResult;
|
|
470
|
-
type VoteOnApiInvocation = (apiMethodName: string, methodArgs: unknown[], voteCounterInstallation: Installation, deadline: import('@agoric/time/src/types').Timestamp) => Promise<ContractGovernanceVoteResult>;
|
|
471
|
-
type VoteOnOfferFilter = (voteCounterInstallation: Installation, deadline: import('@agoric/time/src/types').Timestamp, strings: string[]) => ContractGovernanceVoteResult;
|
|
472
|
-
type ParamGovernor = {
|
|
473
|
-
voteOnParamChanges: VoteOnParamChanges;
|
|
474
|
-
createdQuestion: CreatedQuestion;
|
|
475
|
-
};
|
|
476
|
-
type ApiGovernor = {
|
|
477
|
-
voteOnApiInvocation: VoteOnApiInvocation;
|
|
478
|
-
createdQuestion: CreatedQuestion;
|
|
479
|
-
};
|
|
480
|
-
type FilterGovernor = {
|
|
481
|
-
voteOnFilter: VoteOnOfferFilter;
|
|
482
|
-
createdQuestion: CreatedQuestion;
|
|
483
|
-
};
|
|
484
|
-
/**
|
|
485
|
-
* Was this question created by this ContractGovernor?
|
|
486
|
-
*/
|
|
487
|
-
type CreatedQuestion = (questionInstance: Instance) => boolean;
|
|
488
|
-
type PositionIncluded = (positions: Position[], position: Position) => boolean;
|
|
489
|
-
type GovernedContractTerms = {
|
|
490
|
-
timer: import('@agoric/time/src/types').TimerService;
|
|
491
|
-
issuerKeywordRecord: IssuerKeywordRecord;
|
|
492
|
-
privateArgs: object;
|
|
493
|
-
};
|
|
494
|
-
type AssertContractGovernance = (zoe: ERef<ZoeService>, allegedGoverned: import("@agoric/zoe/src/zoeService/utils.js").Instance<(zcf: ZCF<GovernanceTerms<{}>>) => {}>, allegedGovernor: Instance, contractGovernorInstallation: Installation<(<SF extends GovernableStartFn>(zcf: ZCF<{
|
|
495
|
-
timer: import("@agoric/time/src/types").TimerService;
|
|
496
|
-
governedContractInstallation: Installation<SF>;
|
|
497
|
-
governed: {
|
|
498
|
-
issuerKeywordRecord: IssuerKeywordRecord;
|
|
499
|
-
/**
|
|
500
|
-
* @typedef {object} CompleteOrderedBallot
|
|
501
|
-
* @property {Handle<'Question'>} questionHandle
|
|
502
|
-
* @property {Position[]} ordered - ordered list of position from most preferred
|
|
503
|
-
* to least preferred
|
|
504
|
-
*/
|
|
505
|
-
/**
|
|
506
|
-
* @typedef {object} PositionCount
|
|
507
|
-
* @property {Position} position
|
|
508
|
-
* @property {bigint} total
|
|
509
|
-
*/
|
|
510
|
-
/**
|
|
511
|
-
* @typedef {object} VoteStatistics
|
|
512
|
-
* @property {bigint} spoiled
|
|
513
|
-
* @property {number} votes
|
|
514
|
-
* @property {PositionCount[]} results
|
|
515
|
-
*/
|
|
516
|
-
/**
|
|
517
|
-
* @typedef {object} QuorumCounter
|
|
518
|
-
* @property {(stats: VoteStatistics) => boolean} check
|
|
519
|
-
*/
|
|
520
|
-
/**
|
|
521
|
-
* @callback BuildQuestion
|
|
522
|
-
* @param {QuestionSpec} questionSpec
|
|
523
|
-
* @param {Instance} instance - voteCounter instance
|
|
524
|
-
* @returns {Question}
|
|
525
|
-
*/
|
|
526
|
-
/**
|
|
527
|
-
* @typedef {object} VoteCounterCreatorFacet - a facet that the Electorate should
|
|
528
|
-
* hold tightly. submitVote() is the core capability that allows the holder to
|
|
529
|
-
* specify the identity and choice of a voter. The voteCounter is making that
|
|
530
|
-
* available to the Electorate, which should wrap and attenuate it so each
|
|
531
|
-
* voter gets only the ability to cast their own vote at a weight specified by
|
|
532
|
-
* the electorate.
|
|
533
|
-
* @property {SubmitVote} submitVote
|
|
534
|
-
*/
|
|
535
|
-
/**
|
|
536
|
-
* @typedef {object} VoteCounterPublicFacet
|
|
537
|
-
* @property {() => boolean} isOpen
|
|
538
|
-
* @property {() => Question} getQuestion
|
|
539
|
-
* @property {() => Promise<Position>} getOutcome
|
|
540
|
-
* @property {() => QuestionDetails} getDetails
|
|
541
|
-
* @property {() => Promise<VoteStatistics>} getStats
|
|
542
|
-
*/
|
|
543
|
-
/**
|
|
544
|
-
* @typedef {object} MultiVoteCounterPublicFacet
|
|
545
|
-
* @property {() => boolean} isOpen
|
|
546
|
-
* @property {() => Question} getQuestion
|
|
547
|
-
* @property {() => Promise<Position[]>} getOutcome
|
|
548
|
-
* @property {() => QuestionDetails} getDetails
|
|
549
|
-
* @property {() => Promise<VoteStatistics>} getStats
|
|
550
|
-
*/
|
|
551
|
-
/**
|
|
552
|
-
* @typedef {object} VoteCounterCloseFacet
|
|
553
|
-
* TEST ONLY: Should not be allowed to escape from contracts
|
|
554
|
-
* @property {() => void} closeVoting
|
|
555
|
-
*/
|
|
556
|
-
/**
|
|
557
|
-
* @typedef {object} VoteCounterFacets
|
|
558
|
-
* @property {VoteCounterPublicFacet} publicFacet
|
|
559
|
-
* @property {VoteCounterCreatorFacet} creatorFacet
|
|
560
|
-
* @property {VoteCounterCloseFacet} closeFacet
|
|
561
|
-
*/
|
|
562
|
-
/**
|
|
563
|
-
* @typedef {object} MultiVoteCounterFacets
|
|
564
|
-
* @property {MultiVoteCounterPublicFacet} publicFacet
|
|
565
|
-
* @property {VoteCounterCreatorFacet} creatorFacet
|
|
566
|
-
* @property {VoteCounterCloseFacet} closeFacet
|
|
567
|
-
*/
|
|
568
|
-
/**
|
|
569
|
-
* @callback BuildVoteCounter
|
|
570
|
-
* @param {QuestionSpec} questionSpec
|
|
571
|
-
* @param {bigint} threshold - questionSpec includes quorumRule; the electorate
|
|
572
|
-
* converts that to a number that the counter can enforce.
|
|
573
|
-
* @param {Instance} instance
|
|
574
|
-
* @param {ERef<Publisher<OutcomeRecord>>} publisher
|
|
575
|
-
* @returns {VoteCounterFacets}
|
|
576
|
-
*/
|
|
577
|
-
/**
|
|
578
|
-
* @callback BuildMultiVoteCounter
|
|
579
|
-
* @param {QuestionSpec} questionSpec
|
|
580
|
-
* @param {bigint} threshold - questionSpec includes quorumRule; the electorate
|
|
581
|
-
* converts that to a number that the counter can enforce.
|
|
582
|
-
* @param {Instance} instance
|
|
583
|
-
* @param {ERef<Publisher<MultiOutcomeRecord>>} publisher
|
|
584
|
-
* @returns {MultiVoteCounterFacets}
|
|
585
|
-
*/
|
|
586
|
-
/**
|
|
587
|
-
* @typedef {object} CompletedBallet
|
|
588
|
-
* @property {Position} chosen
|
|
589
|
-
* @property {bigint} shares
|
|
590
|
-
*/
|
|
591
|
-
/**
|
|
592
|
-
* @callback SubmitVote
|
|
593
|
-
* @param {Handle<'Voter'>} voterHandle
|
|
594
|
-
* @param {Position[]} chosenPositions
|
|
595
|
-
* @param {bigint} [weight]
|
|
596
|
-
* @returns {CompletedBallet}
|
|
597
|
-
*/
|
|
598
|
-
/**
|
|
599
|
-
* @callback GetOpenQuestions
|
|
600
|
-
* @returns {Promise<Handle<'Question'>[]>}
|
|
601
|
-
*/
|
|
602
|
-
/**
|
|
603
|
-
* @callback GetQuestion
|
|
604
|
-
* @param {Handle<'Question'>} h
|
|
605
|
-
* @returns {Promise<Question>}
|
|
606
|
-
*/
|
|
607
|
-
/**
|
|
608
|
-
* @typedef {object} ElectoratePublic
|
|
609
|
-
* @property {() => Subscriber<QuestionDetails>} getQuestionSubscriber
|
|
610
|
-
* @property {GetOpenQuestions} getOpenQuestions,
|
|
611
|
-
* @property {() => Instance} getInstance
|
|
612
|
-
* @property {GetQuestion} getQuestion
|
|
613
|
-
*/
|
|
614
|
-
/**
|
|
615
|
-
* @typedef { ElectoratePublic & {makeVoterInvitation: () => ERef<Invitation>} } ClaimsElectoratePublic
|
|
616
|
-
* @typedef { ElectoratePublic & {getName: () => string} } CommitteeElectoratePublic
|
|
617
|
-
*/
|
|
618
|
-
/**
|
|
619
|
-
* @typedef {object} PoserFacet
|
|
620
|
-
* @property {AddQuestion} addQuestion
|
|
621
|
-
*/
|
|
622
|
-
/**
|
|
623
|
-
* @typedef {object} ElectorateCreatorFacet
|
|
624
|
-
* @property {AddQuestion} addQuestion can be used directly when the creator doesn't need any
|
|
625
|
-
* reassurance. When someone needs to connect addQuestion to the Electorate
|
|
626
|
-
* instance, getPoserInvitation() lets them get addQuestion with assurance.
|
|
627
|
-
* @property {() => Promise<Invitation>} getPoserInvitation
|
|
628
|
-
* @property {() => Subscriber<QuestionDetails>} getQuestionSubscriber
|
|
629
|
-
* @property {() => ElectoratePublic} getPublicFacet
|
|
630
|
-
*/
|
|
631
|
-
/**
|
|
632
|
-
* @typedef {object} GetVoterInvitations
|
|
633
|
-
* @property {() => Invitation[]} getVoterInvitations
|
|
634
|
-
*/
|
|
635
|
-
/**
|
|
636
|
-
* @typedef {object} VoterFacet - a facet that the Electorate should hold
|
|
637
|
-
* tightly. It allows specification of the vote's weight, so the Electorate
|
|
638
|
-
* should distribute an attenuated wrapper that doesn't make that available!
|
|
639
|
-
* @property {SubmitVote} submitVote
|
|
640
|
-
*/
|
|
641
|
-
/**
|
|
642
|
-
* @typedef {object} ClosingRule
|
|
643
|
-
* @property {ERef<Timer>} timer
|
|
644
|
-
* @property {import('@agoric/time/src/types').Timestamp} deadline
|
|
645
|
-
*/
|
|
646
|
-
/**
|
|
647
|
-
* @callback CloseVoting
|
|
648
|
-
* @param {ClosingRule} closingRule
|
|
649
|
-
* @param {() => void} closeVoting
|
|
650
|
-
*/
|
|
651
|
-
/**
|
|
652
|
-
* @typedef {object} AddQuestionReturn
|
|
653
|
-
* @property {VoteCounterPublicFacet} publicFacet
|
|
654
|
-
* @property {VoteCounterCreatorFacet} creatorFacet
|
|
655
|
-
* @property {import('@agoric/zoe/src/zoeService/utils.js').Instance<typeof import('./binaryVoteCounter.js').start>} instance
|
|
656
|
-
* @property {import('@agoric/time/src/types').Timestamp} deadline
|
|
657
|
-
* @property {Handle<'Question'>} questionHandle
|
|
658
|
-
*/
|
|
659
|
-
/**
|
|
660
|
-
* @callback AddQuestion
|
|
661
|
-
* @param {ERef<Installation>} voteCounter
|
|
662
|
-
* @param {QuestionSpec} questionSpec
|
|
663
|
-
* @returns {Promise<AddQuestionReturn>}
|
|
664
|
-
*/
|
|
665
|
-
/**
|
|
666
|
-
* @callback CreateQuestion
|
|
667
|
-
*
|
|
668
|
-
* @param {string} name - The name of the parameter to change
|
|
669
|
-
* @param {ParamValue} proposedValue - the proposed value for the named
|
|
670
|
-
* parameter
|
|
671
|
-
* @param {Installation} voteCounterInstallation - the voteCounter to
|
|
672
|
-
* instantiate to count votes. Expected to be a binaryVoteCounter. Other
|
|
673
|
-
* voteCounters might be added here, or might require separate governors.
|
|
674
|
-
* under management so users can trace it back and see that it would use
|
|
675
|
-
* this electionManager to manage parameters
|
|
676
|
-
* @param {Instance} contractInstance - include the instance of the contract
|
|
677
|
-
* @param {ClosingRule} closingRule - deadline and timer for closing voting
|
|
678
|
-
* @returns {Promise<QuestionDetails>}
|
|
679
|
-
*/
|
|
680
|
-
/**
|
|
681
|
-
* @template [P=StandardParamPath] path for a paramManagerRetriever
|
|
682
|
-
* @typedef {object} ParamChangeIssue
|
|
683
|
-
* @property {ParamChangesSpec<P>} spec
|
|
684
|
-
* @property {import('@agoric/zoe/src/zoeService/utils.js').Instance<(zcf: ZCF<GovernanceTerms<{}>>) => {}>} contract
|
|
685
|
-
*/
|
|
686
|
-
/**
|
|
687
|
-
* @typedef {object} ApiInvocationIssue
|
|
688
|
-
* @property {string} apiMethodName
|
|
689
|
-
* @property {unknown[]} methodArgs
|
|
690
|
-
*/
|
|
691
|
-
/**
|
|
692
|
-
* @typedef {object} OfferFilterIssue
|
|
693
|
-
* @property {string[]} strings
|
|
694
|
-
*/
|
|
695
|
-
/**
|
|
696
|
-
* @typedef {object} ParamChangePositions
|
|
697
|
-
* @property {ChangeParamsPosition} positive
|
|
698
|
-
* @property {NoChangeParamsPosition} negative
|
|
699
|
-
*/
|
|
700
|
-
/**
|
|
701
|
-
* @typedef {object} ParamChangeIssueDetails
|
|
702
|
-
* details for a question that can change a contract parameter
|
|
703
|
-
* @property {ChoiceMethod} method
|
|
704
|
-
* @property {ParamChangeIssue<unknown>} issue
|
|
705
|
-
* @property {ParamChangePositions} positions
|
|
706
|
-
* @property {ElectionType} electionType
|
|
707
|
-
* @property {number} maxChoices
|
|
708
|
-
* @property {ClosingRule} closingRule
|
|
709
|
-
* @property {QuorumRule} quorumRule
|
|
710
|
-
* @property {NoChangeParamsPosition} tieOutcome
|
|
711
|
-
* @property {Instance} counterInstance - instance of the VoteCounter
|
|
712
|
-
* @property {Handle<'Question'>} questionHandle
|
|
713
|
-
*/
|
|
714
|
-
/**
|
|
715
|
-
* @typedef {Record<Keyword, ParamValueTyped>} ParamStateRecord a Record containing
|
|
716
|
-
* keyword pairs with descriptions of parameters under governance.
|
|
717
|
-
*/
|
|
718
|
-
/** @typedef {{current: ParamStateRecord}} GovernanceSubscriptionState */
|
|
719
|
-
/**
|
|
720
|
-
* @typedef {object} ParamManagerBase The base paramManager with typed getters
|
|
721
|
-
* @property {() => ERef<ParamStateRecord>} getParams
|
|
722
|
-
* @property {(name: string) => Amount} getAmount
|
|
723
|
-
* @property {(name: string) => Brand} getBrand
|
|
724
|
-
* @property {(name: string) => Instance} getInstance
|
|
725
|
-
* @property {(name: string) => Installation} getInstallation
|
|
726
|
-
* @property {(name: string) => Amount<'set'>} getInvitationAmount
|
|
727
|
-
* @property {(name: string) => bigint} getNat
|
|
728
|
-
* @property {(name: string) => Ratio} getRatio
|
|
729
|
-
* @property {(name: string) => string} getString
|
|
730
|
-
* @property {(name: string) => import('@agoric/time/src/types').TimestampRecord} getTimestamp
|
|
731
|
-
* @property {(name: string) => import('@agoric/time/src/types').RelativeTimeRecord} getRelativeTime
|
|
732
|
-
* @property {(name: string) => any} getUnknown
|
|
733
|
-
* @property {(name: string, proposedValue: ParamValue) => ParamValue} getVisibleValue - for
|
|
734
|
-
* most types, the visible value is the same as proposedValue. For Invitations
|
|
735
|
-
* the visible value is the amount of the invitation.
|
|
736
|
-
* @property {(name: string) => Promise<Invitation>} getInternalParamValue
|
|
737
|
-
* @property {() => StoredSubscription<GovernanceSubscriptionState>} getSubscription
|
|
738
|
-
*/
|
|
739
|
-
/**
|
|
740
|
-
* @callback UpdateParams
|
|
741
|
-
* @param {Record<string,ParamValue>} paramChanges
|
|
742
|
-
* @returns {Promise<void>}
|
|
743
|
-
*/
|
|
744
|
-
/**
|
|
745
|
-
* These are typed `any` because the builder pattern of paramManager makes it very
|
|
746
|
-
* complicated for the type system to know the set of param-specific functions
|
|
747
|
-
* returned by `.build()`. Instead we let paramManager create the desired methods
|
|
748
|
-
* and use typedParamManager to create a version that includes the static types.
|
|
749
|
-
*
|
|
750
|
-
* @typedef {Record<string, any>} ParamManagerGettersAndUpdaters
|
|
751
|
-
* @typedef {ParamManagerBase & ParamManagerGettersAndUpdaters & {updateParams: UpdateParams}} AnyParamManager
|
|
752
|
-
*/
|
|
753
|
-
/**
|
|
754
|
-
* @typedef {Record<string, string[]>} ParameterNameList
|
|
755
|
-
*/
|
|
756
|
-
/**
|
|
757
|
-
* @callback AssertParamManagerType
|
|
758
|
-
* @param {ParamType} type
|
|
759
|
-
* @param {ParamValue} value
|
|
760
|
-
* @param {string} name
|
|
761
|
-
*/
|
|
762
|
-
/**
|
|
763
|
-
* @callback BuildParamManager - ParamManager is a facility that governed
|
|
764
|
-
* contracts can use to manage their visible state in a way that allows the
|
|
765
|
-
* ContractGovernor to update values using governance. When paramManager is
|
|
766
|
-
* instantiated inside the contract, the contract has synchronous access to
|
|
767
|
-
* the values, and clients of the contract can verify that a ContractGovernor
|
|
768
|
-
* can change the values in a legible way.
|
|
769
|
-
* @param {Iterable<ParamValueTyped>} paramDescriptions
|
|
770
|
-
* @returns {AnyParamManager}
|
|
771
|
-
*/
|
|
772
|
-
/**
|
|
773
|
-
* @typedef {object} ChangeParamsPosition
|
|
774
|
-
* @property {Record<string,ParamValue>} changes one or more changes to parameters
|
|
775
|
-
*/
|
|
776
|
-
/**
|
|
777
|
-
* @typedef {object} OfferFilterPosition
|
|
778
|
-
* @property {string[]} strings
|
|
779
|
-
*/
|
|
780
|
-
/**
|
|
781
|
-
* @typedef {object} NoChangeOfferFilterPosition
|
|
782
|
-
* @property {string[]} dontUpdate
|
|
783
|
-
*/
|
|
784
|
-
/**
|
|
785
|
-
* @typedef {object} InvokeApiPosition
|
|
786
|
-
* @property {string} apiMethodName
|
|
787
|
-
* @property {unknown[]} methodArgs
|
|
788
|
-
*/
|
|
789
|
-
/**
|
|
790
|
-
* @typedef {object} DontInvokeApiPosition
|
|
791
|
-
* @property {string} dontInvoke
|
|
792
|
-
*/
|
|
793
|
-
/**
|
|
794
|
-
* @typedef {object} NoChangeParamsPosition
|
|
795
|
-
* @property {string[]} noChange Parameters in the proposal that this position
|
|
796
|
-
* is opposed to
|
|
797
|
-
*/
|
|
798
|
-
/**
|
|
799
|
-
* @typedef {object} Governor
|
|
800
|
-
* @property {CreateQuestion} createQuestion
|
|
801
|
-
*/
|
|
802
|
-
/** @typedef {{ [methodName: string]: (...args: any) => unknown }} GovernedApis */
|
|
803
|
-
/**
|
|
804
|
-
* @typedef {object} GovernorPublic
|
|
805
|
-
* @property {() => Promise<Instance>} getElectorate
|
|
806
|
-
* @property {() => Instance} getGovernedContract
|
|
807
|
-
* @property {(voteCounter: Instance) => Promise<void>} validateVoteCounter
|
|
808
|
-
* @property {(regP: ERef<Instance>) => Promise<void>} validateElectorate
|
|
809
|
-
* @property {(closingRule: ClosingRule) => void} validateTimer
|
|
810
|
-
*/
|
|
811
|
-
/**
|
|
812
|
-
* @typedef {object} ParamKey identifier for a paramManager within a contract
|
|
813
|
-
* @property {unknown} key
|
|
814
|
-
*/
|
|
815
|
-
/**
|
|
816
|
-
* Description of a set of coordinated changes for a ParamManager
|
|
817
|
-
*
|
|
818
|
-
* @template P path for a paramManagerRetriever
|
|
819
|
-
* @typedef {object} ParamChangesSpec<P>
|
|
820
|
-
* @property {P} paramPath
|
|
821
|
-
* @property {Record<string, ParamValue>} changes one or more changes to parameters
|
|
822
|
-
*/
|
|
823
|
-
/**
|
|
824
|
-
* @typedef {object} ContractGovernanceVoteResult
|
|
825
|
-
* @property {Instance} instance - instance of the VoteCounter
|
|
826
|
-
* @property {ERef<QuestionDetails>} details
|
|
827
|
-
* @property {Promise<ParamValue>} outcomeOfUpdate - A promise for the result
|
|
828
|
-
* of updating the parameter value. Primarily useful for its behavior on
|
|
829
|
-
* rejection.
|
|
830
|
-
*/
|
|
831
|
-
/**
|
|
832
|
-
* @template {GovernableStartFn} SF Start function of governed contract
|
|
833
|
-
* @typedef {object} GovernorCreatorFacet
|
|
834
|
-
* @property {VoteOnParamChanges} voteOnParamChanges
|
|
835
|
-
* @property {VoteOnApiInvocation} voteOnApiInvocation
|
|
836
|
-
* @property {VoteOnOfferFilter} voteOnOfferFilter
|
|
837
|
-
* @property {() => LimitedCF<SF>} getCreatorFacet facet of the governed contract,
|
|
838
|
-
* with creator-like powers but without the tightly held ability to change
|
|
839
|
-
* param values.
|
|
840
|
-
* @property {(poserInvitation: Invitation) => Promise<void>} replaceElectorate
|
|
841
|
-
* @property {() => AdminFacet} getAdminFacet
|
|
842
|
-
* @property {() => GovernedPublicFacet<Awaited<ReturnType<SF>>['publicFacet']>} getPublicFacet - public facet of the governed contract
|
|
843
|
-
* @property {() => Instance} getInstance - instance of the governed
|
|
844
|
-
* contract
|
|
845
|
-
*/
|
|
846
|
-
/**
|
|
847
|
-
* @typedef GovernedPublicFacetMethods
|
|
848
|
-
* @property {(key?: any) => StoredSubscription<GovernanceSubscriptionState>} getSubscription
|
|
849
|
-
* @property {(key?: any) => ERef<ParamStateRecord>} getGovernedParams - get descriptions of
|
|
850
|
-
* all the governed parameters
|
|
851
|
-
* @property {(name: string) => Amount} getInvitationAmount
|
|
852
|
-
*/
|
|
853
|
-
/**
|
|
854
|
-
* @template {{}} PF Public facet
|
|
855
|
-
* @typedef {PF & GovernedPublicFacetMethods} GovernedPublicFacet
|
|
856
|
-
*/
|
|
857
|
-
/**
|
|
858
|
-
* @template {GovernableStartFn} SF
|
|
859
|
-
* @typedef {ReturnType<Awaited<ReturnType<SF>>['creatorFacet']['getLimitedCreatorFacet']>} LimitedCF
|
|
860
|
-
*/
|
|
861
|
-
/**
|
|
862
|
-
* @template {{}} CF creator facet
|
|
863
|
-
* @typedef GovernedCreatorFacet
|
|
864
|
-
* What a governed contract must return as its creatorFacet in order to be governed
|
|
865
|
-
* @property {() => ParamManagerRetriever} getParamMgrRetriever - allows accessing
|
|
866
|
-
* and updating governed parameters. Should only be directly accessible to the
|
|
867
|
-
* contractGovernor
|
|
868
|
-
* @property {() => ERef<CF>} getLimitedCreatorFacet - the creator
|
|
869
|
-
* facet of the governed contract. Doesn't provide access to any governance
|
|
870
|
-
* functionality
|
|
871
|
-
* @property {(name: string) => Promise<Invitation>} getInvitation
|
|
872
|
-
* @property {() => ERef<GovernedApis>} getGovernedApis
|
|
873
|
-
* @property {() => (string | symbol)[]} getGovernedApiNames
|
|
874
|
-
* @property {(strings: string[]) => void} setOfferFilter
|
|
875
|
-
*/
|
|
876
|
-
/**
|
|
877
|
-
* @typedef {{key: string}} StandardParamPath
|
|
878
|
-
*/
|
|
879
|
-
/**
|
|
880
|
-
* @typedef {object} ParamManagerRetriever
|
|
881
|
-
* @property {(paramKey?: ParamKey) => AnyParamManager} get
|
|
882
|
-
*/
|
|
883
|
-
/**
|
|
884
|
-
* @template [P=StandardParamPath]
|
|
885
|
-
*
|
|
886
|
-
* @callback VoteOnParamChanges
|
|
887
|
-
* @param {Installation} voteCounterInstallation
|
|
888
|
-
* @param {import('@agoric/time/src/types').Timestamp} deadline
|
|
889
|
-
* @param {ParamChangesSpec<P>} paramSpec
|
|
890
|
-
* @returns {ContractGovernanceVoteResult}
|
|
891
|
-
*/
|
|
892
|
-
/**
|
|
893
|
-
* @callback VoteOnApiInvocation
|
|
894
|
-
* @param {string} apiMethodName
|
|
895
|
-
* @param {unknown[]} methodArgs
|
|
896
|
-
* @param {Installation} voteCounterInstallation
|
|
897
|
-
* @param {import('@agoric/time/src/types').Timestamp} deadline
|
|
898
|
-
* @returns {Promise<ContractGovernanceVoteResult>}
|
|
899
|
-
*/
|
|
900
|
-
/**
|
|
901
|
-
* @callback VoteOnOfferFilter
|
|
902
|
-
* @param {Installation} voteCounterInstallation
|
|
903
|
-
* @param {import('@agoric/time/src/types').Timestamp} deadline
|
|
904
|
-
* @param {string[]} strings
|
|
905
|
-
* @returns {ContractGovernanceVoteResult}
|
|
906
|
-
*/
|
|
907
|
-
/**
|
|
908
|
-
* @typedef {object} ParamGovernor
|
|
909
|
-
* @property {VoteOnParamChanges} voteOnParamChanges
|
|
910
|
-
* @property {CreatedQuestion} createdQuestion
|
|
911
|
-
*/
|
|
912
|
-
/**
|
|
913
|
-
* @typedef {object} ApiGovernor
|
|
914
|
-
* @property {VoteOnApiInvocation} voteOnApiInvocation
|
|
915
|
-
* @property {CreatedQuestion} createdQuestion
|
|
916
|
-
*/
|
|
917
|
-
/**
|
|
918
|
-
* @typedef {object} FilterGovernor
|
|
919
|
-
* @property {VoteOnOfferFilter} voteOnFilter
|
|
920
|
-
* @property {CreatedQuestion} createdQuestion
|
|
921
|
-
*/
|
|
922
|
-
/**
|
|
923
|
-
* @callback CreatedQuestion
|
|
924
|
-
* Was this question created by this ContractGovernor?
|
|
925
|
-
* @param {Instance} questionInstance
|
|
926
|
-
* @returns {boolean}
|
|
927
|
-
*/
|
|
928
|
-
/**
|
|
929
|
-
* @callback PositionIncluded
|
|
930
|
-
* @param {Position[]} positions
|
|
931
|
-
* @param {Position} position
|
|
932
|
-
* @returns {boolean}
|
|
933
|
-
*/
|
|
934
|
-
/**
|
|
935
|
-
* @typedef {object} GovernedContractTerms
|
|
936
|
-
* @property {import('@agoric/time/src/types').TimerService} timer
|
|
937
|
-
* @property {IssuerKeywordRecord} issuerKeywordRecord
|
|
938
|
-
* @property {object} privateArgs
|
|
939
|
-
*/
|
|
940
|
-
/**
|
|
941
|
-
* @callback AssertContractGovernance
|
|
942
|
-
*
|
|
943
|
-
* @param {ERef<ZoeService>} zoe
|
|
944
|
-
* @param {import('@agoric/zoe/src/zoeService/utils.js').Instance<(zcf: ZCF<GovernanceTerms<{}>>) => {}>} allegedGoverned
|
|
945
|
-
* @param {Instance} allegedGovernor
|
|
946
|
-
* @param {Installation<import('@agoric/governance/src/contractGovernor.js').prepare>} contractGovernorInstallation
|
|
947
|
-
* @returns {Promise<GovernancePair>}
|
|
948
|
-
*/
|
|
949
|
-
/**
|
|
950
|
-
* @callback AssertContractElectorate - assert that the contract uses the
|
|
951
|
-
* electorate
|
|
952
|
-
*
|
|
953
|
-
* @param {ERef<ZoeService>} zoe
|
|
954
|
-
* @param {Instance} allegedGovernor
|
|
955
|
-
* @param {Instance} allegedElectorate
|
|
956
|
-
*/
|
|
957
|
-
/**
|
|
958
|
-
* @typedef {import('@agoric/zoe/src/zoeService/utils.js').ContractStartFunction
|
|
959
|
-
* & ((zcf?: any, pa?: any, baggage?: any) => ERef<{creatorFacet: GovernedCreatorFacet<{}>, publicFacet: GovernedPublicFacet<{}>}>)} GovernableStartFn
|
|
960
|
-
*/
|
|
961
|
-
/**
|
|
962
|
-
* @typedef {import('./contractGovernor.js')['prepare']} GovernorSF
|
|
963
|
-
*/
|
|
964
|
-
/**
|
|
965
|
-
* @see {StartedInstanceKit}
|
|
966
|
-
* @template {ERef<Installation<GovernableStartFn>>} I
|
|
967
|
-
* @typedef GovernorStartedInstallationKit
|
|
968
|
-
* Same result as StartedInstanceKit but:
|
|
969
|
-
* - typed for contractGovernor installation being started by Zoe. (It in turn starts the governed contract.)
|
|
970
|
-
* - parameterized by Installation instead of StartFunction
|
|
971
|
-
* @property {import('@agoric/zoe/src/zoeService/utils.js').Instance<GovernorSF>} instance
|
|
972
|
-
* @property {AdminFacet} adminFacet
|
|
973
|
-
* @property {GovernorCreatorFacet<InstallationStart<Awaited<I>>>} creatorFacet
|
|
974
|
-
* @property {GovernorPublic} publicFacet
|
|
975
|
-
*/
|
|
976
|
-
/**
|
|
977
|
-
* @see {StartedInstanceKit}
|
|
978
|
-
* @template {GovernableStartFn} SF
|
|
979
|
-
* @typedef GovernanceFacetKit
|
|
980
|
-
* Akin to StartedInstanceKit but designed for the results of starting governed contracts. Used in bootstrap space.
|
|
981
|
-
* @property {AdminFacet} adminFacet of the governed contract
|
|
982
|
-
* @property {LimitedCF<SF>} creatorFacet creator-like facet within the governed contract (without the powers the governor needs)
|
|
983
|
-
* @property {GovernorCreatorFacet<SF>} governorCreatorFacet of the governing contract
|
|
984
|
-
* @property {AdminFacet} governorAdminFacet of the governing contract
|
|
985
|
-
* @property {Awaited<ReturnType<SF>>['publicFacet']} publicFacet
|
|
986
|
-
* @property {Instance} instance
|
|
987
|
-
* @property {Instance} governor
|
|
988
|
-
*/
|
|
989
|
-
terms: {
|
|
990
|
-
governedParams: {
|
|
991
|
-
Electorate: import("./contractGovernance/typedParamManager.js").InvitationParam;
|
|
992
|
-
};
|
|
993
|
-
};
|
|
994
|
-
label?: string | undefined;
|
|
995
|
-
};
|
|
996
|
-
}>, privateArgs: {
|
|
997
|
-
governed: Record<string, unknown>;
|
|
998
|
-
}, baggage: MapStore<string, unknown>) => Promise<{
|
|
999
|
-
creatorFacet: GovernorCreatorFacet<SF>;
|
|
1000
|
-
publicFacet: GovernorPublic;
|
|
1001
|
-
}>)>) => Promise<GovernancePair>;
|
|
1002
|
-
/**
|
|
1003
|
-
* - assert that the contract uses the
|
|
1004
|
-
* electorate
|
|
1005
|
-
*/
|
|
1006
|
-
type AssertContractElectorate = (zoe: ERef<ZoeService>, allegedGovernor: Instance, allegedElectorate: Instance) => any;
|
|
1007
|
-
type GovernableStartFn = import("@agoric/zoe/src/zoeService/utils.js").ContractStartFunction & ((zcf?: any, pa?: any, baggage?: any) => ERef<{
|
|
1008
|
-
creatorFacet: GovernedCreatorFacet<{}>;
|
|
1009
|
-
publicFacet: GovernedPublicFacet<{}>;
|
|
1010
|
-
}>);
|
|
1011
|
-
type GovernorSF = typeof import("./contractGovernor.js")['prepare'];
|
|
1012
|
-
/**
|
|
1013
|
-
* Same result as StartedInstanceKit but:
|
|
1014
|
-
* - typed for contractGovernor installation being started by Zoe. (It in turn starts the governed contract.)
|
|
1015
|
-
* - parameterized by Installation instead of StartFunction
|
|
1016
|
-
*/
|
|
1017
|
-
type GovernorStartedInstallationKit<I extends ERef<Installation<GovernableStartFn>>> = {
|
|
1018
|
-
instance: import('@agoric/zoe/src/zoeService/utils.js').Instance<GovernorSF>;
|
|
1019
|
-
adminFacet: AdminFacet;
|
|
1020
|
-
creatorFacet: GovernorCreatorFacet<InstallationStart<Awaited<I>>>;
|
|
1021
|
-
publicFacet: GovernorPublic;
|
|
1022
|
-
};
|
|
1023
|
-
/**
|
|
1024
|
-
* Akin to StartedInstanceKit but designed for the results of starting governed contracts. Used in bootstrap space.
|
|
1025
|
-
*/
|
|
1026
|
-
type GovernanceFacetKit<SF extends GovernableStartFn> = {
|
|
1027
|
-
/**
|
|
1028
|
-
* of the governed contract
|
|
1029
|
-
*/
|
|
1030
|
-
adminFacet: AdminFacet;
|
|
1031
|
-
/**
|
|
1032
|
-
* creator-like facet within the governed contract (without the powers the governor needs)
|
|
1033
|
-
*/
|
|
1034
|
-
creatorFacet: LimitedCF<SF>;
|
|
1035
|
-
/**
|
|
1036
|
-
* of the governing contract
|
|
1037
|
-
*/
|
|
1038
|
-
governorCreatorFacet: GovernorCreatorFacet<SF>;
|
|
1039
|
-
/**
|
|
1040
|
-
* of the governing contract
|
|
1041
|
-
*/
|
|
1042
|
-
governorAdminFacet: AdminFacet;
|
|
1043
|
-
publicFacet: Awaited<ReturnType<SF>>['publicFacet'];
|
|
1044
|
-
instance: Instance;
|
|
1045
|
-
governor: Instance;
|
|
1046
|
-
};
|
|
1047
|
-
//# sourceMappingURL=types-ambient.d.ts.map
|