From 458f7a14894159a4679d43354e977314c004af59 Mon Sep 17 00:00:00 2001 From: storywithoutend Date: Mon, 28 Aug 2023 17:53:19 +0800 Subject: [PATCH] Add resolver address param to _getABI --- .../src/functions/getSpecificRecord.test.ts | 17 +++++++++++++++++ .../ensjs/src/functions/getSpecificRecord.ts | 8 ++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/packages/ensjs/src/functions/getSpecificRecord.test.ts b/packages/ensjs/src/functions/getSpecificRecord.test.ts index 7d7a5efa..e0ba0fe9 100644 --- a/packages/ensjs/src/functions/getSpecificRecord.test.ts +++ b/packages/ensjs/src/functions/getSpecificRecord.test.ts @@ -238,4 +238,21 @@ describe('getSpecificRecord', () => { expect(result).toBeUndefined() }) }) + + describe('_getABI', () => { + it('should return if resolver address is included', async () => { + const profile = await ensInstance.getProfile('with-type-1-abi.eth') + expect(profile?.resolverAddress).toBeTruthy() + const result = await ensInstance._getABI( + 'with-type-1-abi.eth', + profile?.resolverAddress, + ) + expect(result).toBeTruthy() + if (result) { + expect(result.contentType).toBe(1) + expect(result.decoded).toBe(true) + expect(result.abi).toMatchObject(dummyABI) + } + }) + }) }) diff --git a/packages/ensjs/src/functions/getSpecificRecord.ts b/packages/ensjs/src/functions/getSpecificRecord.ts index c4a5db4e..ac13e0fb 100644 --- a/packages/ensjs/src/functions/getSpecificRecord.ts +++ b/packages/ensjs/src/functions/getSpecificRecord.ts @@ -245,10 +245,14 @@ export const getAddr = { const supportedContentTypes = '0xf' export const _getABI = { - raw: async ({ contracts }: ENSArgs<'contracts'>, name: string) => { + raw: async ( + { contracts }: ENSArgs<'contracts'>, + name: string, + resolverAddress?: string, + ) => { const publicResolver = await contracts?.getPublicResolver()! return { - to: '0x0000000000000000000000000000000000000000', + to: resolverAddress || '0x0000000000000000000000000000000000000000', data: publicResolver.interface.encodeFunctionData('ABI', [ namehash(name), supportedContentTypes,