Skip to content

Commit

Permalink
Merge pull request Kryha#19 from agoric-labs/fix-governance
Browse files Browse the repository at this point in the history
fix durable creatorFacet
  • Loading branch information
WietzeSlagman authored Sep 23, 2023
2 parents 3df8879 + 3209723 commit 875f5de
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 75 deletions.
21 changes: 0 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,24 +88,3 @@ To run the application for more than one user follow these steps:
4. Navigate to `localhost:3000` on each session and approve the app in both wallets
10. Enjoy!



## to start up the backend on a local chain

1. Start the chain
1. make local-testnet
2. Update KEPLR_ADDRESS in Makefile.paths
1. try to make the committee below, but it'll give you an aswer that some account doesn't exist
2. copy that address into Makefile.paths.local
3. fund the account
1. make fund-account
4. make the committee
1. make kread-committee
5. provision the fee collector wallet
1. make provision-fee-collector
6. start the KREAd contract
1. make clean start-kread

To confirm it started,
- in chain log you should see "CONTRACT INIT SUCCESS"
- after that `agd query vstorage children published` should include "kread"
3 changes: 2 additions & 1 deletion agoric/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ provision-account:

provision-fee-collector:
cd $(COSMIC_SWINGSET_PATH); \
make fund-provision-pool provision-acct ACCT_ADDR=$(FEE_ADDRESS) \
make fund-provision-pool provision-acct ACCT_ADDR=$(ROYALTY_ADDRESS) \
make fund-provision-pool provision-acct ACCT_ADDR=$(PLATFORM_ADDRESS) \

fund-account:
cd $(COSMIC_SWINGSET_PATH); \
Expand Down
71 changes: 22 additions & 49 deletions agoric/README.md
Original file line number Diff line number Diff line change
@@ -1,55 +1,28 @@
# KREAd deploy steps
# Contract deploy steps

To succesfully run the below steps making use of the makefile, it is important to have a local file `Makefile.paths.local` filled in with the required paths and addresses, an example can be found in `Makefile.paths`.

Steps to run:
ensure you are in the agoric folder otherwise cd to agoric folder

```sh
cd agoric
```

get the dependencies for current Mainnet:

```sh
agoric install agoric-upgrade-11
```

run chain from:

```sh
make local-testnet
```

run client for chain:

```sh
make client-local-testnet
```

create kread-bundle and publish it to chain (this step requires the `client-local-testnet` otherwise it has no address to bundle and publish from):

```sh
make kread-bundle
```

provision the account that is in the core eval proposal

```sh
make provision-fee-collector
```

create and vote on proposal

```sh
make proposal
```

The proposal logs some board_id information to chain-logs which can be used to verify it ran correctly.

Vstorage should contain the following after startup:

- kread bundle in bundles
- kread instance in agoricNames/instances
- KREAdCHARACTER and KREAdITEM brands in agoricNames/brands
- kread storage path with kread-info populated with boardIds
1. Start the chain
1. make local-testnet
2. Update KEPLR_ADDRESS in Makefile.paths
1. try to `make kread-committee`
2. it will fail but look for `"sender","value":"agoric1` to find the address
3. copy that address into Makefile.paths.local for KEPLR_ADDRESS
3. fund the account
1. make fund-account
4. make the committee
1. make kread-committee
5. provision the fee collector wallet
1. make provision-fee-collector
6. start the KREAd contract
1. make clean start-kread

To confirm it started,

- in chain log you should see "CONTRACT INIT SUCCESS"
- after that `agd query vstorage children published` should include "kread"

If you encounter `Request would exceed mint limit` try `make fund-account`
3 changes: 2 additions & 1 deletion agoric/contract/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,9 @@ export const start = async (zcf, privateArgs, baggage) => {
),
);

