Skip to content

Commit 2d13d19

Browse files
committed
Changed public key acquisition to query registry contract before subgraph.. umbra-js change
1 parent ad1e40f commit 2d13d19

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

frontend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"@adraffy/ens-normalize": "1.9.2",
2121
"@metamask/jazzicon": "^2.0.0",
2222
"@quasar/extras": "^1.15.8",
23-
"@umbracash/umbra-js": "0.2.0",
23+
"@umbracash/umbra-js": "file:../umbra-js",
2424
"@uniswap/token-lists": "^1.0.0-beta.19",
2525
"@unstoppabledomains/resolution": "8.5.0",
2626
"@web3-onboard/coinbase": "2.2.7",

umbra-js/src/utils/utils.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,18 @@ export async function lookupRecipient(
247247

248248
// If we're not using advanced mode, use the StealthKeyRegistry events
249249
if (!advanced) {
250-
// Fetch the stealth key registry event from the subgraph and fall back to the registry contract if the subgraph returns an error
250+
// Fetch the stealth key registry event from the the registry contract and fall back to subgraph if the registry contract fetch returns an error
251251
try {
252+
const registry = new StealthKeyRegistry(provider);
253+
const { spendingPublicKey, viewingPublicKey } = await registry.getStealthKeys(address);
254+
return { spendingPublicKey, viewingPublicKey };
255+
} catch (error) {
256+
if (error instanceof Error) {
257+
console.log('StrealthKey Registry fetch error: ', error.message);
258+
} else {
259+
console.log('An unknown error occurred: ', error);
260+
}
261+
console.log('Error using Registry contract to lookup receipient stealth keys, will query subgraph');
252262
const chainConfig = parseChainConfig(chainId);
253263
const stealthKeyChangedEvent = await getMostRecentSubgraphStealthKeyChangedEventFromAddress(address, chainConfig);
254264
const spendingPublicKey = KeyPair.getUncompressedFromX(
@@ -264,16 +274,6 @@ export async function lookupRecipient(
264274
viewingPublicKey: viewingPublicKey,
265275
block: stealthKeyChangedEvent.block,
266276
};
267-
} catch (error) {
268-
if (error instanceof Error) {
269-
console.log('Public key subgraph fetch error: ', error.message);
270-
} else {
271-
console.log('An unknown error occurred: ', error);
272-
}
273-
console.log('Error using subgraph to lookup receipient stealth keys, will query registry contract');
274-
const registry = new StealthKeyRegistry(provider);
275-
const { spendingPublicKey, viewingPublicKey } = await registry.getStealthKeys(address);
276-
return { spendingPublicKey, viewingPublicKey };
277277
}
278278
}
279279

0 commit comments

Comments
 (0)