-
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.
- Loading branch information
Showing
24 changed files
with
1,049 additions
and
234 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 |
---|---|---|
|
@@ -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]" | ||
|
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
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 |
---|---|---|
@@ -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>), | ||
) |
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,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 |
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,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 |
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,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.
Oops, something went wrong.