fix linters

This commit is contained in:
Drygin 2022-01-28 19:46:46 +03:00
parent 85e6a88443
commit 61cc980055
12 changed files with 138 additions and 96 deletions

27
.eslintrc Normal file
View File

@ -0,0 +1,27 @@
{
"env": {
"node": true,
"browser": true,
"es6": true,
"mocha": true
},
"extends": ["eslint:recommended", "plugin:prettier/recommended", "prettier"],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 2018
},
"rules": {
"indent": ["error", 2],
"linebreak-style": ["error", "unix"],
"quotes": ["error", "single", { "avoidEscape": true }],
"semi": ["error", "never"],
"object-curly-spacing": ["error", "always"],
"comma-dangle": ["error", "always-multiline"],
"require-await": "error",
"prettier/prettier": ["error", { "printWidth": 110 }]
}
}

8
.prettierignore Normal file
View File

@ -0,0 +1,8 @@
.vscode
.idea
artifacts
artifacts-ovm
cache
cache-ovm
contracts/Verifier*.sol
src/types

16
.prettierrc Normal file
View File

@ -0,0 +1,16 @@
{
"singleQuote": true,
"trailingComma": "all",
"bracketSpacing": true,
"semi": false,
"printWidth": 110,
"overrides": [
{
"files": "*.sol",
"options": {
"singleQuote": false,
"printWidth": 130
}
}
]
}

View File

@ -1,6 +1,9 @@
# Nova upgrade proposal # Nova upgrade proposal
There is Tornado governance proposal for upgrade nova contract on Xdai chain. There is Tornado governance proposal for upgrade nova contract on Xdai chain.
## Tests ## Tests
1. Install dependencies: 1. Install dependencies:
``` ```
@ -20,7 +23,9 @@ There is Tornado governance proposal for upgrade nova contract on Xdai chain.
``` ```
yarn lint yarn lint
``` ```
## Deploy ## Deploy
1. Check `config.json` for actual values. 1. Check `config.json` for actual values.
2. Run deploy: 2. Run deploy:

View File

@ -6,42 +6,41 @@ pragma experimental ABIEncoderV2;
import { ImmutableGovernanceInformation } from "tornado-governance/contracts/v2-vault-and-gas/ImmutableGovernanceInformation.sol"; import { ImmutableGovernanceInformation } from "tornado-governance/contracts/v2-vault-and-gas/ImmutableGovernanceInformation.sol";
interface IUpgradeableProxy { interface IUpgradeableProxy {
function upgradeTo(address newImplementation) external; function upgradeTo(address newImplementation) external;
} }
interface IAMB { interface IAMB {
function requireToPassMessage(address _contract, bytes calldata _data, uint256 _gas) external returns (bytes32); function requireToPassMessage(
address _contract,
bytes calldata _data,
uint256 _gas
) external returns (bytes32);
} }
contract NovaUpgradeProposal is ImmutableGovernanceInformation { contract NovaUpgradeProposal is ImmutableGovernanceInformation {
event MessagePassed(bytes32 msgId);
event MessagePassed(bytes32 msgId); address public immutable novaProxy;
address public immutable newNovaImpl;
IAMB public immutable bridge;
uint256 public immutable gasLimit;
address public immutable novaProxy; constructor(
address public immutable newNovaImpl; address _novaProxy,
IAMB public immutable bridge; address _newNovaImpl,
uint256 public immutable gasLimit; address _bridge,
uint256 _gasLimit
) public {
novaProxy = _novaProxy;
newNovaImpl = _newNovaImpl;
bridge = IAMB(_bridge);
gasLimit = _gasLimit;
}
constructor( function executeProposal() external {
address _novaProxy, bytes4 methodSelector = IUpgradeableProxy(address(0)).upgradeTo.selector;
address _newNovaImpl, bytes memory data = abi.encodeWithSelector(methodSelector, newNovaImpl);
address _bridge, bytes32 msgId = bridge.requireToPassMessage(novaProxy, data, gasLimit);
uint256 _gasLimit emit MessagePassed(msgId);
) public { }
novaProxy = _novaProxy;
newNovaImpl = _newNovaImpl;
bridge = IAMB(_bridge);
gasLimit = _gasLimit;
}
function executeProposal() external {
bytes4 methodSelector = IUpgradeableProxy(address(0)).upgradeTo.selector;
bytes memory data = abi.encodeWithSelector(methodSelector, newNovaImpl);
bytes32 msgId = bridge.requireToPassMessage(
novaProxy,
data,
gasLimit
);
emit MessagePassed(msgId);
}
} }

