Skip to content

Commit

Permalink
Merge pull request #195 from ensdomains/fix/0x-multicoin-addr
Browse files Browse the repository at this point in the history
fix: 0x multicoin addr in history
  • Loading branch information
LeonmanRolls authored Sep 4, 2024
2 parents 88670da + 568616c commit 53a138e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
13 changes: 9 additions & 4 deletions packages/ensjs/deploy/00_register_legacy.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,14 @@ const names = [
],
},
},
{
label: 'with-empty-addr',
namedOwner: 'owner2',
namedAddr: 'owner2',
records: {
addr: [{ key: 61, value: '0x' }],
},
},
{
label: 'with-contenthash',
namedOwner: 'owner',
Expand Down Expand Up @@ -462,10 +470,7 @@ const func = async function (hre) {
* @type {string | Buffer | Uint8Array}
*/
let data
if (
abi.contentType === 1 ||
abi.contentType === 256
) {
if (abi.contentType === 1 || abi.contentType === 256) {
data = JSON.stringify(abi.data)
} else if (abi.contentType === 2) {
data = pako.deflate(JSON.stringify(abi.data))
Expand Down
15 changes: 15 additions & 0 deletions packages/ensjs/src/functions/subgraph/getNameHistory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,18 @@ it('returns the history of a subname', async () => {
expect(result.registrationEvents).toBeNull()
expect(result.resolverEvents).not.toBeNull()
})

it('returns the history of a name with a null addr record', async () => {
const result = await getNameHistory(publicClient, {
name: 'with-empty-addr.eth',
})
if (!result) throw new Error('No result')
expect(result.domainEvents.length).toBeGreaterThan(0)
expect(result.registrationEvents!.length).toBeGreaterThan(0)
expect(result.resolverEvents).not.toBeNull()
expect(
result.resolverEvents!.some(
(event) => event.type === 'MulticoinAddrChanged' && event.addr === null,
),
).toBe(true)
})
4 changes: 2 additions & 2 deletions packages/ensjs/src/functions/subgraph/getNameHistory.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getCoderByCoinType } from '@ensdomains/address-encoder'
import { gql } from 'graphql-request'
import { hexToBytes } from 'viem'
import { hexToBytes, trim } from 'viem'
import type { ClientWithEns } from '../../contracts/consts.js'
import { decodeContentHash } from '../../utils/contentHash.js'
import { namehash } from '../../utils/normalise.js'
Expand Down Expand Up @@ -286,7 +286,7 @@ const getNameHistory = async (
addr: multiaddr,
}
}
if (BigInt(multiaddr) === 0n) {
if (multiaddr === '0x' || trim(multiaddr) === '0x00') {
return {
...event_,
coinName: format.name,
Expand Down

0 comments on commit 53a138e

Please sign in to comment.