-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #181 from ensdomains/update-normlization-lib
Update ens-normalise
- Loading branch information
Showing
3 changed files
with
79 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,17 @@ | ||
import { createPublicClient, http } from 'viem' | ||
import { goerli, mainnet } from 'viem/chains' | ||
import { mainnet } from 'viem/chains' | ||
import { describe, expect, it, vi } from 'vitest' | ||
import { addEnsContracts } from '../../contracts/addEnsContracts.js' | ||
import { ccipRequest } from '../../utils/ccipRequest.js' | ||
import batch from './batch.js' | ||
import getAddressRecord from './getAddressRecord.js' | ||
import getRecords from './getRecords.js' | ||
import getText from './getTextRecord.js' | ||
// import getText from './getTextRecord.js' | ||
|
||
vi.setConfig({ | ||
testTimeout: 30000, | ||
}) | ||
|
||
const goerliPublicClient = createPublicClient({ | ||
chain: addEnsContracts(goerli), | ||
transport: http('https://goerli.gateway.tenderly.co/4imxc4hQfRjxrVB2kWKvTo'), | ||
}) | ||
|
||
const mainnetPublicClient = createPublicClient({ | ||
chain: addEnsContracts(mainnet), | ||
transport: http('https://mainnet.gateway.tenderly.co/4imxc4hQfRjxrVB2kWKvTo'), | ||
|
@@ -25,90 +20,50 @@ const mainnetPublicClient = createPublicClient({ | |
describe('CCIP', () => { | ||
describe('getRecords', () => { | ||
it('should return records from a ccip-read name', async () => { | ||
const result = await getRecords(goerliPublicClient, { | ||
name: '1.offchainexample.eth', | ||
texts: ['email', 'description'], | ||
contentHash: true, | ||
coins: ['ltc', '60'], | ||
const result = await getRecords(mainnetPublicClient, { | ||
name: 'sg.offchaindemo.eth', | ||
// texts: ['email', 'description'], | ||
// contentHash: true, | ||
coins: ['60'], | ||
}) | ||
expect(result).toMatchInlineSnapshot(` | ||
{ | ||
"coins": [ | ||
{ | ||
"id": 2, | ||
"name": "ltc", | ||
"value": "MQMcJhpWHYVeQArcZR3sBgyPZxxRtnH441", | ||
}, | ||
{ | ||
"id": 60, | ||
"name": "eth", | ||
"value": "0x41563129cDbbD0c5D3e1c86cf9563926b243834d", | ||
}, | ||
], | ||
"contentHash": { | ||
"decoded": "bafybeico3uuyj3vphxpvbowchdwjlrlrh62awxscrnii7w7flu5z6fk77y", | ||
"protocolType": "ipfs", | ||
}, | ||
"resolverAddress": "0xEE28bdfBB91dE63bfBDA454082Bb1850f7804B09", | ||
"texts": [ | ||
{ | ||
"key": "email", | ||
"value": "[email protected]", | ||
}, | ||
{ | ||
"key": "description", | ||
"value": "hello offchainresolver wildcard record", | ||
"value": "0x80c5657CEE59A5a193EfDCfDf3D3913Fad977B61", | ||
}, | ||
], | ||
"resolverAddress": "0xDB34Da70Cfd694190742E94B7f17769Bc3d84D27", | ||
} | ||
`) | ||
}) | ||
it('should return records from a ccip-read name with custom ccipRequest', async () => { | ||
const goerliWithEns = addEnsContracts(goerli) | ||
const goerliWithEns = addEnsContracts(mainnet) | ||
const goerliPublicClientWithCustomCcipRequest = createPublicClient({ | ||
chain: goerliWithEns, | ||
transport: http( | ||
'https://goerli.gateway.tenderly.co/4imxc4hQfRjxrVB2kWKvTo', | ||
'https://mainnet.gateway.tenderly.co/4imxc4hQfRjxrVB2kWKvTo', | ||
), | ||
ccipRead: { | ||
request: ccipRequest(goerliWithEns), | ||
}, | ||
}) | ||
const result = await getRecords(goerliPublicClientWithCustomCcipRequest, { | ||
name: '1.offchainexample.eth', | ||
texts: ['email', 'description'], | ||
contentHash: true, | ||
coins: ['ltc', '60'], | ||
name: 'sg.offchaindemo.eth', | ||
coins: ['60'], | ||
}) | ||
expect(result).toMatchInlineSnapshot(` | ||
{ | ||
"coins": [ | ||
{ | ||
"id": 2, | ||
"name": "ltc", | ||
"value": "MQMcJhpWHYVeQArcZR3sBgyPZxxRtnH441", | ||
}, | ||
{ | ||
"id": 60, | ||
"name": "eth", | ||
"value": "0x41563129cDbbD0c5D3e1c86cf9563926b243834d", | ||
}, | ||
], | ||
"contentHash": { | ||
"decoded": "bafybeico3uuyj3vphxpvbowchdwjlrlrh62awxscrnii7w7flu5z6fk77y", | ||
"protocolType": "ipfs", | ||
}, | ||
"resolverAddress": "0xEE28bdfBB91dE63bfBDA454082Bb1850f7804B09", | ||
"texts": [ | ||
{ | ||
"key": "email", | ||
"value": "[email protected]", | ||
}, | ||
{ | ||
"key": "description", | ||
"value": "hello offchainresolver wildcard record", | ||
"value": "0x80c5657CEE59A5a193EfDCfDf3D3913Fad977B61", | ||
}, | ||
], | ||
"resolverAddress": "0xDB34Da70Cfd694190742E94B7f17769Bc3d84D27", | ||
} | ||
`) | ||
}) | ||
|
@@ -138,39 +93,38 @@ describe('CCIP', () => { | |
describe('batch', () => { | ||
it('allows batch ccip', async () => { | ||
const result = await batch( | ||
goerliPublicClient, | ||
getAddressRecord.batch({ name: '1.offchainexample.eth' }), | ||
getAddressRecord.batch({ name: '1.offchainexample.eth', coin: 'ltc' }), | ||
getText.batch({ name: '1.offchainexample.eth', key: 'email' }), | ||
mainnetPublicClient, | ||
getAddressRecord.batch({ name: 'sg.offchaindemo.eth' }), | ||
getAddressRecord.batch({ name: 'sg.offchaindemo.eth', coin: '60' }), | ||
// getText.batch({ name: '1.offchainexample.eth', key: 'email' }), | ||
) | ||
expect(result).toMatchInlineSnapshot(` | ||
[ | ||
{ | ||
"id": 60, | ||
"name": "eth", | ||
"value": "0x41563129cDbbD0c5D3e1c86cf9563926b243834d", | ||
"value": "0x80c5657CEE59A5a193EfDCfDf3D3913Fad977B61", | ||
}, | ||
{ | ||
"id": 2, | ||
"name": "ltc", | ||
"value": "MQMcJhpWHYVeQArcZR3sBgyPZxxRtnH441", | ||
"id": 60, | ||
"name": "eth", | ||
"value": "0x80c5657CEE59A5a193EfDCfDf3D3913Fad977B61", | ||
}, | ||
"[email protected]", | ||
] | ||
`) | ||
}) | ||
it('allows nested batch ccip', async () => { | ||
const result = await batch( | ||
goerliPublicClient, | ||
batch.batch(getAddressRecord.batch({ name: '1.offchainexample.eth' })), | ||
mainnetPublicClient, | ||
batch.batch(getAddressRecord.batch({ name: 'sg.offchaindemo.eth' })), | ||
) | ||
expect(result).toMatchInlineSnapshot(` | ||
[ | ||
[ | ||
{ | ||
"id": 60, | ||
"name": "eth", | ||
"value": "0x41563129cDbbD0c5D3e1c86cf9563926b243834d", | ||
"value": "0x80c5657CEE59A5a193EfDCfDf3D3913Fad977B61", | ||
}, | ||
], | ||
] | ||
|
Oops, something went wrong.