Skip to content

Commit ccb0b10

Browse files
committed
refactor: adapt the WASM client example to work with new unstable implementation
1 parent d8615b3 commit ccb0b10

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

mithril-client-wasm/www/index.js

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -64,21 +64,16 @@ function format_tx_list(transactions_hashes) {
6464
return "<ul>" + transactions_hashes.map((tx) => "<li>" + tx + "</li>").join("") + "</ul>";
6565
}
6666

67-
function client_options_with_custom_headers() {
68-
// The following header is set as an example.
69-
// It's used to demonstrate how to add headers.
70-
let http_headers_map = new Map();
71-
http_headers_map.set("Content-Type", "application/json");
72-
73-
return {
74-
http_headers: http_headers_map,
75-
};
76-
}
77-
7867
await initMithrilClient();
7968

80-
let client_options = client_options_with_custom_headers();
81-
let client = new MithrilClient(aggregator_endpoint, genesis_verification_key, client_options);
69+
let client = new MithrilClient(aggregator_endpoint, genesis_verification_key, {
70+
// The following header is set as an example.
71+
// It's used to demonstrate how to add headers.
72+
http_headers: new Map([["Content-Type", "application/json"]]),
73+
// The following option activates the unstable features of the client.
74+
// Unstable features will trigger an error if this option is not set.
75+
unstable: true,
76+
});
8277

8378
displayStepInDOM(1, "Getting stake distributions list...");
8479
let mithril_stake_distributions_list = await client.list_mithril_stake_distributions();
@@ -135,7 +130,7 @@ displayMessageInDOM("Result", "Mithril stake distribution message validated &#x2
135130
console.log("valid_stake_distribution_message:", valid_stake_distribution_message);
136131

137132
displayStepInDOM(7, "Getting transaction proof...");
138-
const proof = await client.unstable.get_cardano_transaction_proofs([
133+
const proof = await client.get_cardano_transaction_proofs([
139134
"eac09f970f47ef3ab378db9232914e146773853397e79b904f1a45123a23c21f",
140135
"81fe7a5dab42867ef309b6d7210158bf99331884ac3c3b6c7188a8c9c18d5974",
141136
"320c13f4a3e51f6f4f66fcd9007e02bf658aa4ee9a88a509028d867d3b8a8e9a",
@@ -157,7 +152,7 @@ displayMessageInDOM("Result", "certificate chain verified &#x2713;");
157152
console.log("verify_certificate_chain OK, last_certificate_from_chain:", proof_certificate);
158153

159154
displayStepInDOM(10, "Validating Cardano transaction proof message...");
160-
let protocol_message = await client.unstable.verify_cardano_transaction_proof_then_compute_message(
155+
let protocol_message = await client.verify_cardano_transaction_proof_then_compute_message(
161156
proof,
162157
proof_certificate,
163158
);

0 commit comments

Comments
 (0)