@@ -44,18 +44,29 @@ export default function useRekeyDateStore() {
47+ // NB(shrugs) using try-catch here to simplify our error handling
47− if (logs.length === 0) {
49+ if (logs.length === 0) {
48− //TODO: better encoding for "no rekeyDate" state?
49− addToRekeyDateCache({
50− [point]: Just(Result.Error('No rekey date available.')),
50+ throw new Error('No logs available.');
53 // last log is most recent
53 // last log is most recent
54 const blockNumber = logs[logs.length - 1].blockNumber;
54 const blockNumber = logs[logs.length - 1].blockNumber;
55+ if (blockNumber === null) {
56+ // the "latest" parameter includes pending blocks,
57+ // which won't have a blockNumber just yet
58+ throw new Error('Latest rekey is still pending');
55 const block = await _web3.eth.getBlock(blockNumber);
61 const block = await _web3.eth.getBlock(blockNumber);
56 addToRekeyDateCache({
62 addToRekeyDateCache({
57 [point]: Just(Result.Ok(new Date(block.timestamp * 1000))),
63 [point]: Just(Result.Ok(new Date(block.timestamp * 1000))),
66+ //TODO: better encoding for "no rekeyDate" state?
67+ addToRekeyDateCache({
68+ [point]: Just(Result.Error('No rekey date available.')),
61 [web3, contracts, addToRekeyDateCache]
72 [web3, contracts, addToRekeyDateCache]