diff --git a/frontend/package.json b/frontend/package.json index 725ef15a..b3301757 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -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", diff --git a/umbra-js/src/utils/utils.ts b/umbra-js/src/utils/utils.ts index f99d5d99..d5aaa188 100644 --- a/umbra-js/src/utils/utils.ts +++ b/umbra-js/src/utils/utils.ts @@ -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( @@ -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 }; } }