diff --git a/src/Resolution.ts b/src/Resolution.ts index 7ef30d01..f9efa195 100644 --- a/src/Resolution.ts +++ b/src/Resolution.ts @@ -569,12 +569,15 @@ export default class Resolution { try { return await this.record(domain, 'gundb.username.value'); } catch (err) { - throw new ResolutionError(ResolutionErrorCode.RecordNotFound, { - domain, - method: err.method, - methodName: 'chatId', - recordName: err.recordName, - }); + if (err.code === ResolutionErrorCode.RecordNotFound) { + throw new ResolutionError(ResolutionErrorCode.RecordNotFound, { + domain, + method: err.method, + methodName: 'chatId', + recordName: err.recordName, + }); + } + throw err; } } @@ -588,12 +591,15 @@ export default class Resolution { try { return await this.record(domain, 'gundb.public_key.value'); } catch (err) { - throw new ResolutionError(ResolutionErrorCode.RecordNotFound, { - domain, - method: err.method, - methodName: 'chatPk', - recordName: err.recordName, - }); + if (err.code === ResolutionErrorCode.RecordNotFound) { + throw new ResolutionError(ResolutionErrorCode.RecordNotFound, { + domain, + method: err.method, + methodName: 'chatPk', + recordName: err.recordName, + }); + } + throw err; } } @@ -954,10 +960,8 @@ export default class Resolution { const ensDomains = domains.filter((domain) => domain.match(/^([^\s\\.]+\.)+(eth|luxe|xyz|kred)+$/), ); - const unsDomains = domains.filter( - (domain) => - !domain.endsWith('.zil') && - !domain.match(/^([^\s\\.]+\.)+(eth|luxe|xyz|kred)+$/), + const nonEnsDomains = domains.filter( + (domain) => !domain.match(/^([^\s\\.]+\.)+(eth|luxe|xyz|kred)+$/), ); // Here, we call both UNS and ZNS methods and merge the results. // If any of the calls fails, this method will fail as well as we aren't interested in partial results. @@ -966,7 +970,7 @@ export default class Resolution { // migrated to UNS), the ZNS call result will be ignored and an error, if there's one, won't be thrown. const unsPromise = - this.serviceMap.UNS.usedServices[0].locations(unsDomains); + this.serviceMap.UNS.usedServices[0].locations(nonEnsDomains); // Fetch UNS locations first. If we see that there are no .zil domains with absent locations, we can return early. const unsLocations = await unsPromise; if (zilDomains.length) { diff --git a/src/tests/Ens.test.ts b/src/tests/Ens.test.ts index 640f4330..831ed826 100644 --- a/src/tests/Ens.test.ts +++ b/src/tests/Ens.test.ts @@ -331,7 +331,9 @@ describe('ENS', () => { }); const ipfsHash = await resolution.ipfsHash('monkybrain.eth'); expectSpyToBeCalled(eyes); - expect(ipfsHash).toBe('QmXSBLw6VMegqkCHSDBPg7xzfLhUyuRBzTb927KVzKC1vq'); + expect(ipfsHash).toBe( + 'ipfs://QmXSBLw6VMegqkCHSDBPg7xzfLhUyuRBzTb927KVzKC1vq', + ); }); // todo(johny) find some domains with url property set