Skip to content

Commit

Permalink
Merge pull request #3 from agoric-labs/develop
Browse files Browse the repository at this point in the history
Add governance in KREAd
  • Loading branch information
WietzeSlagman committed Sep 23, 2023
2 parents c3f7215 + 082dc1b commit 3df8879
Show file tree
Hide file tree
Showing 34 changed files with 3,109 additions and 3,210 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ node_modules

# production
/build
bundles
dist
*.out

# misc
.DS_Store
Expand Down Expand Up @@ -63,6 +66,5 @@ agoric/_agstate/yarn-links/
.vscode/
frontend/src/service/conf/defaults.js
frontend/src/service/conf/defaults.js
agoric/contract/src/proposal/chain-storage-proposal.js-clean.js

agoric/Makefile.paths.local
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,25 @@ To run the application for more than one user follow these steps:
3. `yarn start`
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"
98 changes: 78 additions & 20 deletions agoric/Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
# accounts based on mnemonics in mn2-start.test.js
ROYALTY_ADDRESS=agoric1yjc8llu3fugm7tgqye4rd5n92l9x2dhe30dazp
PLATFORM_ADDRESS=agoric1enwuyn2hzyyvt39x87tk9rhlkpqtyv9haj7mgs
COMMITTEE_ADDRESSES='{"kgov1": "agoric1890064p6j3xhzzdf8daknd6kpvhw766ds8flgw", "kgov2": "agoric1vqm5x5sj4lxmj2kem7x92tuhaum0k2yzyj6mgu"}'
COMMITTEE_NAME=kread-gov

# config options
KREAD_REPO =
SDK_PATH =
COSMIC_SWINGSET_PATH =
VATS_PATH =
KEPLR_ADDRESS =
KEPLR_ADDRESS2 =
FEE_ADDRESS = agoric1d33wj6vgjfdaefs6qzda8np8af6qfdzc433dsu
KREAD_REPO =
EVAL_PERMIT =
EVAL_CODE =
EVAL_CLEAN =

include Makefile.paths.local

COSMIC_SWINGSET_PATH = $(SDK_PATH)/packages/cosmic-swingset
VATS_PATH = $(SDK_PATH)/packages/vats

EVAL_PERMIT = $(KREAD_REPO)/agoric/contract/src/proposal/powers.json
EVAL_CODE = $(KREAD_REPO)/agoric/contract/src/proposal/chain-storage-proposal.js
EVAL_CLEAN = $(EVAL_CODE)-clean.js
AG_DIR = $(KREAD_REPO)/agoric
PROP_DIR = $(AG_DIR)/contract/src/proposal

NEXT_PROPOSAL=$$((`agd query gov proposals --output json | jq -cr '.proposals[-1] | [.proposal_id][0]'`+1))

chain-reset:
agoric start local-chain --reset --verbose

Expand Down Expand Up @@ -38,6 +48,62 @@ wallet1:
deploy:
agoric deploy contract/kread-deploy-contract.js api/kread-deploy-api.js

dist/.keep dist/bundles/.keep:
mkdir -p dist/bundles
touch dist/.keep dist/bundles/.keep
@echo bundles will actually be stored in $(PWD)/dist/bundles
rm -rf $(HOME)/.agoric/cache
ln -s $(PWD)/dist/bundles $(HOME)/.agoric/cache

build-proposals: dist/kread-committee-info.json dist/start-kread-info.json

dist/kread-invite-committee-permit.json dist/kread-invite-committee.js dist/kread-committee-info.json: dist/.keep \
contract/src/proposal/kread-committee-script.js
cd dist && \
KREAD_COMMITTEE_ADDRESSES=$(COMMITTEE_ADDRESSES) \
KREAD_COMMITTEE_NAME=$(COMMITTEE_NAME) \
agoric run ../contract/src/proposal/kread-committee-script.js >kread-committee-info.txt
node contract/scripts/parseProposals.js <dist/kread-committee-info.txt >dist/kread-committee-info.json \
|| rm dist/kread-committee-info.json

dist/start-kread-permit.json dist/start-kread.js dist/start-kread-info.json: dist/.keep \
contract/src/proposal/start-kread-script.js
cd dist && \
KREAD_ROYALTY_ADDRESS=$(ROYALTY_ADDRESS) \
KREAD_PLATFORM_ADDRESS=$(PLATFORM_ADDRESS) \
agoric run ../contract/src/proposal/start-kread-script.js >start-kread-info.txt
node contract/scripts/parseProposals.js <dist/start-kread-info.txt >dist/start-kread-info.json \
|| rm dist/start-kread-info.json

clean:
rm -rf dist

# 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: dist/kread-committee-info.json
jq -r '.bundles[]' dist/kread-committee-info.json | sort -u > kread-committee-bundles.out
for b in `cat kread-committee-bundles.out` ; do \
agoric publish --node 127.0.0.1:26657 $$b --chain-id agoriclocal --home $(COSMIC_SWINGSET_PATH)/t1/8000 ; \
done
cd $(COSMIC_SWINGSET_PATH); \
make scenario2-core-eval EVAL_PERMIT=$(AG_DIR)/dist/kread-invite-committee-permit.json \
EVAL_CODE=$(AG_DIR)/dist/kread-invite-committee.js EVAL_CLEAN=$(AG_DIR)/dist/kread-invite-committee.js.t scenario2-vote VOTE_PROPOSAL=$(NEXT_PROPOSAL) \

