-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f341634
commit bcc4bd9
Showing
1 changed file
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
// @ts-check | ||
|
||
import { M } from '@agoric/store'; | ||
import { TimestampShape } from '../../SwingSet/src/vats/timer/typeGuards'; | ||
|
||
export const ChoiceMethodShape = M.or('unranked', 'order'); | ||
export const QuorumRuleShape = M.or('majority', 'no_quorum', 'all'); | ||
export const ElectionTypeShape = M.or( | ||
'param_change', | ||
'election', | ||
'survey', | ||
'api_invocation', | ||
'offer_filter', | ||
); | ||
|
||
export const TimerShape = M.handle('timer'); | ||
export const InstanceShape = M.handle('instance'); | ||
|
||
export const ClosingRuleShape = harden({ | ||
timer: M.eref(TimerShape), | ||
deadline: TimestampShape, | ||
}); | ||
|
||
// all the strings that will be in the filter after passing | ||
export const YesOfferFilterPositionShape = M.arrayOf(M.string()); | ||
export const NoOfferFilterPositionShape = harden({ | ||
dontUpdate: M.arrayOf(M.string()), | ||
}); | ||
export const OfferFilterPositionsShape = [ | ||
YesOfferFilterPositionShape, | ||
NoOfferFilterPositionShape, | ||
]; | ||
export const OfferFilterIssueShape = harden({ | ||
strings: M.arrayOf(M.string()), | ||
}); | ||
export const OfferFilterQuestionSpecShape = harden({ | ||
method: ChoiceMethodShape, | ||
issue: OfferFilterIssueShape, | ||
positions: OfferFilterPositionsShape, | ||
electionType: ElectionTypeShape, | ||
maxChoices: M.eq(1n), | ||
closingRule: ClosingRuleShape, | ||
quorumRule: QuorumRuleShape, | ||
tieOutcome: NoOfferFilterPositionShape, | ||
}); | ||
|
||
// keys are parameter names, values are proposed values | ||
export const ParamChangesSpecShape = M.recordOf(M.string(), M.any()); | ||
export const YesParamChangesPositionShape = ParamChangesSpecShape; | ||
export const NoParamChangesPositionShape = harden({ | ||
noChange: M.arrayOf(M.string()), | ||
}); | ||
export const ParamChangesPositionsShape = [ | ||
YesParamChangesPositionShape, | ||
NoParamChangesPositionShape, | ||
]; | ||
export const ParamChangesIssueShape = harden({ | ||
spec: ParamChangesSpecShape, | ||
contract: InstanceShape, | ||
}); | ||
export const ParamChangesQuestionSpecShape = harden({ | ||
method: ChoiceMethodShape, | ||
issue: ParamChangesIssueShape, | ||
positions: ParamChangesPositionsShape, | ||
electionType: ElectionTypeShape, | ||
maxChoices: M.eq(1n), | ||
closingRule: ClosingRuleShape, | ||
quorumRule: QuorumRuleShape, | ||
tieOutcome: NoParamChangesPositionShape, | ||
}); | ||
|
||
const ApiInvocationSpecShape = harden({ | ||
apiMethodName: M.string(), | ||
methodArgs: M.string(), | ||
}); | ||
export const YesApiInvocationPositionShape = ApiInvocationSpecShape; | ||
export const NoApiInvocationPositionShape = harden({ | ||
dontInvoke: M.arrayOf(M.string()), | ||
}); | ||
export const ApiInvocationPositionsShape = [ | ||
YesApiInvocationPositionShape, | ||
NoApiInvocationPositionShape, | ||
]; | ||
export const ApiInvocationIssueShape = harden({ | ||
spec: ApiInvocationSpecShape, | ||
}); | ||
export const ApiInvocationQuestionSpecShape = harden({ | ||
method: 'unranked', | ||
issue: ApiInvocationIssueShape, | ||
positions: ApiInvocationPositionsShape, | ||
electionType: 'api_invocation', | ||
maxChoices: M.eq(1), | ||
closingRule: ClosingRuleShape, | ||
quorumRule: QuorumRuleShape, | ||
tieOutcome: NoApiInvocationPositionShape, | ||
}); | ||
|
||
export const QuestionShape = M.or( | ||
ApiInvocationQuestionSpecShape, | ||
OfferFilterQuestionSpecShape, | ||
ParamChangesQuestionSpecShape, | ||
// SimpleQuestionSpecShape, // unused | ||
); |