-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Imported from https://github.com/Agoric/dapp-agoric-basics
- Loading branch information
jovonni
authored and
jovonni
committed
May 14, 2024
0 parents
commit 2db805d
Showing
106 changed files
with
28,515 additions
and
0 deletions.
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,67 @@ | ||
name: CI | ||
|
||
on: | ||
pull_request: | ||
|
||
jobs: | ||
unit: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@v4 | ||
- name: Use Node.js 18 | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: "18" | ||
- 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 | ||
integration: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@v4 | ||
- name: Use Node.js 18 | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: "18" | ||
- name: yarn install | ||
run: yarn | ||
- name: yarn start:docker | ||
run: yarn start:docker | ||
- name: yarn build | ||
run: yarn build | ||
# Borrowed from https://github.com/DCFoundation/cosmos-proposal-builder/blob/main/.github/workflows/pr.yml#L43-L61 | ||
- name: Wait for Docker container to be ready | ||
run: | | ||
timeout 300 bash -c ' | ||
TARGET_HEIGHT=1111 | ||
SLEEP=10 | ||
echo "Waiting for the Agoric service to be fully ready..." | ||
echo "Target block height: $TARGET_HEIGHT" | ||
while true; do | ||
response=$(curl --silent http://localhost:26657/abci_info); | ||
height=$(echo $response | jq -r ".result.response.last_block_height | tonumber"); | ||
if [ "$height" -ge $TARGET_HEIGHT ]; then | ||
echo "Service is ready! Last block height: $height"; | ||
break; | ||
else | ||
echo "Waiting for last block height to reach $TARGET_HEIGHT. Current height: $height"; | ||
fi; | ||
sleep $SLEEP; | ||
done | ||
' | ||
- name: yarn start:contract | ||
run: yarn start:contract | ||
- name: verify contracts started onchain | ||
run: | | ||
curl http://localhost:1317/agoric/vstorage/data/published.agoricNames.instance | grep sellConcertTickets | ||
curl http://localhost:1317/agoric/vstorage/data/published.agoricNames.instance | grep swaparoo | ||
curl http://localhost:1317/agoric/vstorage/data/published.agoricNames.instance | grep postalService |
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 @@ | ||
18.18.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 @@ | ||
.node-version |
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Agoric Dapp Starter: Agoric Basics | ||
|
||
This is a basic Agoric Dapp that contains three smart contracts `postal-service`, `sell-concert-tickets`, and `swaparoo` demonstrating different scenarios which can be implemented easily using Agoric SDK. There is also a UI for `sell-concert-tickets` contract that a user can use to buy three different types of concert tickets and pay through a wallet extension in the browser. | ||
|
||
## Getting started | ||
|
||
Make sure all the required dependecies are already installed (including node, nvm, docker, Keplr, and that your node version is set to `18.x.x` by running `nvm use 18.20.2`. See [a tutorial here](https://docs.agoric.com/guides/getting-started/) on how to install these dependecies.). Here are the steps to run `dapp-agoric-basics`: | ||
- run `yarn install` in the `agoric-basics` directory, to install dependencies of the Dapp. | ||
- run `yarn start:docker` to start Agoric blockchain from the container. | ||
- run `yarn docker:logs` to to make sure blocks are being produced by viewing the Docker logs; once your logs resemble the following, stop the logs by pressing `ctrl+c`. | ||
``` | ||
demo-agd-1 | 2023-12-27T04:08:06.384Z block-manager: block 1003 begin | ||
demo-agd-1 | 2023-12-27T04:08:06.386Z block-manager: block 1003 commit | ||
demo-agd-1 | 2023-12-27T04:08:07.396Z block-manager: block 1004 begin | ||
demo-agd-1 | 2023-12-27T04:08:07.398Z block-manager: block 1004 commit | ||
demo-agd-1 | 2023-12-27T04:08:08.405Z block-manager: block 1005 begin | ||
demo-agd-1 | 2023-12-27T04:08:08.407Z block-manager: block 1005 commit | ||
``` | ||
- run `yarn start:contract` to start the contracts. | ||
- run `yarn start:ui` to start `sell-concert-tickets` contract UI. | ||
- open a browser and navigate to `localhost:5173` to interact with the contract via UI. | ||
|
||
To follow more detailed tutorial, go [here](https://docs.agoric.com/guides/getting-started/tutorial-dapp-agoric-basics.html). | ||
|
||
## Testing | ||
|
||
To perform unit tests: | ||
-run the command `yarn test` in the root directory. | ||
To perform end to end test | ||
-run the command `yarn test:e2e` in the root directory. | ||
|
||
## Contributing | ||
See [CONTRIBUTING](./CONTRIBUTING.md) for more on contributions. |
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-dao-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-dao-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-sell-concert-tickets-permit.json | ||
start-sell-concert-tickets.js | ||
bundles/ |
Oops, something went wrong.