@@ -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