diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..b33d640 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,124 @@ +## Testing the contract + +The contract is on a branch in the agoric-sdk zoe package +(see releases for up-to-date details). + +```console +$ git clone -b dc-gimix-test1 https://github.com/Agoric/agoric-sdk +$ cd agoric-sdk; yarn && yarn build +$ cd packages/zoe +``` + +Then run `test-gimix.js`; output should look something like... + +``` +$ yarn test test/unitTests/contracts/gimix/test-gimix.js +yarn run v1.22.19 +$ ava --verbose test/unitTests/contracts/gimix/test-gimix.js +... + ✔ execute work agreement (678ms) + ℹ githubOracle starts + ℹ alice starts + ℹ bob starts + ℹ oracle received invation { + brand: Object @Alleged: Zoe Invitation brand {}, + value: [ + { + description: 'gimix oracle invitation', + handle: Object @Alleged: InvitationHandle {}, + installation: Object @Alleged: BundleInstallation {}, + instance: Object @Alleged: InstanceHandle {}, + }, + ], + } + ℹ alice offers to give { + Acceptance: { + brand: Object @Alleged: ZDEFAULT brand {}, + value: 12000000n, + }, + } + ℹ alice wants { + Stamp: { + brand: Object @Alleged: GimixOracle brand {}, + value: Object @copyBag { + payload: Array [ … ], + }, + }, + } + ℹ alice exit { + afterDeadline: { + deadline: { + absValue: 1577880000021n, + timerBrand: Object @Alleged: timerBrand {}, + }, + timer: Object @Alleged: ManualTimer { +... + }, + }, + } + ℹ alice invitation Object @Alleged: Zoe Invitation payment {} + ℹ oracle offer result { + invitationMakers: Object @Alleged: JobsReportContinuing invitationMakers {}, + kitMustHaveMultipleFacets: Object @Alleged: JobsReportContinuing kitMustHaveMultipleFacets {}, + } + ℹ alice offer result job id 0n + ℹ alice assigns to bob and waits for news on https://github.com/alice/project1/issues/1 ... + ℹ bob opens PR https://github.com/alice/project1/pull/2 + ℹ alice merges https://github.com/alice/project1/pull/2 + ℹ oracle evaluates delivery claim 0n { + issue: { + assignee: 'bob', + num: 1, + status: 'closed', + type: 'issue', + }, + pull: { + author: 'bob', + fixes: 'https://github.com/alice/project1/issues/1', + num: 2, + status: 'merged', + type: 'pull', + }, + } + ℹ oralce makes JobReport { + deliverDepositAddr: 'agoric1bob', + issueURL: 'https://github.com/alice/project1/issues/1', + jobID: 0n, + } + ℹ bob invitation balance { + brand: Object @Alleged: Zoe Invitation brand {}, + value: [ + { + customDetails: Object { … }, + description: 'gimix delivery', + handle: Object @Alleged: InvitationHandle {}, + installation: Object @Alleged: BundleInstallation {}, + instance: Object @Alleged: InstanceHandle {}, + }, + ], + } + ℹ bob accepts deliver invitation Object @Alleged: ZoeSeatKit userSeat {} undefined + ℹ bob payout Acceptance { + brand: Object @Alleged: ZDEFAULT brand {}, + value: 12000000n, + } + ℹ alice payout Acceptance { + brand: Object @Alleged: ZDEFAULT brand {}, + value: 0n, + } + ℹ alice payout Stamp { + brand: Object @Alleged: GimixOracle brand {}, + value: Object @copyBag { + payload: [ + Array [ … ], + ], + }, + } + ℹ done +start-gimix gimix started! + ─ + + 2 tests passed + 1 test todo +Done in 1.37s. +``` \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..ea158a6 --- /dev/null +++ b/Makefile @@ -0,0 +1,50 @@ +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 + +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]' + +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 diff --git a/README-local-chain.md b/README-local-chain.md new file mode 100644 index 0000000..b8d61e7 --- /dev/null +++ b/README-local-chain.md @@ -0,0 +1,62 @@ +# Agoric Local Chain with docker-compose + +To start a local agoric blockchain: + +```sh +docker-compose up -d +``` + +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-labs/dapp-game-places + +### Deploying the contract + +Get the bundle, script, and permit from a release. + +Use the [Agoric Gov Proposal Builder](https://cosgov.org/) +for deployment: + +1. Use the [Install Bundle](https://cosgov.org/?msgType=installBundle&network=local) tab to install the bundle. + It will likely say **insufficient balance**. + To get enough IST: + +```sh +yarn docker:make mint4k +``` + +2. Get ready to vote. To query the status of proposals, use + +```sh +yarn docker:make gov-q +``` + +Then, don't execute this command, but get it ready: + +```sh +yarn docker:make vote PROPOSAL=N +``` + +2. Use the [CoreEval Proposal](https://cosgov.org/?msgType=coreEvalProposal&network=local) tab to make a proposal to + start the contract using the permit and script. + Note the **10 second voting period**, + When you **Sign & Submit** the proposal, you can replace `N` + above with the proposal number that pops up. + + To verify that the proposal executed correctly: + +```sh +docker-compose logs | less -R +``` + +The logs should include a few lines with no errors: + +``` +agd_1 | 2023-11-17T03:12:36.882Z SwingSet: vat: v1: start-gimix timer board05674 +... +agd_1 | 2023-11-17T03:12:38.911Z SwingSet: vat: v1: start-gimix gimix started! +``` diff --git a/README.md b/README.md index 41b40c3..46ff5b0 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,26 @@ -# GiMiX +# GiMiX - AMiX with GitHub (Prototype) +GiMiX is an Agoric dapp to make a market for completing GitHub issues. + + 1. Requestor proposes a bounty by choosing an issue and + putting the bounty assets in escrow for a period of time. + 2. Responder negotiates an assignment to the issue, + opens a PR for the work, and negotiates to close + the issue with the PR. + 3. Responder signs a claim that a PR closes the issue + while logged in with GitHub credentials. + 4. An oracle server verifies the responder's GitHub credentials + and that the PR belongs to the responder and + closes the issue. It then invites the responder to + claim the bounty. + 5. The responder claims the bounty. + 6. The requestor receives a "stamp" NFT from the oracle, + attesting to the completion of the issue. ## Getting Started +_TODO: explain credentials needed by the server._ + ```bash # start oracle server yarn dev:server @@ -10,3 +28,15 @@ yarn dev:server # start web server (and, proxy to oracle server via /api) yarn dev:web ``` + +[README-local-chain](./README-local-chain.md) has details +about starting a testing environment and deploying the contract. + +## Background: AMIX: The American Information Exchange + +> The American Information Exchange (AMIX) was a platform for the buying and selling of information, goods and services as well as the exchange of information, ideas, and certain kinds of intellectual work product, created ... in the 1980s ... -- [Wikipedia](https://en.wikipedia.org/wiki/American_Information_Exchange) + +See also: + + - [What Agoric Learned from the American Information Exchange About Online Markets](https://agoric.com/blog/technology/what-agoric-learned-from-amix) + - [AMIX: The American Information Exchange](http://erights.org/smart-contracts/history/index.html) on erights diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..f0f8205 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,22 @@ +version: '3.5' + +services: + agd: + # image should include proposals from the main agoric-3 chain + # cf. https://github.com/Agoric/agoric-3-proposals + image: ghcr.io/agoric/agoric-3-proposals:main + # multi-arch is not yet available + platform: linux/amd64 + ports: + # GRPC port (?) + - 26656:26656 + # RPC port + - 26657:26657 + # LCD/API port + - 1317:1317 + environment: + # Include console.log() from vats in node logs + DEBUG: "SwingSet:ls,SwingSet:vat" + volumes: + - .:/workspace + entrypoint: /usr/src/upgrade-test-scripts/start_agd.sh diff --git a/package.json b/package.json index b8a830d..eb8dec1 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,8 @@ "build:web": "yarn workspace web run build", "lint:web": "yarn workspace web run lint", "test:web": "yarn workspace web run test", + "docker:make": "docker-compose exec agd make -C /workspace", + "make:help": "make list", "postinstall": "patch-package" }, "dependencies": {