You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: main/guides/zoe/pub-to-storage.md
+30-10Lines changed: 30 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,32 @@ Contracts can use [notifiers and subscriptions](../js-programming/notifiers)
4
4
to publish to clients. To publish data visible to [vstorage queries](../getting-started/contract-rpc#querying-vstorage), contracts should connect
5
5
a subscriber to a `chainStorage` node.
6
6
7
-
Let's look at the Inter Protocol [assetReserve.js](https://github.com/Agoric/agoric-sdk/blob/agoric-upgrade-13/packages/inter-protocol/src/reserve/assetReserve.js) contract. It publishes to [published.reserve.metrics](https://github.com/Agoric/agoric-sdk/blob/agoric-upgrade-13/packages/inter-protocol/test/reserve/snapshots/test-reserve.js.md) data of the form
7
+
## Deployment Capabilities for Publishing to chainStorage
8
+
9
+
In [Adding Parameter Governance to a Contract](../governance/#adding-parameter-governance-to-a-contract), the contract
10
+
gets 2 properties for publishing to chainStorage in its `privateArgs`: `storageNode` and `marshaller`.
11
+
12
+
In [dapp-agoric-basics](https://github.com/Agoric/dapp-agoric-basics), the `startSwapContract` uses 2 [permitted deployment capabilities](../coreeval/permissions), `chainStorage` and `board` and uses them to make the `privateArgs`:
A `Marshaller` is parameterized by functions for mapping unforgeable object identities to plain data slot references and back. Using the [board](../integration/name-services#the-board-publishing-under-arbitrary-names) name service gives consistent slot references across contracts.
20
+
As discussed in [Marshalling Amounts and Instances](../getting-started/contract-rpc#marshalling-amounts-and-instances), this lets
21
+
off-chain clients use the same `@endo/marshal` API.
22
+
23
+
The `chainStorage` node corresponds to the `published` key in the
24
+
[vstorage hierarchy](/reference/vstorage-ref).
25
+
Using `E(chainStorage).makeChildNode(contractName)` gives the contract
26
+
access to write to the `published.swaparoo` key and all keys under it.
27
+
28
+
The `swaparoo` contract delegates the rest of publishing governance parameters to the `@agoric/governance` package.
29
+
30
+
## Publishing structured data to chainStorage
31
+
32
+
Let's look at the Inter Protocol [assetReserve.js](https://github.com/Agoric/agoric-sdk/blob/agoric-upgrade-13/packages/inter-protocol/src/reserve/assetReserve.js) contract to get more of the details. It publishes to [published.reserve.metrics](https://github.com/Agoric/agoric-sdk/blob/agoric-upgrade-13/packages/inter-protocol/test/reserve/snapshots/test-reserve.js.md) data of the form
The `marshaller` is used to serialize data structures such as `MetricsNotification` above.
111
136
112
-
## Deployment Capabilities for Publishing to chainStorage
137
+
###Deployment Capabilities for the reserve
113
138
114
-
To start a contract such as `assetReserve` above, the [setupReserve](https://github.com/Agoric/agoric-sdk/blob/agoric-upgrade-13/packages/inter-protocol/src/proposals/econ-behaviors.js#L76) function needs to supply
115
-
the two `privateArgs`:`marshaller` and `storageNode`:
139
+
To start `assetReserve`, the [setupReserve](https://github.com/Agoric/agoric-sdk/blob/agoric-upgrade-13/packages/inter-protocol/src/proposals/econ-behaviors.js#L76) function again supplies
140
+
the two relevant `privateArgs`,`marshaller` and `storageNode`:
A `Marshaller` is parameterized by functions for mapping unforgeable object identities to plain data slot references and back. Using the [board](../integration/name-services#the-board-publishing-under-arbitrary-names) name service gives consistent slot references across contracts.
138
-
As discussed in [Marshalling Amounts and Instances](../getting-started/contract-rpc#marshalling-amounts-and-instances), this lets
139
-
off-chain clients use the same `@endo/marshal` API.
0 commit comments