View File

@ -4,36 +4,36 @@ pragma abicoder v2;
import { IAMB } from "omnibridge/contracts/interfaces/IAMB.sol"; import { IAMB } from "omnibridge/contracts/interfaces/IAMB.sol";
abstract contract MockAMB is IAMB { abstract contract MockAMB is IAMB {
address public xDomainMessageSender; address public xDomainMessageSender;
bytes32 public xDomainMessageChainId; bytes32 public xDomainMessageChainId;
struct Call { struct Call {
address who; address who;
bytes callData; bytes callData;
} }
constructor(address _xDomainMessageSender, uint256 _xDomainMessageChainId) { constructor(address _xDomainMessageSender, uint256 _xDomainMessageChainId) {
xDomainMessageSender = _xDomainMessageSender; xDomainMessageSender = _xDomainMessageSender;
xDomainMessageChainId = bytes32(uint256(_xDomainMessageChainId)); xDomainMessageChainId = bytes32(uint256(_xDomainMessageChainId));
} }
function setMessageSender(address _sender) external { function setMessageSender(address _sender) external {
xDomainMessageSender = _sender; xDomainMessageSender = _sender;
} }
function messageSender() external view override returns (address) { function messageSender() external view override returns (address) {
return xDomainMessageSender; return xDomainMessageSender;
} }
function messageSourceChainId() external view override returns (bytes32) { function messageSourceChainId() external view override returns (bytes32) {
return xDomainMessageChainId; return xDomainMessageChainId;
} }
function execute(Call[] calldata _calls) external returns (bool success, bytes memory result) { function execute(Call[] calldata _calls) external returns (bool success, bytes memory result) {
for (uint256 i = 0; i < _calls.length; i++) { for (uint256 i = 0; i < _calls.length; i++) {
(success, result) = _calls[i].who.call(_calls[i].callData); (success, result) = _calls[i].who.call(_calls[i].callData);
require(success, string(result)); require(success, string(result));
}
} }
}
} }

View File

@ -12,17 +12,17 @@ pragma solidity ^0.6.2;
* @author Ricardo Guilherme Schmidt (Status Research & Development GmbH) * @author Ricardo Guilherme Schmidt (Status Research & Development GmbH)
*/ */
contract SingletonFactory { contract SingletonFactory {
/** /**
* @notice Deploys `_initCode` using `_salt` for defining the deterministic address. * @notice Deploys `_initCode` using `_salt` for defining the deterministic address.
* @param _initCode Initialization code. * @param _initCode Initialization code.
* @param _salt Arbitrary value to modify resulting address. * @param _salt Arbitrary value to modify resulting address.
* @return createdContract Created contract address. * @return createdContract Created contract address.
*/ */
function deploy(bytes memory _initCode, bytes32 _salt) public returns (address payable createdContract) { function deploy(bytes memory _initCode, bytes32 _salt) public returns (address payable createdContract) {
assembly { assembly {
createdContract := create2(0, add(_initCode, 0x20), mload(_initCode), _salt) createdContract := create2(0, add(_initCode, 0x20), mload(_initCode), _salt)
}
} }
}
} }
// IV is a value changed to generate the vanity address. // IV is a value changed to generate the vanity address.
// IV: 6583047 // IV: 6583047

View File

