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

chore: update token-distribution to use our linting packages #954

Merged
merged 17 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions packages/eslint-graph-config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export default [
ignoreCase: true,
allowSeparatedGroups: true,
}],
'@stylistic/brace-style': ['error', '1tbs'],
},
},
]
5 changes: 0 additions & 5 deletions packages/token-distribution/.eslintignore

This file was deleted.

15 changes: 0 additions & 15 deletions packages/token-distribution/.eslintrc

This file was deleted.

Empty file.
35 changes: 0 additions & 35 deletions packages/token-distribution/.prettierrc.json

This file was deleted.

14 changes: 0 additions & 14 deletions packages/token-distribution/.solhint.json

This file was deleted.

1 change: 0 additions & 1 deletion packages/token-distribution/.solhintignore

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,10 @@ contract L2GraphTokenLockManager is GraphTokenLockManager, ICallhookReceiver {
* @return Hash of the initialization calldata
* @return Address of the created contract
*/
function _deployFromL1(bytes32 _salt, TransferredWalletData memory _walletData) internal returns (bytes32, address) {
function _deployFromL1(
bytes32 _salt,
TransferredWalletData memory _walletData
) internal returns (bytes32, address) {
bytes memory initializer = _encodeInitializer(_walletData);
address contractAddress = _deployProxy2(_salt, masterCopy, initializer);
return (keccak256(initializer), contractAddress);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,14 @@ contract MinimalProxyFactory {
/// @dev Emitted when a new proxy is created
event ProxyCreated(address indexed proxy);


/**
* @notice Gets the deterministic CREATE2 address for MinimalProxy with a particular implementation
* @dev Uses address(this) as deployer to compute the address. Only for backwards compatibility.
* @param _salt Bytes32 salt to use for CREATE2
* @param _implementation Address of the proxy target implementation
* @return Address of the counterfactual MinimalProxy
*/
function getDeploymentAddress(
bytes32 _salt,
address _implementation
) public view returns (address) {
function getDeploymentAddress(bytes32 _salt, address _implementation) public view returns (address) {
return getDeploymentAddress(_salt, _implementation, address(this));
}

Expand Down
14 changes: 14 additions & 0 deletions packages/token-distribution/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const config = require('eslint-graph-config')

module.exports = [
...config.default,
{
rules: {
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
},
},
]
32 changes: 9 additions & 23 deletions packages/token-distribution/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,8 @@
"test:gas": "RUN_EVM=true REPORT_GAS=true scripts/test",
"test:coverage": "scripts/coverage",
"lint": "yarn run lint:ts && yarn run lint:sol",
"lint:fix": "yarn run lint:ts:fix && yarn run lint:sol:fix",
"lint:ts": "eslint '*/**/*.{js,ts}'",
"lint:ts:fix": "eslint '*/**/*.{js,ts}' --fix",
"lint:sol": "solhint './contracts/**/*.sol'",
"lint:sol:fix": "yarn prettier:sol && solhint --fix './contracts/**/*.sol'",
"prettier": "yarn run prettier:ts && yarn run prettier:sol",
"prettier:ts": "prettier --write 'test/**/*.ts'",
"prettier:sol": "prettier --write 'contracts/**/*.sol'",
"lint:ts": "eslint 'test/**/*.{js,ts}' --fix",
"lint:sol": "prettier --write contracts/**/*.sol && solhint --fix contracts/**/*.sol --config node_modules/solhint-graph-config/index.js",
"security": "scripts/security",
"flatten": "scripts/flatten",
"typechain": "hardhat typechain",
Expand Down Expand Up @@ -48,21 +42,12 @@
"@typechain/hardhat": "^2.0.0",
"@types/mocha": "^9.1.0",
"@types/node": "^20.4.2",
"@typescript-eslint/eslint-plugin": "^5.20.0",
"@typescript-eslint/parser": "^5.20.0",
"chai": "^4.2.0",
"coingecko-api": "^1.0.10",
"consola": "^2.15.0",
"dotenv": "^16.0.0",
"eslint": "^8.13.0",
"eslint-config-prettier": "^8.5.0",
"eslint-config-standard": "^16.0.3",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-mocha-no-only": "^1.1.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-promise": "^6.0.0",
"eslint-plugin-standard": "5.0.0",
"eslint": "^8.56.0",
"eslint-graph-config": "workspace:^",
"ethereum-waffle": "^3.1.1",
"ethers": "^5.0.18",
"graphql": "^16.5.0",
Expand All @@ -73,10 +58,11 @@
"hardhat-gas-reporter": "^1.0.1",
"inquirer": "8.0.0",
"p-queue": "^6.6.2",
"prettier": "^2.1.1",
"prettier-plugin-solidity": "^1.0.0-alpha.56",
"solhint": "^3.3.7",
"solhint-plugin-prettier": "^0.0.5",
"prettier": "^3.2.5",
"prettier-plugin-solidity": "^1.3.1",
"solhint-community": "^3.7.0",
"solhint-graph-config": "workspace:^0.0.1",
"solhint-plugin-prettier": "^0.1.0",
"ts-node": "^10.9.1",
"typechain": "^5.0.0",
"typescript": "^4.0.2"
Expand Down
2 changes: 2 additions & 0 deletions packages/token-distribution/prettier.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const prettierGraphConfig = require('solhint-graph-config/prettier')
module.exports = prettierGraphConfig
16 changes: 8 additions & 8 deletions packages/token-distribution/test/distributor.test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { expect } from 'chai'
import { deployments } from 'hardhat'
import 'hardhat-deploy'

import { GraphTokenMock } from '../build/typechain/contracts/GraphTokenMock'
import { deployments } from 'hardhat'
import { expect } from 'chai'
import { GraphTokenDistributor } from '../build/typechain/contracts/GraphTokenDistributor'
import { GraphTokenMock } from '../build/typechain/contracts/GraphTokenMock'

import { getContract, getAccounts, toGRT, Account } from './network'
import { Account, getAccounts, getContract, toGRT } from './network'
import { DeployOptions } from 'hardhat-deploy/types'

// Fixture
const setupTest = deployments.createFixture(async ({ deployments }) => {
const { deploy } = deployments
const deploy = (name: string, options: DeployOptions) => deployments.deploy(name, options)
const [deployer] = await getAccounts()

// Start from a fresh snapshot
Expand Down Expand Up @@ -44,11 +44,11 @@ describe('GraphTokenDistributor', () => {
let distributor: GraphTokenDistributor

before(async function () {
;[deployer, beneficiary1, beneficiary2] = await getAccounts()
[deployer, beneficiary1, beneficiary2] = await getAccounts()
})

beforeEach(async () => {
;({ grt, distributor } = await setupTest())
({ grt, distributor } = await setupTest())
})

describe('init', function () {
Expand Down
25 changes: 13 additions & 12 deletions packages/token-distribution/test/l1TokenLockTransferTool.test.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
import { BigNumber, constants, Signer } from 'ethers'
import { expect } from 'chai'
import { deployments, ethers, upgrades } from 'hardhat'
import { expect } from 'chai'

import '@nomiclabs/hardhat-ethers'
import 'hardhat-deploy'

import { GraphTokenMock } from '../build/typechain/contracts/GraphTokenMock'
import { GraphTokenLockWallet } from '../build/typechain/contracts/GraphTokenLockWallet'
import { GraphTokenLockManager } from '../build/typechain/contracts/GraphTokenLockManager'
import { StakingMock } from '../build/typechain/contracts/StakingMock'
import { L1TokenGatewayMock } from '../build/typechain/contracts/L1TokenGatewayMock'
import { GraphTokenLockWallet } from '../build/typechain/contracts/GraphTokenLockWallet'
import { GraphTokenMock } from '../build/typechain/contracts/GraphTokenMock'
import { L1GraphTokenLockTransferTool } from '../build/typechain/contracts/L1GraphTokenLockTransferTool'
import { L1TokenGatewayMock } from '../build/typechain/contracts/L1TokenGatewayMock'
import { StakingMock } from '../build/typechain/contracts/StakingMock'

import { L1GraphTokenLockTransferTool__factory } from '../build/typechain/contracts/factories/L1GraphTokenLockTransferTool__factory'
import { Staking__factory } from '@graphprotocol/contracts/dist/types/factories/Staking__factory'

import { defaultInitArgs, Revocability, TokenLockParameters } from './config'
import { getAccounts, getContract, toGRT, Account, toBN } from './network'
import { Account, getAccounts, getContract, toBN, toGRT } from './network'
import { defaultAbiCoder, hexValue, keccak256, parseEther } from 'ethers/lib/utils'
import { defaultInitArgs, Revocability, TokenLockParameters } from './config'
import { advanceTimeAndBlock } from './network'
import { DeployOptions } from 'hardhat-deploy/types'

const { AddressZero } = constants

Expand All @@ -29,7 +30,7 @@ async function impersonateAccount(address: string): Promise<Signer> {

// Fixture
const setupTest = deployments.createFixture(async ({ deployments }) => {
const { deploy } = deployments
const deploy = (name: string, options: DeployOptions) => deployments.deploy(name, options)
const [deployer, , , , l2LockImplementationMock] = await getAccounts()

// Start from a fresh snapshot
Expand Down Expand Up @@ -79,7 +80,7 @@ const setupTest = deployments.createFixture(async ({ deployments }) => {
// tokenLock: tokenLockWallet as GraphTokenLockWallet,
tokenLockManager: tokenLockManager as GraphTokenLockManager,
gateway: gateway as L1TokenGatewayMock,
transferTool: transferTool as L1GraphTokenLockTransferTool,
transferTool: transferTool,
}
})

Expand Down Expand Up @@ -143,12 +144,12 @@ describe('L1GraphTokenLockTransferTool', () => {
}

before(async function () {
;[deployer, beneficiary, hacker, l2ManagerMock, l2LockImplementationMock, l2Owner, l2Beneficiary] =
await getAccounts()
[deployer, beneficiary, hacker, l2ManagerMock, l2LockImplementationMock, l2Owner, l2Beneficiary]
= await getAccounts()
})

beforeEach(async () => {
;({ grt, tokenLockManager, staking, gateway, transferTool } = await setupTest())
({ grt, tokenLockManager, staking, gateway, transferTool } = await setupTest())

// Setup authorized functions in Manager
await authProtocolFunctions(tokenLockManager, staking.address, transferTool.address)
Expand Down
19 changes: 10 additions & 9 deletions packages/token-distribution/test/l2TokenLockManager.test.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
import { constants, Wallet } from 'ethers'
import { expect } from 'chai'
import { deployments, ethers } from 'hardhat'
import { expect } from 'chai'

import '@nomiclabs/hardhat-ethers'
import 'hardhat-deploy'

import { GraphTokenMock } from '../build/typechain/contracts/GraphTokenMock'
import { L2GraphTokenLockWallet } from '../build/typechain/contracts/L2GraphTokenLockWallet'
import { L2GraphTokenLockManager } from '../build/typechain/contracts/L2GraphTokenLockManager'
import { StakingMock } from '../build/typechain/contracts/StakingMock'
import { L2GraphTokenLockWallet } from '../build/typechain/contracts/L2GraphTokenLockWallet'
import { Staking__factory } from '@graphprotocol/contracts/dist/types/factories/Staking__factory'
import { StakingMock } from '../build/typechain/contracts/StakingMock'

import { defaultInitArgs, Revocability, TokenLockParameters } from './config'
import { advanceTimeAndBlock, getAccounts, getContract, toGRT, Account } from './network'
import { Account, advanceTimeAndBlock, getAccounts, getContract, toGRT } from './network'
import { defaultAbiCoder, keccak256 } from 'ethers/lib/utils'
import { defaultInitArgs, Revocability, TokenLockParameters } from './config'
import { DeployOptions } from 'hardhat-deploy/types'
import { Staking } from '@graphprotocol/contracts'

const { AddressZero } = constants

// Fixture
const setupTest = deployments.createFixture(async ({ deployments }) => {
const { deploy } = deployments
const deploy = (name: string, options: DeployOptions) => deployments.deploy(name, options)
const [deployer, , l1TransferToolMock, gateway] = await getAccounts()

// Start from a fresh snapshot
Expand Down Expand Up @@ -101,11 +102,11 @@ describe('L2GraphTokenLockManager', () => {
}

before(async function () {
;[deployer, beneficiary, l1TransferToolMock, gateway, l1TokenLock] = await getAccounts()
[deployer, beneficiary, l1TransferToolMock, gateway, l1TokenLock] = await getAccounts()
})

beforeEach(async () => {
;({ grt, tokenLockManager, staking, tokenLockImplementation } = await setupTest())
({ grt, tokenLockManager, staking, tokenLockImplementation } = await setupTest())

// Setup authorized functions in Manager
await authProtocolFunctions(tokenLockManager, staking.address)
Expand All @@ -116,7 +117,7 @@ describe('L2GraphTokenLockManager', () => {

describe('TokenLockManager standard behavior', function () {
it('reverts if initialized with empty token', async function () {
const { deploy } = deployments
const deploy = (name: string, options: DeployOptions) => deployments.deploy(name, options)

const d = deploy('L2GraphTokenLockManager', {
from: deployer.address,
Expand Down
Loading