-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: charter for the PSM, enabling governance (#6090)
* feat: charter for the PSM, enabling governance No tests are included. * refactor: turn it into a continuing invitation Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
- Loading branch information
1 parent
14b20e6
commit e80b763
Showing
3 changed files
with
81 additions
and
1 deletion.
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
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,80 @@ | ||
// @ts-check | ||
|
||
import '@agoric/governance/src/exported.js'; | ||
import '@agoric/zoe/exported.js'; | ||
import '@agoric/zoe/src/contracts/exported.js'; | ||
|
||
import { E, Far } from '@endo/far'; | ||
|
||
/** | ||
* @file | ||
* | ||
* This contract makes it possible for those who govern the PSM to call for | ||
* votes on changes. A more complete implementation would validate parameters, | ||
* constrain deadlines and possibly split the ability to call for votes into | ||
* separate capabilities for finer grain encapsulation. | ||
*/ | ||
|
||
/** | ||
* @param {ZCF<{binaryVoteCounterInstallation:Installation}>} zcf | ||
* @param {{psm:GovernedContractFacetAccess<{},{}>}} privateArgs | ||
*/ | ||
export const start = async (zcf, privateArgs) => { | ||
const { binaryVoteCounterInstallation: counter } = zcf.getTerms(); | ||
const { psm } = privateArgs; | ||
|
||
const makeParamInvitaion = () => { | ||
/** | ||
* @param {Record<string, unknown>} params | ||
* @param {bigint} deadline | ||
* @param {{paramPath: { key: string }}} [path] | ||
*/ | ||
const voteOnParamChanges = ( | ||
params, | ||
deadline, | ||
path = { paramPath: { key: 'governedApi' } }, | ||
) => { | ||
return E(psm).voteOnParamChanges(counter, deadline, { | ||
...path, | ||
changes: params, | ||
}); | ||
}; | ||
|
||
return zcf.makeInvitation( | ||
() => Far('param change hook', { voteOnParamChanges }), | ||
'vote on param changes', | ||
); | ||
}; | ||
|
||
const makeOfferFilterInvitation = () => { | ||
/** | ||
* @param {string[]} strings | ||
* @param {bigint} deadline | ||
*/ | ||
const voteOnOfferFilter = (strings, deadline) => { | ||
return E(psm).voteOnOfferFilter(counter, deadline, strings); | ||
}; | ||
|
||
return zcf.makeInvitation( | ||
() => Far('offer filter hook', { voteOnOfferFilter }), | ||
'vote on offer filter', | ||
); | ||
}; | ||
|
||
const invitationMakers = Far('PSM Invitation Makers', { | ||
VoteOnParamChange: makeParamInvitaion, | ||
VoteOnPauseOffers: makeOfferFilterInvitation, | ||
}); | ||
|
||
const charterMemberHandler = seat => { | ||
seat.exit(); | ||
return invitationMakers; | ||
}; | ||
|
||
const creatorFacet = Far('psm charter creator', { | ||
makeCharterMemberInvitation: () => | ||
zcf.makeInvitation(charterMemberHandler, 'PSM charter member invitation'), | ||
}); | ||
|
||
return harden({ creatorFacet }); | ||
}; |
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