Skip to content

Commit 8757732

Browse files
authored
build: update to ethers v5 (#224)
* build: use ethers-v5 * build: update tests to use ethers-v5 * build: remove typechain v4
1 parent db53db8 commit 8757732

13 files changed

+3295
-1457
lines changed

buidler.config.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ dotenv.config()
1111

1212
usePlugin('@nomiclabs/buidler-waffle')
1313
usePlugin('solidity-coverage')
14-
usePlugin('buidler-typechain')
1514

1615
// Helpers
1716

@@ -121,11 +120,7 @@ const config: BuidlerConfig = {
121120
mnemonic: getAccountMnemonic(),
122121
},
123122
},
124-
},
125-
typechain: {
126-
outDir: './build/typechain/contracts',
127-
target: 'ethers-v4',
128-
},
123+
}
129124
}
130125

131126
export default config

package-lock.json

Lines changed: 3191 additions & 1362 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,19 @@
55
"directories": {
66
"test": "test"
77
},
8-
"dependencies": {
8+
"devDependencies": {
99
"@connext/contracts": "^3.2.1",
10-
"@connext/types": "^6.6.5",
11-
"@connext/utils": "^6.6.5",
10+
"@connext/types": "^7.0.0-alpha.2",
11+
"@connext/utils": "^7.0.0-alpha.2",
12+
"@graphprotocol/common-ts": "0.0.32",
13+
"@nomiclabs/buidler": "^1.3.7",
14+
"@nomiclabs/buidler-ethers": "^2.0.0-alpha.1",
15+
"@nomiclabs/buidler-waffle": "^2.0.0-alpha.1",
1216
"@openzeppelin/contracts": "3.0.1",
13-
"buidler-typechain": "^0.1.1",
14-
"truffle-hdwallet-provider": "^1.0.14",
15-
"ts-generator": "0.0.8"
16-
},
17-
"devDependencies": {
18-
"@graphprotocol/common-ts": "^0.0.31",
19-
"@nomiclabs/buidler": "^1.3.6",
20-
"@nomiclabs/buidler-ethers": "^1.3.3",
21-
"@nomiclabs/buidler-waffle": "^1.3.4",
22-
"@typechain/ethers-v4": "^1.0.0",
23-
"@types/bs58": "^4.0.1",
24-
"@types/minimist": "^1.2.0",
25-
"@typechain/truffle-v4": "^2.0.3",
26-
"@typechain/truffle-v5": "^2.0.2",
2717
"@typechain/web3-v1": "^1.0.0",
18+
"@types/bs58": "^4.0.1",
2819
"@types/dotenv": "^8.2.0",
20+
"@types/minimist": "^1.2.0",
2921
"@types/mocha": "^7.0.2",
3022
"@types/node": "^14.0.5",
3123
"@types/yargs": "^15.0.5",
@@ -42,8 +34,8 @@
4234
"eslint-plugin-prettier": "^3.1.3",
4335
"eslint-plugin-promise": "^4.2.1",
4436
"eslint-plugin-standard": "^4.0.1",
45-
"ethereum-waffle": "^2.5.1",
46-
"ethers": "^4.0.47",
37+
"ethereum-waffle": "^3.0.0",
38+
"ethers": "^5.0.2",
4739
"ethlint": "^1.2.5",
4840
"husky": "^4.2.5",
4941
"ipfs-http-client": "34.0.0",
@@ -54,8 +46,11 @@
5446
"solidity-coverage": "^0.7.5",
5547
"truffle-abi": "^1.0.3",
5648
"truffle-flattener": "^1.4.4",
49+
"truffle-hdwallet-provider": "^1.0.14",
50+
"ts-generator": "0.0.8",
5751
"ts-node": "^8.10.1",
5852
"typechain": "^2.0.0",
53+
"typechain-target-ethers-v5": "^1.2.0",
5954
"typescript": "^3.9.3",
6055
"yaml": "^1.10.0",
6156
"yargs": "^15.3.1"
@@ -68,7 +63,7 @@
6863
"deploy": "npm run migrate",
6964
"deploy-kovan": "npm run migrate -- --force --network kovan",
7065
"migrate": "buidler migrate",
71-
"test": "buidler typechain && buidler test",
66+
"test": "npm run typechain && buidler test",
7267
"coverage": "SOLIDITY_COVERAGE=true npm run evm:test",
7368
"evm:test": "scripts/evm.sh",
7469
"lint": "npm run lint:ts && npm run lint:sol",
@@ -82,7 +77,7 @@
8277
"prettier:sol": "prettier --write 'contracts/*.sol'",
8378
"flatten": "scripts/flatten.sh",
8479
"abi:extract": "truffle-abi -d ./build/contracts -o ./build/abis/ -v",
85-
"typechain": "buidler typechain"
80+
"typechain": "typechain --target ethers-v5 --outDir build/typechain/contracts 'build/abis/*.json'"
8681
},
8782
"lint-staged": {
8883
"contracts/*.sol": [

test/connext/general.test.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { expect } from 'chai'
22
import { ethers } from '@nomiclabs/buidler'
3-
import { Signer } from 'ethers'
4-
import { bigNumberify, parseEther, BigNumberish, BigNumber } from 'ethers/utils'
3+
import { constants, utils, BigNumberish, BigNumber, Signer } from 'ethers'
4+
55
import { ChallengeStatus, MinimalTransaction } from '@connext/types'
6-
import { ChannelSigner, toBN, stringify } from '@connext/utils'
6+
import { ChannelSigner, toBN } from '@connext/utils'
77

88
import { deployGRT, deployMultisigWithProxy } from '../lib/deployment'
99
import {
@@ -23,11 +23,13 @@ import { IndexerMultiAssetInterpreter } from '../../build/typechain/contracts/In
2323
import { IndexerWithdrawInterpreter } from '../../build/typechain/contracts/IndexerWithdrawInterpreter'
2424
import { MockStaking } from '../../build/typechain/contracts/MockStaking'
2525
import { GraphToken } from '../../build/typechain/contracts/GraphToken'
26-
import { AddressZero, Zero } from 'ethers/constants'
2726
import { MockDispute } from '../../build/typechain/contracts/MockDispute'
2827
import { AppWithAction } from '../../build/typechain/contracts/AppWithAction'
2928
import { IdentityApp } from '../../build/typechain/contracts/IdentityApp'
3029

30+
const { AddressZero, Zero } = constants
31+
const { parseEther } = utils
32+
3133
describe('Indexer Channel Operations', () => {
3234
let indexerMultisig: MinimumViableMultisig
3335
let nonIndexerMultisig: MinimumViableMultisig
@@ -109,7 +111,7 @@ describe('Indexer Channel Operations', () => {
109111
expect(preDeposit.toString()).to.be.eq('0')
110112

111113
// Fund multisig from governor
112-
await fundMultisig(new BigNumber(amount), multisig.address, governer, tokenContract)
114+
await fundMultisig(BigNumber.from(amount), multisig.address, governer, tokenContract)
113115

114116
// Get + verify post deposit balance
115117
const postDeposit = tokenContract
@@ -139,7 +141,7 @@ describe('Indexer Channel Operations', () => {
139141

140142
describe('funding + withdrawal', function() {
141143
// Establish test constants
142-
const ETH_DEPOSIT = bigNumberify(180)
144+
const ETH_DEPOSIT = BigNumber.from(180)
143145
const TOKEN_DEPOSIT = parseEther('4')
144146

145147
let sendWithdrawalCommitment: (
@@ -320,7 +322,7 @@ describe('Indexer Channel Operations', () => {
320322

321323
describe('disputes', function() {
322324
// Establish test constants
323-
const ETH_DEPOSIT = bigNumberify(180)
325+
const ETH_DEPOSIT = BigNumber.from(180)
324326
const TOKEN_DEPOSIT = parseEther('4')
325327
const APP_DEPOSIT = toBN(15)
326328

test/connext/multisig.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { expect } from 'chai'
22
import { ethers } from '@nomiclabs/buidler'
33
import { ChannelSigner } from '@connext/utils'
44
import { Signer } from 'ethers'
5-
import { parseEther } from 'ethers/utils'
65

76
import { GraphToken } from '../../build/typechain/contracts/GraphToken'
87
import { deployMultisigWithProxy, deployGRT } from '../lib/deployment'

test/disputes.test.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { expect } from 'chai'
2-
import { AddressZero } from 'ethers/constants'
3-
import { defaultAbiCoder as abi, arrayify, concat, hexlify, solidityKeccak256 } from 'ethers/utils'
1+
import { expect, use } from 'chai'
2+
import { constants, utils } from 'ethers'
3+
import { solidity } from 'ethereum-waffle'
44
import { attestations } from '@graphprotocol/common-ts'
55

66
import { DisputeManager } from '../build/typechain/contracts/DisputeManager'
@@ -20,6 +20,11 @@ import {
2020
toGRT,
2121
} from './lib/testHelpers'
2222

23+
use(solidity)
24+
25+
const { AddressZero } = constants
26+
const { defaultAbiCoder: abi, arrayify, concat, hexlify, solidityKeccak256 } = utils
27+
2328
const MAX_PPM = 1000000
2429
const NON_EXISTING_DISPUTE_ID = randomHexBytes()
2530

test/epochs.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { expect } from 'chai'
2-
import { BigNumber } from 'ethers/utils'
1+
import { expect, use } from 'chai'
2+
import { BigNumber } from 'ethers'
3+
import { solidity } from 'ethereum-waffle'
34

45
import { EpochManager } from '../build/typechain/contracts/EpochManager'
56

@@ -13,6 +14,8 @@ import {
1314
toBN,
1415
} from './lib/testHelpers'
1516

17+
use(solidity)
18+
1619
describe('EpochManager', () => {
1720
const [me, governor] = provider().getWallets()
1821

test/graphToken.test.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1-
import { expect } from 'chai'
2-
import { AddressZero } from 'ethers/constants'
3-
import { BigNumber, Arrayish, HDNode, SigningKey, keccak256, Signature } from 'ethers/utils'
1+
import { expect, use } from 'chai'
2+
import { constants, utils, BytesLike, BigNumber, Signature } from 'ethers'
3+
import { solidity } from 'ethereum-waffle'
44
import { eip712 } from '@graphprotocol/common-ts/dist/attestations'
55

66
import { GraphToken } from '../build/typechain/contracts/GraphToken'
77

88
import * as deployment from './lib/deployment'
99
import { getChainID, provider, toBN, toGRT } from './lib/testHelpers'
1010

11+
use(solidity)
12+
13+
const { AddressZero } = constants
14+
const { keccak256, SigningKey } = utils
15+
1116
const MAX_UINT256 = toBN('2')
1217
.pow('256')
1318
.sub(1)
@@ -34,7 +39,7 @@ function hashEncodePermit(permit: Permit) {
3439
}
3540

3641
function signPermit(
37-
signer: Arrayish | HDNode.HDNode,
42+
signer: BytesLike,
3843
chainId: number,
3944
contractAddress: string,
4045
permit: Permit,

test/lib/channel.ts

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,23 @@ import {
55
singleAssetTwoPartyCoinTransferInterpreterParamsEncoding,
66
} from '@connext/types'
77
import { Signer } from 'ethers'
8-
import {
8+
import { constants, utils, BigNumber, BigNumberish } from 'ethers'
9+
import { GraphToken } from '../../build/typechain/contracts/GraphToken'
10+
import MultisigArtifact from '../../build/contracts/MinimumViableMultisig.json'
11+
import { IndexerCtdt } from '../../build/typechain/contracts/IndexerCtdt'
12+
import { toBN } from './testHelpers'
13+
import { MockDispute } from '../../build/typechain/contracts/MockDispute'
14+
15+
const { Zero, AddressZero } = constants
16+
const {
917
parseEther,
10-
BigNumber,
1118
Interface,
1219
randomBytes,
1320
solidityKeccak256,
14-
bigNumberify,
1521
solidityPack,
1622
keccak256,
17-
BigNumberish,
1823
defaultAbiCoder,
19-
} from 'ethers/utils'
20-
import { GraphToken } from '../../build/typechain/contracts/GraphToken'
21-
import MultisigArtifact from '../../build/contracts/MinimumViableMultisig.json'
22-
import { IndexerCtdt } from '../../build/typechain/contracts/IndexerCtdt'
23-
import { toBN } from './testHelpers'
24-
import { MockDispute } from '../../build/typechain/contracts/MockDispute'
25-
import { Zero, AddressZero } from 'ethers/constants'
24+
} = utils
2625

2726
export async function getRandomFundedChannelSigners(
2827
numSigners: number,
@@ -160,7 +159,7 @@ export const getFreeBalanceState = (
160159
},
161160
{
162161
assetId: AddressZero,
163-
deposit: new BigNumber(0),
162+
deposit: BigNumber.from(0),
164163
},
165164
)
166165

@@ -174,7 +173,7 @@ export const getFreeBalanceState = (
174173
},
175174
{
176175
assetId: AddressZero,
177-
deposit: new BigNumber(0),
176+
deposit: BigNumber.from(0),
178177
},
179178
)
180179

@@ -310,12 +309,12 @@ export class MiniCommitment {
310309
return {
311310
to: ctdt.address,
312311
value: 0,
313-
data: ctdt.interface.functions.executeWithdraw.encode([
312+
data: ctdt.interface.encodeFunctionData('executeWithdraw(address,bytes32,bytes,bytes)', [
314313
withdrawInterpreterAddress,
315314
randomBytes(32), // nonce
316-
encode(withdrawOutcomeEncoding, { to: recipient, amount: bigNumberify(amount) }),
315+
encode(withdrawOutcomeEncoding, { to: recipient, amount: BigNumber.from(amount) }),
317316
encode(withdrawOutcomeInterpreterParamsEncoding, {
318-
limit: bigNumberify(amount),
317+
limit: BigNumber.from(amount),
319318
tokenAddress: assetId,
320319
}),
321320
]),
@@ -345,16 +344,20 @@ export class MiniCommitment {
345344
return {
346345
to: ctdt.address,
347346
value: 0,
348-
data: ctdt.interface.functions.executeEffectOfInterpretedAppOutcome.encode([
349-
mockDispute.address,
350-
freeBalanceIdentityHash,
351-
appIdentityHash,
352-
interpreterAddr,
353-
encodedParams,
354-
]),
347+
data: ctdt.interface.encodeFunctionData(
348+
'executeEffectOfInterpretedAppOutcome(address,bytes32,bytes32,address,bytes)',
349+
[
350+
mockDispute.address,
351+
freeBalanceIdentityHash,
352+
appIdentityHash,
353+
interpreterAddr,
354+
encodedParams,
355+
],
356+
),
355357
operation: MultisigOperation.DelegateCall,
356358
}
357359
}
360+
358361
// TODO: returns signed app execute effect tx
359362
case CommitmentTypes.setup: {
360363
const {
@@ -366,11 +369,10 @@ export class MiniCommitment {
366369
return {
367370
to: ctdt.address,
368371
value: 0,
369-
data: ctdt.interface.functions.executeEffectOfFreeBalance.encode([
370-
mockDispute.address,
371-
freeBalanceIdentityHash,
372-
interpreterAddr,
373-
]),
372+
data: ctdt.interface.encodeFunctionData(
373+
'executeEffectOfFreeBalance(address,bytes32,address)',
374+
[mockDispute.address, freeBalanceIdentityHash, interpreterAddr],
375+
),
374376
operation: MultisigOperation.DelegateCall,
375377
}
376378
}
@@ -406,13 +408,11 @@ export class MiniCommitment {
406408

407409
// Encode call to execute transaction
408410
const multisig = new Interface(MultisigArtifact.abi)
409-
const txData = multisig.functions.execTransaction.encode([
410-
details.to,
411-
details.value,
412-
details.data,
413-
details.operation,
414-
signatures,
415-
])
411+
412+
const txData = multisig.encodeFunctionData(
413+
'execTransaction(address,uint256,bytes,uint8,bytes[])',
414+
[details.to, details.value, details.data, details.operation, signatures],
415+
)
416416

417417
return { to: this.multisigAddress, value: 0, data: txData }
418418
}

0 commit comments

Comments
 (0)