Skip to content
This repository has been archived by the owner on Dec 6, 2023. It is now read-only.

Commit

Permalink
feat: npm scripts to run local chaing with docker
Browse files Browse the repository at this point in the history
 - start:docker, docker:logs, docker:bash, docker:make, docker:help
 - agd cheat-sheet in the form of a Makefile
  • Loading branch information
dckc committed Nov 8, 2023
1 parent 284192e commit e7919f0
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 1 deletion.
46 changes: 46 additions & 0 deletions contract/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
CHAINID=agoriclocal
USER1ADDR=$(shell agd keys show user1 -a --keyring-backend="test")
ACCT_ADDR=$(USER1ADDR)
BLD=000000ubld

.PHONY: list
# https://stackoverflow.com/a/73159833/7963
list:
make -npq : 2> /dev/null | \
awk -v RS= -F: '$$1 ~ /^[^#%]+$$/ { print $$1 }'

balance-q:
agd keys show user1 -a --keyring-backend="test"
agd query bank balances $(ACCT_ADDR)

GAS_ADJUSTMENT=1.2
SIGN_BROADCAST_OPTS=--keyring-backend=test --chain-id=$(CHAINID) \
--gas=auto --gas-adjustment=$(GAS_ADJUSTMENT) \
--yes -b block

mint4k:
make FUNDS=1000$(ATOM) fund-acct
agops vaults open --wantMinted 4000 --giveCollateral 1000 >/tmp/want4k.json
agops perf satisfaction --executeOffer /tmp/want4k.json --from user1 --keyring-backend=test

FUNDS=321$(BLD)
fund-acct:
agd tx bank send validator $(ACCT_ADDR) $(FUNDS) \
$(SIGN_BROADCAST_OPTS) \
-o json >,tx.json
jq '{code: .code, height: .height}' ,tx.json

gov-q:
agd query gov proposals --output json | \
jq -c '.proposals[] | [.proposal_id,.voting_end_time,.status]'

PROPOSAL=1
VOTE_OPTION=yes
vote:
agd tx gov vote $(PROPOSAL) $(VOTE_OPTION) --from=validator \
$(SIGN_BROADCAST_OPTS) \
-o json >,tx.json
jq '{code: .code, height: .height}' ,tx.json

instance-q:
agd query vstorage data published.agoricNames.instance -o json
5 changes: 5 additions & 0 deletions contract/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
"name": "simple-game",
"type": "module",
"scripts": {
"start:docker": "docker-compose up -d",
"docker:logs": "docker-compose logs --tail 200 -f",
"docker:bash": "docker-compose exec agd bash",
"docker:make": "docker-compose exec agd make -C /workspace/contract",
"make:help": "make list",
"build:proposal": "agoric run ./scripts/build-game1-start.js"
},
"dependencies": {
Expand Down
17 changes: 17 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: '3.5'

services:
agd:
# image publication is WIP
# cf. https://github.com/Agoric/agoric-3-proposals/issues/6
image: ghcr.io/agoric/agoric-3-proposals:main
ports:
- 26656:26656
- 26657:26657
- 1317:1317
environment:
DEST: 1
DEBUG: "SwingSet:ls,SwingSet:vat"
volumes:
- .:/workspace
entrypoint: /usr/src/upgrade-test-scripts/start_agd.sh
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"build:proposal": "cd contract; yarn && yarn build:proposal",
"build:contract": "cd contract; yarn",
"build:proposal": "yarn build:contract; HOME=$PWD/dist; cd contract; yarn build:proposal",
"start:docker": "docker-compose up -d",
"docker:logs": "docker-compose logs --tail 200 -f",
"docker:bash": "docker-compose exec agd bash",
"docker:make": "docker-compose exec agd make -C /workspace/contract",
"make:help": "make -C contract list",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
},
Expand Down

0 comments on commit e7919f0

Please sign in to comment.