Skip to content

Commit 21ed6fc

Browse files
authored
Merge pull request input-output-hk#1891 from input-output-hk/dlachaume/1844/add-missing-cardano-stake-distribution-example
Add missing Cardano stake distribution example in developer documentation
2 parents c0fa486 + fec04a7 commit 21ed6fc

File tree

1 file changed

+63
-3
lines changed

1 file changed

+63
-3
lines changed

docs/website/root/manual/developer-docs/nodes/mithril-client-library-wasm.md

+63-3
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,10 @@ You can verify that the aggregator signs **CardanoTransactions** by running the
156156
wget -q -O - YOUR_AGGREGATOR_ENDPOINT | jq '.capabilities.signed_entity_types | contains(["CardanoTransactions"])'
157157
```
158158

159-
For example with the aggregator on `testing-sanchonet` Mithril network:
159+
For example with the aggregator on `pre-release-preview` Mithril network:
160160

161161
```bash
162-
wget -q -O - https://aggregator.testing-sanchonet.api.mithril.network/aggregator | jq '.capabilities.signed_entity_types | contains(["CardanoTransactions"])'
162+
wget -q -O - https://aggregator.pre-release-preview.api.mithril.network/aggregator | jq '.capabilities.signed_entity_types | contains(["CardanoTransactions"])'
163163
```
164164

165165
:::
@@ -191,8 +191,68 @@ console.log(
191191
);
192192
```
193193

194+
With the same logic as above, if the aggregator signs **CardanoStakeDistribution**, you can add the code below to the previous example:
195+
194196
:::tip
195197

196-
You can read the complete [Rust developer documentation](https://mithril.network/rust-doc/mithril_client_wasm/index.html).
198+
You can verify that the aggregator signs **CardanoStakeDistribution** by running the command below:
199+
200+
```bash
201+
wget -q -O - YOUR_AGGREGATOR_ENDPOINT | jq '.capabilities.signed_entity_types | contains(["CardanoStakeDistribution"])'
202+
```
203+
204+
For example with the aggregator on `testing-preview` Mithril network:
205+
206+
```bash
207+
wget -q -O - https://aggregator.testing-preview.api.mithril.network/aggregator | jq '.capabilities.signed_entity_types | contains(["CardanoStakeDistribution"])'
208+
```
197209

198210
:::
211+
212+
```js
213+
let cardano_stake_distributions_list =
214+
await client.unstable.list_cardano_stake_distributions();
215+
console.log("cardano stake distributions:", cardano_stake_distributions_list);
216+
217+
let last_cardano_stake_distribution =
218+
await client.unstable.get_cardano_stake_distribution(
219+
cardano_stake_distributions_list[0].hash,
220+
);
221+
console.log(
222+
"last_cardano_stake_distribution:",
223+
last_cardano_stake_distribution,
224+
);
225+
226+
let certificate = await client.get_mithril_certificate(
227+
last_cardano_stake_distribution.certificate_hash,
228+
);
229+
console.log("certificate:", certificate);
230+
231+
let last_certificate_from_chain = await client.verify_certificate_chain(
232+
certificate.hash,
233+
);
234+
console.log(
235+
"verify certificate chain OK, last_certificate_from_chain:",
236+
last_certificate_from_chain,
237+
);
238+
239+
let cardano_stake_distribution_message =
240+
await client.unstable.compute_cardano_stake_distribution_message(
241+
certificate,
242+
last_cardano_stake_distribution,
243+
);
244+
console.log(
245+
"cardano_stake_distribution_message:",
246+
cardano_stake_distribution_message,
247+
);
248+
249+
let valid_cardano_stake_distribution_message =
250+
await client.verify_message_match_certificate(
251+
cardano_stake_distribution_message,
252+
last_certificate_from_chain,
253+
);
254+
console.log(
255+
"valid_cardano_stake_distribution_message:",
256+
valid_cardano_stake_distribution_message,
257+
);
258+
```

0 commit comments

Comments
 (0)