Skip to content

Commit

Permalink
Added valid non-found in subgraph error (vs schema error) and removed…
Browse files Browse the repository at this point in the history
… wasteful retries from wallet function getRegisteredStealthKeys
  • Loading branch information
jferas committed May 2, 2024
1 parent bc1f6a8 commit 6d831ac
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
20 changes: 6 additions & 14 deletions frontend/src/store/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -631,19 +631,11 @@ const hasSetPublicKeysLegacy = async (name: string, provider: Provider) => {

// Helper method to check if user has registered public keys in the StealthKeyRegistry
async function getRegisteredStealthKeys(account: string, provider: Provider) {
let retryCounter = 0;
while (retryCounter < 3) {
try {
console.log(`getting stealth keys for ${account}, try ${retryCounter + 1} of 3`);
const stealthPubKeys = await utils.lookupRecipient(account, provider); // throws if no keys found
return stealthPubKeys;
} catch (err) {
window.logger.warn(err);
retryCounter++;
if (retryCounter < 3) {
await new Promise((resolve) => setTimeout(resolve, 2000)); // Wait for 2 seconds
}
}
try {
const stealthPubKeys = await utils.lookupRecipient(account, provider); // throws if no keys found
return stealthPubKeys;
} catch (err) {
window.logger.warn(err);
return null;
}
return null;
}
1 change: 1 addition & 0 deletions umbra-js/src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ export async function getMostRecentSubgraphStealthKeyChangedEventFromAddress(
}

if (!theEvent) {
console.log(`Searched the subgraph, but found no StealthKeyChangedEvents for address ${address}`);
throw new Error('No stealthKeyChangedEvents found matching address in subgraph');
}
return theEvent;
Expand Down

0 comments on commit 6d831ac

Please sign in to comment.