@ -6,12 +6,9 @@ pragma experimental ABIEncoderV2;
import { GovernanceGasUpgrade } from "tornado-governance/contracts/v2-vault-and-gas/gas/GovernanceGasUpgrade.sol"; import { GovernanceGasUpgrade } from "tornado-governance/contracts/v2-vault-and-gas/gas/GovernanceGasUpgrade.sol";
contract TestGovernanceUpgrade is GovernanceGasUpgrade { contract TestGovernanceUpgrade is GovernanceGasUpgrade {
constructor( constructor(address gasCompLogic, address userVaultAddress) public GovernanceGasUpgrade(gasCompLogic, userVaultAddress) {}
address gasCompLogic,
address userVaultAddress
) public GovernanceGasUpgrade(gasCompLogic, userVaultAddress) {}
function test() public pure returns (int256) { function test() public pure returns (int256) {
return 231; return 231;
} }
} }

View File

@ -57,18 +57,14 @@ module.exports = {
}, },
accounts: process.env.PRIVATE_KEY accounts: process.env.PRIVATE_KEY
? [process.env.PRIVATE_KEY] ? [process.env.PRIVATE_KEY]
: { : { mnemonic: 'test test test test test junk' },
mnemonic: 'test test test test test test test test test test test junk',
},
}, },
mainnet: { mainnet: {
url: `https://eth-mainnet.alchemyapi.io/v2/${process.env.ALCHEMY_KEY}`, url: `https://eth-mainnet.alchemyapi.io/v2/${process.env.ALCHEMY_KEY}`,
accounts: process.env.PRIVATE_KEY accounts: process.env.PRIVATE_KEY
? [process.env.PRIVATE_KEY] ? [process.env.PRIVATE_KEY]
: { : { mnemonic: 'test test test test test junk' },
mnemonic: 'test test test test test test test test test test test junk',
},
timeout: 2147483647, timeout: 2147483647,
}, },
} },
} }

View File

@ -7,12 +7,7 @@ async function generate(config) {
const deploymentBytecodeProposal = const deploymentBytecodeProposal =
ProposalFactory.bytecode + ProposalFactory.bytecode +
ProposalFactory.interface ProposalFactory.interface
.encodeDeploy([ .encodeDeploy([config.novaProxy, config.newNovaImpl, config.ethAmbBridge, config.gasLimit])
config.novaProxy,
config.newNovaImpl,
config.ethAmbBridge,
config.gasLimit,
])
.slice(2) .slice(2)
const proposalAddress = ethers.utils.getCreate2Address( const proposalAddress = ethers.utils.getCreate2Address(

View File

@ -1,6 +1,5 @@
const { ethers } = require('hardhat') const { ethers } = require('hardhat')
const { expect } = require('chai') const { expect } = require('chai')
const fs = require('fs')
const config = require('./test.config.json') const config = require('./test.config.json')
const { getSignerFromAddress, takeSnapshot, revertSnapshot } = require('./utils') const { getSignerFromAddress, takeSnapshot, revertSnapshot } = require('./utils')
@ -102,8 +101,8 @@ describe('General functionality tests', () => {
const filter = amb.filters.UserRequestForAffirmation() const filter = amb.filters.UserRequestForAffirmation()
const fromBlock = await ethers.provider.getBlock() const fromBlock = await ethers.provider.getBlock()
events = await amb.queryFilter(filter, fromBlock.number) events = await amb.queryFilter(filter, fromBlock.number)
bridgedData = events[0].args.encodedData.toString() const bridgedData = events[0].args.encodedData.toString()
expect(bridgedData.slice(106,146)).to.be.equal(config.novaProxy.slice(2)) expect(bridgedData.slice(106, 146)).to.be.equal(config.novaProxy.slice(2))
expect(bridgedData.slice(196)).to.be.equal(config.newNovaImpl.slice(2)) expect(bridgedData.slice(196)).to.be.equal(config.newNovaImpl.slice(2))
state = await gov.state(id) state = await gov.state(id)