Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

Commit

Permalink
Revert "feat: add multi-target Typechain typings build option" (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
JDawg287 authored Mar 19, 2024
1 parent a007fb2 commit 3c5ed0b
Show file tree
Hide file tree
Showing 17 changed files with 31 additions and 131 deletions.
32 changes: 0 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,38 +52,6 @@ To build:
$ npm run build
```

## Build contracts with different Typechain target

To build different Typechain target:

```
npx hardhat compile --typechain-target target
```

Where `target` can be `ethers-v6`, `web3-v1`, etc.

*Note: you need to install the appropriate package for the target you want to build for. For example, to build for `web3-v1`, you need to install `@typechain/web3-v1` package.*

Default target is `ethers-v6` and it is output to `typechain-types/ethers-v6` directory.

You can specify the target in several ways:
- By setting the `TYPECHAIN_TARGET` environment variable
```bash
export TYPECHAIN_TARGET=web3-v1
```
- By setting the `--typechain-target` command line option
```bash
npx hardhat compile --typechain-target web3-v1
```
- By setting the `typechain` field in `hardhat.config.ts`
```typescript
module.exports = {
typechain: {
target: 'web3-v1'
}
}
```

## Tests

To run the tests:
Expand Down
7 changes: 0 additions & 7 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { HardhatUserConfig } from 'hardhat/config'
import '@nomicfoundation/hardhat-toolbox'

import './tasks/compile'

const config: HardhatUserConfig = {
solidity: {
version: '0.8.9',
Expand All @@ -13,11 +11,6 @@ const config: HardhatUserConfig = {
},
},
},
typechain: {
// default 'ethers-v6'
outDir: 'typechain-types/ethers-v6',
target: 'ethers-v6',
},
}

export default config
2 changes: 1 addition & 1 deletion scripts/const-addr-deployer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
Wallet,
} from 'ethers'

import { ConstAddressDeployer__factory } from '../typechain-types/ethers-v6'
import { ConstAddressDeployer__factory } from '../typechain-types/factories/contracts/topos-core/ConstAddressDeployer__factory'

export type Arg = string | number

Expand Down
2 changes: 1 addition & 1 deletion scripts/deploy-subnet-registrator.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { computeAddress, isHexString, JsonRpcProvider, Wallet } from 'ethers'

import subnetRegistratorJSON from '../artifacts/contracts/topos-core/SubnetRegistrator.sol/SubnetRegistrator.json'
import { SubnetRegistrator__factory } from '../typechain-types/ethers-v6'
import { SubnetRegistrator__factory } from '../typechain-types/factories/contracts/topos-core/SubnetRegistrator__factory'
import { Arg, deployContractConstant } from './const-addr-deployer'

const main = async function (..._args: Arg[]) {
Expand Down
8 changes: 3 additions & 5 deletions scripts/deploy-topos-core.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { isHexString, JsonRpcProvider, Wallet } from 'ethers'

import {
ToposCore,
ToposCore__factory,
ToposCoreProxy__factory,
} from '../typechain-types/ethers-v6'
import { ToposCore__factory } from '../typechain-types/factories/contracts/topos-core/ToposCore__factory'
import { ToposCoreProxy__factory } from '../typechain-types/factories/contracts/topos-core/ToposCoreProxy__factory'
import { ToposCore } from '../typechain-types/contracts/topos-core/ToposCore'

const main = async function (...args: string[]) {
const [_providerEndpoint, _sequencerPrivateKey, _gasLimit] = args
Expand Down
12 changes: 5 additions & 7 deletions scripts/deploy-topos-msg-protocol-dynamic.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { isHexString, JsonRpcProvider, Wallet } from 'ethers'

import {
ERC20Messaging__factory,
TokenDeployer__factory,
ToposCore__factory,
ToposCoreProxy__factory,
ToposCore,
} from '../typechain-types/ethers-v6'
import { TokenDeployer__factory } from '../typechain-types/factories/contracts/topos-core/TokenDeployer__factory'
import { ToposCore__factory } from '../typechain-types/factories/contracts/topos-core/ToposCore__factory'
import { ToposCoreProxy__factory } from '../typechain-types/factories/contracts/topos-core/ToposCoreProxy__factory'
import { ERC20Messaging__factory } from '../typechain-types/factories/contracts/examples/ERC20Messaging__factory'
import { ToposCore } from '../typechain-types/contracts/topos-core/ToposCore'

const main = async function (...args: string[]) {
const [providerEndpoint, _sequencerPrivateKey] = args
Expand Down
3 changes: 2 additions & 1 deletion scripts/deploy-topos-msg-protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import {
deployContractConstant,
predictContractConstant,
} from './const-addr-deployer'
import { ToposCore__factory, ToposCore } from '../typechain-types/ethers-v6'
import { ToposCore__factory } from '../typechain-types/factories/contracts/topos-core/ToposCore__factory'
import { ToposCore } from '../typechain-types/contracts/topos-core/ToposCore'

const main = async function (...args: string[]) {
const [providerEndpoint, _sequencerPrivateKey] = args
Expand Down
6 changes: 2 additions & 4 deletions scripts/register-subnet.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { isHexString, JsonRpcProvider, Wallet } from 'ethers'

import {
SubnetRegistrator,
SubnetRegistrator__factory,
} from '../typechain-types/ethers-v6'
import { SubnetRegistrator__factory } from '../typechain-types/factories/contracts/topos-core/SubnetRegistrator__factory'
import { SubnetRegistrator } from '../typechain-types/contracts/topos-core/SubnetRegistrator'

const main = async function (...args: string[]) {
const [
Expand Down
9 changes: 3 additions & 6 deletions scripts/test/send-token.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { isHexString, JsonRpcProvider, Wallet } from 'ethers'

import {
BurnableMintableCappedERC20__factory,
ERC20Messaging,
ERC20Messaging__factory,
} from '../../typechain-types/ethers-v6'
import { ERC20Messaging__factory } from '../../typechain-types/factories/contracts/examples/ERC20Messaging__factory'
import { BurnableMintableCappedERC20__factory } from '../../typechain-types/factories/contracts/topos-core/BurnableMintableCappedERC20__factory'
import { ERC20Messaging } from '../../typechain-types/contracts/examples/ERC20Messaging'
import * as cc from '../../test/topos-core/shared/constants/certificates'
import * as tc from '../../test/topos-core/shared/constants/tokens'
import * as testUtils from '../../test/topos-core/shared/utils/common'
Expand Down
6 changes: 2 additions & 4 deletions scripts/upgrade-topos-core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ import {
Wallet,
} from 'ethers'

import {
ToposCore__factory,
CodeHash__factory,
} from '../typechain-types/ethers-v6'
import { ToposCore__factory } from '../typechain-types/factories/contracts/topos-core/ToposCore__factory'
import { CodeHash__factory } from '../typechain-types/factories/contracts/topos-core/CodeHash__factory'

import toposCoreJSON from '../artifacts/contracts/topos-core/ToposCore.sol/ToposCore.json'

Expand Down
42 changes: 0 additions & 42 deletions tasks/compile.ts

This file was deleted.

6 changes: 2 additions & 4 deletions test/topos-core/BurnableMintableCappedERC20.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ import { EventLog } from 'ethers'
import { expect } from 'chai'
import { ethers } from 'hardhat'

import {
BurnableMintableCappedERC20__factory,
TokenDeployer__factory,
} from '../../typechain-types/ethers-v6'
import { BurnableMintableCappedERC20__factory } from '../../typechain-types/factories/contracts/topos-core/BurnableMintableCappedERC20__factory'
import { TokenDeployer__factory } from '../../typechain-types/factories/contracts/topos-core/TokenDeployer__factory'
import * as tc from './shared/constants/tokens'

describe('BurnableMintableCappedERC20', () => {
Expand Down
6 changes: 2 additions & 4 deletions test/topos-core/Bytes32Sets.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { ethers } from 'hardhat'
import { expect } from 'chai'

import {
Bytes32SetsTest,
Bytes32SetsTest__factory,
} from '../../typechain-types/ethers-v6'
import { Bytes32SetsTest__factory } from '../../typechain-types/factories/contracts/topos-core/Bytes32Sets.sol/Bytes32SetsTest__factory'
import { Bytes32SetsTest } from '../../typechain-types/contracts/topos-core/Bytes32Sets.sol/Bytes32SetsTest'

describe('Bytes32Sets', () => {
let bytes32SetsTest: Bytes32SetsTest
Expand Down
6 changes: 2 additions & 4 deletions test/topos-core/SubnetRegistrator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ import { Signer } from 'ethers'
import { ethers } from 'hardhat'
import { expect } from 'chai'

import {
SubnetRegistrator__factory,
SubnetRegistrator,
} from '../../typechain-types/ethers-v6'
import { SubnetRegistrator__factory } from '../../typechain-types/factories/contracts/topos-core/SubnetRegistrator__factory'
import { SubnetRegistrator } from '../../typechain-types'

describe('SubnetRegistrator', () => {
const chainId = 1
Expand Down
11 changes: 4 additions & 7 deletions test/topos-core/ToposCore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@ import { loadFixture } from '@nomicfoundation/hardhat-network-helpers'
import { ethers } from 'hardhat'
import { expect } from 'chai'

import {
CodeHash__factory,
ToposCore__factory,
ToposCoreProxy,
ToposCoreProxy__factory,
} from '../../typechain-types/ethers-v6'

import { ToposCore__factory } from '../../typechain-types/factories/contracts/topos-core/ToposCore__factory'
import { ToposCoreProxy__factory } from '../../typechain-types/factories/contracts/topos-core/ToposCoreProxy__factory'
import { CodeHash__factory } from '../../typechain-types/factories/contracts/topos-core/CodeHash__factory'
import { ToposCoreProxy } from '../../typechain-types/contracts/topos-core/ToposCoreProxy'
import * as cc from './shared/constants/certificates'
import * as testUtils from './shared/utils/common'

Expand Down
2 changes: 1 addition & 1 deletion test/topos-core/ToposMessaging.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
ToposCoreProxy__factory,
ERC20Messaging__factory,
ERC20Messaging,
} from '../../typechain-types/ethers-v6'
} from '../../typechain-types'
import * as cc from './shared/constants/certificates'
import * as testUtils from './shared/utils/common'
import { getReceiptMptProof } from './shared/utils/mpt_proof'
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
"skipLibCheck": true,
"resolveJsonModule": true
},
"include": ["./scripts", "./test", "./typechain-types", "./tasks"],
"include": ["./scripts", "./test", "./typechain-types"],
"files": ["./hardhat.config.ts"]
}

0 comments on commit 3c5ed0b

Please sign in to comment.