Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SC-911] Migrate to new hardhat-ethers #102

Merged
merged 7 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ runs:
steps:
- uses: actions/setup-node@v3
with:
node-version: 16
node-version: 20

- run: npm install -g yarn
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion deploy/commands/deploy-oracle-and-add.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module.exports = async ({ getNamedAccounts, deployments }) => {
deployer,
deploymentName: PARAMS.deploymentName,
});
await offchainOracle.addOracle(customOracle.address, PARAMS.oracleType);
await offchainOracle.addOracle(customOracle, PARAMS.oracleType);
};

module.exports.skip = async () => true;
4 changes: 2 additions & 2 deletions deploy/commands/deploy-wrapper-and-add.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = async ({ getNamedAccounts, deployments }) => {

const offchainOracle = await getContract(deployments, 'OffchainOracle');
const multiWrapper = await getContract(deployments, 'MultiWrapper');
if (ethers.utils.getAddress(await offchainOracle.multiWrapper()) !== ethers.utils.getAddress(multiWrapper.address)) {
if (ethers.getAddress(await offchainOracle.multiWrapper()) !== ethers.getAddress(await multiWrapper.getAddress())) {
console.warn('MultiWrapper address in deployments is not equal to the address in OffchainOracle');
return;
}
Expand All @@ -28,7 +28,7 @@ module.exports = async ({ getNamedAccounts, deployments }) => {
deployer,
deploymentName: PARAMS.deploymentName,
});
await multiWrapper.addWrapper(customWrapper.address);
await multiWrapper.addWrapper(customWrapper);
};

