-
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
98 changed files
with
9,574 additions
and
9,101 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,9 +25,6 @@ | |
"resolutions": { | ||
"@nomiclabs/hardhat-ethers": "npm:[email protected]" | ||
}, | ||
"dependencies": { | ||
"ethers": "^5.6.1" | ||
}, | ||
"dependenciesMeta": { | ||
"ens-contracts": { | ||
"built": false, | ||
|
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
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,5 @@ | ||
import { ethers } from 'ethers' | ||
import type { JsonRpcProvider } from '@ethersproject/providers' | ||
import { BaseRegistrarImplementation__factory } from '../generated/factories/BaseRegistrarImplementation__factory' | ||
|
||
export default (provider: ethers.providers.JsonRpcProvider, address: string) => | ||
export default (provider: JsonRpcProvider, address: string) => | ||
BaseRegistrarImplementation__factory.connect(address, provider) |
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,6 +1,6 @@ | ||
import { ethers } from 'ethers' | ||
import type { JsonRpcProvider } from '@ethersproject/providers' | ||
import { BulkRenewal__factory } from '../generated/factories/BulkRenewal__factory' | ||
|
||
// Use a higher-order function to overide the address that is passed in from getContractAddress() | ||
export default (provider: ethers.providers.JsonRpcProvider, address: string) => | ||
export default (provider: JsonRpcProvider, address: string) => | ||
BulkRenewal__factory.connect(address, provider) |
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,5 @@ | ||
import { ethers } from 'ethers' | ||
import type { JsonRpcProvider } from '@ethersproject/providers' | ||
import { DNSRegistrar__factory } from '../generated/factories/DNSRegistrar__factory' | ||
|
||
export default (provider: ethers.providers.JsonRpcProvider, address: string) => | ||
export default (provider: JsonRpcProvider, address: string) => | ||
DNSRegistrar__factory.connect(address, provider) |
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,5 @@ | ||
import { ethers } from 'ethers' | ||
import type { JsonRpcProvider } from '@ethersproject/providers' | ||
import { ETHRegistrarController__factory } from '../generated/factories/ETHRegistrarController__factory' | ||
|
||
export default (provider: ethers.providers.JsonRpcProvider, address: string) => | ||
export default (provider: JsonRpcProvider, address: string) => | ||
ETHRegistrarController__factory.connect(address, provider) |
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,48 @@ | ||
/* eslint-disable @typescript-eslint/naming-convention */ | ||
import type { BaseRegistrarImplementation__factory } from '../generated/factories/BaseRegistrarImplementation__factory' | ||
import type { BulkRenewal__factory } from '../generated/factories/BulkRenewal__factory' | ||
import type { DefaultReverseResolver__factory } from '../generated/factories/DefaultReverseResolver__factory' | ||
import type { DNSRegistrar__factory } from '../generated/factories/DNSRegistrar__factory' | ||
import type { DNSSECImpl__factory } from '../generated/factories/DNSSECImpl__factory' | ||
import type { ENSRegistry__factory } from '../generated/factories/ENSRegistry__factory' | ||
import type { ETHRegistrarController__factory } from '../generated/factories/ETHRegistrarController__factory' | ||
import type { Multicall__factory } from '../generated/factories/Multicall__factory' | ||
import type { NameWrapper__factory } from '../generated/factories/NameWrapper__factory' | ||
import type { P256SHA256Algorithm__factory } from '../generated/factories/P256SHA256Algorithm__factory' | ||
import type { PublicResolver__factory } from '../generated/factories/PublicResolver__factory' | ||
import type { ReverseRegistrar__factory } from '../generated/factories/ReverseRegistrar__factory' | ||
import type { Root__factory } from '../generated/factories/Root__factory' | ||
import type { RSASHA1Algorithm__factory } from '../generated/factories/RSASHA1Algorithm__factory' | ||
import type { RSASHA256Algorithm__factory } from '../generated/factories/RSASHA256Algorithm__factory' | ||
import type { SHA1Digest__factory } from '../generated/factories/SHA1Digest__factory' | ||
import type { SHA1NSEC3Digest__factory } from '../generated/factories/SHA1NSEC3Digest__factory' | ||
import type { SHA256Digest__factory } from '../generated/factories/SHA256Digest__factory' | ||
import type { StaticMetadataService__factory } from '../generated/factories/StaticMetadataService__factory' | ||
import type { TLDPublicSuffixList__factory } from '../generated/factories/TLDPublicSuffixList__factory' | ||
import type { UniversalResolver__factory } from '../generated/factories/UniversalResolver__factory' | ||
|
||
type Factories = { | ||
BaseRegistrarImplementation: BaseRegistrarImplementation__factory | ||
DefaultReverseResolver: DefaultReverseResolver__factory | ||
DNSRegistrar: DNSRegistrar__factory | ||
DNSSECImpl: DNSSECImpl__factory | ||
ENSRegistry: ENSRegistry__factory | ||
ETHRegistrarController: ETHRegistrarController__factory | ||
P256SHA256Algorithm: P256SHA256Algorithm__factory | ||
PublicResolver: PublicResolver__factory | ||
ReverseRegistrar: ReverseRegistrar__factory | ||
Root: Root__factory | ||
RSASHA1Algorithm: RSASHA1Algorithm__factory | ||
RSASHA256Algorithm: RSASHA256Algorithm__factory | ||
SHA1Digest: SHA1Digest__factory | ||
SHA1NSEC3Digest: SHA1NSEC3Digest__factory | ||
SHA256Digest: SHA256Digest__factory | ||
TLDPublicSuffixList: TLDPublicSuffixList__factory | ||
Multicall: Multicall__factory | ||
NameWrapper: NameWrapper__factory | ||
StaticMetadataService: StaticMetadataService__factory | ||
UniversalResolver: UniversalResolver__factory | ||
BulkRenewal: BulkRenewal__factory | ||
} | ||
|
||
export default Factories |
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,88 +1,94 @@ | ||
import { ethers } from 'ethers' | ||
import getBaseRegistrar from './baseRegistrar' | ||
import getEthRegistrarController from './ethRegistrarController' | ||
import type { Interface } from '@ethersproject/abi' | ||
import type { Signer } from '@ethersproject/abstract-signer' | ||
import type { BaseContract } from '@ethersproject/contracts' | ||
import type { Provider } from '@ethersproject/providers' | ||
import type { BaseRegistrarImplementation } from '../generated/BaseRegistrarImplementation' | ||
import type { BulkRenewal } from '../generated/BulkRenewal' | ||
import type { DNSRegistrar } from '../generated/DNSRegistrar' | ||
import type { ENSRegistry } from '../generated/ENSRegistry' | ||
import type { ETHRegistrarController } from '../generated/ETHRegistrarController' | ||
import type { Multicall } from '../generated/Multicall' | ||
import type { NameWrapper } from '../generated/NameWrapper' | ||
import type { PublicResolver } from '../generated/PublicResolver' | ||
import type { ReverseRegistrar } from '../generated/ReverseRegistrar' | ||
import type { UniversalResolver } from '../generated/UniversalResolver' | ||
import { ContractAddressFetch } from './getContractAddress' | ||
import getMulticall from './multicall' | ||
import getNameWrapper from './nameWrapper' | ||
import getDNSRegistrar from './dnsRegistrar' | ||
import getPublicResolver from './publicResolver' | ||
import getRegistry from './registry' | ||
import getReverseRegistrar from './reverseRegistrar' | ||
import { ContractName } from './types' | ||
import getUniversalResolver from './universalResolver' | ||
import getBulkRenewal from './bulkRenewal' | ||
|
||
type BaseFactory = { | ||
readonly abi: object | ||
createInterface(): Interface | ||
connect(address: string, signerOrProvider: Signer | Provider): BaseContract | ||
} | ||
|
||
export default class ContractManager { | ||
private provider: ethers.providers.Provider | ||
private provider: Provider | ||
|
||
private fetchAddress: ContractAddressFetch | ||
|
||
// eslint-disable-next-line class-methods-use-this | ||
protected getModule = async (name: string) => { | ||
const mod = (await import( | ||
/* webpackMode: "lazy", webpackChunkName: "[request]", webpackPreload: true, webpackExclude: /.*\.ts$/ */ | ||
`../generated/factories/${name}__factory` | ||
)) as BaseFactory | ||
return mod | ||
} | ||
|
||
constructor( | ||
provider: ethers.providers.Provider, | ||
provider: Provider, | ||
fetchAddress: ContractAddressFetch, | ||
getModule?: (name: string) => Promise<BaseFactory>, | ||
) { | ||
this.provider = provider | ||
this.fetchAddress = fetchAddress | ||
if (getModule) { | ||
this.getModule = getModule | ||
} | ||
} | ||
|
||
private generateContractGetter = <C extends (...args: any) => any>( | ||
private generateContractGetter = <C extends BaseContract>( | ||
name: ContractName, | ||
func: C, | ||
): ((passedProvider?: any, address?: string) => Promise<ReturnType<C>>) => { | ||
return async ( | ||
passedProvider?: any, | ||
address?: string, | ||
): Promise<ReturnType<C>> => { | ||
): ((passedProvider?: any, address?: string) => Promise<C>) => { | ||
return async (passedProvider, address) => { | ||
const mod = await this.getModule(name) | ||
const inputAddress = address || this.fetchAddress(name) | ||
const provider = passedProvider || this.provider | ||
return func(provider, inputAddress) | ||
return mod.connect(inputAddress, provider) as C | ||
} | ||
} | ||
|
||
public getPublicResolver = this.generateContractGetter( | ||
'PublicResolver', | ||
getPublicResolver, | ||
) | ||
public getPublicResolver = | ||
this.generateContractGetter<PublicResolver>('PublicResolver') | ||
|
||
public getUniversalResolver = this.generateContractGetter( | ||
'UniversalResolver', | ||
getUniversalResolver, | ||
) | ||
public getUniversalResolver = | ||
this.generateContractGetter<UniversalResolver>('UniversalResolver') | ||
|
||
public getRegistry = this.generateContractGetter( | ||
public getRegistry = this.generateContractGetter<ENSRegistry>( | ||
'ENSRegistryWithFallback', | ||
getRegistry, | ||
) | ||
|
||
public getReverseRegistrar = this.generateContractGetter( | ||
'ReverseRegistrar', | ||
getReverseRegistrar, | ||
) | ||
public getReverseRegistrar = | ||
this.generateContractGetter<ReverseRegistrar>('ReverseRegistrar') | ||
|
||
public getNameWrapper = this.generateContractGetter( | ||
'NameWrapper', | ||
getNameWrapper, | ||
) | ||
public getNameWrapper = | ||
this.generateContractGetter<NameWrapper>('NameWrapper') | ||
|
||
public getDNSRegistrar = this.generateContractGetter( | ||
'DNSRegistrar', | ||
getDNSRegistrar, | ||
) | ||
public getDNSRegistrar = | ||
this.generateContractGetter<DNSRegistrar>('DNSRegistrar') | ||
|
||
public getBaseRegistrar = this.generateContractGetter( | ||
'BaseRegistrarImplementation', | ||
getBaseRegistrar, | ||
) | ||
public getBaseRegistrar = | ||
this.generateContractGetter<BaseRegistrarImplementation>( | ||
'BaseRegistrarImplementation', | ||
) | ||
|
||
public getEthRegistrarController = this.generateContractGetter( | ||
'ETHRegistrarController', | ||
getEthRegistrarController, | ||
) | ||
public getEthRegistrarController = | ||
this.generateContractGetter<ETHRegistrarController>( | ||
'ETHRegistrarController', | ||
) | ||
|
||
public getMulticall = this.generateContractGetter('Multicall', getMulticall) | ||
public getMulticall = this.generateContractGetter<Multicall>('Multicall') | ||
|
||
public getBulkRenewal = this.generateContractGetter( | ||
'BulkRenewal', | ||
getBulkRenewal, | ||
) | ||
public getBulkRenewal = | ||
this.generateContractGetter<BulkRenewal>('BulkRenewal') | ||
} |
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,5 @@ | ||
import { ethers } from 'ethers' | ||
import type { JsonRpcProvider } from '@ethersproject/providers' | ||
import { Multicall__factory } from '../generated/factories/Multicall__factory' | ||
|
||
export default (provider: ethers.providers.JsonRpcProvider, address: string) => | ||
export default (provider: JsonRpcProvider, address: string) => | ||
Multicall__factory.connect(address, provider) |
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,5 @@ | ||
import { ethers } from 'ethers' | ||
import type { JsonRpcProvider } from '@ethersproject/providers' | ||
import { NameWrapper__factory } from '../generated/factories/NameWrapper__factory' | ||
|
||
export default (provider: ethers.providers.JsonRpcProvider, address: string) => | ||
export default (provider: JsonRpcProvider, address: string) => | ||
NameWrapper__factory.connect(address, provider) |
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,5 @@ | ||
import { ethers } from 'ethers' | ||
import type { JsonRpcProvider } from '@ethersproject/providers' | ||
import { PublicResolver__factory } from '../generated/factories/PublicResolver__factory' | ||
|
||
export default (provider: ethers.providers.JsonRpcProvider, address: string) => | ||
export default (provider: JsonRpcProvider, address: string) => | ||
PublicResolver__factory.connect(address, provider) |
Oops, something went wrong.