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

style(protocol): use semicolons #480

Merged
merged 2 commits into from
Dec 24, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 packages/protocol/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ module.exports = {
"node/no-missing-require": "off",
"no-unused-expressions": "off",
},
}
};
1 change: 0 additions & 1 deletion packages/protocol/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"semi": false,
"overrides": [
{
"files": ["*.sol", "*.ts"],
Expand Down
6 changes: 3 additions & 3 deletions packages/protocol/.solcover.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = {
"test/libs/TestLibReceiptDecoder.sol", //integration tests
"test/thirdparty/TestLibBlockHeaderDecoder.sol", // assembly too long
],
mocha:{
grep: '^[^integration]'
}
mocha: {
grep: "^[^integration]",
},
};
32 changes: 16 additions & 16 deletions packages/protocol/hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import "@nomiclabs/hardhat-etherscan"
import "@nomiclabs/hardhat-waffle"
import "@openzeppelin/hardhat-upgrades"
import "@typechain/hardhat"
import "hardhat-abi-exporter"
import "hardhat-gas-reporter"
import "hardhat-preprocessor"
import { HardhatUserConfig } from "hardhat/config"
import "solidity-coverage"
import "solidity-docgen"
import "./tasks/deploy_L1"
import "@nomiclabs/hardhat-etherscan";
import "@nomiclabs/hardhat-waffle";
import "@openzeppelin/hardhat-upgrades";
import "@typechain/hardhat";
import "hardhat-abi-exporter";
import "hardhat-gas-reporter";
import "hardhat-preprocessor";
import { HardhatUserConfig } from "hardhat/config";
import "solidity-coverage";
import "solidity-docgen";
import "./tasks/deploy_L1";

const hardhatMnemonic =
"test test test test test test test test test test test taik"
"test test test test test test test test test test test taik";
const config: HardhatUserConfig = {
docgen: {
exclude: [
Expand Down Expand Up @@ -114,15 +114,15 @@ const config: HardhatUserConfig = {
) {
return `${line.slice(0, line.indexOf(" ="))} = ${
process.env[constantName]
};`
};`;
}
}

return line
return line;
},
files: "libs/LibConstants.sol",
}),
},
}
};

export default config
export default config;
4 changes: 2 additions & 2 deletions packages/protocol/tasks/config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// https://github.com/ethereum-lists/chains/pull/1611
export const K_CHAIN_ID = 167
export const K_DEPLOY_CONFIRMATIONS = 12
export const K_CHAIN_ID = 167;
export const K_DEPLOY_CONFIRMATIONS = 12;
144 changes: 72 additions & 72 deletions packages/protocol/tasks/deploy_L1.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as ethers from "ethers"
import { task } from "hardhat/config"
import * as types from "hardhat/internal/core/params/argumentTypes"
import * as config from "./config"
import * as log from "./log"
import * as utils from "./utils"
import * as ethers from "ethers";
import { task } from "hardhat/config";
import * as types from "hardhat/internal/core/params/argumentTypes";
import * as config from "./config";
import * as log from "./log";
import * as utils from "./utils";

task("deploy_L1")
.addParam("daoVault", "The DAO vault address")
Expand Down Expand Up @@ -42,110 +42,110 @@ task("deploy_L1")
hre.network.name === "localhost" ||
hre.network.name === "hardhat"
) {
args.confirmations = 1
args.confirmations = 1;
} else if (
hre.network.name === "ropsten" ||
hre.network.name === "goerli"
) {
args.confirmations = 6
args.confirmations = 6;
}

hre.args = args
await deployContracts(hre)
})
hre.args = args;
await deployContracts(hre);
});

export async function deployContracts(hre: any) {
const network = hre.network.name
const { chainId } = await hre.ethers.provider.getNetwork()
const deployer = await utils.getDeployer(hre)
const daoVault = hre.args.daoVault
const teamVault = hre.args.teamVault
const l2GenesisBlockHash = hre.args.l2GenesisBlockHash
const taikoL2Address = hre.args.taikoL2
const l2ChainId = hre.args.l2ChainId
const bridgeFunderPrivateKey = hre.args.bridgeFunderPrivateKey
const bridgeFund = hre.args.bridgeFund

log.debug(`network: ${network}`)
log.debug(`chainId: ${chainId}`)
log.debug(`deployer: ${deployer}`)
log.debug(`daoVault: ${daoVault}`)
log.debug(`l2GenesisBlockHash: ${l2GenesisBlockHash}`)
log.debug(`taikoL2Address: ${taikoL2Address}`)
log.debug(`l2ChainId: ${l2ChainId}`)
log.debug(`bridgeFunderPrivateKey: ${bridgeFunderPrivateKey}`)
log.debug(`bridgeFund: ${bridgeFund}`)
log.debug(`confirmations: ${hre.args.confirmations}`)
log.debug()
const network = hre.network.name;
const { chainId } = await hre.ethers.provider.getNetwork();
const deployer = await utils.getDeployer(hre);
const daoVault = hre.args.daoVault;
const teamVault = hre.args.teamVault;
const l2GenesisBlockHash = hre.args.l2GenesisBlockHash;
const taikoL2Address = hre.args.taikoL2;
const l2ChainId = hre.args.l2ChainId;
const bridgeFunderPrivateKey = hre.args.bridgeFunderPrivateKey;
const bridgeFund = hre.args.bridgeFund;

log.debug(`network: ${network}`);
log.debug(`chainId: ${chainId}`);
log.debug(`deployer: ${deployer}`);
log.debug(`daoVault: ${daoVault}`);
log.debug(`l2GenesisBlockHash: ${l2GenesisBlockHash}`);
log.debug(`taikoL2Address: ${taikoL2Address}`);
log.debug(`l2ChainId: ${l2ChainId}`);
log.debug(`bridgeFunderPrivateKey: ${bridgeFunderPrivateKey}`);
log.debug(`bridgeFund: ${bridgeFund}`);
log.debug(`confirmations: ${hre.args.confirmations}`);
log.debug();

// AddressManager
const AddressManager = await utils.deployContract(hre, "AddressManager")
await utils.waitTx(hre, await AddressManager.init())
const AddressManager = await utils.deployContract(hre, "AddressManager");
await utils.waitTx(hre, await AddressManager.init());
await utils.waitTx(
hre,
await AddressManager.setAddress(`${chainId}.dao_vault`, daoVault)
)
);
await utils.waitTx(
hre,
await AddressManager.setAddress(`${chainId}.team_vault`, teamVault)
)
);
// Used by V1Proving
await utils.waitTx(
hre,
await AddressManager.setAddress(`${l2ChainId}.taiko`, taikoL2Address)
)
);

// TkoToken
const TkoToken = await utils.deployContract(hre, "TkoToken")
await utils.waitTx(hre, await TkoToken.init(AddressManager.address))
const TkoToken = await utils.deployContract(hre, "TkoToken");
await utils.waitTx(hre, await TkoToken.init(AddressManager.address));
await utils.waitTx(
hre,
await AddressManager.setAddress(
`${chainId}.tko_token`,
TkoToken.address
)
)
);

// Config manager
const ConfigManager = await utils.deployContract(hre, "ConfigManager")
await utils.waitTx(hre, await ConfigManager.init())
const ConfigManager = await utils.deployContract(hre, "ConfigManager");
await utils.waitTx(hre, await ConfigManager.init());
await utils.waitTx(
hre,
await AddressManager.setAddress(
`${chainId}.config_manager`,
ConfigManager.address
)
)
);

// TaikoL1
const TaikoL1 = await utils.deployContract(
hre,
"TaikoL1",
await deployBaseLibs(hre)
)
);

await utils.waitTx(
hre,
await TaikoL1.init(AddressManager.address, l2GenesisBlockHash)
)
);

// Used by LibBridgeRead
await utils.waitTx(
hre,
await AddressManager.setAddress(`${chainId}.taiko`, TaikoL1.address)
)
);

// Bridge
const Bridge = await deployBridge(hre, AddressManager.address)
const Bridge = await deployBridge(hre, AddressManager.address);

// TokenVault
const TokenVault = await deployTokenVault(hre, AddressManager.address)
const TokenVault = await deployTokenVault(hre, AddressManager.address);

// Used by TokenVault
await utils.waitTx(
hre,
await AddressManager.setAddress(`${chainId}.bridge`, Bridge.address)
)
);

// Fund L1 bridge, which is necessary when there is a L2 faucet
if (
Expand All @@ -155,21 +155,21 @@ export async function deployContracts(hre: any) {
const funder = new hre.ethers.Wallet(
bridgeFunderPrivateKey,
hre.ethers.provider
)
);

await utils.waitTx(
hre,
await funder.sendTransaction({
to: Bridge.address,
value: hre.ethers.BigNumber.from(bridgeFund),
})
)
);

log.debug(
`L1 bridge balance: ${hre.ethers.utils.hexlify(
await hre.ethers.provider.getBalance(Bridge.address)
)}`
)
);
}

// save deployments
Expand All @@ -185,66 +185,66 @@ export async function deployContracts(hre: any) {
{ Bridge: Bridge.address },
{ TokenVault: TokenVault.address }
),
}
};

utils.saveDeployments(`${network}_L1`, deployments)
utils.saveDeployments(`${network}_L1`, deployments);

return deployments
return deployments;
}

async function deployBaseLibs(hre: any) {
const libZKP = await utils.deployContract(hre, "LibZKP")
const libZKP = await utils.deployContract(hre, "LibZKP");
const libReceiptDecoder = await utils.deployContract(
hre,
"LibReceiptDecoder"
)
const libTxDecoder = await utils.deployContract(hre, "LibTxDecoder")
);
const libTxDecoder = await utils.deployContract(hre, "LibTxDecoder");

const v1Verifying = await utils.deployContract(hre, "V1Verifying", {})
const v1Proposing = await utils.deployContract(hre, "V1Proposing", {})
const v1Verifying = await utils.deployContract(hre, "V1Verifying", {});
const v1Proposing = await utils.deployContract(hre, "V1Proposing", {});

const v1Proving = await utils.deployContract(hre, "V1Proving", {
LibZKP: libZKP.address,
LibReceiptDecoder: libReceiptDecoder.address,
LibTxDecoder: libTxDecoder.address,
})
});

return {
V1Verifying: v1Verifying.address,
V1Proposing: v1Proposing.address,
V1Proving: v1Proving.address,
}
};
}

async function deployBridge(hre: any, addressManager: string): Promise<any> {
const libTrieProof = await utils.deployContract(hre, "LibTrieProof")
const libBridgeRetry = await utils.deployContract(hre, "LibBridgeRetry")
const libTrieProof = await utils.deployContract(hre, "LibTrieProof");
const libBridgeRetry = await utils.deployContract(hre, "LibBridgeRetry");
const libBridgeProcess = await utils.deployContract(
hre,
"LibBridgeProcess",
{
LibTrieProof: libTrieProof.address,
}
)
);

const Bridge = await utils.deployContract(hre, "Bridge", {
LibTrieProof: libTrieProof.address,
LibBridgeRetry: libBridgeRetry.address,
LibBridgeProcess: libBridgeProcess.address,
})
});

await utils.waitTx(hre, await Bridge.init(addressManager))
await utils.waitTx(hre, await Bridge.init(addressManager));

return Bridge
return Bridge;
}

async function deployTokenVault(
hre: any,
addressManager: string
): Promise<any> {
const TokenVault = await utils.deployContract(hre, "TokenVault")
const TokenVault = await utils.deployContract(hre, "TokenVault");

await utils.waitTx(hre, await TokenVault.init(addressManager))
await utils.waitTx(hre, await TokenVault.init(addressManager));

return TokenVault
return TokenVault;
}
Loading