Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
samsiegart committed Aug 21, 2023
1 parent bace879 commit cb711ad
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 38 deletions.
29 changes: 4 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -31,7 +24,7 @@ const watcher = makeAgoricChainStorageWatcher(rpc, chainName);

// Watch vstorage children at a given node.
const stopWatching = watcher.watchLatest<string[]>(
[Kind.Children, 'published.vaultFactory.managers',
[Kind.Children, 'published.vaultFactory.managers'],
managerIds => {
console.log('Got vault manager IDs:', managerIds);
}
Expand All @@ -42,7 +35,7 @@ stopWatching();

// Watch vstorage data at a given node.
watcher.watchLatest<Brands>(
[Kind.Data, 'published.agoricNames.brand',
[Kind.Data, 'published.agoricNames.brand'],
brands => {
console.log('Do something with the brands');
}
Expand All @@ -51,14 +44,6 @@ watcher.watchLatest<Brands>(

## 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';
Expand All @@ -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';
Expand All @@ -99,6 +77,7 @@ connection.makeOffer(
callPipe: [
['getSwapManagerForBrand', [amountToGive.brand]],
['makeSwapOffer']
]
},
{
give: { In: amountToGive },
Expand All @@ -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') {
Expand Down
21 changes: 21 additions & 0 deletions packages/rpc/README.md
Original file line number Diff line number Diff line change
@@ -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<string[]>(
[Kind.Children, 'published.vaultFactory.managers'],
managerIds => {
console.log('Got vault manager IDs:', managerIds);
}
)

// Stop watching.
stopWatching();
```
18 changes: 18 additions & 0 deletions packages/web-components/MAINTAINERS.md
Original file line number Diff line number Diff line change
@@ -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.
27 changes: 14 additions & 13 deletions packages/web-components/README.md
Original file line number Diff line number Diff line change
@@ -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.

0 comments on commit cb711ad

Please sign in to comment.