Skip to content

Commit aaa9818

Browse files
authored
Don't pass empty string, it's optional (#4929)
## Motivation We are seeing errors in the console, coming from the Linera web client, about CryptoHash expecting 32-bytes but getting 0. ## Proposal This happens b/c frontends pass empty string (`''`) to a method (`query`) that expects `Option<CryptoHash>` and assuming that if it's `Some(_)` it must be correct slice. After fixing `query` in #4904 I forgot to update this. ## Test Plan Manual. Verified that with this fix we no longer get the errors. ## Release Plan - Release web demos to the frontend - Backport fix to `main` ## Links - [reviewer checklist](https://github.com/linera-io/linera-protocol/blob/main/CONTRIBUTING.md#reviewer-checklist)
1 parent ecbb2df commit aaa9818

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

examples/counter/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ <h2>Chain history for <code id="chain-id" class="hex">requesting chain…</code>
8585
}
8686

8787
async function updateCount(block_hash) {
88-
const response = await counter.query('{ "query": "query { value }" }', block_hash || '');
88+
const response = await counter.query('{ "query": "query { value }" }', block_hash);
8989
document.getElementById('count').innerText
9090
= JSON.parse(response).data.value;
9191
}

examples/native-fungible/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ <h2>Chain history for <code id="chain-id" class="hex">requesting a new microchai
166166
}
167167

168168
async function updateBalance(application, owner, blockHash) {
169-
const response = JSON.parse(await application.query(gql(`query { tickerSymbol, accounts { entry(key: "${owner}") { value } } }`), blockHash || ''));
169+
const response = JSON.parse(await application.query(gql(`query { tickerSymbol, accounts { entry(key: "${owner}") { value } } }`)));
170170
console.debug('application response:', response);
171171
document.querySelector('#ticker-symbol').textContent = response.data.tickerSymbol;
172172
document.querySelector('#balance').textContent = (+(response?.data?.accounts?.entry.value || 0)).toFixed(2);

0 commit comments

Comments
 (0)