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

update zoe overview to match dapp-offer-up; add contract basics #889

Merged
merged 32 commits into from
Jan 9, 2024

Conversation

dckc
Copy link
Member

@dckc dckc commented Dec 6, 2023

Our getting started material has, to date, been largely disconnected from our Zoe guide. The getting started dapp was a fungible faucet, which had no conditional exchange of assets at all.

The card store app addresses that, but

  • it's not compatible with the smart wallet architecture
  • the Zoe docs ignore it and start with atomic swap

The thinking here is to use the simple game piece contract, which is somewhat like atomic swap but

  • shows how to mint tokens, avoiding "where do the issuers come from?"
  • demonstrably fits with smart wallet
  • is 66 lines

Aspects that this contract does not exhibit:

  • inspecting an invitation: the invitations are requested by the walletFactory and immediately used in a zoe.offer() call. They're never in your purse long enough for you to inspect them.

tasks:

  • smart contract basics - hello, testing, state, access control
  • zoe overview covers mint / sell token using game places contract
  • file/link organization - where to put contract basics vs. the README

fixes #891, #436

refs:

Copy link
Contributor

mergify bot commented Dec 6, 2023

⚠️ The sha of the head commit of this PR conflicts with #881. Mergify cannot evaluate rules on this PR. ⚠️

Copy link

cloudflare-workers-and-pages bot commented Dec 6, 2023

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 1fdcda3
Status: ✅  Deploy successful!
Preview URL: https://1f9b556b.documentation-7tp.pages.dev
Branch Preview URL: https://dc-contract-basic.documentation-7tp.pages.dev

View logs

@dckc dckc changed the title SPIKE: contract basics SPIKE: contract basics; integrate zoe overview with getting started Dec 12, 2023
@dckc dckc marked this pull request as ready for review January 3, 2024 23:46
@dckc dckc marked this pull request as draft January 4, 2024 03:45
@dckc
Copy link
Member Author

dckc commented Jan 4, 2024

weird. I messed up something with git. hang on...

@dckc dckc changed the base branch from dc-npm-only to main January 4, 2024 03:48
@dckc
Copy link
Member Author

dckc commented Jan 4, 2024

ah. I had the wrong target branch. it should be right now.

@dckc dckc marked this pull request as ready for review January 4, 2024 03:49
Copy link
Collaborator

@Chris-Hibbert Chris-Hibbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good.

main/guides/zoe/README.md Outdated Show resolved Hide resolved
]),
);

playerSeat.exit(true);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this also exit() the tmp seat as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know. It seems to work ok without doing that. Doesn't letting it go out of scope and get garbage collected suffice?

Checking ZCFSeat docs... all I see is "Note: You should not use aZCFSeat.exit() when exiting with an error."

I thought I had seen this pattern of using a temp seat with mintGains(), but psm.js seems to use a long-lived seat.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we recently noticed (#8672) that Seats that are not exited can retain some uncollectible (GC-resistant) cycles. Calling .exit() when you know the seat is no longer in use is now a best practice.

main/guides/zoe/contract-basics.md Outdated Show resolved Hide resolved
import { start as startState } from '../src/02-state.js';
import { start as startAccess } from '../src/03-access.js';
// #region test1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see the source code, so I was able to understand the distinction between startAccess and startState, but it's not obvious from looking at the generated docs. Does it make sense to add a comment in the tests where they're called?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I re-factored it to use

import * as state from '../src/02-state.js';

and then state.start(). I hope that's sufficiently clear.

@dckc dckc changed the title SPIKE: contract basics; integrate zoe overview with getting started update zoe overview to match dapp-offer-up; add contract basics Jan 8, 2024
dckc added 10 commits January 8, 2024 18:03
 - don't show region comments
 - reference to Zoe is just a distraction
 - index start later
 - fix test name
 - don't mention snippets
 - connect to surrounding sections
 - link fixes
 - debug.js too
 - refactor(test-alice-trade): rename pmt to Place
   to match keyword, resulting in short property form
   that's handy in a diagram
 - refactor: postpone discussion of harden
   returning a fresh { ... } record does not put a function at
   risk.
 - hide region markers in full listing
   add whole-file region to suppress others
sections that are starting to take shape:

 - Bundling a Contract
   Get this housekeeping aspect out of the way
   so that further tests can ignore it.
 - Contract Installation
 - Starting a contract
@dckc dckc enabled auto-merge (squash) January 9, 2024 19:15
@dckc dckc merged commit 85146a3 into main Jan 9, 2024
4 checks passed
@dckc dckc deleted the dc-contract-basic branch January 9, 2024 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

atomic swap example in zoe docs does not fit with smart wallet architecture
3 participants