Skip to content

Commit

Permalink
Merge pull request #158 from ensdomains/feat/new-dnssec-oracle-updated
Browse files Browse the repository at this point in the history
feat: new dnssec oracle updated
  • Loading branch information
TateB authored Jan 30, 2024
2 parents 848ef85 + 98e1393 commit 8be3361
Show file tree
Hide file tree
Showing 18 changed files with 280 additions and 368 deletions.
120 changes: 0 additions & 120 deletions packages/ensjs/deploy/01_legacy_dnsregistrar.cjs

This file was deleted.

3 changes: 2 additions & 1 deletion packages/ensjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@
"prepublish": "pnpm build && cp ../../README.md ../../LICENSE ./",
"prepack": "pnpm tsn ./scripts/prepack.ts",
"ver": "pnpm tsn ./scripts/updateVersion.ts",
"generateDocs": "pnpm tsn ./scripts/generateDocs.ts"
"generateDocs": "pnpm tsn ./scripts/generateDocs.ts",
"rcBranchVersion": "pnpm tsn ./scripts/rcBranchVersion.ts"
},
"dependencies": {
"@adraffy/ens-normalize": "1.9.0",
Expand Down
27 changes: 27 additions & 0 deletions packages/ensjs/scripts/rcBranchVersion.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { execSync } from 'child_process'
import fs from 'fs-extra'
import path from 'path'
import * as url from 'url'

// get branch name from local git command
const branchName = execSync('git rev-parse --abbrev-ref HEAD')
.toString('utf-8')
.replace(/\//g, '-')
.trim()

// timestamp
const timestamp = new Date().toISOString().replace(/[-:.]/g, '').slice(0, -1)

const newVersion = `0.0.0-${branchName}.${timestamp}`

// // change version in package.json
execSync(`pnpm version --no-workspaces-update ${newVersion}`, {
stdio: 'inherit',
})

const __dirname = url.fileURLToPath(new URL('.', import.meta.url))

// // Writes the new version to `./src/errors/version.ts`.
const versionFilePath = path.join(__dirname, '../src/errors/version.ts')

fs.writeFileSync(versionFilePath, `export const version = '${newVersion}'\n`)
10 changes: 6 additions & 4 deletions packages/ensjs/src/clients/public.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import {
createClient,
type Chain,
type Client,
type ClientConfig,
type PublicRpcSchema,
type Transport,
} from 'viem'
import { addEnsContracts } from '../contracts/addEnsContracts.js'
import type { ChainWithEns } from '../contracts/consts.js'
import type {
ChainWithBaseContracts,
ChainWithEns,
} from '../contracts/consts.js'
import type { Prettify } from '../types.js'
import { ensPublicActions, type EnsPublicActions } from './decorators/public.js'
import {
Expand All @@ -17,7 +19,7 @@ import {

export type EnsPublicClientConfig<
TTransport extends Transport = Transport,
TChain extends Chain = Chain,
TChain extends ChainWithBaseContracts = ChainWithBaseContracts,
> = Pick<
ClientConfig<TTransport, TChain>,
'batch' | 'key' | 'name' | 'pollingInterval' | 'transport'
Expand Down Expand Up @@ -56,7 +58,7 @@ export type EnsPublicClient<
*/
export const createEnsPublicClient = <
TTransport extends Transport,
TChain extends Chain,
TChain extends ChainWithBaseContracts,
>({
batch,
chain,
Expand Down
10 changes: 6 additions & 4 deletions packages/ensjs/src/clients/subgraph.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import {
createClient,
type Chain,
type Client,
type ClientConfig,
type PublicRpcSchema,
type Transport,
} from 'viem'
import { addEnsContracts } from '../contracts/addEnsContracts.js'
import type { ChainWithEns } from '../contracts/consts.js'
import type {
ChainWithBaseContracts,
ChainWithEns,
} from '../contracts/consts.js'
import type { Prettify } from '../types.js'
import {
ensSubgraphActions,
Expand All @@ -16,7 +18,7 @@ import {

export type EnsSubgraphClientConfig<
TTransport extends Transport = Transport,
TChain extends Chain = Chain,
TChain extends ChainWithBaseContracts = ChainWithBaseContracts,
> = Pick<
ClientConfig<TTransport, TChain>,
'batch' | 'key' | 'name' | 'pollingInterval' | 'transport'
Expand Down Expand Up @@ -49,7 +51,7 @@ export type EnsSubgraphClient<
*/
export const createEnsSubgraphClient = <
TTransport extends Transport,
TChain extends Chain,
TChain extends ChainWithBaseContracts,
>({
batch,
chain,
Expand Down
32 changes: 19 additions & 13 deletions packages/ensjs/src/clients/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {
createWalletClient,
type Account,
type Address,
type Chain,
type Client,
type ClientConfig,
type ParseAccount,
Expand All @@ -11,23 +10,30 @@ import {
type WalletRpcSchema,
} from 'viem'
import { addEnsContracts } from '../contracts/addEnsContracts.js'
import type { ChainWithEns } from '../contracts/consts.js'
import type { Prettify } from '../types.js'
import type {
ChainWithBaseContracts,
ChainWithEns,
CheckedChainWithEns,
} from '../contracts/consts.js'
import type { Assign, Prettify } from '../types.js'
import { ensWalletActions, type EnsWalletActions } from './decorators/wallet.js'

export type EnsWalletClientConfig<
TTransport extends Transport,
TChain extends Chain,
TChain extends ChainWithBaseContracts,
TAccountOrAddress extends Account | Address | undefined =
| Account
| Address
| undefined,
> = Pick<
ClientConfig<TTransport, TChain, TAccountOrAddress>,
'account' | 'chain' | 'key' | 'name' | 'pollingInterval' | 'transport'
> & {
chain: TChain
}
> = Assign<
Pick<
ClientConfig<TTransport, TChain, TAccountOrAddress>,
'account' | 'chain' | 'key' | 'name' | 'pollingInterval' | 'transport'
>,
{
chain: TChain
}
>

export type EnsWalletClient<
TTransport extends Transport = Transport,
Expand Down Expand Up @@ -61,7 +67,7 @@ export type EnsWalletClient<
*/
export const createEnsWalletClient = <
TTransport extends Transport,
TChain extends Chain,
TChain extends ChainWithBaseContracts,
TAccountOrAddress extends Account | Address | undefined = undefined,
>({
account,
Expand All @@ -76,12 +82,12 @@ export const createEnsWalletClient = <
TAccountOrAddress
>): EnsWalletClient<
TTransport,
ChainWithEns<TChain>,
CheckedChainWithEns<TChain>,
ParseAccount<TAccountOrAddress>
> => {
return createWalletClient({
account,
chain: addEnsContracts<TChain>(chain),
chain: addEnsContracts(chain),
key,
name,
pollingInterval,
Expand Down
6 changes: 3 additions & 3 deletions packages/ensjs/src/contracts/addEnsContracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
addresses,
subgraphs,
supportedChains,
type ChainWithEns,
type CheckedChainWithEns,
type SupportedChain,
} from './consts.js'

Expand All @@ -22,7 +22,7 @@ import {
* transport: http(),
* })
*/
export const addEnsContracts = <TChain extends Chain>(chain: TChain) => {
export const addEnsContracts = <const TChain extends Chain>(chain: TChain) => {
if (!chain) throw new NoChainError()
if (!supportedChains.includes(chain.network as SupportedChain))
throw new UnsupportedNetworkError({
Expand All @@ -38,5 +38,5 @@ export const addEnsContracts = <TChain extends Chain>(chain: TChain) => {
subgraphs: {
...subgraphs[chain.network as SupportedChain],
},
} as ChainWithEns<TChain>
} as unknown as CheckedChainWithEns<TChain>
}
29 changes: 21 additions & 8 deletions packages/ensjs/src/contracts/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type {
Transport,
WalletClient,
} from 'viem'
import type { Assign, Prettify } from '../types.js'

type ChainContract = {
address: Address
Expand Down Expand Up @@ -56,7 +57,7 @@ export const addresses = {
address: '0xa12159e5131b1eEf6B4857EEE3e1954744b5033A',
},
ensDnssecImpl: {
address: '0x21745FF62108968fBf5aB1E07961CC0FCBeB2364',
address: '0x0fc3152971714E5ed7723FAFa650F86A4BaF30C5',
},
ensUniversalResolver: {
address: '0x8cab227b1162f03b8338331adaad7aadc83b895e',
Expand Down Expand Up @@ -102,7 +103,7 @@ export const addresses = {
address: '0x57f1887a8bf19b14fc0df6fd9b2acc9af147ea85',
},
ensDnsRegistrar: {
address: '0x537625B0D7901FD20C57850d61580Bf1624Ef146',
address: '0x5a07C75Ae469Bf3ee2657B588e8E6ABAC6741b4f',
},
ensEthRegistrarController: {
address: '0xFED6a969AaA60E4961FCD3EBF1A2e8913ac65B72',
Expand All @@ -120,7 +121,7 @@ export const addresses = {
address: '0x4EF77b90762Eddb33C8Eba5B5a19558DaE53D7a1',
},
ensDnssecImpl: {
address: '0x7b3ada1c8f012bae747cf99d6cbbf70d040b84cf',
address: '0xe62E4b6cE018Ad6e916fcC24545e20a33b9d8653',
},
ensUniversalResolver: {
address: '0xBaBC7678D7A63104f1658c11D6AE9A21cdA09725',
Expand Down Expand Up @@ -172,17 +173,29 @@ type BaseChainContracts = {
ensRegistry: ChainContract
}

export type ChainWithEns<TChain extends Chain = Chain> = TChain & {
export type ChainWithEns<TChain extends Chain = Chain> = Omit<
TChain,
'contracts'
> & {
contracts: BaseChainContracts & EnsChainContracts
subgraphs: Subgraphs
}

export type ChainWithBaseContracts = Assign<
Omit<Chain, 'contracts'>,
{
contracts: BaseChainContracts
}
>

export type CheckedChainWithEns<TChain extends Chain> =
TChain['network'] extends SupportedChain
? TChain & {
contracts: (typeof addresses)[TChain['network']]
subgraphs: (typeof subgraphs)[TChain['network']]
}
? TChain['contracts'] extends BaseChainContracts
? TChain & {
contracts: Prettify<(typeof addresses)[TChain['network']]>
subgraphs: (typeof subgraphs)[TChain['network']]
}
: never
: never

export type ClientWithEns<
Expand Down
Loading

0 comments on commit 8be3361

Please sign in to comment.