module.exports.skip = async () => true;
6 changes: 3 additions & 3 deletions deploy/commands/redeploy-oracle.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = async ({ getNamedAccounts, deployments }) => {
const oldCustomOracle = await getContract(deployments, PARAMS.contractName, PARAMS.deploymentName);

const oracles = await offchainOracle.oracles();
const customOracleType = oracles.oracleTypes[oracles.allOracles.indexOf(oldCustomOracle.address)];
const customOracleType = oracles.oracleTypes[oracles.allOracles.indexOf(await oldCustomOracle.getAddress())];

const customOracle = await deployAndGetContract({
contractName: PARAMS.contractName,
Expand All @@ -28,8 +28,8 @@ module.exports = async ({ getNamedAccounts, deployments }) => {
deploymentName: PARAMS.deploymentName,
skipIfAlreadyDeployed: false,
});
await offchainOracle.removeOracle(oldCustomOracle.address, customOracleType);
await offchainOracle.addOracle(customOracle.address, customOracleType);
await offchainOracle.removeOracle(oldCustomOracle, customOracleType);
await offchainOracle.addOracle(customOracle, customOracleType);
};

module.exports.skip = async () => true;
6 changes: 3 additions & 3 deletions deploy/commands/redeploy-wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = async ({ getNamedAccounts, deployments }) => {

const offchainOracle = await getContract(deployments, 'OffchainOracle');
const multiWrapper = await getContract(deployments, 'MultiWrapper');
if (ethers.utils.getAddress(await offchainOracle.multiWrapper()) !== ethers.utils.getAddress(multiWrapper.address)) {
if (ethers.getAddress(await offchainOracle.multiWrapper()) !== ethers.getAddress(await multiWrapper.getAddress())) {
console.warn('MultiWrapper address in deployments is not equal to the address in OffchainOracle');
return;
}
Expand All @@ -30,8 +30,8 @@ module.exports = async ({ getNamedAccounts, deployments }) => {
deploymentName: PARAMS.deploymentName,
skipIfAlreadyDeployed: false,
});
await multiWrapper.removeWrapper(oldCustomWrapper.address);
await multiWrapper.addWrapper(customWrapper.address);
await multiWrapper.removeWrapper(oldCustomWrapper);
await multiWrapper.addWrapper(customWrapper);
};

module.exports.skip = async () => true;
2 changes: 1 addition & 1 deletion deploy/commands/use-create3/deploy-oracle-and-add.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = async ({ getNamedAccounts, deployments }) => {
deploymentName: 'YOUR_DEPLOYMENT_NAME',
oracleType: '0',
};
const SALT_PROD = ethers.utils.keccak256(ethers.utils.toUtf8Bytes(PARAMS.contractName + SALT_INDEX));
const SALT_PROD = ethers.keccak256(ethers.toUtf8Bytes(PARAMS.contractName + SALT_INDEX));

console.log('running deploy script: use-create3/deploy-oracle-and-add');
console.log('network id ', await getChainId());
Expand Down
4 changes: 2 additions & 2 deletions deploy/commands/use-create3/deploy-wrapper-and-add.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ module.exports = async ({ getNamedAccounts, deployments }) => {
args: [],
deploymentName: 'YOUR_DEPLOYMENT_NAME',
};
const SALT_PROD = ethers.utils.keccak256(ethers.utils.toUtf8Bytes(PARAMS.contractName + SALT_INDEX));
const SALT_PROD = ethers.keccak256(ethers.toUtf8Bytes(PARAMS.contractName + SALT_INDEX));

console.log('running deploy script: use-create3/deploy-wrapper-and-add');
console.log('network id ', await getChainId());

const offchainOracle = await getContract(deployments, 'OffchainOracle');
const multiWrapper = await getContract(deployments, 'MultiWrapper');
if (ethers.utils.getAddress(await offchainOracle.multiWrapper()) !== ethers.utils.getAddress(multiWrapper.address)) {
if (ethers.getAddress(await offchainOracle.multiWrapper()) !== ethers.getAddress(await multiWrapper.getAddress())) {
console.warn('MultiWrapper address in deployments is not equal to the address in OffchainOracle');
return;
}
Expand Down
8 changes: 4 additions & 4 deletions deploy/commands/use-create3/redeploy-offchain-oracle.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const { deployContract } = require('./simple-deploy.js');
const SALT_INDEX = '';

module.exports = async ({ getNamedAccounts, deployments }) => {
const SALT_PROD = ethers.utils.keccak256(ethers.utils.toUtf8Bytes('OffchainOracle' + SALT_INDEX));
const SALT_PROD = ethers.keccak256(ethers.toUtf8Bytes('OffchainOracle' + SALT_INDEX));

console.log('running deploy script: use-create3/redeploy-offchain-oracle');
console.log('network id ', await getChainId());
Expand All @@ -21,9 +21,9 @@ module.exports = async ({ getNamedAccounts, deployments }) => {
contractName: 'OffchainOracle',
args: [
await oldOffchainOracle.multiWrapper(),
oracles.allOracles,
oracles.oracleTypes,
await oldOffchainOracle.connectors(),
[...oracles.allOracles],
[...oracles.oracleTypes],
[...await oldOffchainOracle.connectors()],
wBase,
deployer,
],
Expand Down
6 changes: 3 additions & 3 deletions deploy/commands/use-create3/redeploy-oracle.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ module.exports = async ({ getNamedAccounts, deployments }) => {
args: [],
deploymentName: 'YOUR_DEPLOYMENT_NAME',
};
const SALT_PROD = ethers.utils.keccak256(ethers.utils.toUtf8Bytes(PARAMS.contractName + SALT_INDEX));
const SALT_PROD = ethers.keccak256(ethers.toUtf8Bytes(PARAMS.contractName + SALT_INDEX));

console.log('running deploy script: use-create3/redeploy-oracle');
console.log('network id ', await getChainId());

const offchainOracle = await getContract(deployments, 'OffchainOracle');
const oldCustomOracle = await getContract(deployments, PARAMS.contractName, PARAMS.deploymentName);
const oracles = await offchainOracle.oracles();
const customOracleType = oracles.oracleTypes[oracles.allOracles.indexOf(oldCustomOracle.address)];
const customOracleType = oracles.oracleTypes[oracles.allOracles.indexOf(await oldCustomOracle.getAddress())];

const customOracleAddress = await deployContract(PARAMS, SALT_PROD, deployments);

await offchainOracle.removeOracle(oldCustomOracle.address, customOracleType);
await offchainOracle.removeOracle(oldCustomOracle, customOracleType);
await offchainOracle.addOracle(customOracleAddress, customOracleType);
};

Expand Down
6 changes: 3 additions & 3 deletions deploy/commands/use-create3/redeploy-wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ module.exports = async ({ getNamedAccounts, deployments }) => {
args: [],
deploymentName: 'YOUR_DEPLOYMENT_NAME',
};
const SALT_PROD = ethers.utils.keccak256(ethers.utils.toUtf8Bytes(PARAMS.contractName + SALT_INDEX));
const SALT_PROD = ethers.keccak256(ethers.toUtf8Bytes(PARAMS.contractName + SALT_INDEX));

console.log('running deploy script: use-create3/redeploy-wrapper');
console.log('network id ', await getChainId());

const offchainOracle = await getContract(deployments, 'OffchainOracle');
const multiWrapper = await getContract(deployments, 'MultiWrapper');
if (ethers.utils.getAddress(await offchainOracle.multiWrapper()) !== ethers.utils.getAddress(multiWrapper.address)) {
if (ethers.getAddress(await offchainOracle.multiWrapper()) !== ethers.getAddress(await multiWrapper.getAddress())) {
console.warn('MultiWrapper address in deployments is not equal to the address in OffchainOracle');
return;
}

const oldCustomWrapper = await getContract(deployments, PARAMS.contractName, PARAMS.deploymentName);
const customWrapperAddress = await deployContract(PARAMS, SALT_PROD, deployments);

await multiWrapper.removeWrapper(oldCustomWrapper.address);
await multiWrapper.removeWrapper(oldCustomWrapper);
await multiWrapper.addWrapper(customWrapperAddress);
};

Expand Down
7 changes: 4 additions & 3 deletions deploy/commands/use-create3/simple-deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ module.exports = async ({ getNamedAccounts, deployments }) => {
args: [],
deploymentName: 'YOUR_DEPLOYMENT_NAME',
};
const SALT_PROD = ethers.utils.keccak256(ethers.utils.toUtf8Bytes(PARAMS.contractName + SALT_INDEX));

const SALT_PROD = ethers.keccak256(ethers.toUtf8Bytes(PARAMS.contractName + SALT_INDEX));

console.log('running deploy script: use-create3/simple-deploy');
console.log('network id ', await getChainId());
Expand All @@ -21,9 +22,9 @@ module.exports = async ({ getNamedAccounts, deployments }) => {
const deployContract = async (params, saltProd, deployments) => {
const create3Deployer = await ethers.getContractAt('ICreate3Deployer', contracts.create3Deployer);
const CustomContract = await ethers.getContractFactory(params.contractName);
const deployData = CustomContract.getDeployTransaction(
const deployData = (await CustomContract.getDeployTransaction(
...params.args,
).data;
)).data;

const txn = await create3Deployer.deploy(saltProd, deployData);
const receipt = await txn.wait();
Expand Down
4 changes: 2 additions & 2 deletions examples/multiple-prices.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions examples/single-price.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions hardhat.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require('@matterlabs/hardhat-zksync-deploy');
require('@matterlabs/hardhat-zksync-solc');
require('@matterlabs/hardhat-zksync-verify');
require('@nomiclabs/hardhat-ethers');
require('@nomicfoundation/hardhat-ethers');
require('@nomicfoundation/hardhat-verify');
require('@nomicfoundation/hardhat-chai-matchers');
require('hardhat-deploy');
Expand Down Expand Up @@ -47,7 +47,7 @@ module.exports = {
],
},
zksolc: {
version: '1.3.13',
version: '1.3.17',
compilerSource: 'binary',
settings: {},
},
Expand Down
Loading
Loading