Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: migrate dapp-offer-up history to dapp-agoric-basics (WIP) #3

Closed
wants to merge 93 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
716e95c
scaffold: yarn create vite simple-game --template react-ts
dckc Sep 30, 2023
52cf790
build: lock packages
dckc Sep 30, 2023
c95e646
simple game
samsiegart Aug 23, 2023
58245e6
build: fix ses dependency
dckc Nov 2, 2023
231e562
chore(contract): add gameAssetContract from smart-wallet test
dckc Nov 2, 2023
8aa09b9
chore: borrow makeTracer from @agoric/internal
dckc Nov 2, 2023
dbd5ff5
chore: adapt refs around gameAssetContract.js, proposal builder
dckc Nov 2, 2023
f54d509
build: npm script to run contract proposal builder
dckc Nov 2, 2023
c01307d
fix: work around @babel/code-frame override
dckc Nov 2, 2023
284192e
build(contract): lock packages
dckc Nov 2, 2023
e7919f0
feat: npm scripts to run local chaing with docker
dckc Nov 7, 2023
a3a19a7
fixup! feat: npm scripts to run local chaing with docker
dckc Nov 8, 2023
fc670a3
fix: mac support
dckc Nov 9, 2023
cdde0e4
chore: clarify make:help
dckc Nov 9, 2023
b49f77b
docs: simple mainnet-2 style smart wallet app
dckc Nov 9, 2023
133e4b1
docs: getting started
dckc Nov 10, 2023
1899f43
chore: subordinate ui/
dckc Nov 9, 2023
a235379
fixup! chore: subordinate ui/
dckc Nov 9, 2023
1fb25eb
chore: copy test-contract.js from `agoric init`
dckc Nov 8, 2023
12acf09
WIP: test contract with yarn test
dckc Nov 8, 2023
7aa92e9
WIP: lock packages
dckc Nov 8, 2023
0d8f31d
WIP: unlock contract packages
dckc Nov 9, 2023
44bf75c
WIP(contract): integrate deps from dapp-otc
dckc Nov 9, 2023
302bd54
chore: use _agstate to convince `agoric install`
dckc Nov 12, 2023
d1abf4a
build: contract deps
dckc Nov 12, 2023
d796f8f
test: uses ses-ava
dckc Nov 12, 2023
79b831a
build: top-level package.json for use with agoric install
dckc Nov 12, 2023
c65af94
build: lock packages with contract test working
dckc Nov 12, 2023
ed2a778
chore: jsconfig.json cargo-cult from agoric init project
dckc Nov 12, 2023
e1f75da
test: borrow IST minting function from inter-protocol
dckc Nov 12, 2023
65cbdc4
fix: let caller provide IST issuer
dckc Nov 12, 2023
8621aaf
build: proposal builder needs deploy-script-support
dckc Nov 12, 2023
558e4d9
build: ES2022 modules for import.meta
dckc Nov 12, 2023
ad25368
test: buy some game places
dckc Nov 12, 2023
5ef3209
docs: refine README
dckc Nov 12, 2023
ee12368
fix: Add marshal dependency
kriskowal Nov 14, 2023
4f44a1e
chore: Update yarn.lock
kriskowal Nov 14, 2023
433ed0d
docs: note install-SDK-from-npm issue etc.
dckc Nov 28, 2023
f788980
chore: follow @agoric/create-dapp in package.json files
dckc Nov 29, 2023
e698700
build: move zoe to dependencies (should be contractSupport)
dckc Nov 29, 2023
fd2b5e7
fix: use atomicRearrange rather that staging
dckc Nov 29, 2023
28f3528
test(contract): don't expect to import centralSupplyBundle
dckc Nov 29, 2023
0e9a371
build(ui): prune contract scripts
dckc Nov 29, 2023
67dcb21
build(ui): add noop test script
dckc Nov 29, 2023
af4fb9d
build(contract): update endo deps to match agoric-sdk
dckc Nov 29, 2023
eca91cc
build(contract): update @agoric deps to match npm
dckc Nov 29, 2023
d9388d2
build: don't require `agoric install`
dckc Nov 29, 2023
4d20ad7
docs: don't require `agoric install`
dckc Nov 29, 2023
cade5ab
build: lock updated packages
dckc Nov 29, 2023
2b2aa63
build: make docker scripts available at top level
dckc Dec 4, 2023
1e96dd4
WIP: auto mint4k adn approve new proposals
toliaqat Nov 30, 2023
2ae79ac
fix: back to zcf.incrementBy: atomicRearrange bloats the bundle
dckc Dec 5, 2023
00a044c
feat: install bundles automatically
dckc Dec 5, 2023
5e21fc5
feat: automatically propose to start contract
dckc Dec 5, 2023
1b14d6e
feat: print user1 address, mnemonic
dckc Dec 5, 2023
b22d43d
feat: aggregate `yarn start`
dckc Dec 5, 2023
d25577d
refactor(contract): sort endo imports before agoric
dckc Dec 6, 2023
248c0f9
refactor: generalize totalPlaces to bagValueSize
dckc Dec 6, 2023
cd058c0
refactor(core-eval): agoricNames -> brand.consume.IST etc.
dckc Dec 6, 2023
77a9b6d
test: test core-eval; refactor for clarity
dckc Dec 6, 2023
ef8298f
test: bundleSource() usage
dckc Dec 7, 2023
d41d913
test: Install the contract
dckc Dec 7, 2023
431451b
test: Start the contract
dckc Dec 7, 2023
fc079d6
test: refine/refactor tests for use in docs
dckc Dec 7, 2023
1481d0a
fix: docker-compose -> docker compose (#14)
dckc Dec 8, 2023
a5f0c3f
fix: avoid connotations of certain place names
dckc Dec 9, 2023
83a9fb9
docs: update README to take advantage of start:contract
dckc Dec 9, 2023
58d5ee7
UI: interactive offer (#20)
dckc Dec 20, 2023
4f5997f
chore(ui): Inventory -> Wallet
dckc Dec 22, 2023
9bc0884
chore(ui): clarify Give / Want labels
dckc Dec 22, 2023
774d182
Merge pull request #23 from Agoric/dc-label-tweaks
dckc Dec 22, 2023
5211007
fix(contract): yarn lint not configured correctly
0xpatrickdev Jan 3, 2024
7dd5c9a
feat(ci): add github workflow for lint and test
0xpatrickdev Jan 3, 2024
a8a339e
fix(contract): run eslint --fix
0xpatrickdev Jan 3, 2024
1a734ac
chore(contract): update package.json lint scripts
0xpatrickdev Jan 3, 2024
fccae72
docs(ci): document reason for node 18.18.x
0xpatrickdev Jan 3, 2024
5a65fd0
Merge pull request #33 from Agoric/19-contract-linting
0xpatrickdev Jan 3, 2024
3c1cc85
fix(contract): multiple versions of dependencies in generated bundles
0xpatrickdev Jan 3, 2024
5e23ec1
feat(contract): add build script
0xpatrickdev Jan 3, 2024
cf3ac26
chore(ci): include 'yarn build' step
0xpatrickdev Jan 3, 2024
b5b1439
docs(contract): add note about npm resolutions
0xpatrickdev Jan 3, 2024
2754328
Merge pull request #34 from Agoric/npm-resolutions
0xpatrickdev Jan 4, 2024
a66382f
fix: ensure agd tx swingset install-bundle uses gas-adjustment 1.2
0xpatrickdev Jan 4, 2024
802c6ee
Merge pull request #37 from Agoric/bundle-install-gas-adjustment
0xpatrickdev Jan 4, 2024
ad15369
docs: update README screenshot
dckc Jan 5, 2024
8da2191
docs: replace "Getting Started" with pointer to maintained docs
dckc Jan 5, 2024
853c415
fix: lower bundle storage cost to 0.02 IST / Kb like mainnet (#24)
dckc Jan 10, 2024
6591244
build: avoid failure to delete Symbol.dispose using ses 0.18.5 (#51)
dckc Jan 24, 2024
7927d21
fix!: avoid "game", "join", "place" (#45)
dckc Jan 24, 2024
5deaf74
fix: document contract; refactor for clarity; use defensive patterns
dckc Jan 23, 2024
d58a631
fix: exit temp seat used for minting
dckc Jan 23, 2024
db4e168
Merge pull request #49 from Agoric/dc-contract-docs2
dckc Jan 24, 2024
9fde159
Merge dapp-offer-up
dckc Jan 31, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
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
24 changes: 24 additions & 0 deletions .gitignore
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?
111 changes: 111 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
## Testing the contract (WIP)

```sh
cd contract
yarn # may take a while
yarn test
```

```
yarn run v1.22.21
$ ava --verbose

start proposal module evaluating
bundles/ add: assetContract from /home/connolly/projects/dapp-offer-up/contract/src/offer-up.contract.js
✔ bundle-source › bundleSource() bundles the contract for use with zoe (1s)
ℹ 7fffb45de65f0c887401d4a5c5185ad87d41e3842d6eb2e10559a06c747358fe0dc5ef41fd4c04457c5e9bb27ed85e48ea1ff8bdeac524063b7743205f4817e6
ℹ Object @Alleged: BundleInstallation {}
bundles/ bundled 85 files in bundle-assetContract.js at 2024-01-23T02:30:57.437Z
startOfferUpContract()...
✔ contract › Install the contract
ℹ Object @Alleged: BundleInstallation {}
✔ contract › Start the contract (901ms)
ℹ 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 (939ms)
ℹ 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] {}
offerUp (re)started
----- OfferUp.2 2 trade give { Price: { brand: Object [Alleged: PlayMoney brand] {}, value: 5n } } want Object [copyBag] { payload: [ [ 'scroll', 1n ], [ 'map', 1n ] ] }
bundles/ add: centralSupply from /home/connolly/projects/dapp-offer-up/node_modules/@agoric/vats/src/centralSupply.js
bundles/ bundled 132 files in bundle-centralSupply.js at 2024-01-23T02:30:59.505Z
----- OfferUp.2 2 trade give {
Price: { brand: Object [Alleged: ZDEFAULT brand] {}, value: 250000n }
} want Object [copyBag] { payload: [ [ 'scroll', 1n ], [ 'map', 1n ] ] }
✔ contract › Trade in IST rather than play money (2.5s)
ℹ 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 (2.5s)
ℹ 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,
],
],
}
----- OfferUp.2 2 trade give {
Price: { brand: Object [Alleged: ZDEFAULT brand] {}, value: 250000n }
} want Object [copyBag] { payload: [ [ 'scroll', 1n ], [ 'map', 1n ] ] }

6 tests passed
Done in 4.74s.
```

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.
21 changes: 21 additions & 0 deletions README-local-chain.md
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/).
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,24 @@
# dapp-agoric-basics
# dapp-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 added _agstate/.keep
Empty file.
19 changes: 19 additions & 0 deletions _agstate/agoric-servers/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "offer-up-agservers",
"version": "0.0.1",
"description": "Agoric server instances for dapp-offer-up",
"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"
}
}
1 change: 1 addition & 0 deletions api/README-no-api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This dapp has no API.
5 changes: 5 additions & 0 deletions api/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$note": "@agoric/[email protected] expects an api/package.json",
"name": "offer-up-api",
"version": "0.1.0"
}
3 changes: 3 additions & 0 deletions contract/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
start-offer-up-permit.json
start-offer-up.js
bundles/
121 changes: 121 additions & 0 deletions contract/Makefile
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-offer-up.js
PERMIT=start-offer-up-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/
19 changes: 19 additions & 0 deletions contract/jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// This file can contain .js-specific Typescript compiler config.
{
"compilerOptions": {
"target": "esnext",
"module": "ES2022",

"noEmit": true,
/*
// The following flags are for creating .d.ts files:
"noEmit": false,
"declaration": true,
"emitDeclarationOnly": true,
*/
"downlevelIteration": true,
"strictNullChecks": true,
"moduleResolution": "node"
},
"include": ["src/**/*.js", "test/**/*.js", "exported.js", "globals.d.ts"]
}
Loading
Loading