Skip to content

Commit 81535f8

Browse files
authored
fix: hardhat deploy getContract is deprecated (#322)
* fix: hardhat deploy getContract is deprecated * fix: unused * fix: test edge case
1 parent 601afc7 commit 81535f8

File tree

7 files changed

+85
-22
lines changed

7 files changed

+85
-22
lines changed

deploy/InboxStubCreator.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
11
module.exports = async hre => {
22
const { deployments, getNamedAccounts, ethers } = hre
3-
const { deploy } = deployments
43
const { deployer } = await getNamedAccounts()
54

6-
const inboxDeployResult = await deploy('InboxStub', {
5+
const inboxDeployResult = await deployments.deploy('InboxStub', {
76
from: deployer,
87
args: [],
98
})
109

11-
const bridge = await ethers.getContract('BridgeStub')
12-
const inbox = await ethers.getContract('InboxStub')
10+
const bridge = await ethers.getContractAt(
11+
'BridgeStub',
12+
(
13+
await deployments.get('BridgeStub')
14+
).address
15+
)
16+
const inbox = await ethers.getContractAt(
17+
'InboxStub',
18+
(
19+
await deployments.get('InboxStub')
20+
).address
21+
)
1322

1423
if (inboxDeployResult.newlyDeployed) {
1524
await bridge.setDelayedInbox(inbox.address, true)

deploy/SequencerInbox.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,18 @@ module.exports = async hre => {
33
const { deploy } = deployments
44
const { deployer } = await getNamedAccounts()
55

6-
const blobBasefeeReader = await ethers.getContract('BlobBasefeeReader')
7-
const dataHashReader = await ethers.getContract('DataHashReader')
6+
const blobBasefeeReader = await ethers.getContractAt(
7+
'BlobBasefeeReader',
8+
(
9+
await deployments.get('BlobBasefeeReader')
10+
).address
11+
)
12+
const dataHashReader = await ethers.getContractAt(
13+
'DataHashReader',
14+
(
15+
await deployments.get('DataHashReader')
16+
).address
17+
)
818

919
await deploy('SequencerInbox', { from: deployer, args: [117964] })
1020
}

deploy/SequencerInboxStubCreator.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import { Toolkit4844 } from '../test/contract/toolkit4844'
22

33
module.exports = async hre => {
4-
const { deployments, getSigners, getNamedAccounts, ethers } = hre
5-
const { deploy } = deployments
4+
const { deployments, getNamedAccounts, ethers } = hre
65
const { deployer } = await getNamedAccounts()
76

8-
const bridge = await ethers.getContract('BridgeStub')
7+
const bridge = await deployments.get('BridgeStub')
98
const reader4844 = await Toolkit4844.deployReader4844(
109
await ethers.getSigner(deployer)
1110
)
@@ -15,7 +14,7 @@ module.exports = async hre => {
1514
delaySeconds: 10000,
1615
futureSeconds: 10000,
1716
}
18-
await deploy('SequencerInboxStub', {
17+
await deployments.deploy('SequencerInboxStub', {
1918
from: deployer,
2019
args: [
2120
bridge.address,
@@ -24,6 +23,7 @@ module.exports = async hre => {
2423
117964,
2524
reader4844.address,
2625
false,
26+
true,
2727
],
2828
})
2929
}

test/foundry/AbsOutbox.t.sol

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,17 @@ abstract contract AbsOutboxTest is Test {
5353
function test_executeTransactionSimulation(
5454
address from
5555
) public {
56-
vm.assume(from != address(0) && from != address(this));
56+
address outboxProxyAdmin = address(
57+
uint160(
58+
uint256(
59+
vm.load(
60+
address(outbox),
61+
0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103
62+
)
63+
)
64+
)
65+
);
66+
vm.assume(from != address(0) && from != address(this) && from != outboxProxyAdmin);
5767
vm.prank(from);
5868
vm.expectRevert(SimulationOnlyEntrypoint.selector);
5969
outbox.executeTransactionSimulation(

test/prover/hash-proofs.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
import { assert } from 'chai'
2-
import { ethers, run } from 'hardhat'
2+
import { ethers, run, deployments } from 'hardhat'
33

44
describe('HashProofHelper', function () {
55
it('Should produce valid proofs from full preimages', async function () {
66
await run('deploy', { tags: 'HashProofHelper' })
77

8-
const hashProofHelper = await ethers.getContract('HashProofHelper')
8+
const hashProofHelper = await ethers.getContractAt(
9+
'HashProofHelper',
10+
(
11+
await deployments.get('HashProofHelper')
12+
).address
13+
)
914

1015
for (let i = 0; i < 16; i += 1) {
1116
const len = Math.floor(Math.random() * 256)
@@ -33,7 +38,12 @@ describe('HashProofHelper', function () {
3338
it('Should produce valid proofs from split preimages', async function () {
3439
await run('deploy', { tags: 'HashProofHelper' })
3540

36-
const hashProofHelper = await ethers.getContract('HashProofHelper')
41+
const hashProofHelper = await ethers.getContractAt(
42+
'HashProofHelper',
43+
(
44+
await deployments.get('HashProofHelper')
45+
).address
46+
)
3747

3848
for (let i = 0; i < 16; i += 1) {
3949
const len = Math.floor(Math.random() * 1024)

test/prover/one-step-proof.ts

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
1-
import { ethers, run, getNamedAccounts } from 'hardhat'
1+
import { ethers, run, getNamedAccounts, deployments } from 'hardhat'
22
import fs from 'fs'
33
import assert from 'assert'
44
import readline from 'readline'
55

66
const PARALLEL = 128
77

88
async function sendTestMessages() {
9-
const { deployer } = await getNamedAccounts()
10-
const inbox = await ethers.getContract('InboxStub', deployer)
11-
const seqInbox = await ethers.getContract('SequencerInboxStub', deployer)
9+
const inbox = await ethers.getContractAt(
10+
'InboxStub',
11+
(
12+
await deployments.get('InboxStub')
13+
).address
14+
)
15+
const seqInbox = await ethers.getContractAt(
16+
'SequencerInboxStub',
17+
(
18+
await deployments.get('SequencerInboxStub')
19+
).address
20+
)
1221
const msgRoot = '../arbitrator/prover/test-cases/rust/data/'
1322
const gasOpts = {
1423
gasLimit: ethers.utils.hexlify(250000),
@@ -59,8 +68,18 @@ describe('OneStepProof', function () {
5968
for (const [path, file] of proofs) {
6069
it('Should pass ' + file + ' proofs', async function () {
6170
const proofs = JSON.parse(fs.readFileSync(path).toString('utf8'))
62-
const osp = await ethers.getContract('OneStepProofEntry')
63-
const bridge = await ethers.getContract('BridgeStub')
71+
const osp = await ethers.getContractAt(
72+
'OneStepProofEntry',
73+
(
74+
await deployments.get('OneStepProofEntry')
75+
).address
76+
)
77+
const bridge = await ethers.getContractAt(
78+
'BridgeStub',
79+
(
80+
await deployments.get('BridgeStub')
81+
).address
82+
)
6483

6584
const promises = []
6685
const isdone = []

test/prover/value-arrays.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
import { ethers, run } from 'hardhat'
1+
import { ethers, run, deployments } from 'hardhat'
22

33
describe('ValueArray', function () {
44
it('Should pass ValueArrayTester', async function () {
55
await run('deploy', { tags: 'ValueArrayTester' })
66

7-
const valueArrayTester = await ethers.getContract('ValueArrayTester')
7+
const valueArrayTester = await ethers.getContractAt(
8+
'ValueArrayTester',
9+
(
10+
await deployments.get('ValueArrayTester')
11+
).address
12+
)
813

914
await valueArrayTester.test()
1015
})

0 commit comments

Comments
 (0)