From f8674ceb0ba1a2952de5ac3ec8f27114d11bfeb0 Mon Sep 17 00:00:00 2001 From: Samuel Siegart Date: Sat, 19 Aug 2023 10:06:51 -0700 Subject: [PATCH] Update README.md --- README.md | 29 ++++---------------------- packages/rpc/README.md | 21 +++++++++++++++++++ packages/web-components/MAINTAINERS.md | 18 ++++++++++++++++ packages/web-components/README.md | 27 ++++++++++++------------ 4 files changed, 57 insertions(+), 38 deletions(-) create mode 100644 packages/rpc/README.md create mode 100644 packages/web-components/MAINTAINERS.md diff --git a/README.md b/README.md index b0c1e5c..058f104 100644 --- a/README.md +++ b/README.md @@ -14,13 +14,6 @@ It polls the RPC periodically, automatically batching and de-duping requests for See https://github.com/p2p-org/p2p-agoric-vstorage-viewer to explore vstorage more. -*package.json:* -``` -"@agoric/rpc": "^0.4.1-dev-7cf64bb.0" -``` - - -*app.ts:* ```ts import { makeAgoricChainStorageWatcher, @@ -31,7 +24,7 @@ const watcher = makeAgoricChainStorageWatcher(rpc, chainName); // Watch vstorage children at a given node. const stopWatching = watcher.watchLatest( - [Kind.Children, 'published.vaultFactory.managers', + [Kind.Children, 'published.vaultFactory.managers'], managerIds => { console.log('Got vault manager IDs:', managerIds); } @@ -42,7 +35,7 @@ stopWatching(); // Watch vstorage data at a given node. watcher.watchLatest( - [Kind.Data, 'published.agoricNames.brand', + [Kind.Data, 'published.agoricNames.brand'], brands => { console.log('Do something with the brands'); } @@ -51,14 +44,6 @@ watcher.watchLatest( ## Connecting to User's Account (Keplr) -*package.json:* -``` -"@agoric/notifier": "^0.6.2", -"@agoric/rpc": "^0.4.1-dev-7cf64bb.0", -"@agoric/web-components": "0.10.1-dev-7cf64bb.0" -``` - -*app.ts:* ```ts import { subscribeLatest } from '@agoric/notifier'; import { makeAgoricChainStorageWatcher } from '@agoric/rpc'; @@ -75,13 +60,6 @@ for await (const purses of subscribeLatest(pursesNotifier)) { ## Executing Offers -*package.json:* -``` -"@agoric/rpc": "^0.4.1-dev-7cf64bb.0", -"@agoric/web-components": "0.10.1-dev-7cf64bb.0" -``` - -*app.ts:* ```ts import { makeAgoricChainStorageWatcher } from '@agoric/rpc'; import { makeAgoricWalletConnection } from '@agoric/web-components'; @@ -99,6 +77,7 @@ connection.makeOffer( callPipe: [ ['getSwapManagerForBrand', [amountToGive.brand]], ['makeSwapOffer'] + ] }, { give: { In: amountToGive }, @@ -113,7 +92,7 @@ connection.makeOffer( console.log('Transaction submitted:', data.txn); console.log('Offer id:', data.offerId); } - if (status === 'refunded') + if (status === 'refunded') { console.log('Offer refunded'); } if (status === 'accepted') { diff --git a/packages/rpc/README.md b/packages/rpc/README.md new file mode 100644 index 0000000..3018413 --- /dev/null +++ b/packages/rpc/README.md @@ -0,0 +1,21 @@ +For more complete examples and setup see [Agoric/ui-kit](https://github.com/Agoric/ui-kit) + +```ts +import { + makeAgoricChainStorageWatcher, + AgoricChainStoragePathKind as Kind +} from '@agoric/rpc'; + +const watcher = makeAgoricChainStorageWatcher(rpc, chainName); + +// Watch vstorage children at a given node. +const stopWatching = watcher.watchLatest( + [Kind.Children, 'published.vaultFactory.managers'], + managerIds => { + console.log('Got vault manager IDs:', managerIds); + } +) + +// Stop watching. +stopWatching(); +``` diff --git a/packages/web-components/MAINTAINERS.md b/packages/web-components/MAINTAINERS.md new file mode 100644 index 0000000..51cb38a --- /dev/null +++ b/packages/web-components/MAINTAINERS.md @@ -0,0 +1,18 @@ +## Linting and formatting + +To scan the package for linting and formatting errors, run + +```bash +yarn lint +``` + +To automatically fix linting and formatting errors, run + +```bash +yarn format +``` + +## Tooling configs + +For most of the tools, the configuration is in the `package.json` to minimize +the amount of files in this package. diff --git a/packages/web-components/README.md b/packages/web-components/README.md index 51cb38a..d43290e 100644 --- a/packages/web-components/README.md +++ b/packages/web-components/README.md @@ -1,18 +1,19 @@ -## Linting and formatting +For complete examples and setup see [Agoric/ui-kit](https://github.com/Agoric/ui-kit) -To scan the package for linting and formatting errors, run +```ts +import { subscribeLatest } from '@agoric/notifier'; +import { makeAgoricChainStorageWatcher } from '@agoric/rpc'; +import { makeAgoricWalletConnection } from '@agoric/web-components'; -```bash -yarn lint -``` +const watcher = makeAgoricChainStorageWatcher(rpc, chainName); +const connection = await makeAgoricWalletConnection(watcher); +const {pursesNotifier, publicSubscribersNotifier} = chainConnection; -To automatically fix linting and formatting errors, run +// Sign an on-chain offer transaction. +connection.makeOffer(...offer); -```bash -yarn format +// Read the user's token balances. +for await (const purses of subscribeLatest(pursesNotifier)) { + console.log('Got user purses:', purses); +} ``` - -## Tooling configs - -For most of the tools, the configuration is in the `package.json` to minimize -the amount of files in this package.