-
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.
added NameWrapper + UniversalResolver deploy scripts
- Loading branch information
Showing
9 changed files
with
476 additions
and
71 deletions.
There are no files selected for viewing
Binary file not shown.
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 |
---|---|---|
|
@@ -7,22 +7,17 @@ | |
"devDependencies": { | ||
"@typescript-eslint/eslint-plugin": "^5.15.0", | ||
"@typescript-eslint/parser": "^5.15.0", | ||
"dotenv": "^16.0.0", | ||
"ens-contracts": "github:ensdomains/ens-contracts#universal", | ||
"eslint": "^8.11.0", | ||
"eslint-config-airbnb": "^19.0.4", | ||
"eslint-config-airbnb-base": "^15.0.0", | ||
"eslint-config-airbnb-typescript": "^16.1.2", | ||
"eslint-config-prettier": "^8.5.0", | ||
"eslint-plugin-prettier": "^4.0.0", | ||
"ethers": "^5.6.1", | ||
"prettier": "^2.6.0", | ||
"ts-node": "^10.7.0", | ||
"typescript": "^4.6.2" | ||
}, | ||
"dependenciesMeta": { | ||
"[email protected]": { | ||
"unplugged": true | ||
} | ||
"dependencies": { | ||
"ethers": "^5.6.1" | ||
} | ||
} |
File renamed without changes.
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,131 @@ | ||
import { ethers } from 'ethers' | ||
import fs from 'fs' | ||
import nModule from 'module' | ||
import path from 'path' | ||
import solc from 'solc' | ||
|
||
const pnp = nModule.findPnpApi('./') | ||
const contracts = pnp.resolveToUnqualified( | ||
'ens-contracts-namewrapper/contracts', | ||
'./', | ||
) | ||
|
||
const findImports = (ogPath) => (filePath) => { | ||
let newPath = path.resolve(contracts, ogPath, './' + filePath) | ||
if (!fs.existsSync(newPath)) { | ||
newPath = path.resolve(contracts, ogPath, '../' + filePath) | ||
} | ||
if (!fs.existsSync(newPath)) { | ||
newPath = pnp.resolveToUnqualified(filePath, './') | ||
} | ||
return { | ||
contents: fs.readFileSync(newPath, 'utf8'), | ||
} | ||
} | ||
|
||
async function compile(name, inputPath) { | ||
const input = JSON.stringify({ | ||
language: 'Solidity', | ||
sources: { | ||
[name]: { | ||
content: fs.readFileSync( | ||
path.resolve(contracts, inputPath + name + '.sol'), | ||
'utf8', | ||
), | ||
}, | ||
}, | ||
settings: { | ||
outputSelection: { | ||
'*': { | ||
'*': ['*'], | ||
}, | ||
}, | ||
optimizer: { | ||
enabled: true, | ||
runs: 200, | ||
}, | ||
}, | ||
}) | ||
const compiled = solc.compile(input, { import: findImports(inputPath) }) | ||
const parsed = JSON.parse(compiled) | ||
return parsed.contracts[name][name] | ||
} | ||
|
||
const deployContract = async (InputContract, args) => { | ||
const deployment = await InputContract.deploy(...args, { | ||
gasLimit: 30000000, | ||
}) | ||
await deployment.deployTransaction.wait() | ||
return deployment.address | ||
} | ||
|
||
export default async (server) => { | ||
let metadataAddress, | ||
wrapperAddress, | ||
resolverAddress, | ||
metadataHost, | ||
wrapperArguments, | ||
resolverArguments, | ||
metadataArguments | ||
;({ | ||
METADATA_ADDRESS: metadataAddress, | ||
WRAPPER_ADDRESS: wrapperAddress, | ||
RESOLVER_ADDRESS: resolverAddress, | ||
METADATA_HOST: metadataHost, | ||
} = process.env) | ||
|
||
const registryAddress = '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e' | ||
const registrarAddress = '0x57f1887a8BF19b14fC0dF6Fd9B2acc9Af147eA85' | ||
const controllerAddress = '0x283Af0B28c62C092C9727F1Ee09c02CA627EB7F5' | ||
const reverseRegisrarAddress = '0x084b1c3C81545d370f3634392De611CaaBFf8148' | ||
const metadataUrl = `${metadataHost}/name/0x{id}` | ||
|
||
const address = server.provider.getInitialAccounts() | ||
const provider = new ethers.providers.Web3Provider(server.provider) | ||
const deployer = provider.getSigner(Object.keys(address)[0]) | ||
|
||
console.log('Deploying wrapper with account:', deployer._address) | ||
|
||
const CompiledNameWrapper = await compile('NameWrapper', 'wrapper/') | ||
const CompiledStaticMetadataService = await compile( | ||
'StaticMetadataService', | ||
'wrapper/', | ||
) | ||
const CompiledPublicResolver = await compile('PublicResolver', 'resolvers/') | ||
|
||
const NameWrapper = ethers.ContractFactory.fromSolidity( | ||
CompiledNameWrapper, | ||
deployer, | ||
) | ||
const StaticMetadataService = ethers.ContractFactory.fromSolidity( | ||
CompiledStaticMetadataService, | ||
deployer, | ||
) | ||
const PublicResolver = ethers.ContractFactory.fromSolidity( | ||
CompiledPublicResolver, | ||
deployer, | ||
) | ||
|
||
console.log('Setting metadata service URL to:', metadataUrl) | ||
console.log('Deploying StaticMetadataService...') | ||
metadataAddress = await deployContract(StaticMetadataService, [metadataUrl]) | ||
console.log('StaticMetadataService Address:', metadataAddress) | ||
|
||
console.log('Deploying NameWrapper...') | ||
wrapperAddress = await deployContract(NameWrapper, [ | ||
registryAddress, | ||
registrarAddress, | ||
metadataAddress, | ||
]) | ||
console.log('NameWrapper Address:', wrapperAddress) | ||
|
||
console.log('Deploying Resolver...') | ||
resolverAddress = await deployContract(PublicResolver, [ | ||
registryAddress, | ||
wrapperAddress, | ||
controllerAddress, | ||
reverseRegisrarAddress, | ||
]) | ||
console.log('Resolver Address:', resolverAddress) | ||
return | ||
} |
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,83 @@ | ||
import { ethers } from 'ethers' | ||
import fs from 'fs' | ||
import nModule from 'module' | ||
import path from 'path' | ||
import solc from 'solc' | ||
|
||
const pnp = nModule.findPnpApi('./') | ||
const contracts = pnp.resolveToUnqualified( | ||
'ens-contracts-universal/contracts', | ||
'./', | ||
) | ||
|
||
const findImports = (ogPath) => (filePath) => { | ||
let newPath = path.resolve(contracts, ogPath, './' + filePath) | ||
if (!fs.existsSync(newPath)) { | ||
newPath = path.resolve(contracts, ogPath, '../' + filePath) | ||
} | ||
if (!fs.existsSync(newPath)) { | ||
newPath = pnp.resolveToUnqualified(filePath, './') | ||
} | ||
return { | ||
contents: fs.readFileSync(newPath, 'utf8'), | ||
} | ||
} | ||
|
||
async function compile(name, inputPath) { | ||
const input = JSON.stringify({ | ||
language: 'Solidity', | ||
sources: { | ||
[name]: { | ||
content: fs.readFileSync( | ||
path.resolve(contracts, inputPath + name + '.sol'), | ||
'utf8', | ||
), | ||
}, | ||
}, | ||
settings: { | ||
outputSelection: { | ||
'*': { | ||
'*': ['*'], | ||
}, | ||
}, | ||
optimizer: { | ||
enabled: true, | ||
runs: 200, | ||
}, | ||
}, | ||
}) | ||
const compiled = solc.compile(input, { import: findImports(inputPath) }) | ||
const parsed = JSON.parse(compiled) | ||
return parsed.contracts[name][name] | ||
} | ||
|
||
const deployContract = async (InputContract, args) => { | ||
const deployment = await InputContract.deploy(...args, { | ||
gasLimit: 30000000, | ||
}) | ||
await deployment.deployTransaction.wait() | ||
return deployment.address | ||
} | ||
|
||
export default async (server) => { | ||
const registryAddress = '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e' | ||
|
||
const address = server.provider.getInitialAccounts() | ||
const provider = new ethers.providers.Web3Provider(server.provider) | ||
const deployer = provider.getSigner(Object.keys(address)[0]) | ||
|
||
console.log('Deploying UniversalResolver with account:', deployer._address) | ||
|
||
const CompiledUniversalResolver = await compile('UniversalResolver', 'utils/') | ||
|
||
const UniversalResolver = ethers.ContractFactory.fromSolidity( | ||
CompiledUniversalResolver, | ||
deployer, | ||
) | ||
|
||
const universalResolverAddress = await deployContract(UniversalResolver, [ | ||
registryAddress, | ||
]) | ||
console.log('Universal Resolver Address:', universalResolverAddress) | ||
return | ||
} |
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 |
---|---|---|
|
@@ -11,7 +11,17 @@ | |
}, | ||
"packageManager": "[email protected]", | ||
"dependencies": { | ||
"@ensdomains/ens-contracts": "^0.0.11" | ||
"@ensdomains/ens-contracts": "^0.0.11", | ||
"ethers": "^5.6.1" | ||
}, | ||
"devDependencies": { | ||
"@ensdomains/buffer": "^0.0.13", | ||
"@ensdomains/ens-test-env": "workspace:*", | ||
"@openzeppelin/contracts": "^4.5.0", | ||
"dotenv": "^16.0.0", | ||
"ens-contracts-namewrapper": "github:ensdomains/ens-contracts#commit=9b42c4b57e76aa4041847579c0bd5c3ca3cf6375", | ||
"ens-contracts-universal": "github:ensdomains/ens-contracts#universal", | ||
"solc": "^0.8.13" | ||
}, | ||
"peerDependencies": { | ||
"ethers": "*" | ||
|
Oops, something went wrong.