Skip to content

Commit

Permalink
fix: allow empty address records to be set
Browse files Browse the repository at this point in the history
  • Loading branch information
TateB committed Mar 30, 2023
1 parent a3f3216 commit 8dba5b4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
19 changes: 19 additions & 0 deletions packages/ensjs/src/utils/recordHelpers.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { PublicResolver__factory } from '../generated'
import { namehash } from './normalise'
import { generateSetAddr } from './recordHelpers'

describe('generateSetAddr()', () => {
it('should allow empty string as address', () => {
expect(() =>
generateSetAddr(
namehash('test'),
'BNB',
'',
PublicResolver__factory.connect(
'0x0000000000000000000000000000000000000000',
undefined as any,
),
),
).not.toThrowError()
})
})
3 changes: 2 additions & 1 deletion packages/ensjs/src/utils/recordHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ export const generateSetAddr = (
coinTypeInstance = formatsByName[coinType.toUpperCase()]
}
const inputCoinType = coinTypeInstance.coinType
const encodedAddress = coinTypeInstance.decoder(address)
const encodedAddress =
address !== '' ? coinTypeInstance.decoder(address) : '0x'
return resolver?.interface.encodeFunctionData(
'setAddr(bytes32,uint256,bytes)',
[namehash, inputCoinType, encodedAddress],
Expand Down

0 comments on commit 8dba5b4

Please sign in to comment.