start-kread: dist/start-kread-info.json
jq -r '.bundles[]' dist/start-kread-info.json | sort -u > start-kread-bundles.out
for b in `cat start-kread-bundles.out` ; do \
agoric publish --node 127.0.0.1:26657 $$b --chain-id agoriclocal --home $(COSMIC_SWINGSET_PATH)/t1/8000 ; \
done
cd $(COSMIC_SWINGSET_PATH); \
make scenario2-core-eval EVAL_PERMIT=$(AG_DIR)/dist/start-kread-permit.json \
EVAL_CODE=$(AG_DIR)/dist/start-kread.js EVAL_CLEAN=$(AG_DIR)/dist/start-kread.js.t scenario2-vote VOTE_PROPOSAL=$(NEXT_PROPOSAL) \

kread-bundle:
cd $(VATS_PATH); \
yarn bundle-source --cache-json bundles/ ${KREAD_REPO} kread; \
Expand All @@ -63,7 +129,7 @@ provision-fee-collector:
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 @@ -73,23 +139,15 @@ 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
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; \
10 changes: 3 additions & 7 deletions agoric/Makefile.paths
Original file line number Diff line number Diff line change
@@ -1,9 +1,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

# changes by making scenario2
KEPLR_ADDRESS = agoric10s7qs6cznnmswahwzh9lak6pac6we5k86qvnt8
21 changes: 13 additions & 8 deletions agoric/README.md
Original file line number Diff line number Diff line change
@@ -1,49 +1,54 @@
# KREAd 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`.

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
ensure you are in the agoric folder otherwise cd to agoric folder

```sh
cd agoric
```

run agoric install
get the dependencies for current Mainnet:

```sh
agoric install
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 ('agoric1d33wj6vgjfdaefs6qzda8np8af6qfdzc433dsu')
provision the account that is in the core eval proposal

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


Copy the bundle id returned from the previous step into `chain-storage-proposal.js` (located it `agoric/contract/src/proposal`) it's on line 346, `b1-YOUR_NEW_STRING`

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
Expand Down
2 changes: 1 addition & 1 deletion agoric/_agstate/agoric-servers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
"author": "Agoric",
"license": "Apache-2.0",
"dependencies": {
"@agoric/cosmic-swingset": "@agoric/ertp"
"@agoric/cosmic-swingset": "agoric-upgrade-11"
}
}
47 changes: 47 additions & 0 deletions agoric/contract/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"env": {
"browser": true,
"es2021": true
},
"extends": [
"@agoric",
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
],
"rules": {
// used for noting unhandled promises
"no-void": "off",
// mostly stylistic
"import/order": "off",
// mostly stylistic
"github/array-foreach": "off",
"@typescript-eslint/no-unused-vars": [
"warn",
{
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_",
"caughtErrorsIgnorePattern": "^_"
}
],
"@typescript-eslint/no-empty-interface": "warn",
"@typescript-eslint/explicit-module-boundary-types": "off",
"import/newline-after-import": [
"error",
{
"count": 1
}
]
}
}
31 changes: 15 additions & 16 deletions agoric/contract/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "KREAd-contract",
"name": "kread-contract",
"version": "0.1.0",
"private": true,
"description": "Contract for the KREAd nested NFTs",
Expand All @@ -15,6 +15,7 @@
},
"devDependencies": {
"ava": "^4.3.1",
"@agoric/internal": "agoric-upgrade-11",
"@endo/eslint-plugin": "^0.4.4",
"@jessie.js/eslint-plugin": "^0.4.0",
"eslint": "^8.47.0",
Expand All @@ -30,18 +31,22 @@
"prettier": "^2.2.1"
},
"dependencies": {
"@agoric/assert": "beta",
"@agoric/assert": "agoric-upgrade-11",
"@agoric/babel-parser": "^7.6.4",
"@agoric/deploy-script-support": "beta",
"@agoric/ertp": "beta",
"@agoric/deploy-script-support": "agoric-upgrade-11",
"@agoric/ertp": "agoric-upgrade-11",
"@agoric/governance": "agoric-upgrade-11",
"@agoric/nat": "dev",
"@agoric/notifier": "beta",
"@agoric/store": "beta",
"@agoric/vat-data": "^0.5.2",
"@agoric/zoe": "beta",
"@agoric/vats": "beta",
"@agoric/notifier": "agoric-upgrade-11",
"@agoric/store": "agoric-upgrade-11",
"@agoric/time": "agoric-upgrade-11",
"@agoric/vat-data": "agoric-upgrade-11",
"@agoric/zoe": "agoric-upgrade-11",
"@agoric/zone": "agoric-upgrade-11",
"@agoric/vats": "agoric-upgrade-11",
"@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 All @@ -56,19 +61,13 @@
"keywords": [],
"author": "Kryha",
"license": "Apache-2.0",
"eslintConfig": {
"extends": [
"@agoric"
]
},
"prettier": {
"trailingComma": "all",
"singleQuote": true
},
"eslintIgnore": [
"characters.js",
"items.js",
"chain-storage-proposal.js",
"chain-storage-proposal.js-clean.js"
"*-clean.js"
]
}
Loading

0 comments on commit 3df8879

Please sign in to comment.