Skip to content

Commit

Permalink
added typechain
Browse files Browse the repository at this point in the history
  • Loading branch information
TateB committed Apr 7, 2022
1 parent 51c1865 commit ad281db
Show file tree
Hide file tree
Showing 98 changed files with 17,375 additions and 217 deletions.
351 changes: 350 additions & 1 deletion .pnp.cjs

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
14 changes: 14 additions & 0 deletions packages/ensjs/deployments/00_NameWrapper.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ethers } from 'ethers'
import fs from 'fs'
import fsP from 'fs/promises'
import nModule from 'module'
import path from 'path'
import solc from 'solc'
Expand Down Expand Up @@ -97,14 +98,27 @@ export default async (server) => {
CompiledNameWrapper,
deployer,
)
console.log(process.cwd())
await fsP.writeFile(
process.cwd() + '/src/ABIs/NameWrapper.json',
NameWrapper.interface.format(ethers.utils.FormatTypes.json),
)
const StaticMetadataService = ethers.ContractFactory.fromSolidity(
CompiledStaticMetadataService,
deployer,
)
await fsP.writeFile(
process.cwd() + '/src/ABIs/StaticMetadataService.json',
StaticMetadataService.interface.format(ethers.utils.FormatTypes.json),
)
const PublicResolver = ethers.ContractFactory.fromSolidity(
CompiledPublicResolver,
deployer,
)
await fsP.writeFile(
process.cwd() + '/src/ABIs/PublicResolver.json',
PublicResolver.interface.format(ethers.utils.FormatTypes.json),
)

console.log('Setting metadata service URL to:', metadataUrl)
console.log('Deploying StaticMetadataService...')
Expand Down
5 changes: 5 additions & 0 deletions packages/ensjs/deployments/01_UniversalResolver.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ethers } from 'ethers'
import fs from 'fs'
import fsP from 'fs/promises'
import nModule from 'module'
import path from 'path'
import solc from 'solc'
Expand Down Expand Up @@ -74,6 +75,10 @@ export default async (server) => {
CompiledUniversalResolver,
deployer,
)
await fsP.writeFile(
process.cwd() + '/src/ABIs/UniversalResolver.json',
UniversalResolver.interface.format(ethers.utils.FormatTypes.json),
)

const universalResolverAddress = await deployContract(UniversalResolver, [
registryAddress,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ethers } from 'ethers'
import fs from 'fs'
import fsP from 'fs/promises'
import nModule from 'module'
import path from 'path'
import solc from 'solc'
Expand Down Expand Up @@ -77,6 +78,10 @@ export default async (server) => {
CompiledDNCOCURP,
deployer,
)
await fsP.writeFile(
process.cwd() + '/src/ABIs/DNCOCURP.json',
DNCOCURP.interface.format(ethers.utils.FormatTypes.json),
)

const DNCOCURPAddress = await deployContract(DNCOCURP, [
universalResolverAddress,
Expand Down
13 changes: 5 additions & 8 deletions packages/ensjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"author": "TateB <[email protected]>",
"license": "MIT",
"scripts": {
"generate-types": "ts-node scripts/runTypechain.ts",
"start": "ts-node --files src/index.test.ts",
"test": "jest --run-in-band src/tests",
"test:specific": "ts-node --files ",
Expand All @@ -33,9 +34,12 @@
"devDependencies": {
"@ensdomains/buffer": "^0.0.13",
"@ensdomains/ens-test-env": "workspace:*",
"@ethersproject/abi": "^5.6.0",
"@ethersproject/providers": "^5.6.2",
"@openzeppelin/contracts": "^4.5.0",
"@swc/core": "^1.2.162",
"@swc/jest": "^0.2.20",
"@typechain/ethers-v5": "^10.0.0",
"@types/bn.js": "^5.1.0",
"@types/jest": "^27.4.1",
"dotenv": "^16.0.0",
Expand All @@ -46,17 +50,10 @@
"solc": "^0.8.13",
"ts-jest": "^27.1.4",
"ts-node": "^10.7.0",
"typechain": "^8.0.0",
"typescript": "^4.6.2"
},
"peerDependencies": {
"ethers": "*"
},
"dependenciesMeta": {
"ens-contracts-namewrapper": {
"built": false
},
"ens-contracts-universal": {
"built": false
}
}
}
30 changes: 30 additions & 0 deletions packages/ensjs/scripts/runTypechain.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import nModule from 'module'
import { glob, runTypeChain } from 'typechain'

const pnp = (nModule as any).findPnpApi('./')
const contracts = pnp.resolveToUnqualified('@ensdomains/ens-contracts', './')

async function main() {
const cwd = process.cwd()
const importABIs = glob(cwd, [
`${contracts}/deployments/mainnet/**/+([a-zA-Z0-9_]).json`,
])
const customABIs = glob(cwd, ['./src/ABIs/**/*.json'])

await runTypeChain({
cwd,
filesToProcess: importABIs,
allFiles: importABIs,
outDir: './src/generated',
target: 'ethers-v5',
})
await runTypeChain({
cwd,
filesToProcess: customABIs,
allFiles: customABIs,
outDir: './src/generated',
target: 'ethers-v5',
})
}

main().catch(console.error)
7 changes: 7 additions & 0 deletions packages/ensjs/scripts/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"compilerOptions": {
"module": "NodeNext",
"moduleResolution": "node",

},
}
1 change: 1 addition & 0 deletions packages/ensjs/src/ABIs/DNCOCURP.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"type":"constructor","payable":false,"inputs":[{"type":"address","name":"_resolver"}]},{"type":"event","anonymous":false,"name":"OwnershipTransferred","inputs":[{"type":"address","name":"previousOwner","indexed":true},{"type":"address","name":"newOwner","indexed":true}]},{"type":"function","name":"isOwner","constant":true,"stateMutability":"view","payable":false,"inputs":[{"type":"address","name":"addr"}],"outputs":[{"type":"bool"}]},{"type":"function","name":"owner","constant":true,"stateMutability":"view","payable":false,"inputs":[],"outputs":[{"type":"address"}]},{"type":"function","name":"reverse","constant":true,"stateMutability":"view","payable":false,"inputs":[{"type":"bytes","name":"reverseNode"},{"type":"tuple[]","name":"calls","components":[{"type":"address","name":"target"},{"type":"bytes","name":"data"},{"type":"uint8","name":"dataType"},{"type":"uint256[]","name":"locations"}]}],"outputs":[{"type":"string","name":"name"},{"type":"bytes[]","name":"returnData"}]},{"type":"function","name":"setUniversalResolver","constant":false,"payable":false,"inputs":[{"type":"address","name":"newUniversalResolver"}],"outputs":[]},{"type":"function","name":"transferOwnership","constant":false,"payable":false,"inputs":[{"type":"address","name":"newOwner"}],"outputs":[]},{"type":"function","name":"universalResolver","constant":true,"stateMutability":"view","payable":false,"inputs":[],"outputs":[{"type":"address"}]}]
Loading

0 comments on commit ad281db

Please sign in to comment.