diff --git a/agoric/Makefile b/agoric/Makefile index 0c919db30..0940c3d9d 100644 --- a/agoric/Makefile +++ b/agoric/Makefile @@ -2,12 +2,8 @@ SDK_PATH = COSMIC_SWINGSET_PATH = VATS_PATH = KEPLR_ADDRESS = -KEPLR_ADDRESS2 = FEE_ADDRESS = agoric1d33wj6vgjfdaefs6qzda8np8af6qfdzc433dsu KREAD_REPO = -EVAL_PERMIT = -EVAL_CODE = -EVAL_CLEAN = KR_AG_DIR = PROP_DIR = $(KR_AG_DIR)/contract/src/proposal @@ -40,6 +36,14 @@ wallet1: deploy: agoric deploy contract/kread-deploy-contract.js api/kread-deploy-api.js +# To start the KREAd contract: +# 1. start the chain using `make local-testnet' +# 2. TBD ... update KEPLR_ADDRESS in Makefile.paths +# 3. fund the account using `make fund-account` +# 4. make the committee using 'KREAD_COMMITTEE_NAME='kread' KREAD_COMMITTEE_ADDRESSES='{"voter": "agoric1ersatz"}' make kread-committee' +# 5. make provision-fee-collector +# 6. start the KREAd contract using 'KREAD_COMMITTEE_NAME='kread' KREAD_COMMITTEE_ADDRESSES='{"voter": "agoric1ersatz"}' make start-kread' + kread-committee: agoric run contract/src/proposal/kread-committee-script.js | tee kread-committee.out node contract/scripts/parseProposals.js < kread-committee.out | jq -r '.bundles[]' | sort -u > kread-committee-bundles.out @@ -95,14 +99,6 @@ fund-account-atom: cd $(COSMIC_SWINGSET_PATH); \ make fund-acct ACCT_ADDR=$(KEPLR_ADDRESS) FUNDS=100000000ibc/toyatom; \ -proposal: - cd $(COSMIC_SWINGSET_PATH); \ - make scenario2-core-eval EVAL_PERMIT=$(EVAL_PERMIT) EVAL_CLEAN=$(EVAL_CLEAN) scenario2-vote \ - -proposal-2: - cd $(COSMIC_SWINGSET_PATH); \ - make scenario2-core-eval EVAL_PERMIT=$(EVAL_PERMIT) EVAL_CLEAN=$(EVAL_CLEAN) scenario2-vote VOTE_PROPOSAL=2 \ - # note if you made changes to the contract code you must # copy the resulting hash from kread-bundle into the proposal # before running make proposal diff --git a/agoric/Makefile.paths b/agoric/Makefile.paths index 4aa240724..e14e468a6 100644 --- a/agoric/Makefile.paths +++ b/agoric/Makefile.paths @@ -2,9 +2,5 @@ SDK_PATH = /Users/carlostrigo/kryha/agoric/agoric-sdk COSMIC_SWINGSET_PATH = /Users/carlostrigo/kryha/agoric/agoric-sdk/packages/cosmic-swingset VATS_PATH = /Users/carlostrigo/kryha/agoric/agoric-sdk/packages/vats KEPLR_ADDRESS = agoric1tq3v943uaycqp90qvuyaqzwdc3eh52xzrcl4p6 -KEPLR_ADDRESS2 = agoric1tq3v943uaycqp90qvuyaqzwdc3eh52xzrcl4p6 KREAD_REPO = /Users/carlostrigo/kryha/agoric/code/Agoric/agoric/contract/src/index.js -EVAL_PERMIT = /Users/carlostrigo/kryha/agoric/code/Agoric/agoric/contract/src/proposal/powers.json -EVAL_CODE = /Users/carlostrigo/kryha/agoric/code/Agoric/agoric/contract/src/proposal/chain-storage-proposal.js -EVAL_CLEAN = $(EVAL_CODE)-clean.js KR_AG_DIR = /Users/carlostrigo/agoric-kread/agoric diff --git a/agoric/contract/src/proposal/chain-storage-proposal.js b/agoric/contract/src/proposal/chain-storage-proposal.js index 3b21a1437..caf63944e 100644 --- a/agoric/contract/src/proposal/chain-storage-proposal.js +++ b/agoric/contract/src/proposal/chain-storage-proposal.js @@ -277,226 +277,3 @@ export const baseItems = [ artistMetadata: '', }, ]; - -const contractInfo = { - storagePath: 'kread', - instanceName: 'kread', - // see discussion of publish-bundle and bundleID - // from Dec 14 office hours - // https://github.com/Agoric/agoric-sdk/issues/6454#issuecomment-1351949397 - bundleID: - 'b1-3610e0a646b00a307f713e02765b7bb9320c195e5bc616106cfec05b98b78881f1ece60f2738d8d7be637d6a50e6f9ea373b31c1d331985dd4f5f6ead8a09d18', -}; - -const fail = (reason) => { - throw reason; -}; - -const reserveThenGetNamePaths = async (nameAdmin, paths) => { - /** - * @param {ERef} nextAdmin - * @param {string[]} path - */ - const nextPath = async (nextAdmin, path) => { - const [nextName, ...rest] = path; - assert.typeof(nextName, 'string'); - - // Ensure we wait for the next name until it exists. - await E(nextAdmin).reserve(nextName); - - if (rest.length === 0) { - // Now return the readonly lookup of the name. - const nameHub = E(nextAdmin).readonly(); - return E(nameHub).lookup(nextName); - } - - // Wait until the next admin is resolved. - const restAdmin = await E(nextAdmin).lookupAdmin(nextName); - return nextPath(restAdmin, rest); - }; - - return Promise.all( - paths.map(async (path) => { - Array.isArray(path) || Fail`path ${path} is not an array`; - return nextPath(nameAdmin, path); - }), - ); -}; - -/** - * Execute a proposal to start a contract that publishes bake sales. - * - * See also: - * BLDer DAO governance using arbitrary code injection: swingset.CoreEval - * https://community.agoric.com/t/blder-dao-governance-using-arbitrary-code-injection-swingset-coreeval/99 - * - * @param {BootstrapPowers} powers see the `behavior(powers)` call - * in `bridgeCoreEval()` - */ -const executeProposal = async (powers) => { - // Destructure the powers that we use. - // See also powers.json - const { - consume: { - board, - chainStorage, - zoe, - startUpgradable, - chainTimerService, - namesByAddressAdmin, - }, - // @ts-expect-error bakeSaleKit isn't declared in vats/src/core/types.js - // FIXME: Remove? - produce: { kreadKit }, - brand: { - produce: { - KREAdCHARACTER: produceCharacterBrand, - KREAdITEM: produceItemBrand, - }, - }, - issuer: { - consume: { IST: istIssuerP }, - produce: { - KREAdCHARACTER: produceCharacterIssuer, - KREAdITEM: produceItemIssuer, - }, - }, - instance: { - // @ts-expect-error kreadKit isn't declared in vats/src/core/types.js - produce: { [contractInfo.instanceName]: kread }, - }, - } = powers; - - const royaltyAddr = 'agoric1d33wj6vgjfdaefs6qzda8np8af6qfdzc433dsu'; - const platformFeeAddr = 'agoric1d33wj6vgjfdaefs6qzda8np8af6qfdzc433dsu'; - - const [royaltyDepositFacet] = await reserveThenGetNamePaths( - namesByAddressAdmin, - [[royaltyAddr, 'depositFacet']], - ); - const [platformFeeDepositFacet] = await reserveThenGetNamePaths( - namesByAddressAdmin, - [[platformFeeAddr, 'depositFacet']], - ); - - const istIssuer = await istIssuerP; - const brand = await E(istIssuer).getBrand(); - - const royaltyRate = { - numerator: 10n, - denominator: 100n, - }; - const platformFeeRate = { - numerator: 3n, - denominator: 100n, - }; - - const mintRoyaltyRate = { - numerator: 85n, - denominator: 100n, - }; - const mintPlatformFeeRate = { - numerator: 15n, - denominator: 100n, - }; - - const chainStorageSettled = - (await chainStorage) || fail(Error('no chainStorage - sim chain?')); - const storageNode = E(chainStorageSettled).makeChildNode( - contractInfo.storagePath, - ); - const marshaller = await E(board).getReadonlyMarshaller(); - const kreadPowers = { storageNode, marshaller }; - const settledTimer = await chainTimerService; - const clock = await E(settledTimer).getClock(); - - //FIXME: update this based privageargs/terms - const kreadConfig = harden({ - clock, - seed: 303, - }); - - const privateArgs = harden({ powers: kreadPowers, ...kreadConfig }); - - const installation = await E(zoe).installBundleID(contractInfo.bundleID); - const issuers = harden({ Money: istIssuer }); - const terms = harden({ - royaltyRate, - platformFeeRate, - mintRoyaltyRate, - mintPlatformFeeRate, - royaltyDepositFacet, - platformFeeDepositFacet, - paymentBrand: brand, - mintFee: 30000000n, - assetNames: { - character: 'KREAdCHARACTER', - item: 'KREAdITEM', - }, - }); - - const { instance, creatorFacet } = await E(startUpgradable)({ - installation, - label: 'KREAd', - issuers, - privateArgs, - terms, - }); - - // Get board ids for instance and assets - const boardId = await E(board).getId(instance); - //FIXME: update this based no getTerms - const { - issuers: { KREAdCHARACTER: characterIssuer, KREAdITEM: itemIssuer }, - brands: { KREAdCHARACTER: characterBrand, KREAdITEM: itemBrand }, - } = await E(zoe).getTerms(instance); - - //FIXME: remove these infavour of terms and getting them differently - const [ - CHARACTER_BRAND_BOARD_ID, - CHARACTER_ISSUER_BOARD_ID, - ITEM_BRAND_BOARD_ID, - ITEM_ISSUER_BOARD_ID, - ] = await Promise.all([ - E(board).getId(characterBrand), - E(board).getId(characterIssuer), - E(board).getId(itemBrand), - E(board).getId(itemIssuer), - ]); - - await E(creatorFacet).publishKreadInfo( - boardId, - CHARACTER_BRAND_BOARD_ID, - CHARACTER_ISSUER_BOARD_ID, - ITEM_BRAND_BOARD_ID, - ITEM_ISSUER_BOARD_ID, - ); - - await E(creatorFacet).initializeBaseAssets(baseCharacters, baseItems); - - await E(creatorFacet).initializeMetrics(); - - // FIXME: Get the most recent state of metrics from the storage node and send it to the contract - // const data = {}; - // const restoreMetricsInvitation = await E( - // creatorFacet, - // ).makeRestoreMetricsInvitation(); - // await E(zoe).offer(restoreMetricsInvitation, {}, {}, data); - - // Revive seat exit subscribers after upgrade - await E(creatorFacet).reviveMarketExitSubscribers(); - - kread.resolve(instance); - - produceCharacterIssuer.resolve(characterIssuer); - produceCharacterBrand.resolve(characterBrand); - produceItemIssuer.resolve(itemIssuer); - produceItemBrand.resolve(itemBrand); - - console.log('CONTRACT INIT SUCCESS!'); -}; - -harden(executeProposal); - -// "export" the function as the script completion value -executeProposal; diff --git a/agoric/contract/src/proposal/powers.json b/agoric/contract/src/proposal/powers.json deleted file mode 100644 index d3ffceb69..000000000 --- a/agoric/contract/src/proposal/powers.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "consume": { - "chainTimerService": "timer", - "board": true, - "chainStorage": true, - "zoe": true, - "startUpgradable": true, - "namesByAddressAdmin": true, - "agoricNamesAdmin": true, - "agoricNames": true, - "diagnostics": true, - "kreadCommitteeCreatorFacet": true - }, - "produce": { - "kreadKit": true - }, - "brand": { - "produce": { - "KREAdCHARACTER": true, - "KREAdITEM": true - } - }, - "issuer": { - "consume":{ - "IST": true - }, - "produce": { - "KREAdCHARACTER": true, - "KREAdITEM": true - } - }, - "instance": { - "produce": { - "kread": true - } - } -} diff --git a/agoric/contract/src/proposal/start-kread-proposal.js b/agoric/contract/src/proposal/start-kread-proposal.js index cfc542cdd..89551b27e 100644 --- a/agoric/contract/src/proposal/start-kread-proposal.js +++ b/agoric/contract/src/proposal/start-kread-proposal.js @@ -22,7 +22,6 @@ const fail = (reason) => { /** @typedef {import('@agoric/deploy-script-support/src/coreProposalBehavior.js').BootstrapPowers} BootstrapPowers */ /** @typedef {import('@agoric/governance/src/types-ambient.js').GovernanceFacetKit} GovernanceFacetKit */ -// copied from chain-storage-proposal because that file is a script, and this uses E. const reserveThenGetNamePaths = async (nameAdmin, paths) => { /** * @param {ERef} nextAdmin