-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from Agoric/lp-938-initial-skeleton
feat: initial skeleton
- Loading branch information
Showing
57 changed files
with
10,461 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Lint and Test | ||
|
||
on: | ||
pull_request: | ||
|
||
jobs: | ||
all: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@v3 | ||
- name: Use Node.js 18.8.x | ||
uses: actions/setup-node@v3 | ||
with: | ||
# use node 18.8.x until Agoric/agoric-sdk#8636 | ||
node-version: '18.8.x' | ||
- name: yarn install | ||
run: yarn | ||
- name: yarn lint | ||
run: yarn lint | ||
- name: yarn build | ||
run: yarn build | ||
- name: yarn test | ||
run: yarn test | ||
- name: yarn test:e2e | ||
run: yarn test:e2e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
node_modules | ||
dist | ||
dist-ssr | ||
*.local | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
.idea | ||
.DS_Store | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
## Testing the contract (WIP) | ||
|
||
```sh | ||
cd contract | ||
yarn # may take a while | ||
yarn test | ||
``` | ||
|
||
``` | ||
yarn test | ||
yarn run v1.22.21 | ||
$ ava --verbose | ||
start proposal module evaluating | ||
bundles/ add: assetContract from /Users/luqi/github/Agoric/dapp-agoric-basics/contract/src/agoric-basics.contract.js | ||
✔ bundle-source › bundleSource() bundles the contract for use with zoe (960ms) | ||
ℹ 1ec13424eb2a4e76ed175ae38e42a85bd5d54d0d21c28bbfb54805f1188f7ac3276cc1a525d1cc78fbdbfa430802355ba910d10c4e3b9f0cd8f88a500a0e1db0 | ||
ℹ Object @Alleged: BundleInstallation {} | ||
bundles/ bundled 155 files in bundle-assetContract.js at 2024-02-07T19:45:55.154Z | ||
startAgoricBasicsContract()... | ||
✔ contract › Install the contract | ||
ℹ Object @Alleged: BundleInstallation {} | ||
agoric: run: running /Users/luqi/github/Agoric/dapp-agoric-basics/contract/scripts/build-contract-deployer.js | ||
start proposal module evaluating | ||
/Users/luqi/github/Agoric/dapp-agoric-basics/contract/bundles add: agoric-basics from /Users/luqi/github/Agoric/dapp-agoric-basics/contract/src/agoric-basics.contract.js | ||
/Users/luqi/github/Agoric/dapp-agoric-basics/contract/bundles bundled 155 files in bundle-agoric-basics.js at 2024-02-07T19:45:55.537Z | ||
✔ build-proposal › proposal builder generates compressed bundles less than 1MB (2.2s) | ||
ℹ agoric run stdout: agoric: run: Deploy script will run with Node.js ESM | ||
bundle-source --to /Users/luqi/github/Agoric/dapp-agoric-basics/contract/bundles /Users/luqi/github/Agoric/dapp-agoric-basics/contract/src/agoric-basics.contract.js agoric-basics | ||
creating start-agoric-basics-permit.json | ||
creating start-agoric-basics.js | ||
You can now run a governance submission command like: | ||
agd tx gov submit-proposal swingset-core-eval start-agoric-basics-permit.json start-agoric-basics.js \ | ||
--title="Enable <something>" --description="Evaluate start-agoric-basics.js" --deposit=1000000ubld \ | ||
--gas=auto --gas-adjustment=1.2 | ||
Remember to install bundles before submitting the proposal: | ||
agd tx swingset install-bundle @/Users/luqi/.agoric/cache/b1-1ec13424eb2a4e76ed175ae38e42a85bd5d54d0d21c28bbfb54805f1188f7ac3276cc1a525d1cc78fbdbfa430802355ba910d10c4e3b9f0cd8f88a500a0e1db0.json | ||
agd tx swingset install-bundle @/Users/luqi/.agoric/cache/b1-404e6c68f4ca70f434e7e06e537027ca57539746f093ec3c46900451e65b7896807a8e94c36a0b719ad1b4cc24c5cae8ace02bb3df9e12470d26c8decfbdb168.json | ||
ℹ { | ||
bundleId: 'b1-1ec13424eb2a4e76ed175ae38e42a85bd5d54d0d21c28bbfb54805f1188f7ac3276cc1a525d1cc78fbdbfa430802355ba910d10c4e3b9f0cd8f88a500a0e1db0', | ||
compressedSize: '0.31427860260009766 MB', | ||
} | ||
ℹ { | ||
bundleId: 'b1-404e6c68f4ca70f434e7e06e537027ca57539746f093ec3c46900451e65b7896807a8e94c36a0b719ad1b4cc24c5cae8ace02bb3df9e12470d26c8decfbdb168', | ||
compressedSize: '0.15766525268554688 MB', | ||
} | ||
✔ contract › Start the contract (910ms) | ||
ℹ terms: { | ||
tradePrice: { | ||
brand: Object @Alleged: PlayMoney brand {}, | ||
value: 5n, | ||
}, | ||
} | ||
ℹ Object @Alleged: InstanceHandle {} | ||
CoreEval script: started contract Object [Alleged: InstanceHandle] {} | ||
✔ contract › Alice trades: give some play money, want items (930ms) | ||
ℹ Object @Alleged: InstanceHandle {} | ||
ℹ Alice gives { | ||
Price: { | ||
brand: Object @Alleged: PlayMoney brand {}, | ||
value: 5n, | ||
}, | ||
} | ||
ℹ Alice payout brand Object @Alleged: Item brand {} | ||
ℹ Alice payout value Object @copyBag { | ||
payload: [ | ||
[ | ||
'scroll', | ||
1n, | ||
], | ||
[ | ||
'map', | ||
1n, | ||
], | ||
], | ||
} | ||
CoreEval script: share via agoricNames: Object [Alleged: Item brand] {} | ||
agoricBasics (re)started | ||
bundles/ add: centralSupply from /Users/luqi/github/Agoric/dapp-agoric-basics/node_modules/@agoric/vats/src/centralSupply.js | ||
bundles/ bundled 119 files in bundle-centralSupply.js at 2024-02-07T19:45:56.736Z | ||
✔ contract › Trade in IST rather than play money (1.9s) | ||
ℹ Alice gives { | ||
Price: { | ||
brand: Object @Alleged: ZDEFAULT brand {}, | ||
value: 250000n, | ||
}, | ||
} | ||
ℹ Alice payout brand Object @Alleged: Item brand {} | ||
ℹ Alice payout value Object @copyBag { | ||
payload: [ | ||
[ | ||
'scroll', | ||
1n, | ||
], | ||
[ | ||
'map', | ||
1n, | ||
], | ||
], | ||
} | ||
✔ contract › use the code that will go on chain to start the contract (1.9s) | ||
ℹ Alice gives { | ||
Price: { | ||
brand: Object @Alleged: ZDEFAULT brand {}, | ||
value: 250000n, | ||
}, | ||
} | ||
ℹ Alice payout brand Object @Alleged: Item brand {} | ||
ℹ Alice payout value Object @copyBag { | ||
payload: [ | ||
[ | ||
'scroll', | ||
1n, | ||
], | ||
[ | ||
'map', | ||
1n, | ||
], | ||
], | ||
} | ||
─ | ||
7 tests passed | ||
✨ Done in 3.94s. | ||
``` | ||
|
||
Any `Error#1: changed ...` diagnostics are benign reports of updated files | ||
outdating the contract bundle. It's benign: the test will re-build the bundle | ||
as necessary. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Agoric Local Chain with docker-compose | ||
|
||
To start a local agoric blockchain: | ||
|
||
```sh | ||
docker compose up -d | ||
``` | ||
|
||
**NOTE**: The image, which is several Gb, has to be pulled | ||
and extracted the first time you start the docker application | ||
services. | ||
|
||
Then use `docker-compose logs` etc. as usual. | ||
|
||
Some useful recipies are included in `Makefile`. | ||
Use `yarn make:help` to list them. | ||
For example: `yarn docker:make mint4k`. | ||
|
||
See also https://github.com/Agoric/documentation/pull/881 | ||
|
||
See also the [Agoric Gov Proposal Builder](https://cosgov.org/). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,24 @@ | ||
# dapp-agoric-basics | ||
# Agoric Dapp Starter: Agoric Basics | ||
|
||
This is a simple app for the [Agoric smart contract platform](https://docs.agoric.com/). | ||
|
||
<img alt="Vite + React + Agoric page with Connect Wallet button" | ||
style="border: 1px solid" width="300" | ||
src="https://docs.agoric.com/assets/img/new_002_small2.2dfb7462.png" /> | ||
|
||
The contract lets you make an offer to give a small amount of [IST](https://inter.trade/) in exchange for | ||
a few NFTs. | ||
|
||
## Getting started | ||
|
||
See [Your First Agoric Dapp](https://docs.agoric.com/guides/getting-started/) tutorial. | ||
|
||
## Contributing: Development, Testing | ||
|
||
The UI is a React app started with the [vite](https://vitejs.dev/) `react-ts` template. | ||
On top of that, we add | ||
|
||
- Watching [blockchain state queries](https://docs.agoric.com/guides/getting-started/contract-rpc.html#querying-vstorage) | ||
- [Signing and sending offers](https://docs.agoric.com/guides/getting-started/contract-rpc.html#signing-and-broadcasting-offers) | ||
|
||
See [CONTRIBUTING](./CONTRIBUTING.md) for more on testing. |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "dapp-agoric-basics-agservers", | ||
"version": "0.0.1", | ||
"description": "Agoric server instances for dapp-agoric-basics", | ||
"private": true, | ||
"type": "module", | ||
"scripts": { | ||
"build": "exit 0", | ||
"test": "exit 0", | ||
"lint": "exit 0", | ||
"lint-check": "exit 0", | ||
"lint-fix": "exit 0" | ||
}, | ||
"author": "Agoric", | ||
"license": "Apache-2.0", | ||
"dependencies": { | ||
"@agoric/cosmic-swingset": "^0.41.3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This dapp has no API. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"$note": "@agoric/[email protected] expects an api/package.json", | ||
"name": "dapp-agoric-basics-api", | ||
"version": "0.1.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
start-agoric-basics-permit.json | ||
start-agoric-basics.js | ||
bundles/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
CHAINID=agoriclocal | ||
USER1ADDR=$(shell agd keys show user1 -a --keyring-backend="test") | ||
ACCT_ADDR=$(USER1ADDR) | ||
BLD=000000ubld | ||
|
||
ATOM_DENOM=ibc/BA313C4A19DFBF943586C0387E6B11286F9E416B4DD27574E6909CABE0E342FA | ||
ATOM=000000$(ATOM_DENOM) | ||
|
||
.PHONY: list | ||
# https://stackoverflow.com/a/73159833/7963 | ||
list: | ||
@make -npq : 2> /dev/null | grep -v PHONY |\ | ||
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 | ||
|
||
mint100: | ||
make FUNDS=1000$(ATOM) fund-acct | ||
cd /usr/src/agoric-sdk && \ | ||
yarn --silent agops vaults open --wantMinted 100 --giveCollateral 100 >/tmp/want-ist.json && \ | ||
yarn --silent agops perf satisfaction --executeOffer /tmp/want-ist.json --from user1 --keyring-backend=test | ||
|
||
# https://agoric.explorers.guru/proposal/61 | ||
lower-bundle-cost: bundles/lower-bundle-cost.json ./scripts/voteLatestProposalAndWait.sh | ||
agd tx gov submit-proposal param-change bundles/lower-bundle-cost.json \ | ||
$(SIGN_BROADCAST_OPTS) \ | ||
--from user1 | ||
./scripts/voteLatestProposalAndWait.sh | ||
# agd query swingset params | ||
|
||
|
||
bundles/swingset-params.json: | ||
mkdir -p bundles/ | ||
agd query swingset params -o json >$@ | ||
|
||
.ONESHELL: | ||
bundles/lower-bundle-cost.json: bundles/swingset-params.json | ||
@read PARAMS < bundles/swingset-params.json; export PARAMS | ||
node - <<- EOF >$@ | ||
const storageByte = '20000000'; | ||
const paramChange = { | ||
title: 'Lower Bundle Cost to 0.02 IST/Kb (a la mainnet 61)', | ||
description: '0.02 IST/Kb', | ||
deposit: '10000000ubld', | ||
changes: [{ | ||
subspace: 'swingset', | ||
key: 'beans_per_unit', | ||
value: '...', | ||
}], | ||
}; | ||
const params = JSON.parse(process.env.PARAMS); | ||
const ix = params.beans_per_unit.findIndex(({key}) => key === 'storageByte'); | ||
params.beans_per_unit[ix].beans = storageByte; | ||
paramChange.changes[0].value = params.beans_per_unit; | ||
console.log(JSON.stringify(paramChange, null, 2)); | ||
EOF | ||
|
||
# Keep mint4k around a while for compatibility | ||
mint4k: | ||
make FUNDS=1000$(ATOM) fund-acct | ||
cd /usr/src/agoric-sdk && \ | ||
yarn --silent agops vaults open --wantMinted 4000 --giveCollateral 1000 >/tmp/want4k.json && \ | ||
yarn --silent 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]' | ||
|
||
gov-voting-q: | ||
agd query gov proposals --status=voting_period --output json | \ | ||
jq -c '.proposals[].proposal_id' | ||
|
||
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 | ||
|
||
print-key: /root/.agoric/user1.key | ||
@echo Import the following mnemonic into Keplr: | ||
@cat $< | ||
@echo | ||
@echo -n 'The resulting address should be: ' | ||
@agd keys show user1 -a --keyring-backend="test" | ||
@echo | ||
|
||
SCRIPT=start-agoric-basics.js | ||
PERMIT=start-agoric-basics-permit.json | ||
start-contract: $(SCRIPT) $(PERMIT) install-bundles | ||
scripts/propose-start-contract.sh | ||
|
||
install-bundles: bundles/bundle-list | ||
./scripts/install-bundles.sh | ||
|
||
build-proposal: bundles/bundle-list | ||
|
||
bundles/bundle-list $(SCRIPT) $(PERMIT): | ||
./scripts/build-proposal.sh | ||
|
||
|
||
clean: | ||
@rm -rf $(SCRIPT) $(PERMIT) bundles/ |
Oops, something went wrong.