Skip to content

Commit

Permalink
Merge pull request #148 from ensdomains/add-resolver-address-to-getabi
Browse files Browse the repository at this point in the history
Add resolver address param to _getABI
  • Loading branch information
storywithoutend authored Aug 28, 2023
2 parents d4e2c8e + 458f7a1 commit ae9cdab
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
17 changes: 17 additions & 0 deletions packages/ensjs/src/functions/getSpecificRecord.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
})
})
})
8 changes: 6 additions & 2 deletions packages/ensjs/src/functions/getSpecificRecord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit ae9cdab

Please sign in to comment.