const { governorFacet } = makeDurableGovernorFacet(baggage, kreadKit.creator);
return harden({
creatorFacet: makeDurableGovernorFacet(baggage, kreadKit.creator),
creatorFacet: governorFacet,
// no governed parameters, so no need to augment.
publicFacet: kreadKit.public,
});
Expand Down
18 changes: 16 additions & 2 deletions agoric/contract/src/proposal/start-kread-proposal.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@

/** @file This is a module for use with swingset.CoreEval. */

// XXX this is unsupported, but it's already included in the bundle (statically linked)
import { makeTracer } from '@agoric/internal';
import { E } from '@endo/far';
import { deeplyFulfilled } from '@endo/marshal';

import { baseCharacters, baseItems } from './base-inventory.js';

import '@agoric/governance/src/types-ambient.js';
import { deeplyFulfilled } from '@endo/marshal';

const KREAD_LABEL = 'KREAd';

const trace = makeTracer(KREAD_LABEL);

const contractInfo = {
storagePath: 'kread',
instanceName: 'kread',
Expand Down Expand Up @@ -91,6 +96,7 @@ const startGovernedInstance = async (
E(E(zoe).getInvitationIssuer()).getAmountOf(poserInvitationP),
]);

trace('awaiting governorTerms');
const governorTerms = await deeplyFulfilled(
harden({
timer,
Expand All @@ -111,6 +117,8 @@ const startGovernedInstance = async (
},
}),
);

trace('awaiting startInstance');
const governorFacets = await E(zoe).startInstance(
contractGovernor,
{},
Expand All @@ -124,6 +132,8 @@ const startGovernedInstance = async (
}),
`${label}-governor`,
);

trace('awaiting facets');
const [instance, publicFacet, creatorFacet, adminFacet] = await Promise.all([
E(governorFacets.creatorFacet).getInstance(),
E(governorFacets.creatorFacet).getPublicFacet(),
Expand Down Expand Up @@ -195,10 +205,12 @@ export const startKread = async (powers, config) => {

const { royaltyAddr, platformFeeAddr } = config.options;

trace('awaiting royaltyDepositFacet');
const [royaltyDepositFacet] = await reserveThenGetNamePaths(
namesByAddressAdmin,
[[royaltyAddr, 'depositFacet']],
);
trace('awaiting platformFeeDepositFacet');
const [platformFeeDepositFacet] = await reserveThenGetNamePaths(
namesByAddressAdmin,
[[platformFeeAddr, 'depositFacet']],
Expand Down Expand Up @@ -253,6 +265,7 @@ export const startKread = async (powers, config) => {

const privateArgs = harden({ powers: kreadPowers, ...kreadConfig });

trace('awaiting startGovernedInstance');
const facets = await startGovernedInstance(
{
zoe,
Expand Down Expand Up @@ -285,6 +298,7 @@ export const startKread = async (powers, config) => {
brands: { KREAdCHARACTER: characterBrand, KREAdITEM: itemBrand },
} = await E(zoe).getTerms(instance);

trace('awaiting KREAd initialization');
await Promise.all([
E(creatorFacet).initializeBaseAssets(baseCharacters, baseItems),
E(creatorFacet).initializeMetrics(),
Expand All @@ -300,7 +314,7 @@ export const startKread = async (powers, config) => {
produceItemIssuer.resolve(itemIssuer);
produceItemBrand.resolve(itemBrand);

console.log('CONTRACT INIT SUCCESS!');
trace('CONTRACT INIT SUCCESS!');
};
harden(startKread);

Expand Down
3 changes: 2 additions & 1 deletion agoric/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"@agoric/cosmic-swingset": "agoric-upgrade-11"
},
"dependencies": {
"agoric": "agoric-upgrade-11"
"agoric": "agoric-upgrade-11",
"@agoric/internal": "agoric-upgrade-11"
},
"scripts": {
"preinstall": "node -e \"process.env.AGORIC_INSTALL && process.exit(0); console.warn('please use: agoric install . For details, see https://agoric.com/documentation/'); process.exit(1)\"",
Expand Down

0 comments on commit 875f5de

Please sign in to comment.