Skip to content

Commit

Permalink
feat: install changes on chain
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris-Hibbert committed Sep 18, 2023
1 parent 6c676f0 commit 0dab20f
Show file tree
Hide file tree
Showing 11 changed files with 963 additions and 20 deletions.
25 changes: 22 additions & 3 deletions agoric/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,25 @@ wallet1:
deploy:
agoric deploy contract/kread-deploy-contract.js api/kread-deploy-api.js

install-kread:
agoric run contract/src/proposal/kread-committee-script.js
agoric publish --node 127.0.0.1:26657 /Users/chris/.agoric/cache/b1-610ae18f1dcefba0d443196aaf853550d26a69704113ba5cfcea8f811a0c17fa21a98cd485c25b403bf22d629c3e161d4b42e16fa5b1c77aee5457919aad74c0.json \
--chain-id agoriclocal --home $(COSMIC_SWINGSET_PATH)/t1/8000;
agoric publish --node 127.0.0.1:26657 /Users/chris/.agoric/cache/b1-0c780c20b02a7e3a10126ca84ce76c50bb34744d9621c83e230ec977b85a8d21ab8f88842fe89edf3a219008edb375178a9dc54f4867ad17463bc0a05470e5ee.json \
--chain-id agoriclocal --home $(COSMIC_SWINGSET_PATH)/t1/8000;
# agd tx swingset install-bundle @/Users/chris/.agoric/cache/b1-.json \
# --from gov1 --keyring-backend=test --gas=auto --chain-id=agoriclocal -bblock --yes
# agd tx gov submit-proposal swingset-core-eval kread-invite-committee-permit.json kread-invite-committee.js \
# --title="Install Kread Committee" --description="Evaluate kread-invite-committee.js" --deposit=1000000ubld \
# --gas=auto --gas-adjustment=1.2
# agoric run contract/src/proposal/start-kread-script.js
# agd tx gov submit-proposal swingset-core-eval kread-invite-committee-permit.json kread-invite-committee.js \
# --title="Enable <something>" --description="Evaluate kread-invite-committee.js" --deposit=1000000ubld \
# --gas=auto --gas-adjustment=1.2
# agd tx gov submit-proposal swingset-core-eval kread-invite-committee-permit.json kread-invite-committee.js \
# --title="Enable <something>" --description="Evaluate kread-invite-committee.js" --deposit=1000000ubld \
# --gas=auto --gas-adjustment=1.

kread-bundle:
cd $(VATS_PATH); \
yarn bundle-source --cache-json bundles/ ${KREAD_REPO} kread; \
Expand All @@ -58,7 +77,7 @@ provision-account:
fund-account:
cd $(COSMIC_SWINGSET_PATH); \
make fund-acct ACCT_ADDR=$(KEPLR_ADDRESS) FUNDS=1000000000000uist; \
make fund-acct ACCT_ADDR=$(KEPLR_ADDRESS) FUNDS=1000000000000ubld; \
make fund-acct ACCT_ADDR=$(KEPLR_ADDRESS) FUNDS=1000000000000ubld; \

fund-pool:
cd $(COSMIC_SWINGSET_PATH); \
Expand All @@ -81,10 +100,10 @@ proposal-2:
# before running make proposal
bootstrap:
make provision-account; \
make fund-account; \
make fund-account; \
make kread-bundle; \
make proposal; \

fund+provision:
make provision-account; \
make fund-account; \
make fund-account; \
3 changes: 3 additions & 0 deletions agoric/contract/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,17 @@
"@agoric/deploy-script-support": "beta",
"@agoric/ertp": "beta",
"@agoric/governance": "beta",
"@agoric/inter-protocol": "beta",
"@agoric/nat": "dev",
"@agoric/notifier": "beta",
"@agoric/store": "beta",
"@agoric/time": "beta",
"@agoric/vat-data": "^0.5.2",
"@agoric/zoe": "beta",
"@agoric/vats": "beta",
"@endo/bundle-source": "^2.1.1",
"@endo/eventual-send": "^0.14.8",
"@endo/far": "^0.2.18",
"@endo/init": "^0.5.37",
"@endo/marshal": "^0.6.9",
"@endo/ses-ava": "^0.2.40",
Expand Down
111 changes: 111 additions & 0 deletions agoric/contract/src/kreadCommitteeCharter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
// @jessie-check

import '@agoric/governance/exported.js';
import { M } from '@agoric/store';
import { TimestampShape } from '@agoric/time';
import { prepareExo, provideDurableMapStore } from '@agoric/vat-data';
import '@agoric/zoe/exported.js';
import '@agoric/zoe/src/contracts/exported.js';
import {
InstallationShape,
InstanceHandleShape,
} from '@agoric/zoe/src/typeGuards.js';
import { E } from '@endo/far';

/**
* @file This contract makes it possible for those who govern the KREAd contract
* to call for votes to pause offers.
*/

export const INVITATION_MAKERS_DESC = 'charter member invitation';

/** @type {ContractMeta} */
export const meta = {
customTermsShape: {
binaryVoteCounterInstallation: InstallationShape,
},
upgradability: 'canUpgrade',
};
harden(meta);

/**
* @param {ZCF<{ binaryVoteCounterInstallation: Installation }>} zcf
* @param {undefined} privateArgs
* @param {import('@agoric/vat-data').Baggage} baggage
*/
export const start = async (zcf, privateArgs, baggage) => {
const { binaryVoteCounterInstallation: counter } = zcf.getTerms();
/** @type {MapStore<Instance, GovernorCreatorFacet<any>>} */
const instanceToGovernor = provideDurableMapStore(
baggage,
'instanceToGovernor',
);

const makeOfferFilterInvitation = (instance, strings, deadline) => {
const voteOnOfferFilterHandler = seat => {
seat.exit();

const governor = instanceToGovernor.get(instance);
return E(governor).voteOnOfferFilter(counter, deadline, strings);
};

return zcf.makeInvitation(voteOnOfferFilterHandler, 'vote on offer filter');
};

const MakerI = M.interface('Charter InvitationMakers', {
VoteOnPauseOffers: M.call(
InstanceHandleShape,
M.arrayOf(M.string()),
TimestampShape,
).returns(M.promise()),
});

// durable so that when this contract is upgraded this ocap held
// by committee members (from their invitations) stay capable
const invitationMakers = prepareExo(
baggage,
'Charter Invitation Makers',
MakerI,
{
VoteOnPauseOffers: makeOfferFilterInvitation,
},
);

const charterMemberHandler = seat => {
seat.exit();
return harden({ invitationMakers });
};

const CharterCreatorI = M.interface('Charter creatorFacet', {
addInstance: M.call(InstanceHandleShape, M.any())
.optional(M.string())
.returns(),
makeCharterMemberInvitation: M.call().returns(M.promise()),
});

const creatorFacet = prepareExo(
baggage,
'Charter creatorFacet',
CharterCreatorI,
{
/**
* @param {Instance} governedInstance
* @param {GovernorCreatorFacet<any>} governorFacet
* @param {string} [label] for diagnostic use only
*/
addInstance: (governedInstance, governorFacet, label) => {
console.log('charter: adding instance', label);
instanceToGovernor.init(governedInstance, governorFacet);
},
makeCharterMemberInvitation: () =>
zcf.makeInvitation(charterMemberHandler, INVITATION_MAKERS_DESC),
},
);

return harden({ creatorFacet });
};
harden(start);

/**
* @typedef {import('@agoric/zoe/src/zoeService/utils.js').StartedInstanceKit<start>} KreadCharterStartResult
*/
Loading

0 comments on commit 0dab20f

Please sign in to comment.