Skip to content

Commit

Permalink
checkpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
TateB committed Apr 27, 2023
1 parent cd81e4c commit 2bd1872
Show file tree
Hide file tree
Showing 24 changed files with 1,049 additions and 234 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
},
"eslint.nodePath": ".yarn/sdks",
"prettier.prettierPath": ".yarn/sdks/prettier/index.js",
"typescript.tsdk": ".yarn/sdks/typescript/lib",
"typescript.tsdk": "node_modules/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"eslint-plugin-prettier": "^4.0.0",
"prettier": "^2.6.0",
"ts-node": "^10.7.0",
"typescript": "^4.7.4"
"typescript": "^5.0.4"
},
"resolutions": {
"@nomiclabs/hardhat-ethers": "npm:[email protected]"
Expand Down
2 changes: 1 addition & 1 deletion packages/ensjs/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const config = {
'^.+\\.(t|j)sx?$': ['@swc/jest'],
},
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
transformIgnorePatterns: []
transformIgnorePatterns: [],
}

export default config
6 changes: 4 additions & 2 deletions packages/ensjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,14 @@
"@ensdomains/address-encoder": "^0.2.18",
"@ensdomains/content-hash": "^2.5.7",
"@ensdomains/dnssecoraclejs": "^0.2.8",
"abitype": "^0.8.0",
"cbor": "^8.1.0",
"dns-packet": "^5.3.1",
"graphql": "^16.3.0",
"graphql-request": "5.1.0",
"pako": "^2.1.0",
"traverse": "^0.6.6"
"traverse": "^0.6.6",
"viem": "^0.3.11"
},
"devDependencies": {
"@ensdomains/buffer": "^0.0.13",
Expand Down Expand Up @@ -134,7 +136,7 @@
"ts-jest": "^27.1.4",
"ts-node": "^10.7.0",
"typechain": "^8.1.0",
"typescript": "^4.7.4",
"typescript": "^5.0.4",
"wait-on": "^6.0.1"
},
"peerDependencies": {
Expand Down
93 changes: 93 additions & 0 deletions packages/ensjs/src/contracts/addContracts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import type { Chain, PublicClient, Transport } from 'viem'
import type { ChainContract } from 'viem/src/types/chain'
import { Prettify } from '../types'

const supportedChains = ['homestead', 'goerli']

const addresses = {
homestead: {
baseRegistrarImplementation: {
address: '0x57f1887a8bf19b14fc0df6fd9b2acc9af147ea85',
},
dnsRegistrar: {
address: '0x58774Bb8acD458A640aF0B88238369A167546ef2',
},
ethRegistrarController: {
address: '0x253553366Da8546fC250F225fe3d25d0C782303b',
},
nameWrapper: {
address: '0xD4416b13d2b3a9aBae7AcD5D6C2BbDBE25686401',
},
publicResolver: {
address: '0x231b0Ee14048e9dCcD1d247744d114a4EB5E8E63',
},
reverseRegistrar: {
address: '0xa58E81fe9b61B5c3fE2AFD33CF304c454AbFc7Cb',
},
bulkRenewal: {
address: '0xa12159e5131b1eEf6B4857EEE3e1954744b5033A',
},
},
goerli: {
baseRegistrarImplementation: {
address: '0x57f1887a8bf19b14fc0df6fd9b2acc9af147ea85',
},
dnsRegistrar: {
address: '0x8edc487D26F6c8Fa76e032066A3D4F87E273515d',
},
ethRegistrarController: {
address: '0xCc5e7dB10E65EED1BBD105359e7268aa660f6734',
},
nameWrapper: {
address: '0x114D4603199df73e7D157787f8778E21fCd13066',
},
publicResolver: {
address: '0xd7a4F6473f32aC2Af804B3686AE8F19E48B8fF5f',
},
reverseRegistrar: {
address: '0x6d9F26FfBcF1c6f0bAe9F2C1f7fBe8eE6B1d8d4d',
},
bulkRenewal: {
address: '0x6d9F26FfBcF1c6f0bAe9F2C1f7fBe8eE6B1d8d4d',
},
},
} as const

export type ChainWithEns<TChain extends Chain = Chain> = Prettify<
TChain & {
contracts: {
ensjs: {
baseRegistrarImplementation: ChainContract
dnsRegistrar: ChainContract
ethRegistrarController: ChainContract
nameWrapper: ChainContract
publicResolver: ChainContract
reverseRegistrar: ChainContract
bulkRenewal: ChainContract
}
}
}
>

export type ClientWithEns<
TTransport extends Transport = Transport,
TChain extends ChainWithEns = ChainWithEns,
> = PublicClient<TTransport, TChain>

export const addContracts = <TChain extends Chain = Chain>(
chains: TChain[],
): ChainWithEns<TChain>[] =>
chains
.filter((chain) => supportedChains.includes(chain.network))
.map(
(chain) =>
({
...chain,
contracts: {
...chain.contracts,
ensjs: {
...addresses[chain.name as keyof typeof addresses],
},
},
} as ChainWithEns<TChain>),
)
48 changes: 43 additions & 5 deletions packages/ensjs/src/contracts/multicall.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,43 @@
import type { JsonRpcProvider } from '@ethersproject/providers'
import { Multicall__factory } from '../generated/factories/Multicall__factory'

export default (provider: JsonRpcProvider, address: string) =>
Multicall__factory.connect(address, provider)
export const tryAggregateSnippet = [
{
inputs: [
{
name: 'requireSuccess',
type: 'bool',
},
{
components: [
{
name: 'target',
type: 'address',
},
{
name: 'callData',
type: 'bytes',
},
],
name: 'calls',
type: 'tuple[]',
},
],
name: 'tryAggregate',
outputs: [
{
components: [
{
name: 'success',
type: 'bool',
},
{
name: 'returnData',
type: 'bytes',
},
],
name: 'returnData',
type: 'tuple[]',
},
],
stateMutability: 'payable',
type: 'function',
},
] as const
46 changes: 42 additions & 4 deletions packages/ensjs/src/contracts/publicResolver.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,43 @@
import type { JsonRpcProvider } from '@ethersproject/providers'
import { PublicResolver__factory } from '../generated/factories/PublicResolver__factory'
export const singleAddrSnippet = [
{
inputs: [
{
name: 'node',
type: 'bytes32',
},
],
name: 'addr',
outputs: [
{
name: '',
type: 'address',
},
],
stateMutability: 'view',
type: 'function',
},
] as const

export default (provider: JsonRpcProvider, address: string) =>
PublicResolver__factory.connect(address, provider)
export const multiAddrSnippet = [
{
inputs: [
{
name: 'node',
type: 'bytes32',
},
{
name: 'coinType',
type: 'uint256',
},
],
name: 'addr',
outputs: [
{
name: '',
type: 'bytes',
},
],
stateMutability: 'view',
type: 'function',
},
] as const
50 changes: 46 additions & 4 deletions packages/ensjs/src/contracts/universalResolver.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,47 @@
import type { JsonRpcProvider } from '@ethersproject/providers'
import { UniversalResolver__factory } from '../generated/factories/UniversalResolver__factory'
export const reverseSnippet = [
{
inputs: [
{
name: 'reverseName',
type: 'bytes',
},
],
name: 'reverse',
outputs: [
{ type: 'string', name: 'resolvedName' },
{ type: 'address', name: 'resolvedAddress' },
{ type: 'address', name: 'reverseResolver' },
{ type: 'address', name: 'resolver' },
],
stateMutability: 'view',
type: 'function',
},
] as const

export default (provider: JsonRpcProvider, address: string) =>
UniversalResolver__factory.connect(address, provider)
export const resolveSnippet = [
{
inputs: [
{
name: 'name',
type: 'bytes',
},
{
name: 'data',
type: 'bytes',
},
],
name: 'resolve',
outputs: [
{
name: 'data',
type: 'bytes',
},
{
name: 'resolver',
type: 'address',
},
],
stateMutability: 'view',
type: 'function',
},
] as const
Empty file added packages/ensjs/src/errors.ts
Empty file.
Loading

0 comments on commit 2bd1872

Please sign in to comment.