Skip to content

Commit

Permalink
Changed public key acquisition to query registry contract before subg…
Browse files Browse the repository at this point in the history
…raph.. umbra-js change
  • Loading branch information
jferas committed Jul 11, 2024
1 parent 637f0fa commit 7fc2c24
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@adraffy/ens-normalize": "1.9.2",
"@metamask/jazzicon": "^2.0.0",
"@quasar/extras": "^1.15.8",
"@umbracash/umbra-js": "0.2.0",
"@umbracash/umbra-js": "file:../umbra-js",
"@uniswap/token-lists": "^1.0.0-beta.19",
"@unstoppabledomains/resolution": "8.5.0",
"@web3-onboard/coinbase": "2.2.7",
Expand Down
22 changes: 11 additions & 11 deletions umbra-js/src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,18 @@ export async function lookupRecipient(

// If we're not using advanced mode, use the StealthKeyRegistry events
if (!advanced) {
// Fetch the stealth key registry event from the subgraph and fall back to the registry contract if the subgraph returns an error
// Fetch the stealth key registry event from the the registry contract and fall back to subgraph if the registry contract fetch returns an error
try {
const registry = new StealthKeyRegistry(provider);
const { spendingPublicKey, viewingPublicKey } = await registry.getStealthKeys(address);
return { spendingPublicKey, viewingPublicKey };
} catch (error) {
if (error instanceof Error) {
console.log('StrealthKey Registry fetch error: ', error.message);
} else {
console.log('An unknown error occurred: ', error);
}
console.log('Error using Registry contract to lookup receipient stealth keys, will query subgraph');
const chainConfig = parseChainConfig(chainId);
const stealthKeyChangedEvent = await getMostRecentSubgraphStealthKeyChangedEventFromAddress(address, chainConfig);
const spendingPublicKey = KeyPair.getUncompressedFromX(
Expand All @@ -264,16 +274,6 @@ export async function lookupRecipient(
viewingPublicKey: viewingPublicKey,
block: stealthKeyChangedEvent.block,
};
} catch (error) {
if (error instanceof Error) {
console.log('Public key subgraph fetch error: ', error.message);
} else {
console.log('An unknown error occurred: ', error);
}
console.log('Error using subgraph to lookup receipient stealth keys, will query registry contract');
const registry = new StealthKeyRegistry(provider);
const { spendingPublicKey, viewingPublicKey } = await registry.getStealthKeys(address);
return { spendingPublicKey, viewingPublicKey };
}
}

Expand Down

0 comments on commit 7fc2c24

Please sign in to comment.