From 16b45e30d4154bb8824014595b53bf1271a3dfa4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Thu, 7 Mar 2024 16:24:00 -0300 Subject: [PATCH 1/9] feat(eslint): properly ignore paths MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- packages/eslint-graph-config/README.md | 6 ++++++ packages/eslint-graph-config/index.ts | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/eslint-graph-config/README.md b/packages/eslint-graph-config/README.md index 8dca2ba6e..3e0a41cff 100644 --- a/packages/eslint-graph-config/README.md +++ b/packages/eslint-graph-config/README.md @@ -40,6 +40,12 @@ module.exports = [ '@typescript-eslint/no-unsafe-argument': 'off', }, }, + { + ignores: [ + 'library/*', // ignore its contents + '!node_modules/mylibrary/' // unignore `node_modules/mylibrary` directory + ] + } ] ``` diff --git a/packages/eslint-graph-config/index.ts b/packages/eslint-graph-config/index.ts index ccffd6b14..2ab60d95b 100644 --- a/packages/eslint-graph-config/index.ts +++ b/packages/eslint-graph-config/index.ts @@ -31,7 +31,6 @@ export default [ 'no-only-tests': noOnlyTests, 'no-secrets': noSecrets, }, - ignores: ['dist/*', 'node_modules/*', 'build/*'], rules: { 'prefer-const': 'warn', '@typescript-eslint/no-inferrable-types': 'warn', @@ -47,4 +46,7 @@ export default [ '@stylistic/brace-style': ['error', '1tbs'], }, }, + { + ignores: ['**/dist/*', '**/node_modules/*', '**/build/*', '**/cache/*', '**/.graphclient/*'], + }, ] From 17bcac762347ae9716cce4a1740d5763b1acffec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Thu, 7 Mar 2024 16:24:26 -0300 Subject: [PATCH 2/9] chore(token-distribution): apply latest linting rules MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- packages/token-distribution/deploy/1_test.ts | 4 +- .../deploy/2_l1_manager_wallet.ts | 4 +- .../token-distribution/deploy/3_l2_wallet.ts | 5 +-- .../deploy/4_l1_transfer_tool.ts | 5 +-- .../token-distribution/deploy/5_l2_manager.ts | 4 +- .../deploy/6_l2_transfer_tool.ts | 7 +--- .../token-distribution/deploy/lib/utils.ts | 6 +-- packages/token-distribution/hardhat.config.ts | 4 +- packages/token-distribution/ops/create.ts | 18 ++++---- packages/token-distribution/ops/delete.ts | 2 +- packages/token-distribution/ops/info.ts | 42 +++++++++---------- packages/token-distribution/ops/tx-builder.ts | 18 +++++++- packages/token-distribution/package.json | 2 +- packages/token-distribution/tsconfig.json | 1 + 14 files changed, 66 insertions(+), 56 deletions(-) diff --git a/packages/token-distribution/deploy/1_test.ts b/packages/token-distribution/deploy/1_test.ts index 779cf5b36..92b626012 100644 --- a/packages/token-distribution/deploy/1_test.ts +++ b/packages/token-distribution/deploy/1_test.ts @@ -2,14 +2,14 @@ import { utils } from 'ethers' import consola from 'consola' import { HardhatRuntimeEnvironment } from 'hardhat/types' -import { DeployFunction } from 'hardhat-deploy/types' +import { DeployFunction, DeployOptions } from 'hardhat-deploy/types' const { parseEther } = utils const logger = consola.create({}) const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { - const { deploy } = hre.deployments + const deploy = (name: string, options: DeployOptions) => hre.deployments.deploy(name, options) const { deployer } = await hre.getNamedAccounts() // -- Fake Graph Token -- diff --git a/packages/token-distribution/deploy/2_l1_manager_wallet.ts b/packages/token-distribution/deploy/2_l1_manager_wallet.ts index 66cbc3af9..a2bd7ecac 100644 --- a/packages/token-distribution/deploy/2_l1_manager_wallet.ts +++ b/packages/token-distribution/deploy/2_l1_manager_wallet.ts @@ -3,7 +3,7 @@ import { utils } from 'ethers' import '@nomiclabs/hardhat-ethers' import { HardhatRuntimeEnvironment } from 'hardhat/types' -import { DeployFunction } from 'hardhat-deploy/types' +import { DeployFunction, DeployOptions } from 'hardhat-deploy/types' import { GraphTokenMock } from '../build/typechain/contracts/GraphTokenMock' import { GraphTokenLockManager } from '../build/typechain/contracts/GraphTokenLockManager' @@ -14,7 +14,7 @@ const { parseEther, formatEther } = utils const logger = consola.create({}) const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { - const { deploy } = hre.deployments + const deploy = (name: string, options: DeployOptions) => hre.deployments.deploy(name, options) const { deployer } = await hre.getNamedAccounts() // -- Graph Token -- diff --git a/packages/token-distribution/deploy/3_l2_wallet.ts b/packages/token-distribution/deploy/3_l2_wallet.ts index 53a9f7f5c..36679613c 100644 --- a/packages/token-distribution/deploy/3_l2_wallet.ts +++ b/packages/token-distribution/deploy/3_l2_wallet.ts @@ -1,15 +1,14 @@ import consola from 'consola' import '@nomiclabs/hardhat-ethers' import { HardhatRuntimeEnvironment } from 'hardhat/types' -import { DeployFunction } from 'hardhat-deploy/types' +import { DeployFunction, DeployOptions } from 'hardhat-deploy/types' import { getDeploymentName } from './lib/utils' - const logger = consola.create({}) const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { - const { deploy } = hre.deployments + const deploy = (name: string, options: DeployOptions) => hre.deployments.deploy(name, options) const { deployer } = await hre.getNamedAccounts() // Deploy the master copy of GraphTokenLockWallet diff --git a/packages/token-distribution/deploy/4_l1_transfer_tool.ts b/packages/token-distribution/deploy/4_l1_transfer_tool.ts index b8fb04473..125483f56 100644 --- a/packages/token-distribution/deploy/4_l1_transfer_tool.ts +++ b/packages/token-distribution/deploy/4_l1_transfer_tool.ts @@ -1,5 +1,4 @@ import consola from 'consola' -import { utils } from 'ethers' import '@nomiclabs/hardhat-ethers' import { HardhatRuntimeEnvironment } from 'hardhat/types' @@ -50,12 +49,12 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { owner = deployer logger.warn(`No owner address provided, will use the deployer address as owner: ${owner}`) } - + // Deploy the L1GraphTokenLockTransferTool with a proxy. // hardhat-deploy doesn't get along with constructor arguments in the implementation // combined with an OpenZeppelin transparent proxy, so we need to do this using // the OpenZeppelin hardhat-upgrades tooling, and save the deployment manually. - + // TODO modify this to use upgradeProxy if a deployment already exists? logger.info('Deploying L1GraphTokenLockTransferTool proxy...') const transferToolFactory = await ethers.getContractFactory('L1GraphTokenLockTransferTool') diff --git a/packages/token-distribution/deploy/5_l2_manager.ts b/packages/token-distribution/deploy/5_l2_manager.ts index 5572345da..93016663f 100644 --- a/packages/token-distribution/deploy/5_l2_manager.ts +++ b/packages/token-distribution/deploy/5_l2_manager.ts @@ -3,7 +3,7 @@ import { utils } from 'ethers' import '@nomiclabs/hardhat-ethers' import { HardhatRuntimeEnvironment } from 'hardhat/types' -import { DeployFunction } from 'hardhat-deploy/types' +import { DeployFunction, DeployOptions } from 'hardhat-deploy/types' import { GraphTokenMock } from '../build/typechain/contracts/GraphTokenMock' import { askConfirm, getDeploymentName, promptContractAddress } from './lib/utils' @@ -14,7 +14,7 @@ const { parseEther, formatEther } = utils const logger = consola.create({}) const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { - const { deploy } = hre.deployments + const deploy = (name: string, options: DeployOptions) => hre.deployments.deploy(name, options) const { deployer } = await hre.getNamedAccounts() // -- Graph Token -- diff --git a/packages/token-distribution/deploy/6_l2_transfer_tool.ts b/packages/token-distribution/deploy/6_l2_transfer_tool.ts index 659a104a4..f449ebe84 100644 --- a/packages/token-distribution/deploy/6_l2_transfer_tool.ts +++ b/packages/token-distribution/deploy/6_l2_transfer_tool.ts @@ -1,5 +1,4 @@ import consola from 'consola' -import { utils } from 'ethers' import '@nomiclabs/hardhat-ethers' import { HardhatRuntimeEnvironment } from 'hardhat/types' @@ -18,8 +17,6 @@ const artifacts = new Artifacts(ARTIFACTS_PATH) const l2TransferToolAbi = artifacts.readArtifactSync('L2GraphTokenLockTransferTool').abi const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { - const { deployer } = await hre.getNamedAccounts() - // -- Graph Token -- // Get the addresses we will use @@ -40,12 +37,12 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { logger.warn('No L1 GRT address provided') process.exit(1) } - + // Deploy the L2GraphTokenLockTransferTool with a proxy. // hardhat-deploy doesn't get along with constructor arguments in the implementation // combined with an OpenZeppelin transparent proxy, so we need to do this using // the OpenZeppelin hardhat-upgrades tooling, and save the deployment manually. - + // TODO modify this to use upgradeProxy if a deployment already exists? logger.info('Deploying L2GraphTokenLockTransferTool proxy...') const transferToolFactory = await ethers.getContractFactory('L2GraphTokenLockTransferTool') diff --git a/packages/token-distribution/deploy/lib/utils.ts b/packages/token-distribution/deploy/lib/utils.ts index 7330f4e55..afc38555b 100644 --- a/packages/token-distribution/deploy/lib/utils.ts +++ b/packages/token-distribution/deploy/lib/utils.ts @@ -12,10 +12,10 @@ export const askConfirm = async (message: string) => { type: 'confirm', message, }) - return res.confirm + return res.confirm ? res.confirm as boolean : false } -export const promptContractAddress = async (name: string, logger: Consola): Promise => { +export const promptContractAddress = async (name: string, logger: Consola): Promise => { const res1 = await inquirer.prompt({ name: 'contract', type: 'input', @@ -37,5 +37,5 @@ export const getDeploymentName = async (defaultName: string): Promise => default: defaultName, message: 'Save deployment as?', }) - return res['deployment-name'] + return res['deployment-name'] as string } diff --git a/packages/token-distribution/hardhat.config.ts b/packages/token-distribution/hardhat.config.ts index 4fa7a9cb8..eaa994346 100644 --- a/packages/token-distribution/hardhat.config.ts +++ b/packages/token-distribution/hardhat.config.ts @@ -80,6 +80,7 @@ function setupNetworkConfig(config) { // Env +// eslint-disable-next-line @typescript-eslint/no-misused-promises extendEnvironment(async (hre) => { const accounts = await hre.ethers.getSigners() try { @@ -152,7 +153,6 @@ const config = { }, }, etherscan: { - //url: process.env.ETHERSCAN_API_URL, apiKey: process.env.ETHERSCAN_API_KEY, customChains: [ { @@ -163,7 +163,7 @@ const config = { browserURL: 'https://sepolia.arbiscan.io', }, }, - ] + ], }, typechain: { outDir: 'build/typechain/contracts', diff --git a/packages/token-distribution/ops/create.ts b/packages/token-distribution/ops/create.ts index 778865ec0..0dce2d253 100644 --- a/packages/token-distribution/ops/create.ts +++ b/packages/token-distribution/ops/create.ts @@ -2,7 +2,7 @@ import PQueue from 'p-queue' import fs from 'fs' import consola from 'consola' import inquirer from 'inquirer' -import { utils, BigNumber, Event, ContractTransaction, ContractReceipt, Contract, ContractFactory } from 'ethers' +import { BigNumber, Contract, ContractFactory, ContractReceipt, ContractTransaction, Event, utils } from 'ethers' import { NonceManager } from '@ethersproject/experimental' import { task } from 'hardhat/config' @@ -47,7 +47,7 @@ export const askConfirm = async () => { type: 'confirm', message: `Are you sure you want to proceed?`, }) - return res.confirm + return res.confirm ? res.confirm as boolean : false } const isValidAddress = (address: string) => { @@ -68,10 +68,10 @@ export const isValidAddressOrFail = (address: string) => { const loadDeployData = (filepath: string): TokenLockConfigEntry[] => { const data = fs.readFileSync(filepath, 'utf8') - const entries = data.split('\n').map((e) => e.trim()) + const entries = data.split('\n').map(e => e.trim()) entries.shift() // remove the title from the csv return entries - .filter((entryData) => !!entryData) + .filter(entryData => !!entryData) .map((entryData) => { const entry = entryData.split(',') return { @@ -89,9 +89,9 @@ const loadDeployData = (filepath: string): TokenLockConfigEntry[] => { const loadResultData = (filepath: string): TokenLockConfigEntry[] => { const data = fs.readFileSync(filepath, 'utf8') - const entries = data.split('\n').map((e) => e.trim()) + const entries = data.split('\n').map(e => e.trim()) return entries - .filter((entryData) => !!entryData) + .filter(entryData => !!entryData) .map((entryData) => { const entry = entryData.split(',') return { @@ -246,7 +246,7 @@ const populateEntries = async ( tokenAddress: string, ownerAddress: string, ) => { - const results = [] + const results: TokenLockConfigEntry[] = [] for (const entry of entries) { entry.owner = ownerAddress entry.salt = await calculateSalt(hre, entry, managerAddress, tokenAddress) @@ -323,7 +323,7 @@ task('create-token-locks', 'Create token lock contracts from file') entries = await populateEntries(hre, entries, manager.address, tokenAddress, taskArgs.ownerAddress) // Filter out already deployed ones - entries = entries.filter((entry) => !deployedEntries.find((deployedEntry) => deployedEntry.salt === entry.salt)) + entries = entries.filter(entry => !deployedEntries.find(deployedEntry => deployedEntry.salt === entry.salt)) logger.success(`Total of ${entries.length} entries after removing already deployed. All good!`) if (entries.length === 0) { logger.warn('Nothing new to deploy') @@ -378,7 +378,7 @@ task('create-token-locks', 'Create token lock contracts from file') const queue = new PQueue({ concurrency: 6 }) for (const entry of entries) { - queue.add(async () => { + await queue.add(async () => { logger.log('') logger.info(`Creating contract...`) logger.log(prettyConfigEntry(entry)) diff --git a/packages/token-distribution/ops/delete.ts b/packages/token-distribution/ops/delete.ts index d4ca09b25..1cb84c755 100644 --- a/packages/token-distribution/ops/delete.ts +++ b/packages/token-distribution/ops/delete.ts @@ -1,6 +1,6 @@ import { task } from 'hardhat/config' import { HardhatRuntimeEnvironment } from 'hardhat/types' -import { prettyEnv, askConfirm, waitTransaction } from './create' +import { askConfirm, prettyEnv, waitTransaction } from './create' import consola from 'consola' import { TxBuilder } from './tx-builder' diff --git a/packages/token-distribution/ops/info.ts b/packages/token-distribution/ops/info.ts index a0a024a37..4906293df 100644 --- a/packages/token-distribution/ops/info.ts +++ b/packages/token-distribution/ops/info.ts @@ -1,21 +1,21 @@ import PQueue from 'p-queue' import { task } from 'hardhat/config' import '@nomiclabs/hardhat-ethers' -import { BigNumber, Contract, utils, providers } from 'ethers' +import { BigNumber, Contract, utils } from 'ethers' import { HardhatRuntimeEnvironment } from 'hardhat/types' import CoinGecko from 'coingecko-api' import { Block } from '@ethersproject/abstract-provider' import * as GraphClient from '../.graphclient' import { + CuratorWalletsDocument, + CuratorWalletsQuery, execute, + GraphAccountDocument, + GraphAccountQuery, GraphNetworkDocument, GraphNetworkQuery, TokenLockWalletsDocument, TokenLockWalletsQuery, - CuratorWalletsDocument, - CuratorWalletsQuery, - GraphAccountQuery, - GraphAccountDocument, } from '../.graphclient' import { ExecutionResult } from 'graphql' @@ -58,7 +58,7 @@ type GraphAccount = Pick & { // Helpers -const toInt = (s) => parseInt(s) / 1e18 +const toInt = s => parseInt(s) / 1e18 const toBN = (s: string): BigNumber => BigNumber.from(s) const formatGRT = (n: BigNumber): string => utils.formatEther(n) const formatRoundGRT = (n: BigNumber): string => formatGRT(n).split('.')[0] @@ -251,8 +251,8 @@ async function getExtendedWalletInfo( const walletInfoEntries: { [key: string]: WalletInfo } = {} const queue = new PQueue({ concurrency: RPC_CONCURRENCY }) - contracts.map(async (contract) => { - queue.add(async () => { + void contracts.map(async (contract) => { + await queue.add(async () => { // Get subgraph data const graphAccount = await getGraphAccount(contract.address, blockNumber) @@ -333,12 +333,12 @@ class TokenSummary { public show(detail = false) { console.log(`= Managed: ${formatRoundGRT(this.totalManaged)} [n:${this.totalCount}]`) console.log( - `- Available (${this.totalAvailable.mul(100).div(this.totalManaged)}%):`, + `- Available (${this.totalAvailable.mul(100).div(this.totalManaged).toString()}%):`, formatRoundGRT(this.totalAvailable), ) - console.log(`- Free (${this.totalFree.mul(100).div(this.totalManaged)}%):`, formatRoundGRT(this.totalFree)) + console.log(`- Free (${this.totalFree.mul(100).div(this.totalManaged).toString()}%):`, formatRoundGRT(this.totalFree)) console.log( - `-- Released (${this.totalFree.gt(0) ? this.totalReleased.mul(100).div(this.totalFree) : 0}%): ${formatRoundGRT( + `-- Released (${this.totalFree.gt(0) ? this.totalReleased.mul(100).div(this.totalFree).toString() : 0}%): ${formatRoundGRT( this.totalReleased, )} [n:${this.contractsReleased.length}]`, ) @@ -414,8 +414,8 @@ task('contracts:list', 'List all token lock contracts') const tokensUsedStaked = BigNumber.from(graphAccount.indexer?.stakedTokens || 0) const tokensUsedDelegated = graphAccount.delegator ? BigNumber.from(graphAccount.delegator.totalStakedTokens).sub( - BigNumber.from(graphAccount.delegator.totalUnstakedTokens), - ) + BigNumber.from(graphAccount.delegator.totalUnstakedTokens), + ) : BigNumber.from(0) // print wallet entries @@ -471,7 +471,7 @@ task('contracts:summary', 'Show summary of balances') const block = await hre.ethers.provider.getBlock(blockNumber) console.log('Block:', block.number, '/', new Date(block.timestamp * 1000).toDateString(), '\n') const allWallets = await getWallets(block.number) - const revocableWallets = allWallets.filter((wallet) => wallet.revocable === 'Enabled') + const revocableWallets = allWallets.filter(wallet => wallet.revocable === 'Enabled') // Calculate summaries (for all vestings) const summary: TokenSummary = new TokenSummary(block) @@ -482,8 +482,8 @@ task('contracts:summary', 'Show summary of balances') // Calculate summaries (for revocable vestings) const queue = new PQueue({ concurrency: RPC_CONCURRENCY }) const revocableSummary: TokenSummary = new TokenSummary(block) - revocableWallets.map(async (wallet) => { - queue.add(async () => { + void revocableWallets.map(async (wallet) => { + await queue.add(async () => { const contract = await hre.ethers.getContractAt('GraphTokenLockWallet', wallet.id) await revocableSummary.addWallet(wallet, contract) }) @@ -514,10 +514,10 @@ task('contracts:summary', 'Show summary of balances') // Exchange locked let managedAmountExchanges = vestingListExchanges - .map((vesting) => toBN(vesting.managedAmount)) + .map(vesting => toBN(vesting.managedAmount)) .reduce((a, b) => a.add(b), toBN('0')) let freeAmountExchanges = vestingListExchanges - .map((vesting) => getFreeAmount(vesting, block.timestamp)) + .map(vesting => getFreeAmount(vesting, block.timestamp)) .reduce((a, b) => a.add(b), toBN('0')) managedAmountExchanges = managedAmountExchanges.add(toWei('283333334')) freeAmountExchanges = freeAmountExchanges.add(toWei('150000000')) @@ -574,7 +574,7 @@ task('contracts:show', 'Show info about an specific contract') await contract.amountPerPeriod(), await contract.surplusAmount(), await contract.vestedAmount(), - ]).then((results) => results.map((e) => formatRoundGRT(e))) + ]).then(results => results.map(e => formatRoundGRT(e))) const [startTime, endTime, periods, currentPeriod, periodDuration, revocable, owner, manager] = await Promise.all([ contract.startTime(), @@ -693,8 +693,8 @@ task('contracts:list-pending-lock', 'List all token lock contracts that have not console.log(`Checking lock status...`) const queue = new PQueue({ concurrency: RPC_CONCURRENCY }) const pendingLocks: TokenLockWallet[] = [] - allWallets.map(async (wallet) => { - queue.add(async () => { + void allWallets.map(async (wallet) => { + await queue.add(async () => { // Original contract didn't support accepting/cancelling lock, we can safely ignore those // so we wrap isAccepted() call in try/catch and keep going if it fails try { diff --git a/packages/token-distribution/ops/tx-builder.ts b/packages/token-distribution/ops/tx-builder.ts index 159bd9a21..6a6f200d7 100644 --- a/packages/token-distribution/ops/tx-builder.ts +++ b/packages/token-distribution/ops/tx-builder.ts @@ -1,8 +1,22 @@ import fs from 'fs' import path from 'path' +export interface BuilderTx { + to: string + data: string + value: number | string + contractMethod?: null + contractInputsValues?: null +} + +interface TxBuilderContents { + createdAt: number + chainId: string + transactions: BuilderTx[] +} + export class TxBuilder { - contents: any + contents: TxBuilderContents outputFile: string constructor(chainId: string, _template?: string) { @@ -20,7 +34,7 @@ export class TxBuilder { this.contents.chainId = chainId } - addTx(tx: any) { + addTx(tx: BuilderTx) { this.contents.transactions.push({ ...tx, contractMethod: null, contractInputsValues: null }) } diff --git a/packages/token-distribution/package.json b/packages/token-distribution/package.json index 331fa3bd7..37069fc41 100644 --- a/packages/token-distribution/package.json +++ b/packages/token-distribution/package.json @@ -13,7 +13,7 @@ "test:gas": "RUN_EVM=true REPORT_GAS=true scripts/test", "test:coverage": "scripts/coverage", "lint": "yarn run lint:ts && yarn run lint:sol", - "lint:ts": "eslint 'test/**/*.{js,ts}' --fix", + "lint:ts": "eslint '**/*.{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", diff --git a/packages/token-distribution/tsconfig.json b/packages/token-distribution/tsconfig.json index 8027b0d63..ba8d0153c 100644 --- a/packages/token-distribution/tsconfig.json +++ b/packages/token-distribution/tsconfig.json @@ -10,6 +10,7 @@ }, "exclude": ["dist", "node_modules"], "include": [ + ".solcover.js", "eslint.config.js", "prettier.config.js", "./hardhat.config.ts", From 22b0cca484d322dbab4423fe267fb5b979224931 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Thu, 7 Mar 2024 17:27:41 -0300 Subject: [PATCH 3/9] feat(eslint): custom config for unused var rule MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- packages/eslint-graph-config/index.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/eslint-graph-config/index.ts b/packages/eslint-graph-config/index.ts index 2ab60d95b..b9548595e 100644 --- a/packages/eslint-graph-config/index.ts +++ b/packages/eslint-graph-config/index.ts @@ -36,7 +36,7 @@ export default [ '@typescript-eslint/no-inferrable-types': 'warn', '@typescript-eslint/no-empty-function': 'warn', 'no-only-tests/no-only-tests': 'error', - 'no-secrets/no-secrets': 'error', + 'no-secrets/no-secrets': ['error', { tolerance: 4.1 }], 'sort-imports': [ 'warn', { memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'], @@ -44,6 +44,18 @@ export default [ allowSeparatedGroups: true, }], '@stylistic/brace-style': ['error', '1tbs'], + '@typescript-eslint/no-unused-vars': [ + 'error', + { + args: 'all', + argsIgnorePattern: '^_', + caughtErrors: 'all', + caughtErrorsIgnorePattern: '^_', + destructuredArrayIgnorePattern: '^_', + varsIgnorePattern: '^_', + ignoreRestSiblings: true, + }, + ], }, }, { From 48361b5ca727c8f7b3d802f06919be63e9676069 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Thu, 7 Mar 2024 17:28:18 -0300 Subject: [PATCH 4/9] chore: lint ts with graph lint package MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- packages/contracts/.eslintignore | 7 - packages/contracts/.eslintrc | 19 - packages/contracts/.prettierignore | 4 - packages/contracts/.prettierrc.json | 35 -- packages/contracts/eslint.config.js | 17 + packages/contracts/hardhat.config.ts | 14 +- packages/contracts/package.json | 23 +- .../scripts/ops/parseTestnetAddresses.ts | 8 +- packages/contracts/tasks/bridge/deposits.ts | 13 +- .../contracts/tasks/bridge/withdrawals.ts | 13 +- packages/contracts/tasks/contract/deploy.ts | 2 +- packages/contracts/tasks/contract/upgrade.ts | 2 +- packages/contracts/tasks/deployment/config.ts | 4 +- packages/contracts/tasks/e2e/e2e.ts | 9 +- packages/contracts/tasks/migrate/nitro.ts | 8 +- packages/contracts/tasks/migrate/protocol.ts | 2 +- packages/contracts/tasks/test-upgrade.ts | 2 +- packages/contracts/tasks/verify/defender.ts | 14 +- packages/contracts/tasks/verify/sourcify.ts | 5 +- packages/contracts/tasks/verify/verify.ts | 6 +- .../e2e/deployment/config/controller.test.ts | 2 +- .../deployment/config/l1/bridgeEscrow.test.ts | 2 +- .../e2e/deployment/config/l1/curation.test.ts | 2 +- .../e2e/deployment/config/l1/l1GNS.test.ts | 6 +- .../config/l1/l1GraphTokenGateway.test.ts | 6 +- .../deployment/config/l1/l1Staking.test.ts | 6 +- .../config/l1/rewardsManager.test.ts | 2 +- .../deployment/config/l2/l2Curation.test.ts | 2 +- .../e2e/deployment/config/l2/l2GNS.test.ts | 6 +- .../config/l2/l2GraphTokenGateway.test.ts | 4 +- .../deployment/config/l2/l2Staking.test.ts | 6 +- .../config/l2/rewardsManager.test.ts | 2 +- .../e2e/deployment/config/staking.test.ts | 2 +- .../deployment/init/l1/bridgeEscrow.test.ts | 4 +- .../e2e/deployment/init/l1/graphToken.test.ts | 2 +- .../e2e/deployment/init/l2/graphToken.test.ts | 2 +- .../e2e/scenarios/close-allocations.test.ts | 8 +- .../test/e2e/scenarios/close-allocations.ts | 6 +- .../e2e/scenarios/create-subgraphs.test.ts | 4 +- .../test/e2e/scenarios/create-subgraphs.ts | 10 +- .../e2e/scenarios/open-allocations.test.ts | 2 +- .../test/e2e/scenarios/open-allocations.ts | 6 +- .../test/e2e/scenarios/send-grt-to-l2.test.ts | 2 +- .../test/e2e/upgrades/example/post-upgrade.ts | 4 + .../test/e2e/upgrades/example/pre-upgrade.ts | 4 + .../exponential-rebates/post-upgrade.test.ts | 12 +- .../exponential-rebates/pre-upgrade.ts | 1 + .../test/unit/curation/configuration.test.ts | 2 +- .../test/unit/curation/curation.test.ts | 30 +- .../test/unit/disputes/configuration.test.ts | 5 +- .../contracts/test/unit/disputes/poi.test.ts | 13 +- .../test/unit/disputes/query.test.ts | 23 +- packages/contracts/test/unit/epochs.test.ts | 6 +- .../test/unit/gateway/bridgeEscrow.test.ts | 6 +- .../unit/gateway/l1GraphTokenGateway.test.ts | 20 +- packages/contracts/test/unit/gns.test.ts | 63 ++- .../test/unit/governance/controller.test.ts | 6 +- .../test/unit/governance/governed.test.ts | 2 +- .../test/unit/governance/pausing.test.ts | 6 +- .../contracts/test/unit/l2/l2Curation.test.ts | 36 +- packages/contracts/test/unit/l2/l2GNS.test.ts | 51 +- .../test/unit/l2/l2GraphToken.test.ts | 24 +- .../test/unit/l2/l2GraphTokenGateway.test.ts | 45 +- .../contracts/test/unit/l2/l2Staking.test.ts | 14 +- packages/contracts/test/unit/lib/fixtures.ts | 10 +- packages/contracts/test/unit/lib/gnsUtils.ts | 7 +- .../test/unit/lib/graphTokenTests.ts | 10 +- .../unit/payments/allocationExchange.test.ts | 22 +- .../test/unit/rewards/rewards.test.ts | 34 +- .../test/unit/serviceRegisty.test.ts | 4 +- .../test/unit/staking/allocation.test.ts | 23 +- .../test/unit/staking/configuration.test.ts | 8 +- .../test/unit/staking/delegation.test.ts | 10 +- .../test/unit/staking/l2Transfer.test.ts | 14 +- .../test/unit/staking/rebate.test.ts | 7 +- .../test/unit/staking/staking.test.ts | 10 +- .../contracts/test/unit/upgrade/admin.test.ts | 20 +- packages/contracts/tsconfig.json | 11 +- yarn.lock | 451 +++--------------- 79 files changed, 463 insertions(+), 852 deletions(-) delete mode 100644 packages/contracts/.eslintignore delete mode 100644 packages/contracts/.eslintrc delete mode 100644 packages/contracts/.prettierignore delete mode 100644 packages/contracts/.prettierrc.json create mode 100644 packages/contracts/eslint.config.js diff --git a/packages/contracts/.eslintignore b/packages/contracts/.eslintignore deleted file mode 100644 index 02127cba1..000000000 --- a/packages/contracts/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -build/ -cache/ -coverage/ -node_modules/ -truffle.js -cache/ -dist/ diff --git a/packages/contracts/.eslintrc b/packages/contracts/.eslintrc deleted file mode 100644 index 89b53531b..000000000 --- a/packages/contracts/.eslintrc +++ /dev/null @@ -1,19 +0,0 @@ -{ - "parser": "@typescript-eslint/parser", - "parserOptions": { - "ecmaVersion": 2020, - "sourceType": "module" - }, - "extends": ["plugin:@typescript-eslint/recommended", "plugin:prettier/recommended"], - "rules": { - "prefer-const": "warn", - "no-extra-semi": "off", - "@typescript-eslint/no-extra-semi": "off", - "@typescript-eslint/no-inferrable-types": "warn", - "@typescript-eslint/no-empty-function": "warn", - "no-only-tests/no-only-tests": "error" - }, - "plugins": [ - "no-only-tests" - ] -} diff --git a/packages/contracts/.prettierignore b/packages/contracts/.prettierignore deleted file mode 100644 index 4e76680e5..000000000 --- a/packages/contracts/.prettierignore +++ /dev/null @@ -1,4 +0,0 @@ -build -reports -cache -coverage.json \ No newline at end of file diff --git a/packages/contracts/.prettierrc.json b/packages/contracts/.prettierrc.json deleted file mode 100644 index 0b2b67edd..000000000 --- a/packages/contracts/.prettierrc.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "printWidth": 100, - "useTabs": false, - "bracketSpacing": true, - "plugins": ["prettier-plugin-solidity"], - "overrides": [ - { - "files": "*.js", - "options": { - "semi": false, - "trailingComma": "all", - "tabWidth": 2, - "singleQuote": true, - "explicitTypes": "always" - } - }, - { - "files": "*.ts", - "options": { - "semi": false, - "trailingComma": "all", - "tabWidth": 2, - "singleQuote": true, - "explicitTypes": "always" - } - }, - { - "files": "*.sol", - "options": { - "tabWidth": 4, - "singleQuote": false - } - } - ] -} diff --git a/packages/contracts/eslint.config.js b/packages/contracts/eslint.config.js new file mode 100644 index 000000000..c7c0ba1b2 --- /dev/null +++ b/packages/contracts/eslint.config.js @@ -0,0 +1,17 @@ +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', + }, + }, + { + ignores: ['**/reports/*'], + }, +] diff --git a/packages/contracts/hardhat.config.ts b/packages/contracts/hardhat.config.ts index d91c12eec..b90eb1290 100644 --- a/packages/contracts/hardhat.config.ts +++ b/packages/contracts/hardhat.config.ts @@ -31,7 +31,7 @@ function loadTasks() { ;['contract', 'bridge', 'deployment', 'migrate', 'verify', 'e2e'].forEach((folder) => { const tasksPath = path.join(__dirname, 'tasks', folder) fs.readdirSync(tasksPath) - .filter((pth) => pth.includes('.ts')) + .filter(pth => pth.includes('.ts')) .forEach((task) => { require(`${tasksPath}/${task}`) }) @@ -110,11 +110,11 @@ function setupNetworkProviders(hardhatConfig) { // Config -const DEFAULT_TEST_MNEMONIC = - 'myth like bonus scare over problem client lizard pioneer submit female collect' +const DEFAULT_TEST_MNEMONIC + = 'myth like bonus scare over problem client lizard pioneer submit female collect' -const DEFAULT_L2_TEST_MNEMONIC = - 'urge never interest human any economy gentle canvas anxiety pave unlock find' +const DEFAULT_L2_TEST_MNEMONIC + = 'urge never interest human any economy gentle canvas anxiety pave unlock find' const config: HardhatUserConfig = { paths: { @@ -233,8 +233,8 @@ const config: HardhatUserConfig = { disambiguatePaths: false, }, defender: { - apiKey: process.env.DEFENDER_API_KEY!, - apiSecret: process.env.DEFENDER_API_SECRET!, + apiKey: process.env.DEFENDER_API_KEY, + apiSecret: process.env.DEFENDER_API_SECRET, }, } diff --git a/packages/contracts/package.json b/packages/contracts/package.json index 633513a57..48d52d57d 100644 --- a/packages/contracts/package.json +++ b/packages/contracts/package.json @@ -42,8 +42,6 @@ "@types/sinon-chai": "^3.2.12", "@types/winston": "^2.4.4", "@types/yargs": "^16.0.0", - "@typescript-eslint/eslint-plugin": "^4.0.0", - "@typescript-eslint/parser": "^4.0.0", "@urql/core": "^2.1.3", "arbos-precompiles": "^1.0.2", "bignumber.js": "^9.0.0", @@ -51,10 +49,8 @@ "chai-as-promised": "^7.1.1", "cli-table": "^0.3.6", "dotenv": "^9.0.0", - "eslint": "^7.24.0", - "eslint-config-prettier": "^8.3.0", - "eslint-plugin-no-only-tests": "^2.4.0", - "eslint-plugin-prettier": "^3.4.0", + "eslint": "^8.57.0", + "eslint-graph-config": "workspace:^0.0.1", "ethereum-waffle": "^3.2.0", "ethers": "^5.7.2", "form-data": "^4.0.0", @@ -72,10 +68,7 @@ "isomorphic-fetch": "^3.0.0", "lint-staged": "^10.5.4", "p-queue": "^6.6.1", - "prettier": "^2.2.1", - "prettier-plugin-solidity": "1.0.0-beta.19", "solhint": "^3.3.6", - "solhint-plugin-prettier": "^0.0.5", "solidity-coverage": "^0.7.16", "ts-node": "^10.9.1", "typechain": "^5.0.0", @@ -98,13 +91,11 @@ "test:coverage": "scripts/coverage", "test:upgrade": "scripts/upgrade", "lint": "yarn lint:ts && yarn lint:sol", - "lint:fix": "yarn lint:ts:fix && yarn lint:sol:fix", - "lint:ts": "eslint '**/*.{js,ts}'", - "lint:ts:fix": "yarn prettier:ts && eslint '**/*.{js,ts}' --fix", + "lint:fix": "yarn lint:ts && yarn lint:sol:fix", + "lint:ts": "eslint '**/*.{js,ts}' --fix", "lint:sol": "solhint 'contracts/**/*.sol'", "lint:sol:fix": "yarn prettier:sol && solhint --fix 'contracts/**/*.sol'", "prettier": "yarn prettier:ts && yarn prettier:sol", - "prettier:ts": "prettier --write '**/*.{js,ts,json}'", "prettier:sol": "prettier --write 'contracts/**/*.sol'", "analyze": "scripts/analyze", "myth": "scripts/myth", @@ -118,13 +109,13 @@ "yarn lint:sol:fix" ], "**/*.ts": [ - "yarn lint:ts:fix" + "yarn lint:ts" ], "**/*.js": [ - "yarn lint:ts:fix" + "yarn lint:ts" ], "**/*.json": [ - "yarn lint:ts:fix" + "yarn lint:ts" ] }, "repository": { diff --git a/packages/contracts/scripts/ops/parseTestnetAddresses.ts b/packages/contracts/scripts/ops/parseTestnetAddresses.ts index 96ad27be4..921859368 100755 --- a/packages/contracts/scripts/ops/parseTestnetAddresses.ts +++ b/packages/contracts/scripts/ops/parseTestnetAddresses.ts @@ -16,18 +16,18 @@ interface TeamMember { export const teamAddresses: Array = [] -async function main() { +function main() { const data = fs.readFileSync('indexers.csv', 'utf8') - const entries = data.split('\n').map((e) => e.trim()) + const entries = data.split('\n').map(e => e.trim()) for (const entry of entries) { if (!entry) continue - const [name, address] = entry.split(',').map((e) => e.trim()) + const [name, address] = entry.split(',').map(e => e.trim()) // Verify address try { getAddress(address.trim()) - } catch (err) { + } catch (_) { console.log('Invalid', name, address) process.exit(1) } diff --git a/packages/contracts/tasks/bridge/deposits.ts b/packages/contracts/tasks/bridge/deposits.ts index 94bc7eb56..b8a7838fc 100644 --- a/packages/contracts/tasks/bridge/deposits.ts +++ b/packages/contracts/tasks/bridge/deposits.ts @@ -4,6 +4,13 @@ import { Table } from 'console-table-printer' import { L1ToL2MessageStatus } from '@arbitrum/sdk' import { getL1ToL2MessageStatus } from '@graphprotocol/sdk' +interface PrintEvent { + blockNumber: string + tx: string + amount: string + status: string +} + greTask('bridge:deposits', 'List deposits initiated on L1GraphTokenGateway') .addOptionalParam('startBlock', 'Start block for the search') .addOptionalParam('endBlock', 'End block for the search') @@ -21,7 +28,7 @@ greTask('bridge:deposits', 'List deposits initiated on L1GraphTokenGateway') const events = await Promise.all( ( await gateway.queryFilter(gateway.filters.DepositInitiated(), startBlock, endBlock) - ).map(async (e) => ({ + ).map(async e => ({ blockNumber: `${e.blockNumber} (${new Date( (await graph.l1.provider.getBlock(e.blockNumber)).timestamp * 1000, ).toLocaleString()})`, @@ -48,7 +55,7 @@ greTask('bridge:deposits', 'List deposits initiated on L1GraphTokenGateway') printEvents(events) }) -function printEvents(events: any[]) { +function printEvents(events: PrintEvent[]) { const tablePrinter = new Table({ charLength: { '🚧': 2, '✅': 2, '⚠️': 1, '⌛': 2, '❌': 2 }, columns: [ @@ -64,7 +71,7 @@ function printEvents(events: any[]) { ], }) - events.map((e) => tablePrinter.addRow(e)) + events.map(e => tablePrinter.addRow(e)) tablePrinter.printTable() } diff --git a/packages/contracts/tasks/bridge/withdrawals.ts b/packages/contracts/tasks/bridge/withdrawals.ts index 3e9a6a9b7..d36511813 100644 --- a/packages/contracts/tasks/bridge/withdrawals.ts +++ b/packages/contracts/tasks/bridge/withdrawals.ts @@ -4,6 +4,13 @@ import { L2ToL1MessageStatus } from '@arbitrum/sdk' import { greTask } from '@graphprotocol/sdk/gre' import { getL2ToL1MessageStatus } from '@graphprotocol/sdk' +interface PrintEvent { + blockNumber: string + tx: string + amount: string + status: string +} + greTask('bridge:withdrawals', 'List withdrawals initiated on L2GraphTokenGateway') .addOptionalParam('startBlock', 'Start block for the search') .addOptionalParam('endBlock', 'End block for the search') @@ -21,7 +28,7 @@ greTask('bridge:withdrawals', 'List withdrawals initiated on L2GraphTokenGateway const events = await Promise.all( ( await gateway.queryFilter(gateway.filters.WithdrawalInitiated(), startBlock, endBlock) - ).map(async (e) => ({ + ).map(async e => ({ blockNumber: `${e.blockNumber} (${new Date( (await graph.l2.provider.getBlock(e.blockNumber)).timestamp * 1000, ).toLocaleString()})`, @@ -48,7 +55,7 @@ greTask('bridge:withdrawals', 'List withdrawals initiated on L2GraphTokenGateway printEvents(events) }) -function printEvents(events: any[]) { +function printEvents(events: PrintEvent[]) { const tablePrinter = new Table({ charLength: { '🚧': 2, '✅': 2, '⚠️': 1, '❌': 2 }, columns: [ @@ -64,7 +71,7 @@ function printEvents(events: any[]) { ], }) - events.map((e) => tablePrinter.addRow(e)) + events.map(e => tablePrinter.addRow(e)) tablePrinter.printTable() } diff --git a/packages/contracts/tasks/contract/deploy.ts b/packages/contracts/tasks/contract/deploy.ts index 70d0901d2..3571444d0 100644 --- a/packages/contracts/tasks/contract/deploy.ts +++ b/packages/contracts/tasks/contract/deploy.ts @@ -1,4 +1,4 @@ -import { DeployType, GraphNetworkAddressBook, confirm, deploy } from '@graphprotocol/sdk' +import { confirm, deploy, DeployType, GraphNetworkAddressBook } from '@graphprotocol/sdk' import { greTask } from '@graphprotocol/sdk/gre' greTask('contract:deploy', 'Deploy a contract') diff --git a/packages/contracts/tasks/contract/upgrade.ts b/packages/contracts/tasks/contract/upgrade.ts index d50b30d6f..6825ba06a 100644 --- a/packages/contracts/tasks/contract/upgrade.ts +++ b/packages/contracts/tasks/contract/upgrade.ts @@ -1,5 +1,5 @@ import { greTask } from '@graphprotocol/sdk/gre' -import { DeployType, GraphNetworkAddressBook, deploy } from '@graphprotocol/sdk' +import { deploy, DeployType, GraphNetworkAddressBook } from '@graphprotocol/sdk' greTask('contract:upgrade', 'Upgrades a contract') .addParam('contract', 'Name of the contract to upgrade') diff --git a/packages/contracts/tasks/deployment/config.ts b/packages/contracts/tasks/deployment/config.ts index 375007c3d..76192b1c3 100644 --- a/packages/contracts/tasks/deployment/config.ts +++ b/packages/contracts/tasks/deployment/config.ts @@ -1,15 +1,15 @@ import { + confirm, GraphNetworkConfigContractList, GraphNetworkConfigGeneralParams, updateContractParams, updateGeneralParams, writeConfig, - confirm, } from '@graphprotocol/sdk' import { greTask } from '@graphprotocol/sdk/gre' greTask('update-config', 'Update graph config parameters with onchain data') - .addFlag('dryRun', "Only print the changes, don't write them to the config file") + .addFlag('dryRun', 'Only print the changes, don\'t write them to the config file') .addFlag('skipConfirmation', 'Skip confirmation prompt on write actions.') .setAction(async (taskArgs, hre) => { const networkName = hre.network.name diff --git a/packages/contracts/tasks/e2e/e2e.ts b/packages/contracts/tasks/e2e/e2e.ts index bb8486976..43f23ad1e 100644 --- a/packages/contracts/tasks/e2e/e2e.ts +++ b/packages/contracts/tasks/e2e/e2e.ts @@ -11,7 +11,7 @@ const INIT_TESTS = 'test/e2e/deployment/init/**/*.test.ts' // Built-in test & run tasks don't support GRE arguments // so we pass them by overriding GRE config object -const setGraphConfig = async (args: TaskArguments, hre: HardhatRuntimeEnvironment) => { +const setGraphConfig = (args: TaskArguments, hre: HardhatRuntimeEnvironment) => { const greArgs = [ 'graphConfig', 'l1GraphConfig', @@ -42,7 +42,7 @@ greTask('e2e', 'Run all e2e tests') ] if (args.skipBridge) { - testFiles = testFiles.filter((file) => !/l1|l2/.test(file)) + testFiles = testFiles.filter(file => !/l1|l2/.test(file)) } // Disable secure accounts, we don't need them for this task @@ -84,7 +84,7 @@ greTask('e2e:init', 'Run deployment initialization e2e tests').setAction( greTask('e2e:scenario', 'Run scenario scripts and e2e tests') .addPositionalParam('scenario', 'Name of the scenario to run') - .addFlag('skipScript', "Don't run scenario script") + .addFlag('skipScript', 'Don\'t run scenario script') .setAction(async (args, hre: HardhatRuntimeEnvironment) => { setGraphConfig(args, hre) @@ -126,7 +126,8 @@ greTask('e2e:upgrade', 'Run upgrade tests') await runUpgrade(args, hre, args.post ? 'post' : 'pre') }) -async function runUpgrade(args: any, hre: HardhatRuntimeEnvironment, type: 'pre' | 'post') { +// eslint-disable-next-line @typescript-eslint/no-explicit-any +async function runUpgrade(args: { [key: string]: any }, hre: HardhatRuntimeEnvironment, type: 'pre' | 'post') { const script = `test/e2e/upgrades/${args.upgrade}/${type}-upgrade.ts` const test = `test/e2e/upgrades/${args.upgrade}/${type}-upgrade.test.ts` diff --git a/packages/contracts/tasks/migrate/nitro.ts b/packages/contracts/tasks/migrate/nitro.ts index e3a382467..a399b5002 100644 --- a/packages/contracts/tasks/migrate/nitro.ts +++ b/packages/contracts/tasks/migrate/nitro.ts @@ -19,7 +19,8 @@ greTask( // This adds the testnodes to the SDK configuration subtask('migrate:nitro:register', 'Adds nitro testnodes to SDK config') .addParam('deploymentFile', 'The testnode deployment file to use', 'localNetwork.json') - .setAction(async (taskArgs) => { + // eslint-disable-next-line @typescript-eslint/require-await + .setAction(async (taskArgs): Promise => { helpers.addLocalNetwork(taskArgs.deploymentFile) }) @@ -29,6 +30,7 @@ subtask('migrate:nitro:deployment-file', 'Fetches nitro deployment file from a l 'Path to the file where to deployment file will be saved', 'localNetwork.json', ) + // eslint-disable-next-line @typescript-eslint/require-await .setAction(async (taskArgs) => { console.log(`Attempting to fetch deployment file from testnode...`) @@ -53,7 +55,7 @@ task('migrate:nitro:address-book', 'Write arbitrum addresses to address book') const deployment = JSON.parse(fs.readFileSync(taskArgs.deploymentFile, 'utf-8')) const addressBook = { - '1337': { + 1337: { L1GatewayRouter: { address: deployment.l2Network.tokenBridge.l1GatewayRouter, }, @@ -61,7 +63,7 @@ task('migrate:nitro:address-book', 'Write arbitrum addresses to address book') address: deployment.l2Network.ethBridge.inbox, }, }, - '412346': { + 412346: { L2GatewayRouter: { address: deployment.l2Network.tokenBridge.l2GatewayRouter, }, diff --git a/packages/contracts/tasks/migrate/protocol.ts b/packages/contracts/tasks/migrate/protocol.ts index 3fe21ef2e..38664a573 100644 --- a/packages/contracts/tasks/migrate/protocol.ts +++ b/packages/contracts/tasks/migrate/protocol.ts @@ -1,4 +1,4 @@ -import { GraphChainId, deployGraphNetwork } from '@graphprotocol/sdk' +import { deployGraphNetwork, GraphChainId } from '@graphprotocol/sdk' import { greTask } from '@graphprotocol/sdk/gre' greTask('migrate', 'Deploy protocol contracts') diff --git a/packages/contracts/tasks/test-upgrade.ts b/packages/contracts/tasks/test-upgrade.ts index 93e45d43c..911d2ac75 100644 --- a/packages/contracts/tasks/test-upgrade.ts +++ b/packages/contracts/tasks/test-upgrade.ts @@ -24,7 +24,7 @@ const UPGRADEABLE_CONTRACTS: UpgradeableContract[] = [ ] task('test:upgrade-setup', 'Deploy contracts using an OZ proxy').setAction( - async (taskArgs, hre) => { + async (_, hre) => { const contractAddresses = {} for (const upgradeableContract of UPGRADEABLE_CONTRACTS) { // Deploy libraries diff --git a/packages/contracts/tasks/verify/defender.ts b/packages/contracts/tasks/verify/defender.ts index 68775afef..24ad83f59 100644 --- a/packages/contracts/tasks/verify/defender.ts +++ b/packages/contracts/tasks/verify/defender.ts @@ -7,7 +7,7 @@ import type { VerificationResponse } from '@openzeppelin/hardhat-defender/dist/v import { GraphNetworkContractName, isGraphNetworkContractName } from '@graphprotocol/sdk' async function main( - args: { referenceUrl?: string; contracts: GraphNetworkContractName[] }, + args: { referenceUrl?: string, contracts: GraphNetworkContractName[] }, hre: HRE, ) { const { referenceUrl, contracts } = args @@ -15,16 +15,16 @@ async function main( const summaryPath = process.env.GITHUB_STEP_SUMMARY if (summaryPath) appendFileSync(summaryPath, `# Contracts deployment verification\n\n`) - const workflowUrl = - referenceUrl || - process.env.WORKFLOW_URL || - execSync(`git config --get remote.origin.url`).toString().trim() + const workflowUrl + = referenceUrl + || process.env.WORKFLOW_URL + || execSync(`git config --get remote.origin.url`).toString().trim() const addressBook = graph().addressBook const errs = [] for (const contractName of contracts) { if (!isGraphNetworkContractName(contractName)) { - throw new Error(`Invalid contract name: ${contractName}`) + throw new Error(`Invalid contract name: ${contractName as string}`) } const entry = addressBook.getEntry(contractName) if (!entry || entry.address === constants.AddressZero) { @@ -49,7 +49,7 @@ async function main( if (response.matchType === 'NO_MATCH') { errs.push([contractName, { message: `No bytecode match.` }]) } - } catch (err: any) { + } catch (err) { if (summaryPath) { appendFileSync( summaryPath, diff --git a/packages/contracts/tasks/verify/sourcify.ts b/packages/contracts/tasks/verify/sourcify.ts index a872884bc..027885006 100644 --- a/packages/contracts/tasks/verify/sourcify.ts +++ b/packages/contracts/tasks/verify/sourcify.ts @@ -1,3 +1,4 @@ +/* eslint-disable no-secrets/no-secrets */ /* eslint-disable @typescript-eslint/no-explicit-any */ import axios from 'axios' import FormData from 'form-data' @@ -43,7 +44,7 @@ export async function submitSourcesToSourcify( return } } catch (e) { - console.error(((e as any).response && JSON.stringify((e as any).response.data)) || e) + console.error(((e).response && JSON.stringify((e).response.data)) || e) } console.log(`verifying ${contract.name} (${contract.address} on chain ${chainId}) ...`) @@ -72,6 +73,6 @@ export async function submitSourcesToSourcify( console.error(` => contract ${contract.name} is not verified`) } } catch (e) { - console.error(((e as any).response && JSON.stringify((e as any).response.data)) || e) + console.error(((e).response && JSON.stringify((e).response.data)) || e) } } diff --git a/packages/contracts/tasks/verify/verify.ts b/packages/contracts/tasks/verify/verify.ts index 23cfad023..451409e12 100644 --- a/packages/contracts/tasks/verify/verify.ts +++ b/packages/contracts/tasks/verify/verify.ts @@ -88,7 +88,7 @@ greTask('verifyAll', 'Verifies all contracts on etherscan').setAction(async (arg const contractConfig = getContractConfig(graphConfig, addressBook, contractName, deployer) const contractPath = getContractPath(contractName) - const constructorParams = contractConfig.params.map((p) => p.value.toString()) + const constructorParams = contractConfig.params.map(p => p.value.toString()) if (contractPath) { const contract = addressBook.getEntry(contractName) @@ -119,7 +119,7 @@ greTask('verifyAll', 'Verifies all contracts on etherscan').setAction(async (arg }) // etherscan API throws errors if the contract is already verified -async function safeVerify(hre: HardhatRuntimeEnvironment, taskArguments: any): Promise { +async function safeVerify(hre: HardhatRuntimeEnvironment, taskArguments: unknown): Promise { try { await hre.run('verify', taskArguments) } catch (error) { @@ -129,7 +129,7 @@ async function safeVerify(hre: HardhatRuntimeEnvironment, taskArguments: any): P function getContractPath(contract: string): string | undefined { const files = readDirRecursive('contracts/') - return files.find((f) => path.basename(f) === `${contract}.sol`) + return files.find(f => path.basename(f) === `${contract}.sol`) } function readDirRecursive(dir: string, allFiles: string[] = []) { diff --git a/packages/contracts/test/e2e/deployment/config/controller.test.ts b/packages/contracts/test/e2e/deployment/config/controller.test.ts index 820864542..fea7eadc2 100644 --- a/packages/contracts/test/e2e/deployment/config/controller.test.ts +++ b/packages/contracts/test/e2e/deployment/config/controller.test.ts @@ -60,7 +60,7 @@ describe('Controller configuration', () => { expect(pauseGuardian).eq(namedAccounts.pauseGuardian.address) }) - describe('proxy contract', async function () { + describe('proxy contract', function () { const proxyContracts = isGraphL1ChainId(graph.chainId) ? l1ProxyContracts : l2ProxyContracts for (const contract of proxyContracts) { it(`${contract} should match deployed`, async function () { diff --git a/packages/contracts/test/e2e/deployment/config/l1/bridgeEscrow.test.ts b/packages/contracts/test/e2e/deployment/config/l1/bridgeEscrow.test.ts index 9d6fd606b..bea48aea6 100644 --- a/packages/contracts/test/e2e/deployment/config/l1/bridgeEscrow.test.ts +++ b/packages/contracts/test/e2e/deployment/config/l1/bridgeEscrow.test.ts @@ -6,7 +6,7 @@ describe('[L1] BridgeEscrow configuration', function () { const graph = hre.graph() const { Controller, BridgeEscrow } = graph.contracts - before(async function () { + before(function () { if (isGraphL2ChainId(graph.chainId)) this.skip() }) diff --git a/packages/contracts/test/e2e/deployment/config/l1/curation.test.ts b/packages/contracts/test/e2e/deployment/config/l1/curation.test.ts index 1b7492506..f0fa363c5 100644 --- a/packages/contracts/test/e2e/deployment/config/l1/curation.test.ts +++ b/packages/contracts/test/e2e/deployment/config/l1/curation.test.ts @@ -9,7 +9,7 @@ describe('[L1] Curation configuration', () => { contracts: { Controller, Curation, BancorFormula, GraphCurationToken }, } = graph - before(async function () { + before(function () { if (isGraphL2ChainId(graph.chainId)) this.skip() }) diff --git a/packages/contracts/test/e2e/deployment/config/l1/l1GNS.test.ts b/packages/contracts/test/e2e/deployment/config/l1/l1GNS.test.ts index 5a8fe8924..e33934d5e 100644 --- a/packages/contracts/test/e2e/deployment/config/l1/l1GNS.test.ts +++ b/packages/contracts/test/e2e/deployment/config/l1/l1GNS.test.ts @@ -1,4 +1,3 @@ -import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers' import { expect } from 'chai' import hre from 'hardhat' import { isGraphL2ChainId } from '@graphprotocol/sdk' @@ -7,11 +6,8 @@ describe('[L1] GNS', () => { const graph = hre.graph() const { L1GNS, L1GraphTokenGateway } = graph.contracts - let unauthorized: SignerWithAddress - - before(async function () { + before(function () { if (isGraphL2ChainId(graph.chainId)) this.skip() - unauthorized = (await graph.getTestAccounts())[0] }) describe('L1GNS', () => { diff --git a/packages/contracts/test/e2e/deployment/config/l1/l1GraphTokenGateway.test.ts b/packages/contracts/test/e2e/deployment/config/l1/l1GraphTokenGateway.test.ts index be55d9bfe..e188fc89e 100644 --- a/packages/contracts/test/e2e/deployment/config/l1/l1GraphTokenGateway.test.ts +++ b/packages/contracts/test/e2e/deployment/config/l1/l1GraphTokenGateway.test.ts @@ -1,7 +1,7 @@ import { expect } from 'chai' import hre from 'hardhat' import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers' -import { SimpleAddressBook, isGraphL2ChainId } from '@graphprotocol/sdk' +import { isGraphL2ChainId, SimpleAddressBook } from '@graphprotocol/sdk' describe('[L1] L1GraphTokenGateway configuration', function () { const graph = hre.graph() @@ -38,7 +38,7 @@ describe('[L1] L1GraphTokenGateway configuration', function () { expect(escrow).eq(graph.l1.contracts.BridgeEscrow.address) }) - it("inbox should match Arbitrum's Inbox address", async function () { + it('inbox should match Arbitrum\'s Inbox address', async function () { const inbox = await L1GraphTokenGateway.inbox() const arbitrumAddressBook = process.env.ARBITRUM_ADDRESS_BOOK ?? 'arbitrum-addresses-local.json' const arbAddressBook = new SimpleAddressBook(arbitrumAddressBook, graph.l1.chainId) @@ -47,7 +47,7 @@ describe('[L1] L1GraphTokenGateway configuration', function () { expect(inbox.toLowerCase()).eq(arbIInbox.address.toLowerCase()) }) - it("l1Router should match Arbitrum's router address", async function () { + it('l1Router should match Arbitrum\'s router address', async function () { const l1Router = await L1GraphTokenGateway.l1Router() const arbitrumAddressBook = process.env.ARBITRUM_ADDRESS_BOOK ?? 'arbitrum-addresses-local.json' const arbAddressBook = new SimpleAddressBook(arbitrumAddressBook, graph.l1.chainId) diff --git a/packages/contracts/test/e2e/deployment/config/l1/l1Staking.test.ts b/packages/contracts/test/e2e/deployment/config/l1/l1Staking.test.ts index 25d0b3805..185f2a2fe 100644 --- a/packages/contracts/test/e2e/deployment/config/l1/l1Staking.test.ts +++ b/packages/contracts/test/e2e/deployment/config/l1/l1Staking.test.ts @@ -1,4 +1,3 @@ -import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers' import { expect } from 'chai' import hre from 'hardhat' import { isGraphL2ChainId } from '@graphprotocol/sdk' @@ -7,11 +6,8 @@ describe('[L1] Staking', () => { const graph = hre.graph() const { L1Staking, L1GraphTokenGateway } = graph.contracts - let unauthorized: SignerWithAddress - - before(async function () { + before(function () { if (isGraphL2ChainId(graph.chainId)) this.skip() - unauthorized = (await graph.getTestAccounts())[0] }) describe('L1Staking', () => { diff --git a/packages/contracts/test/e2e/deployment/config/l1/rewardsManager.test.ts b/packages/contracts/test/e2e/deployment/config/l1/rewardsManager.test.ts index afc9287d6..0f9807d92 100644 --- a/packages/contracts/test/e2e/deployment/config/l1/rewardsManager.test.ts +++ b/packages/contracts/test/e2e/deployment/config/l1/rewardsManager.test.ts @@ -6,7 +6,7 @@ describe('[L1] RewardsManager configuration', () => { const graph = hre.graph() const { RewardsManager } = graph.contracts - before(async function () { + before(function () { if (isGraphL2ChainId(graph.chainId)) this.skip() }) diff --git a/packages/contracts/test/e2e/deployment/config/l2/l2Curation.test.ts b/packages/contracts/test/e2e/deployment/config/l2/l2Curation.test.ts index 3722b6b14..b38f679a6 100644 --- a/packages/contracts/test/e2e/deployment/config/l2/l2Curation.test.ts +++ b/packages/contracts/test/e2e/deployment/config/l2/l2Curation.test.ts @@ -9,7 +9,7 @@ describe('[L2] L2Curation configuration', () => { contracts: { Controller, L2Curation, GraphCurationToken }, } = graph - before(async function () { + before(function () { if (isGraphL1ChainId(graph.chainId)) this.skip() }) diff --git a/packages/contracts/test/e2e/deployment/config/l2/l2GNS.test.ts b/packages/contracts/test/e2e/deployment/config/l2/l2GNS.test.ts index 133d77077..2ebd7cf5e 100644 --- a/packages/contracts/test/e2e/deployment/config/l2/l2GNS.test.ts +++ b/packages/contracts/test/e2e/deployment/config/l2/l2GNS.test.ts @@ -1,4 +1,3 @@ -import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers' import { expect } from 'chai' import hre from 'hardhat' import { isGraphL1ChainId } from '@graphprotocol/sdk' @@ -7,11 +6,8 @@ describe('[L2] GNS', () => { const graph = hre.graph() const { L2GNS } = graph.l2.contracts - let unauthorized: SignerWithAddress - - before(async function () { + before(function () { if (isGraphL1ChainId(graph.chainId)) this.skip() - unauthorized = (await graph.getTestAccounts())[0] }) describe('L2GNS', () => { diff --git a/packages/contracts/test/e2e/deployment/config/l2/l2GraphTokenGateway.test.ts b/packages/contracts/test/e2e/deployment/config/l2/l2GraphTokenGateway.test.ts index 45033cb28..cae73cbd9 100644 --- a/packages/contracts/test/e2e/deployment/config/l2/l2GraphTokenGateway.test.ts +++ b/packages/contracts/test/e2e/deployment/config/l2/l2GraphTokenGateway.test.ts @@ -1,7 +1,7 @@ import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers' import { expect } from 'chai' import hre from 'hardhat' -import { SimpleAddressBook, isGraphL1ChainId } from '@graphprotocol/sdk' +import { isGraphL1ChainId, SimpleAddressBook } from '@graphprotocol/sdk' describe('[L2] L2GraphTokenGateway configuration', function () { const graph = hre.graph() @@ -33,7 +33,7 @@ describe('[L2] L2GraphTokenGateway configuration', function () { expect(l1Counterpart).eq(graph.l1.contracts.L1GraphTokenGateway.address) }) - it("l2Router should match Arbitrum's router address", async function () { + it('l2Router should match Arbitrum\'s router address', async function () { const l2Router = await L2GraphTokenGateway.l2Router() // TODO: is there a cleaner way to get the router address? diff --git a/packages/contracts/test/e2e/deployment/config/l2/l2Staking.test.ts b/packages/contracts/test/e2e/deployment/config/l2/l2Staking.test.ts index 0e81d9892..dda82fd85 100644 --- a/packages/contracts/test/e2e/deployment/config/l2/l2Staking.test.ts +++ b/packages/contracts/test/e2e/deployment/config/l2/l2Staking.test.ts @@ -1,4 +1,3 @@ -import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers' import { expect } from 'chai' import hre from 'hardhat' import { isGraphL1ChainId } from '@graphprotocol/sdk' @@ -7,11 +6,8 @@ describe('[L2] Staking', () => { const graph = hre.graph() const { L2Staking } = graph.l2.contracts - let unauthorized: SignerWithAddress - - before(async function () { + before(function () { if (isGraphL1ChainId(graph.chainId)) this.skip() - unauthorized = (await graph.getTestAccounts())[0] }) describe('L2Staking', () => { diff --git a/packages/contracts/test/e2e/deployment/config/l2/rewardsManager.test.ts b/packages/contracts/test/e2e/deployment/config/l2/rewardsManager.test.ts index a2846001e..9759ba78d 100644 --- a/packages/contracts/test/e2e/deployment/config/l2/rewardsManager.test.ts +++ b/packages/contracts/test/e2e/deployment/config/l2/rewardsManager.test.ts @@ -6,7 +6,7 @@ describe('[L2] RewardsManager configuration', () => { const graph = hre.graph() const { RewardsManager } = graph.contracts - before(async function () { + before(function () { if (isGraphL1ChainId(graph.chainId)) this.skip() }) diff --git a/packages/contracts/test/e2e/deployment/config/staking.test.ts b/packages/contracts/test/e2e/deployment/config/staking.test.ts index 2d93da605..cfd4110b4 100644 --- a/packages/contracts/test/e2e/deployment/config/staking.test.ts +++ b/packages/contracts/test/e2e/deployment/config/staking.test.ts @@ -5,7 +5,7 @@ import { getItemValue, isGraphL2ChainId } from '@graphprotocol/sdk' describe('Staking configuration', () => { const { graphConfig, - contracts: { Staking, Controller, DisputeManager, AllocationExchange }, + contracts: { Staking, Controller, DisputeManager }, chainId, } = hre.graph() let contractName: string diff --git a/packages/contracts/test/e2e/deployment/init/l1/bridgeEscrow.test.ts b/packages/contracts/test/e2e/deployment/init/l1/bridgeEscrow.test.ts index 98e64d5ab..0abb37278 100644 --- a/packages/contracts/test/e2e/deployment/init/l1/bridgeEscrow.test.ts +++ b/packages/contracts/test/e2e/deployment/init/l1/bridgeEscrow.test.ts @@ -6,11 +6,11 @@ describe('[L1] BridgeEscrow initialization', () => { const graph = hre.graph() const { BridgeEscrow, GraphToken, L1GraphTokenGateway } = graph.contracts - before(async function () { + before(function () { if (isGraphL2ChainId(graph.chainId)) this.skip() }) - it("should allow L1GraphTokenGateway contract to spend MAX_UINT256 tokens on BridgeEscrow's behalf", async function () { + it('should allow L1GraphTokenGateway contract to spend MAX_UINT256 tokens on BridgeEscrow\'s behalf', async function () { const allowance = await GraphToken.allowance(BridgeEscrow.address, L1GraphTokenGateway.address) expect(allowance).eq(hre.ethers.constants.MaxUint256) }) diff --git a/packages/contracts/test/e2e/deployment/init/l1/graphToken.test.ts b/packages/contracts/test/e2e/deployment/init/l1/graphToken.test.ts index be95373c5..87ad5769a 100644 --- a/packages/contracts/test/e2e/deployment/init/l1/graphToken.test.ts +++ b/packages/contracts/test/e2e/deployment/init/l1/graphToken.test.ts @@ -6,7 +6,7 @@ describe('[L1] GraphToken initialization', () => { const graph = hre.graph() const { GraphToken } = graph.contracts - before(async function () { + before(function () { if (isGraphL2ChainId(graph.chainId)) this.skip() }) diff --git a/packages/contracts/test/e2e/deployment/init/l2/graphToken.test.ts b/packages/contracts/test/e2e/deployment/init/l2/graphToken.test.ts index 2debc22d7..c7978ac81 100644 --- a/packages/contracts/test/e2e/deployment/init/l2/graphToken.test.ts +++ b/packages/contracts/test/e2e/deployment/init/l2/graphToken.test.ts @@ -6,7 +6,7 @@ describe('[L2] GraphToken initialization', () => { const graph = hre.graph() const { GraphToken } = graph.contracts - before(async function () { + before(function () { if (isGraphL1ChainId(graph.chainId)) this.skip() }) diff --git a/packages/contracts/test/e2e/scenarios/close-allocations.test.ts b/packages/contracts/test/e2e/scenarios/close-allocations.test.ts index efbb18004..a8ace4c7c 100644 --- a/packages/contracts/test/e2e/scenarios/close-allocations.test.ts +++ b/packages/contracts/test/e2e/scenarios/close-allocations.test.ts @@ -23,10 +23,10 @@ describe('Close allocations', () => { let openAllocations: AllocationFixture[] = [] let closedAllocations: AllocationFixture[] = [] - before(async () => { - allocations = indexerFixtures.map((i) => i.allocations).flat() - openAllocations = allocations.filter((a) => !a.close) - closedAllocations = allocations.filter((a) => a.close) + before(() => { + allocations = indexerFixtures.map(i => i.allocations).flat() + openAllocations = allocations.filter(a => !a.close) + closedAllocations = allocations.filter(a => a.close) }) it(`some allocatons should be open`, async function () { diff --git a/packages/contracts/test/e2e/scenarios/close-allocations.ts b/packages/contracts/test/e2e/scenarios/close-allocations.ts index f37589230..96c59174b 100644 --- a/packages/contracts/test/e2e/scenarios/close-allocations.ts +++ b/packages/contracts/test/e2e/scenarios/close-allocations.ts @@ -9,7 +9,7 @@ import hre from 'hardhat' import { getIndexerFixtures } from './fixtures/indexers' -import { helpers, closeAllocation } from '@graphprotocol/sdk' +import { closeAllocation, helpers } from '@graphprotocol/sdk' import { getGREOptsFromArgv } from '@graphprotocol/sdk/gre' @@ -18,7 +18,7 @@ async function main() { const graph = hre.graph(graphOpts) const indexerFixtures = getIndexerFixtures(await graph.getTestAccounts()) - const ethBalances = indexerFixtures.map((i) => ({ + const ethBalances = indexerFixtures.map(i => ({ address: i.signer.address, balance: i.ethBalance, })) @@ -37,7 +37,7 @@ async function main() { console.log('\n== Close allocations') for (const indexer of indexerFixtures) { - for (const allocation of indexer.allocations.filter((a) => a.close)) { + for (const allocation of indexer.allocations.filter(a => a.close)) { await closeAllocation(graph.contracts, indexer.signer, { allocationId: allocation.signer.address, }) diff --git a/packages/contracts/test/e2e/scenarios/create-subgraphs.test.ts b/packages/contracts/test/e2e/scenarios/create-subgraphs.test.ts index b2ece4dd8..055093dc6 100644 --- a/packages/contracts/test/e2e/scenarios/create-subgraphs.test.ts +++ b/packages/contracts/test/e2e/scenarios/create-subgraphs.test.ts @@ -3,7 +3,7 @@ import hre from 'hardhat' import { recreatePreviousSubgraphId } from '@graphprotocol/sdk' import { BigNumber } from 'ethers' import { CuratorFixture, getCuratorFixtures } from './fixtures/curators' -import { SubgraphFixture, getSubgraphFixtures, getSubgraphOwner } from './fixtures/subgraphs' +import { getSubgraphFixtures, getSubgraphOwner, SubgraphFixture } from './fixtures/subgraphs' import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers' let curatorFixtures: CuratorFixture[] @@ -55,7 +55,7 @@ describe('Publish subgraphs', () => { let totalSignal: BigNumber = BigNumber.from(0) for (const curator of curatorFixtures) { - const _subgraph = curator.subgraphs.find((s) => s.deploymentId === subgraph.deploymentId) + const _subgraph = curator.subgraphs.find(s => s.deploymentId === subgraph.deploymentId) if (_subgraph) { totalSignal = totalSignal.add(_subgraph.signal) } diff --git a/packages/contracts/test/e2e/scenarios/create-subgraphs.ts b/packages/contracts/test/e2e/scenarios/create-subgraphs.ts index 09306b059..9f2486ff7 100644 --- a/packages/contracts/test/e2e/scenarios/create-subgraphs.ts +++ b/packages/contracts/test/e2e/scenarios/create-subgraphs.ts @@ -8,7 +8,7 @@ import hre from 'hardhat' import { getSubgraphFixtures, getSubgraphOwner } from './fixtures/subgraphs' import { getCuratorFixtures } from './fixtures/curators' import { getGREOptsFromArgv } from '@graphprotocol/sdk/gre' -import { helpers, publishNewSubgraph, mintSignal, setGRTBalances } from '@graphprotocol/sdk' +import { helpers, mintSignal, publishNewSubgraph, setGRTBalances } from '@graphprotocol/sdk' async function main() { const graphOpts = getGREOptsFromArgv() @@ -26,8 +26,8 @@ async function main() { balance: subgraphOwnerFixture.ethBalance, }, ] - curatorFixtures.map((c) => ethBalances.push({ address: c.signer.address, balance: c.ethBalance })) - const grtBalances = curatorFixtures.map((c) => ({ + curatorFixtures.map(c => ethBalances.push({ address: c.signer.address, balance: c.ethBalance })) + const grtBalances = curatorFixtures.map(c => ({ address: c.signer.address, balance: c.grtBalance, })) @@ -45,7 +45,7 @@ async function main() { deploymentId: subgraph.deploymentId, chainId: graph.chainId, }) - const subgraphData = subgraphFixtures.find((s) => s.deploymentId === subgraph.deploymentId) + const subgraphData = subgraphFixtures.find(s => s.deploymentId === subgraph.deploymentId) if (subgraphData) subgraphData.subgraphId = id } @@ -53,7 +53,7 @@ async function main() { console.log('\n== Signaling subgraphs') for (const curator of curatorFixtures) { for (const subgraph of curator.subgraphs) { - const subgraphData = subgraphFixtures.find((s) => s.deploymentId === subgraph.deploymentId) + const subgraphData = subgraphFixtures.find(s => s.deploymentId === subgraph.deploymentId) if (subgraphData) await mintSignal(graph.contracts, curator.signer, { subgraphId: subgraphData.subgraphId, diff --git a/packages/contracts/test/e2e/scenarios/open-allocations.test.ts b/packages/contracts/test/e2e/scenarios/open-allocations.test.ts index 7cbbb7505..159e81505 100644 --- a/packages/contracts/test/e2e/scenarios/open-allocations.test.ts +++ b/packages/contracts/test/e2e/scenarios/open-allocations.test.ts @@ -36,7 +36,7 @@ describe('Open allocations', () => { describe('Allocations', () => { it(`allocations should be open`, async function () { - const allocations = indexerFixtures.map((i) => i.allocations).flat() + const allocations = indexerFixtures.map(i => i.allocations).flat() for (const allocation of allocations) { const state = await Staking.getAllocationState(allocation.signer.address) expect(state).eq(AllocationState.Active) diff --git a/packages/contracts/test/e2e/scenarios/open-allocations.ts b/packages/contracts/test/e2e/scenarios/open-allocations.ts index 2d971224e..8beac8d99 100644 --- a/packages/contracts/test/e2e/scenarios/open-allocations.ts +++ b/packages/contracts/test/e2e/scenarios/open-allocations.ts @@ -7,7 +7,7 @@ import hre from 'hardhat' import { getIndexerFixtures } from './fixtures/indexers' import { getGREOptsFromArgv } from '@graphprotocol/sdk/gre' -import { helpers, allocateFrom, stake, setGRTBalances } from '@graphprotocol/sdk' +import { allocateFrom, helpers, setGRTBalances, stake } from '@graphprotocol/sdk' async function main() { const graphOpts = getGREOptsFromArgv() @@ -15,11 +15,11 @@ async function main() { const indexerFixtures = getIndexerFixtures(await graph.getTestAccounts()) const deployer = await graph.getDeployer() - const indexerETHBalances = indexerFixtures.map((i) => ({ + const indexerETHBalances = indexerFixtures.map(i => ({ address: i.signer.address, balance: i.ethBalance, })) - const indexerGRTBalances = indexerFixtures.map((i) => ({ + const indexerGRTBalances = indexerFixtures.map(i => ({ address: i.signer.address, balance: i.grtBalance, })) diff --git a/packages/contracts/test/e2e/scenarios/send-grt-to-l2.test.ts b/packages/contracts/test/e2e/scenarios/send-grt-to-l2.test.ts index 9b81371b6..3cb5ba83e 100644 --- a/packages/contracts/test/e2e/scenarios/send-grt-to-l2.test.ts +++ b/packages/contracts/test/e2e/scenarios/send-grt-to-l2.test.ts @@ -1,6 +1,6 @@ import { expect } from 'chai' import hre from 'hardhat' -import { getBridgeFixture, BridgeFixture } from './fixtures/bridge' +import { BridgeFixture, getBridgeFixture } from './fixtures/bridge' describe('Bridge GRT to L2', () => { const graph = hre.graph() diff --git a/packages/contracts/test/e2e/upgrades/example/post-upgrade.ts b/packages/contracts/test/e2e/upgrades/example/post-upgrade.ts index b3617dc23..ecd2ca395 100644 --- a/packages/contracts/test/e2e/upgrades/example/post-upgrade.ts +++ b/packages/contracts/test/e2e/upgrades/example/post-upgrade.ts @@ -1,3 +1,7 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ +/* eslint-disable @typescript-eslint/require-await */ +// REMOVE the above lines + import hre from 'hardhat' import { getGREOptsFromArgv } from '@graphprotocol/sdk/gre' diff --git a/packages/contracts/test/e2e/upgrades/example/pre-upgrade.ts b/packages/contracts/test/e2e/upgrades/example/pre-upgrade.ts index 12984e5c6..affbfc34d 100644 --- a/packages/contracts/test/e2e/upgrades/example/pre-upgrade.ts +++ b/packages/contracts/test/e2e/upgrades/example/pre-upgrade.ts @@ -1,3 +1,7 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ +/* eslint-disable @typescript-eslint/require-await */ +// REMOVE the above lines + import hre from 'hardhat' import { getGREOptsFromArgv } from '@graphprotocol/sdk/gre' diff --git a/packages/contracts/test/e2e/upgrades/exponential-rebates/post-upgrade.test.ts b/packages/contracts/test/e2e/upgrades/exponential-rebates/post-upgrade.test.ts index 14534f16e..f212343df 100644 --- a/packages/contracts/test/e2e/upgrades/exponential-rebates/post-upgrade.test.ts +++ b/packages/contracts/test/e2e/upgrades/exponential-rebates/post-upgrade.test.ts @@ -3,7 +3,7 @@ import chaiAsPromised from 'chai-as-promised' import hre from 'hardhat' import { Contract, ethers } from 'ethers' import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers' -import { helpers, randomHexBytes, AllocationState } from '@graphprotocol/sdk' +import { AllocationState, helpers, randomHexBytes } from '@graphprotocol/sdk' import removedABI from './abis/staking' import allocations from './fixtures/allocations' @@ -32,7 +32,7 @@ describe('[AFTER UPGRADE] Exponential rebates upgrade', () => { describe('> Allocation state transitions', () => { it('Null allocations should remain Null', async function () { - for (const allocation of allocations.filter((a) => a.state === AllocationState.Null)) { + for (const allocation of allocations.filter(a => a.state === AllocationState.Null)) { await expect(Staking.getAllocationState(allocation.id)).to.eventually.equal( AllocationState.Null, ) @@ -40,7 +40,7 @@ describe('[AFTER UPGRADE] Exponential rebates upgrade', () => { }) it('Active allocations should remain Active', async function () { - for (const allocation of allocations.filter((a) => a.state === AllocationState.Active)) { + for (const allocation of allocations.filter(a => a.state === AllocationState.Active)) { await expect(Staking.getAllocationState(allocation.id)).to.eventually.equal( AllocationState.Active, ) @@ -48,7 +48,7 @@ describe('[AFTER UPGRADE] Exponential rebates upgrade', () => { }) it('Closed allocations should remain Closed', async function () { - for (const allocation of allocations.filter((a) => a.state === AllocationState.Closed)) { + for (const allocation of allocations.filter(a => a.state === AllocationState.Closed)) { await expect(Staking.getAllocationState(allocation.id)).to.eventually.equal( AllocationState.Closed, ) @@ -56,7 +56,7 @@ describe('[AFTER UPGRADE] Exponential rebates upgrade', () => { }) it('Finalized allocations should transition to Closed', async function () { - for (const allocation of allocations.filter((a) => a.state === AllocationState.Finalized)) { + for (const allocation of allocations.filter(a => a.state === AllocationState.Finalized)) { await expect(Staking.getAllocationState(allocation.id)).to.eventually.equal( AllocationState.Closed, ) @@ -64,7 +64,7 @@ describe('[AFTER UPGRADE] Exponential rebates upgrade', () => { }) it('Claimed allocations should transition to Closed', async function () { - for (const allocation of allocations.filter((a) => a.state === AllocationState.Claimed)) { + for (const allocation of allocations.filter(a => a.state === AllocationState.Claimed)) { await expect(Staking.getAllocationState(allocation.id)).to.eventually.equal( AllocationState.Closed, ) diff --git a/packages/contracts/test/e2e/upgrades/exponential-rebates/pre-upgrade.ts b/packages/contracts/test/e2e/upgrades/exponential-rebates/pre-upgrade.ts index d5e8ffba1..e4bed87b1 100644 --- a/packages/contracts/test/e2e/upgrades/exponential-rebates/pre-upgrade.ts +++ b/packages/contracts/test/e2e/upgrades/exponential-rebates/pre-upgrade.ts @@ -11,6 +11,7 @@ async function main() { // Make the deployer an asset holder const deployer = await graph.getDeployer() const { governor } = await graph.getNamedAccounts() + // @ts-expect-error asset holder existed back then await Staking.connect(governor).setAssetHolder(deployer.address, true) // Get some funds on the deployer diff --git a/packages/contracts/test/unit/curation/configuration.test.ts b/packages/contracts/test/unit/curation/configuration.test.ts index b0346b60b..8e4695234 100644 --- a/packages/contracts/test/unit/curation/configuration.test.ts +++ b/packages/contracts/test/unit/curation/configuration.test.ts @@ -23,7 +23,7 @@ describe('Curation:Config', () => { const defaults = graph.graphConfig.defaults before(async function () { - ;[me] = await graph.getTestAccounts() + [me] = await graph.getTestAccounts() ;({ governor } = await graph.getNamedAccounts()) fixture = new NetworkFixture(graph.provider) contracts = await fixture.load(governor) diff --git a/packages/contracts/test/unit/curation/curation.test.ts b/packages/contracts/test/unit/curation/curation.test.ts index 428b33b86..ee8e30bd7 100644 --- a/packages/contracts/test/unit/curation/curation.test.ts +++ b/packages/contracts/test/unit/curation/curation.test.ts @@ -1,16 +1,16 @@ import hre from 'hardhat' import { expect } from 'chai' -import { utils, BigNumber, Event } from 'ethers' +import { BigNumber, Event, utils } from 'ethers' import { NetworkFixture } from '../lib/fixtures' import { parseEther } from 'ethers/lib/utils' import { formatGRT, + GraphNetworkContracts, + helpers, randomHexBytes, toBN, toGRT, - helpers, - GraphNetworkContracts, } from '@graphprotocol/sdk' import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers' @@ -29,7 +29,7 @@ const chunkify = (total: BigNumber, maxChunks = 10): Array => { if (total.gt(0)) { chunks.push(total) } - return chunks + return chunks as BigNumber[] } const toFloat = (n: BigNumber) => parseFloat(formatGRT(n)) @@ -60,7 +60,7 @@ describe('Curation', () => { reserveBalance: BigNumber, reserveRatio: number, depositAmount: BigNumber, - ) { + ): Promise { // Handle the initialization of the bonding curve if (supply.eq(0)) { const minDeposit = await contracts.Curation.minimumCurationDeposit() @@ -80,8 +80,8 @@ describe('Curation', () => { } // Calculate bonding curve in the test return ( - toFloat(supply) * - ((1 + toFloat(depositAmount) / toFloat(reserveBalance)) ** (reserveRatio / 1000000) - 1) + toFloat(supply) + * ((1 + toFloat(depositAmount) / toFloat(reserveBalance)) ** (reserveRatio / 1000000) - 1) ) } @@ -201,7 +201,7 @@ describe('Curation', () => { before(async function () { // Use stakingMock so we can call collect - ;[me, curator, stakingMock] = await graph.getTestAccounts() + [me, curator, stakingMock] = await graph.getTestAccounts() ;({ governor } = await graph.getNamedAccounts()) fixture = new NetworkFixture(graph.provider) @@ -288,7 +288,7 @@ describe('Curation', () => { }) }) - describe('curate', async function () { + describe('curate', function () { it('reject deposit below minimum tokens required', async function () { const tokensToDeposit = (await contracts.Curation.minimumCurationDeposit()).sub(toBN(1)) const tx = contracts.Curation.connect(curator).mint(subgraphDeploymentID, tokensToDeposit, 0) @@ -332,8 +332,8 @@ describe('Curation', () => { }) }) - describe('collect', async function () { - context('> not curated', async function () { + describe('collect', function () { + context('> not curated', function () { it('reject collect tokens distributed to the curation pool', async function () { // Source of tokens must be the staking for this to work await contracts.Controller.connect(governor).setContractProxy( @@ -350,7 +350,7 @@ describe('Curation', () => { }) }) - context('> curated', async function () { + context('> curated', function () { beforeEach(async function () { await contracts.Curation.connect(curator).mint(subgraphDeploymentID, toGRT('1000'), 0) }) @@ -435,7 +435,7 @@ describe('Curation', () => { }) }) - describe('burn', async function () { + describe('burn', function () { beforeEach(async function () { await contracts.Curation.connect(curator).mint(subgraphDeploymentID, tokensToDeposit, 0) }) @@ -528,7 +528,7 @@ describe('Curation', () => { }) }) - describe('conservation', async function () { + describe('conservation', function () { it('should match multiple deposits and redeems back to initial state', async function () { this.timeout(60000) // increase timeout for test runner @@ -573,7 +573,7 @@ describe('Curation', () => { }) }) - describe('multiple minting', async function () { + describe('multiple minting', function () { it('should mint less signal every time due to the bonding curve', async function () { const tokensToDepositMany = [ toGRT('1000'), // should mint if we start with number above minimum deposit diff --git a/packages/contracts/test/unit/disputes/configuration.test.ts b/packages/contracts/test/unit/disputes/configuration.test.ts index 0b94ee18a..baf426815 100644 --- a/packages/contracts/test/unit/disputes/configuration.test.ts +++ b/packages/contracts/test/unit/disputes/configuration.test.ts @@ -15,7 +15,6 @@ const MAX_PPM = 1000000 describe('DisputeManager:Config', () => { let me: SignerWithAddress let governor: SignerWithAddress - let slasher: SignerWithAddress let arbitrator: SignerWithAddress const graph = hre.graph() @@ -26,12 +25,12 @@ describe('DisputeManager:Config', () => { let disputeManager: DisputeManager before(async function () { - ;[me, slasher] = await graph.getTestAccounts() + [me] = await graph.getTestAccounts() ;({ governor, arbitrator } = await graph.getNamedAccounts()) fixture = new NetworkFixture(graph.provider) contracts = await fixture.load(governor) - disputeManager = contracts.DisputeManager as DisputeManager + disputeManager = contracts.DisputeManager }) beforeEach(async function () { diff --git a/packages/contracts/test/unit/disputes/poi.test.ts b/packages/contracts/test/unit/disputes/poi.test.ts index 5d482056c..ea644c522 100644 --- a/packages/contracts/test/unit/disputes/poi.test.ts +++ b/packages/contracts/test/unit/disputes/poi.test.ts @@ -11,19 +11,18 @@ import { NetworkFixture } from '../lib/fixtures' import { MAX_PPM } from './common' import { - helpers, deriveChannelKey, + GraphNetworkContracts, + helpers, randomHexBytes, toBN, toGRT, - GraphNetworkContracts, } from '@graphprotocol/sdk' import type { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers' const { keccak256 } = utils -describe('DisputeManager:POI', async () => { - let other: SignerWithAddress +describe('DisputeManager:POI', () => { let governor: SignerWithAddress let arbitrator: SignerWithAddress let indexer: SignerWithAddress @@ -95,13 +94,13 @@ describe('DisputeManager:POI', async () => { } before(async function () { - ;[other, indexer, fisherman, assetHolder, rewardsDestination] = await graph.getTestAccounts() + [indexer, fisherman, assetHolder, rewardsDestination] = await graph.getTestAccounts() ;({ governor, arbitrator } = await graph.getNamedAccounts()) fixture = new NetworkFixture(graph.provider) contracts = await fixture.load(governor) - disputeManager = contracts.DisputeManager as DisputeManager - epochManager = contracts.EpochManager as EpochManager + disputeManager = contracts.DisputeManager + epochManager = contracts.EpochManager grt = contracts.GraphToken as GraphToken staking = contracts.Staking as IStaking diff --git a/packages/contracts/test/unit/disputes/query.test.ts b/packages/contracts/test/unit/disputes/query.test.ts index ea6f4888e..38b8c04a2 100644 --- a/packages/contracts/test/unit/disputes/query.test.ts +++ b/packages/contracts/test/unit/disputes/query.test.ts @@ -10,25 +10,24 @@ import { IStaking } from '../../../build/types/IStaking' import { NetworkFixture } from '../lib/fixtures' -import { Dispute, createQueryDisputeID, encodeAttestation, MAX_PPM } from './common' +import { createQueryDisputeID, Dispute, encodeAttestation, MAX_PPM } from './common' import { - helpers, deriveChannelKey, + GraphNetworkContracts, + helpers, randomHexBytes, toBN, toGRT, - GraphNetworkContracts, } from '@graphprotocol/sdk' import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers' -const { AddressZero, HashZero } = constants +const { HashZero } = constants const NON_EXISTING_DISPUTE_ID = randomHexBytes() -describe('DisputeManager:Query', async () => { +describe('DisputeManager:Query', () => { let me: SignerWithAddress - let other: SignerWithAddress let governor: SignerWithAddress let arbitrator: SignerWithAddress let indexer: SignerWithAddress @@ -129,14 +128,14 @@ describe('DisputeManager:Query', async () => { } before(async function () { - ;[me, other, indexer, indexer2, fisherman, fisherman2, assetHolder, rewardsDestination] = - await graph.getTestAccounts() + [me, indexer, indexer2, fisherman, fisherman2, assetHolder, rewardsDestination] + = await graph.getTestAccounts() ;({ governor, arbitrator } = await graph.getNamedAccounts()) fixture = new NetworkFixture(graph.provider) contracts = await fixture.load(governor) - disputeManager = contracts.DisputeManager as DisputeManager - epochManager = contracts.EpochManager as EpochManager + disputeManager = contracts.DisputeManager + epochManager = contracts.EpochManager grt = contracts.GraphToken as GraphToken staking = contracts.Staking as IStaking @@ -388,7 +387,7 @@ describe('DisputeManager:Query', async () => { }) }) - describe('reject a dispute', async function () { + describe('reject a dispute', function () { it('reject to reject a dispute if not the arbitrator', async function () { const tx = disputeManager.connect(me).rejectDispute(dispute.id) await expect(tx).revertedWith('Caller is not the Arbitrator') @@ -417,7 +416,7 @@ describe('DisputeManager:Query', async () => { }) }) - describe('draw a dispute', async function () { + describe('draw a dispute', function () { it('reject to draw a dispute if not the arbitrator', async function () { const tx = disputeManager.connect(me).drawDispute(dispute.id) await expect(tx).revertedWith('Caller is not the Arbitrator') diff --git a/packages/contracts/test/unit/epochs.test.ts b/packages/contracts/test/unit/epochs.test.ts index 8aed78c5e..951114dfd 100644 --- a/packages/contracts/test/unit/epochs.test.ts +++ b/packages/contracts/test/unit/epochs.test.ts @@ -4,7 +4,7 @@ import { BigNumber } from 'ethers' import { EpochManager } from '../../build/types/EpochManager' -import { DeployType, deploy, helpers, toBN } from '@graphprotocol/sdk' +import { deploy, DeployType, helpers, toBN } from '@graphprotocol/sdk' import type { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers' describe('EpochManager', () => { @@ -18,7 +18,7 @@ describe('EpochManager', () => { const epochLength: BigNumber = toBN('3') before(async function () { - ;[me, governor] = await graph.getTestAccounts() + [me, governor] = await graph.getTestAccounts() ;({ governor } = await graph.getNamedAccounts()) }) @@ -31,7 +31,7 @@ describe('EpochManager', () => { }, graph.addressBook, ) - const { contract: proxyAdmin } = await deploy( + await deploy( DeployType.DeployAndSave, governor, { diff --git a/packages/contracts/test/unit/gateway/bridgeEscrow.test.ts b/packages/contracts/test/unit/gateway/bridgeEscrow.test.ts index 872b82451..34fa860fd 100644 --- a/packages/contracts/test/unit/gateway/bridgeEscrow.test.ts +++ b/packages/contracts/test/unit/gateway/bridgeEscrow.test.ts @@ -25,13 +25,13 @@ describe('BridgeEscrow', () => { const nTokens = toGRT('1000') before(async function () { - ;[tokenReceiver, spender] = await graph.getTestAccounts() + [tokenReceiver, spender] = await graph.getTestAccounts() ;({ governor } = await graph.getNamedAccounts()) fixture = new NetworkFixture(graph.provider) contracts = await fixture.load(governor) grt = contracts.GraphToken as GraphToken - bridgeEscrow = contracts.BridgeEscrow as BridgeEscrow + bridgeEscrow = contracts.BridgeEscrow // Give some funds to the Escrow await grt.connect(governor).mint(bridgeEscrow.address, nTokens) @@ -69,7 +69,7 @@ describe('BridgeEscrow', () => { const tx = bridgeEscrow.connect(tokenReceiver).revokeAll(spender.address) await expect(tx).revertedWith('Only Controller governor') }) - it("revokes a spender's permission to transfer GRT held by the contract", async function () { + it('revokes a spender\'s permission to transfer GRT held by the contract', async function () { await bridgeEscrow.connect(governor).approveAll(spender.address) await bridgeEscrow.connect(governor).revokeAll(spender.address) // We shouldn't be able to transfer _anything_ diff --git a/packages/contracts/test/unit/gateway/l1GraphTokenGateway.test.ts b/packages/contracts/test/unit/gateway/l1GraphTokenGateway.test.ts index c7439a7ba..872ff77fe 100644 --- a/packages/contracts/test/unit/gateway/l1GraphTokenGateway.test.ts +++ b/packages/contracts/test/unit/gateway/l1GraphTokenGateway.test.ts @@ -12,7 +12,7 @@ import { BridgeEscrow } from '../../../build/types/BridgeEscrow' import { NetworkFixture } from '../lib/fixtures' -import { helpers, applyL1ToL2Alias, toBN, toGRT, GraphNetworkContracts } from '@graphprotocol/sdk' +import { applyL1ToL2Alias, GraphNetworkContracts, helpers, toBN, toGRT } from '@graphprotocol/sdk' import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers' const { AddressZero } = constants @@ -60,7 +60,7 @@ describe('L1GraphTokenGateway', () => { ) before(async function () { - ;[tokenSender, l2Receiver] = await graph.getTestAccounts() + [tokenSender, l2Receiver] = await graph.getTestAccounts() ;({ governor, pauseGuardian } = await graph.getNamedAccounts()) fixture = new NetworkFixture(graph.provider) @@ -68,8 +68,8 @@ describe('L1GraphTokenGateway', () => { // Deploy L1 fixtureContracts = await fixture.load(governor) grt = fixtureContracts.GraphToken as GraphToken - l1GraphTokenGateway = fixtureContracts.L1GraphTokenGateway as L1GraphTokenGateway - bridgeEscrow = fixtureContracts.BridgeEscrow as BridgeEscrow + l1GraphTokenGateway = fixtureContracts.L1GraphTokenGateway + bridgeEscrow = fixtureContracts.BridgeEscrow // Deploy L1 arbitrum bridge ;({ bridgeMock, inboxMock, outboxMock, routerMock } = await fixture.loadL1ArbitrumBridge( @@ -78,8 +78,8 @@ describe('L1GraphTokenGateway', () => { // Deploy L2 mock l2MockContracts = await fixture.loadMock(true) - l2GRTMock = l2MockContracts.L2GraphToken as L2GraphToken - l2GRTGatewayMock = l2MockContracts.L2GraphTokenGateway as L2GraphTokenGateway + l2GRTMock = l2MockContracts.L2GraphToken + l2GRTGatewayMock = l2MockContracts.L2GraphTokenGateway // Give some funds to the token sender/router mock await grt.connect(governor).mint(tokenSender.address, senderTokens) @@ -286,10 +286,10 @@ describe('L1GraphTokenGateway', () => { await fixture.configureL1Bridge(governor, fixtureContracts, l2MockContracts) let tx = l1GraphTokenGateway.connect(governor).setPaused(true) await expect(tx).emit(l1GraphTokenGateway, 'PauseChanged').withArgs(true) - await expect(await l1GraphTokenGateway.paused()).eq(true) + expect(await l1GraphTokenGateway.paused()).eq(true) tx = l1GraphTokenGateway.connect(governor).setPaused(false) await expect(tx).emit(l1GraphTokenGateway, 'PauseChanged').withArgs(false) - await expect(await l1GraphTokenGateway.paused()).eq(false) + expect(await l1GraphTokenGateway.paused()).eq(false) }) describe('setPauseGuardian', function () { it('cannot be called by someone other than governor', async function () { @@ -310,10 +310,10 @@ describe('L1GraphTokenGateway', () => { await l1GraphTokenGateway.connect(governor).setPauseGuardian(pauseGuardian.address) let tx = l1GraphTokenGateway.connect(pauseGuardian).setPaused(true) await expect(tx).emit(l1GraphTokenGateway, 'PauseChanged').withArgs(true) - await expect(await l1GraphTokenGateway.paused()).eq(true) + expect(await l1GraphTokenGateway.paused()).eq(true) tx = l1GraphTokenGateway.connect(pauseGuardian).setPaused(false) await expect(tx).emit(l1GraphTokenGateway, 'PauseChanged').withArgs(false) - await expect(await l1GraphTokenGateway.paused()).eq(false) + expect(await l1GraphTokenGateway.paused()).eq(false) }) }) }) diff --git a/packages/contracts/test/unit/gns.test.ts b/packages/contracts/test/unit/gns.test.ts index 21587d221..028d6b729 100644 --- a/packages/contracts/test/unit/gns.test.ts +++ b/packages/contracts/test/unit/gns.test.ts @@ -1,8 +1,8 @@ import hre from 'hardhat' import { expect } from 'chai' -import { ethers, ContractTransaction, BigNumber, Event } from 'ethers' +import { BigNumber, ContractTransaction, ethers, Event } from 'ethers' import { defaultAbiCoder } from 'ethers/lib/utils' -import { SubgraphDeploymentID, formatGRT } from '@graphprotocol/common-ts' +import { formatGRT, SubgraphDeploymentID } from '@graphprotocol/common-ts' import { LegacyGNSMock } from '../../build/types/LegacyGNSMock' import { GraphToken } from '../../build/types/GraphToken' @@ -14,27 +14,27 @@ import { L1GNS } from '../../build/types/L1GNS' import { L1GraphTokenGateway } from '../../build/types/L1GraphTokenGateway' import { AccountDefaultName, + burnSignal, createDefaultName, + deprecateSubgraph, + mintSignal, publishNewSubgraph, publishNewVersion, - mintSignal, - deprecateSubgraph, - burnSignal, } from './lib/gnsUtils' import { - PublishSubgraph, - Subgraph, buildLegacySubgraphId, buildSubgraph, buildSubgraphId, - randomHexBytes, - helpers, - toGRT, - toBN, deploy, DeployType, - loadContractAt, GraphNetworkContracts, + helpers, + loadContractAt, + PublishSubgraph, + randomHexBytes, + Subgraph, + toBN, + toGRT, } from '@graphprotocol/sdk' import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers' import { L2GNS, L2GraphTokenGateway, SubgraphNFT } from '../../build/types' @@ -125,8 +125,8 @@ describe('L1GNS', () => { } // Calculate bonding curve in the test return ( - toFloat(supply) * - ((1 + toFloat(depositAmount) / toFloat(reserveBalance)) ** (reserveRatio / 1000000) - 1) + toFloat(supply) + * ((1 + toFloat(depositAmount) / toFloat(reserveBalance)) ** (reserveRatio / 1000000) - 1) ) } @@ -190,8 +190,7 @@ describe('L1GNS', () => { return tx } - - const deployLegacyGNSMock = async (): Promise => { + const deployLegacyGNSMock = async (): Promise => { const { contract: subgraphDescriptor } = await deploy(DeployType.Deploy, governor, { name: 'SubgraphNFTDescriptor', }) @@ -222,7 +221,7 @@ describe('L1GNS', () => { } before(async function () { - ;[me, other, governor, another] = await graph.getTestAccounts() + [me, other, governor, another] = await graph.getTestAccounts() fixture = new NetworkFixture(graph.provider) @@ -231,17 +230,17 @@ describe('L1GNS', () => { grt = fixtureContracts.GraphToken as GraphToken curation = fixtureContracts.Curation as Curation gns = fixtureContracts.GNS as L1GNS - controller = fixtureContracts.Controller as Controller - l1GraphTokenGateway = fixtureContracts.L1GraphTokenGateway as L1GraphTokenGateway - subgraphNFT = fixtureContracts.SubgraphNFT as SubgraphNFT + controller = fixtureContracts.Controller + l1GraphTokenGateway = fixtureContracts.L1GraphTokenGateway + subgraphNFT = fixtureContracts.SubgraphNFT // Deploy L1 arbitrum bridge await fixture.loadL1ArbitrumBridge(governor) // Deploy L2 mock l2MockContracts = await fixture.loadMock(true) - l2GNSMock = l2MockContracts.L2GNS as L2GNS - l2GRTGatewayMock = l2MockContracts.L2GraphTokenGateway as L2GraphTokenGateway + l2GNSMock = l2MockContracts.L2GNS + l2GRTGatewayMock = l2MockContracts.L2GraphTokenGateway // Configure graph bridge await fixture.configureL1Bridge(governor, fixtureContracts, l2MockContracts) @@ -275,7 +274,7 @@ describe('L1GNS', () => { await fixture.tearDown() }) - describe('Configuration', async function () { + describe('Configuration', function () { describe('setOwnerTaxPercentage', function () { const newValue = 10 @@ -384,7 +383,7 @@ describe('L1GNS', () => { }) }) - describe('publishNewSubgraph', async function () { + describe('publishNewSubgraph', function () { it('should publish a new subgraph and first version with it', async function () { await publishNewSubgraph(me, newSubgraph0, gns, graph.chainId) }) @@ -403,7 +402,7 @@ describe('L1GNS', () => { }) }) - describe('publishNewVersion', async function () { + describe('publishNewVersion', function () { let subgraph: Subgraph beforeEach(async () => { @@ -548,7 +547,7 @@ describe('L1GNS', () => { expect(await gns.subgraphSignal(subgraph.id)).eq(expectedSignal) }) }) - describe('deprecateSubgraph', async function () { + describe('deprecateSubgraph', function () { let subgraph: Subgraph beforeEach(async () => { @@ -586,8 +585,8 @@ describe('L1GNS', () => { }) }) - describe('Curating on names', async function () { - describe('mintSignal()', async function () { + describe('Curating on names', function () { + describe('mintSignal()', function () { it('should deposit into the name signal curve', async function () { const subgraph = await publishNewSubgraph(me, newSubgraph0, gns, graph.chainId) await mintSignal(other, subgraph.id, tokens10000, gns, curation) @@ -617,7 +616,7 @@ describe('L1GNS', () => { }) }) - describe('burnSignal()', async function () { + describe('burnSignal()', function () { let subgraph: Subgraph beforeEach(async () => { @@ -659,7 +658,7 @@ describe('L1GNS', () => { }) }) - describe('transferSignal()', async function () { + describe('transferSignal()', function () { let subgraph: Subgraph let otherNSignal: BigNumber @@ -695,7 +694,7 @@ describe('L1GNS', () => { await expect(tx).revertedWith('GNS: Curator transfer amount exceeds balance') }) }) - describe('withdraw()', async function () { + describe('withdraw()', function () { let subgraph: Subgraph beforeEach(async () => { @@ -727,7 +726,7 @@ describe('L1GNS', () => { }) }) - describe('multiple minting', async function () { + describe('multiple minting', function () { it('should mint less signal every time due to the bonding curve', async function () { const tokensToDepositMany = [ toGRT('1000'), // should mint if we start with number above minimum deposit diff --git a/packages/contracts/test/unit/governance/controller.test.ts b/packages/contracts/test/unit/governance/controller.test.ts index 0d914d268..5b3074865 100644 --- a/packages/contracts/test/unit/governance/controller.test.ts +++ b/packages/contracts/test/unit/governance/controller.test.ts @@ -25,14 +25,14 @@ describe('Managed', () => { let controller: Controller before(async function () { - ;[me, mockController, newMockEpochManager] = await graph.getTestAccounts() + [me, mockController, newMockEpochManager] = await graph.getTestAccounts() ;({ governor } = await graph.getNamedAccounts()) // We just run the fixures to set up a contract with Managed, as this // is cleaner and easier for us to test fixture = new NetworkFixture(graph.provider) contracts = await fixture.load(governor) - epochManager = contracts.EpochManager as EpochManager - controller = contracts.Controller as Controller + epochManager = contracts.EpochManager + controller = contracts.Controller }) beforeEach(async function () { diff --git a/packages/contracts/test/unit/governance/governed.test.ts b/packages/contracts/test/unit/governance/governed.test.ts index 577c20c46..fb94b343a 100644 --- a/packages/contracts/test/unit/governance/governed.test.ts +++ b/packages/contracts/test/unit/governance/governed.test.ts @@ -16,7 +16,7 @@ describe('Governed', () => { let governed: Governed beforeEach(async function () { - ;[me, governor] = await graph.getTestAccounts() + [me, governor] = await graph.getTestAccounts() const factory = await ethers.getContractFactory('GovernedMock') governed = (await factory.connect(governor).deploy()) as Governed diff --git a/packages/contracts/test/unit/governance/pausing.test.ts b/packages/contracts/test/unit/governance/pausing.test.ts index 17b339892..fbb9b3abc 100644 --- a/packages/contracts/test/unit/governance/pausing.test.ts +++ b/packages/contracts/test/unit/governance/pausing.test.ts @@ -1,6 +1,5 @@ import hre from 'hardhat' import { expect } from 'chai' -import { constants } from 'ethers' import { Controller } from '../../../build/types/Controller' import { IStaking } from '../../../build/types/IStaking' @@ -31,14 +30,13 @@ describe('Pausing', () => { await expect(tx).emit(controller, 'PauseChanged').withArgs(setValue) expect(await controller.paused()).eq(setValue) } - const AddressZero = constants.AddressZero before(async function () { - ;[me] = await graph.getTestAccounts() + [me] = await graph.getTestAccounts() ;({ governor, pauseGuardian: guardian } = await graph.getNamedAccounts()) fixture = new NetworkFixture(graph.provider) contracts = await fixture.load(governor) staking = contracts.Staking as IStaking - controller = contracts.Controller as Controller + controller = contracts.Controller }) beforeEach(async function () { diff --git a/packages/contracts/test/unit/l2/l2Curation.test.ts b/packages/contracts/test/unit/l2/l2Curation.test.ts index 407eeb09d..f004318f1 100644 --- a/packages/contracts/test/unit/l2/l2Curation.test.ts +++ b/packages/contracts/test/unit/l2/l2Curation.test.ts @@ -1,6 +1,6 @@ import hre from 'hardhat' import { expect } from 'chai' -import { utils, BigNumber, Event, Signer, constants } from 'ethers' +import { BigNumber, constants, Event, Signer, utils } from 'ethers' import { L2Curation } from '../../../build/types/L2Curation' import { GraphToken } from '../../../build/types/GraphToken' @@ -11,12 +11,12 @@ import { GNS } from '../../../build/types/GNS' import { parseEther } from 'ethers/lib/utils' import { formatGRT, + GraphNetworkContracts, + helpers, randomAddress, randomHexBytes, toBN, toGRT, - helpers, - GraphNetworkContracts, } from '@graphprotocol/sdk' import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers' @@ -25,7 +25,7 @@ const { AddressZero } = constants const MAX_PPM = 1000000 const chunkify = (total: BigNumber, maxChunks = 10): Array => { - const chunks = [] + const chunks: BigNumber[] = [] while (total.gt(0) && maxChunks > 0) { const m = 1000000 const p = Math.floor(Math.random() * m) @@ -55,12 +55,12 @@ describe('L2Curation:Config', () => { let curation: L2Curation before(async function () { - ;[me] = await graph.getTestAccounts() + [me] = await graph.getTestAccounts() ;({ governor } = await graph.getNamedAccounts()) fixture = new NetworkFixture(graph.provider) contracts = await fixture.load(governor, true) - curation = contracts.L2Curation as L2Curation + curation = contracts.L2Curation }) beforeEach(async function () { @@ -189,8 +189,8 @@ describe('L2Curation', () => { } const minSupply = signalAmountForMinimumCuration return ( - (await calcLinearBondingCurve(minSupply, minDeposit, depositAmount.sub(minDeposit))) + - toFloat(minSupply) + (await calcLinearBondingCurve(minSupply, minDeposit, depositAmount.sub(minDeposit))) + + toFloat(minSupply) ) } // Calculate bonding curve in the test @@ -343,13 +343,13 @@ describe('L2Curation', () => { before(async function () { // Use stakingMock so we can call collect - ;[me, curator, stakingMock] = await graph.getTestAccounts() + [me, curator, stakingMock] = await graph.getTestAccounts() ;({ governor } = await graph.getNamedAccounts()) fixture = new NetworkFixture(graph.provider) contracts = await fixture.load(governor, true) curation = contracts.Curation as L2Curation grt = contracts.GraphToken as GraphToken - controller = contracts.Controller as Controller + controller = contracts.Controller gns = contracts.GNS as GNS gnsImpersonator = await helpers.impersonateAccount(gns.address) @@ -427,7 +427,7 @@ describe('L2Curation', () => { }) }) - describe('curate', async function () { + describe('curate', function () { it('reject deposit below minimum tokens required', async function () { // Set the minimum to a value greater than 1 so that we can test await curation.connect(governor).setMinimumCurationDeposit(toBN('2')) @@ -512,7 +512,7 @@ describe('L2Curation', () => { }) }) - describe('curate tax free (from GNS)', async function () { + describe('curate tax free (from GNS)', function () { it('can not be called by anyone other than GNS', async function () { const tokensToDeposit = await curation.minimumCurationDeposit() const tx = curation.connect(curator).mintTaxFree(subgraphDeploymentID, tokensToDeposit) @@ -555,8 +555,8 @@ describe('L2Curation', () => { }) }) - describe('collect', async function () { - context('> not curated', async function () { + describe('collect', function () { + context('> not curated', function () { it('reject collect tokens distributed to the curation pool', async function () { // Source of tokens must be the staking for this to work await controller @@ -569,7 +569,7 @@ describe('L2Curation', () => { }) }) - context('> curated', async function () { + context('> curated', function () { beforeEach(async function () { await curation.connect(curator).mint(subgraphDeploymentID, toGRT('1000'), 0) }) @@ -645,7 +645,7 @@ describe('L2Curation', () => { }) }) - describe('burn', async function () { + describe('burn', function () { beforeEach(async function () { await curation.connect(curator).mint(subgraphDeploymentID, tokensToDeposit, 0) }) @@ -724,7 +724,7 @@ describe('L2Curation', () => { }) }) - describe('conservation', async function () { + describe('conservation', function () { it('should match multiple deposits and redeems back to initial state', async function () { this.timeout(60000) // increase timeout for test runner @@ -761,7 +761,7 @@ describe('L2Curation', () => { }) }) - describe('multiple minting', async function () { + describe('multiple minting', function () { it('should mint the same signal every time due to the flat bonding curve', async function () { const tokensToDepositMany = [ toGRT('1000'), // should mint if we start with number above minimum deposit diff --git a/packages/contracts/test/unit/l2/l2GNS.test.ts b/packages/contracts/test/unit/l2/l2GNS.test.ts index 4b9b7d06c..496a4fe76 100644 --- a/packages/contracts/test/unit/l2/l2GNS.test.ts +++ b/packages/contracts/test/unit/l2/l2GNS.test.ts @@ -1,6 +1,7 @@ +/* eslint-disable no-secrets/no-secrets */ import hre from 'hardhat' import { expect } from 'chai' -import { ethers, ContractTransaction, BigNumber } from 'ethers' +import { BigNumber, ContractTransaction, ethers } from 'ethers' import { defaultAbiCoder, parseEther } from 'ethers/lib/utils' import { NetworkFixture } from '../lib/fixtures' @@ -125,17 +126,17 @@ describe('L2GNS', () => { // Deploy L2 fixtureContracts = await fixture.load(governor, true) - l2GraphTokenGateway = fixtureContracts.L2GraphTokenGateway as L2GraphTokenGateway - gns = fixtureContracts.L2GNS as L2GNS + l2GraphTokenGateway = fixtureContracts.L2GraphTokenGateway + gns = fixtureContracts.L2GNS staking = fixtureContracts.L2Staking as unknown as IL2Staking - curation = fixtureContracts.L2Curation as L2Curation + curation = fixtureContracts.L2Curation grt = fixtureContracts.GraphToken as GraphToken // Deploy L1 mock l1MockContracts = await fixture.loadMock(false) l1GRTMock = l1MockContracts.GraphToken as GraphToken - l1GNSMock = l1MockContracts.L1GNS as L1GNS - l1GRTGatewayMock = l1MockContracts.L1GraphTokenGateway as L1GraphTokenGateway + l1GNSMock = l1MockContracts.L1GNS + l1GRTGatewayMock = l1MockContracts.L1GraphTokenGateway // Deploy L2 arbitrum bridge await fixture.loadL2ArbitrumBridge(governor) @@ -155,7 +156,7 @@ describe('L2GNS', () => { }) // Adapted from the L1 GNS tests but allowing curating to a pre-curated subgraph deployment - describe('publishNewVersion', async function () { + describe('publishNewVersion', function () { let subgraph: Subgraph beforeEach(async () => { @@ -369,8 +370,8 @@ describe('L2GNS', () => { describe('finishing a subgraph transfer from L1', function () { it('publishes the transferred subgraph and mints signal with no tax', async function () { - const { l1SubgraphId, curatedTokens, subgraphMetadata, versionMetadata } = - await defaultL1SubgraphParams() + const { l1SubgraphId, curatedTokens, subgraphMetadata, versionMetadata } + = await defaultL1SubgraphParams() const callhookData = defaultAbiCoder.encode( ['uint8', 'uint256', 'address'], [toBN(0), l1SubgraphId, me.address], @@ -415,8 +416,8 @@ describe('L2GNS', () => { .withArgs(l2SubgraphId, me.address, expectedNSignal, expectedSignal, curatedTokens) }) it('protects the owner against a rounding attack', async function () { - const { l1SubgraphId, curatedTokens, subgraphMetadata, versionMetadata } = - await defaultL1SubgraphParams() + const { l1SubgraphId, curatedTokens, subgraphMetadata, versionMetadata } + = await defaultL1SubgraphParams() const collectTokens = curatedTokens.mul(20) await staking.connect(governor).setCurationPercentage(100000) @@ -476,8 +477,8 @@ describe('L2GNS', () => { await expect(tx).emit(gns, 'SubgraphL2TransferFinalized').withArgs(l2SubgraphId) }) it('cannot be called by someone other than the subgraph owner', async function () { - const { l1SubgraphId, curatedTokens, subgraphMetadata, versionMetadata } = - await defaultL1SubgraphParams() + const { l1SubgraphId, curatedTokens, subgraphMetadata, versionMetadata } + = await defaultL1SubgraphParams() const callhookData = defaultAbiCoder.encode( ['uint8', 'uint256', 'address'], [toBN(0), l1SubgraphId, me.address], @@ -523,8 +524,8 @@ describe('L2GNS', () => { await expect(tx).revertedWith('INVALID_SUBGRAPH') }) it('accepts calls to a pre-curated subgraph deployment', async function () { - const { l1SubgraphId, curatedTokens, subgraphMetadata, versionMetadata } = - await defaultL1SubgraphParams() + const { l1SubgraphId, curatedTokens, subgraphMetadata, versionMetadata } + = await defaultL1SubgraphParams() const callhookData = defaultAbiCoder.encode( ['uint8', 'uint256', 'address'], [toBN(0), l1SubgraphId, me.address], @@ -622,8 +623,8 @@ describe('L2GNS', () => { // Eth for gas: await helpers.setBalance(await l1GNSMockL2Alias.getAddress(), parseEther('1')) - const { l1SubgraphId, curatedTokens, subgraphMetadata, versionMetadata } = - await defaultL1SubgraphParams() + const { l1SubgraphId, curatedTokens, subgraphMetadata, versionMetadata } + = await defaultL1SubgraphParams() await transferMockSubgraphFromL1( l1SubgraphId, curatedTokens, @@ -663,8 +664,8 @@ describe('L2GNS', () => { // Eth for gas: await helpers.setBalance(await l1GNSMockL2Alias.getAddress(), parseEther('1')) - const { l1SubgraphId, curatedTokens, subgraphMetadata, versionMetadata } = - await defaultL1SubgraphParams() + const { l1SubgraphId, curatedTokens, subgraphMetadata, versionMetadata } + = await defaultL1SubgraphParams() await transferMockSubgraphFromL1( l1SubgraphId, curatedTokens, @@ -702,8 +703,8 @@ describe('L2GNS', () => { expect(l2CuratorBalance).eq(prevSignal.add(expectedNewCuratorSignal)) }) it('cannot be called by someone other than the L2GraphTokenGateway', async function () { - const { l1SubgraphId, curatedTokens, subgraphMetadata, versionMetadata } = - await defaultL1SubgraphParams() + const { l1SubgraphId, curatedTokens, subgraphMetadata, versionMetadata } + = await defaultL1SubgraphParams() await transferMockSubgraphFromL1( l1SubgraphId, curatedTokens, @@ -718,8 +719,8 @@ describe('L2GNS', () => { await expect(tx).revertedWith('ONLY_GATEWAY') }) it('rejects calls if the L1 sender is not the L1GNS', async function () { - const { l1SubgraphId, curatedTokens, subgraphMetadata, versionMetadata } = - await defaultL1SubgraphParams() + const { l1SubgraphId, curatedTokens, subgraphMetadata, versionMetadata } + = await defaultL1SubgraphParams() await transferMockSubgraphFromL1( l1SubgraphId, curatedTokens, @@ -878,8 +879,8 @@ describe('L2GNS', () => { // Eth for gas: await helpers.setBalance(await l1GNSMockL2Alias.getAddress(), parseEther('1')) - const { l1SubgraphId, curatedTokens, subgraphMetadata, versionMetadata } = - await defaultL1SubgraphParams() + const { l1SubgraphId, curatedTokens, subgraphMetadata, versionMetadata } + = await defaultL1SubgraphParams() await transferMockSubgraphFromL1( l1SubgraphId, curatedTokens, diff --git a/packages/contracts/test/unit/l2/l2GraphToken.test.ts b/packages/contracts/test/unit/l2/l2GraphToken.test.ts index cdc6637d6..3b2fe2021 100644 --- a/packages/contracts/test/unit/l2/l2GraphToken.test.ts +++ b/packages/contracts/test/unit/l2/l2GraphToken.test.ts @@ -5,7 +5,7 @@ import { L2GraphToken } from '../../../build/types/L2GraphToken' import { grtTests } from '../lib/graphTokenTests' import { NetworkFixture } from '../lib/fixtures' -import { toGRT, GraphNetworkContracts } from '@graphprotocol/sdk' +import { GraphNetworkContracts, toGRT } from '@graphprotocol/sdk' import type { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers' describe('L2GraphToken', () => { @@ -24,11 +24,11 @@ describe('L2GraphToken', () => { let grt: L2GraphToken before(async function () { - ;[mockL1GRT, mockL2Gateway, user] = await graph.getTestAccounts() + [mockL1GRT, mockL2Gateway, user] = await graph.getTestAccounts() ;({ governor } = await graph.getNamedAccounts()) fixture = new NetworkFixture(graph.provider) contracts = await fixture.load(governor, true) - grt = contracts.L2GraphToken as L2GraphToken + grt = contracts.L2GraphToken }) beforeEach(async function () { @@ -39,7 +39,7 @@ describe('L2GraphToken', () => { await fixture.tearDown() }) - describe('setGateway', async function () { + describe('setGateway', function () { it('cannot be called by someone who is not the governor', async function () { const tx = grt.connect(mockL2Gateway).setGateway(mockL2Gateway.address) await expect(tx).revertedWith('Only Governor can call') @@ -47,10 +47,10 @@ describe('L2GraphToken', () => { it('sets the L2 Gateway address when called by the governor', async function () { const tx = grt.connect(governor).setGateway(mockL2Gateway.address) await expect(tx).emit(grt, 'GatewaySet').withArgs(mockL2Gateway.address) - await expect(await grt.gateway()).eq(mockL2Gateway.address) + expect(await grt.gateway()).eq(mockL2Gateway.address) }) }) - describe('setL1Address', async function () { + describe('setL1Address', function () { it('cannot be called by someone who is not the governor', async function () { const tx = grt.connect(mockL2Gateway).setL1Address(mockL1GRT.address) await expect(tx).revertedWith('Only Governor can call') @@ -58,16 +58,16 @@ describe('L2GraphToken', () => { it('sets the L1 GRT address when called by the governor', async function () { const tx = grt.connect(governor).setL1Address(mockL1GRT.address) await expect(tx).emit(grt, 'L1AddressSet').withArgs(mockL1GRT.address) - await expect(await grt.l1Address()).eq(mockL1GRT.address) + expect(await grt.l1Address()).eq(mockL1GRT.address) }) }) - describe('bridge minting and burning', async function () { + describe('bridge minting and burning', function () { beforeEach(async function () { // Configure the l1Address and gateway await grt.connect(governor).setL1Address(mockL1GRT.address) await grt.connect(governor).setGateway(mockL2Gateway.address) }) - describe('bridgeMint', async function () { + describe('bridgeMint', function () { it('cannot be called by someone who is not the gateway', async function () { const tx = grt.connect(governor).bridgeMint(user.address, toGRT('100')) await expect(tx).revertedWith('NOT_GATEWAY') @@ -75,10 +75,10 @@ describe('L2GraphToken', () => { it('mints GRT into a destination account', async function () { const tx = grt.connect(mockL2Gateway).bridgeMint(user.address, toGRT('100')) await expect(tx).emit(grt, 'BridgeMinted').withArgs(user.address, toGRT('100')) - await expect(await grt.balanceOf(user.address)).eq(toGRT('100')) + expect(await grt.balanceOf(user.address)).eq(toGRT('100')) }) }) - describe('bridgeBurn', async function () { + describe('bridgeBurn', function () { it('cannot be called by someone who is not the gateway', async function () { const tx = grt.connect(governor).bridgeBurn(user.address, toGRT('100')) await expect(tx).revertedWith('NOT_GATEWAY') @@ -99,7 +99,7 @@ describe('L2GraphToken', () => { await grt.connect(user).approve(mockL2Gateway.address, toGRT('20')) const tx = grt.connect(mockL2Gateway).bridgeBurn(user.address, toGRT('20')) await expect(tx).emit(grt, 'BridgeBurned').withArgs(user.address, toGRT('20')) - await expect(await grt.balanceOf(user.address)).eq(toGRT('80')) + expect(await grt.balanceOf(user.address)).eq(toGRT('80')) }) }) it('does not allow the bridge to mint as a regular minter', async function () { diff --git a/packages/contracts/test/unit/l2/l2GraphTokenGateway.test.ts b/packages/contracts/test/unit/l2/l2GraphTokenGateway.test.ts index ab217563a..5718cf571 100644 --- a/packages/contracts/test/unit/l2/l2GraphTokenGateway.test.ts +++ b/packages/contracts/test/unit/l2/l2GraphTokenGateway.test.ts @@ -13,7 +13,7 @@ import { FakeContract, smock } from '@defi-wonderland/smock' use(smock.matchers) import { RewardsManager } from '../../../build/types/RewardsManager' -import { DeployType, GraphNetworkContracts, deploy, helpers, toBN, toGRT } from '@graphprotocol/sdk' +import { deploy, DeployType, GraphNetworkContracts, helpers, toBN, toGRT } from '@graphprotocol/sdk' import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers' import { GraphToken, L1GraphTokenGateway } from '../../../build/types' @@ -49,16 +49,16 @@ describe('L2GraphTokenGateway', () => { ) before(async function () { - ;[me, governor, tokenSender, l1Receiver, l2Receiver, pauseGuardian] = - await graph.getTestAccounts() + [me, governor, tokenSender, l1Receiver, l2Receiver, pauseGuardian] + = await graph.getTestAccounts() fixture = new NetworkFixture(graph.provider) // Deploy L2 fixtureContracts = await fixture.load(governor, true) grt = fixtureContracts.GraphToken as L2GraphToken - l2GraphTokenGateway = fixtureContracts.L2GraphTokenGateway as L2GraphTokenGateway - rewardsManager = fixtureContracts.RewardsManager as RewardsManager + l2GraphTokenGateway = fixtureContracts.L2GraphTokenGateway + rewardsManager = fixtureContracts.RewardsManager // Deploy L2 arbitrum bridge ;({ routerMock } = await fixture.loadL2ArbitrumBridge(governor)) @@ -66,7 +66,7 @@ describe('L2GraphTokenGateway', () => { // Deploy L1 mock l1MockContracts = await fixture.loadMock(false) l1GRTMock = l1MockContracts.GraphToken as GraphToken - l1GRTGatewayMock = l1MockContracts.L1GraphTokenGateway as L1GraphTokenGateway + l1GRTGatewayMock = l1MockContracts.L1GraphTokenGateway callhookReceiverMock = ( await deploy(DeployType.Deploy, governor, { @@ -102,8 +102,7 @@ describe('L2GraphTokenGateway', () => { describe('outboundTransfer', function () { it('reverts because it is paused', async function () { const tx = l2GraphTokenGateway - .connect(tokenSender) - ['outboundTransfer(address,address,uint256,bytes)']( + .connect(tokenSender)['outboundTransfer(address,address,uint256,bytes)']( grt.address, l1Receiver.address, toGRT('10'), @@ -192,10 +191,10 @@ describe('L2GraphTokenGateway', () => { await fixture.configureL2Bridge(governor, fixtureContracts, l1MockContracts) let tx = l2GraphTokenGateway.connect(governor).setPaused(true) await expect(tx).emit(l2GraphTokenGateway, 'PauseChanged').withArgs(true) - await expect(await l2GraphTokenGateway.paused()).eq(true) + expect(await l2GraphTokenGateway.paused()).eq(true) tx = l2GraphTokenGateway.connect(governor).setPaused(false) await expect(tx).emit(l2GraphTokenGateway, 'PauseChanged').withArgs(false) - await expect(await l2GraphTokenGateway.paused()).eq(false) + expect(await l2GraphTokenGateway.paused()).eq(false) }) describe('setPauseGuardian', function () { it('cannot be called by someone other than governor', async function () { @@ -216,10 +215,10 @@ describe('L2GraphTokenGateway', () => { await l2GraphTokenGateway.connect(governor).setPauseGuardian(pauseGuardian.address) let tx = l2GraphTokenGateway.connect(pauseGuardian).setPaused(true) await expect(tx).emit(l2GraphTokenGateway, 'PauseChanged').withArgs(true) - await expect(await l2GraphTokenGateway.paused()).eq(true) + expect(await l2GraphTokenGateway.paused()).eq(true) tx = l2GraphTokenGateway.connect(pauseGuardian).setPaused(false) await expect(tx).emit(l2GraphTokenGateway, 'PauseChanged').withArgs(false) - await expect(await l2GraphTokenGateway.paused()).eq(false) + expect(await l2GraphTokenGateway.paused()).eq(false) }) }) }) @@ -228,8 +227,7 @@ describe('L2GraphTokenGateway', () => { context('> after configuring and unpausing', function () { const testValidOutboundTransfer = async function (signer: Signer, data: string) { const tx = l2GraphTokenGateway - .connect(signer) - ['outboundTransfer(address,address,uint256,bytes)']( + .connect(signer)['outboundTransfer(address,address,uint256,bytes)']( l1GRTMock.address, l1Receiver.address, toGRT('10'), @@ -262,10 +260,10 @@ describe('L2GraphTokenGateway', () => { // For some reason the call count doesn't work properly, // and each function call is counted 12 times. // Possibly related to https://github.com/defi-wonderland/smock/issues/85 ? - //expect(arbSysMock.sendTxToL1).to.have.been.calledOnce + // expect(arbSysMock.sendTxToL1).to.have.been.calledOnce expect(arbSysMock.sendTxToL1).to.have.been.calledWith(l1GRTGatewayMock.address, calldata) const senderBalance = await grt.balanceOf(tokenSender.address) - await expect(senderBalance).eq(toGRT('990')) + expect(senderBalance).eq(toGRT('990')) } before(async function () { await fixture.configureL2Bridge(governor, fixtureContracts, l1MockContracts) @@ -285,8 +283,7 @@ describe('L2GraphTokenGateway', () => { describe('outboundTransfer', function () { it('reverts when called with the wrong token address', async function () { const tx = l2GraphTokenGateway - .connect(tokenSender) - ['outboundTransfer(address,address,uint256,bytes)']( + .connect(tokenSender)['outboundTransfer(address,address,uint256,bytes)']( tokenSender.address, l1Receiver.address, toGRT('10'), @@ -309,8 +306,7 @@ describe('L2GraphTokenGateway', () => { it('reverts when called with nonempty calldata', async function () { await grt.connect(tokenSender).approve(l2GraphTokenGateway.address, toGRT('10')) const tx = l2GraphTokenGateway - .connect(tokenSender) - ['outboundTransfer(address,address,uint256,bytes)']( + .connect(tokenSender)['outboundTransfer(address,address,uint256,bytes)']( l1GRTMock.address, l1Receiver.address, toGRT('10'), @@ -321,8 +317,7 @@ describe('L2GraphTokenGateway', () => { it('reverts when the sender does not have enough GRT', async function () { await grt.connect(tokenSender).approve(l2GraphTokenGateway.address, toGRT('1001')) const tx = l2GraphTokenGateway - .connect(tokenSender) - ['outboundTransfer(address,address,uint256,bytes)']( + .connect(tokenSender)['outboundTransfer(address,address,uint256,bytes)']( l1GRTMock.address, l1Receiver.address, toGRT('1001'), @@ -354,10 +349,10 @@ describe('L2GraphTokenGateway', () => { // Unchanged const senderBalance = await grt.balanceOf(tokenSender.address) - await expect(senderBalance).eq(toGRT('1000')) + expect(senderBalance).eq(toGRT('1000')) // 10 newly minted GRT const receiverBalance = await grt.balanceOf(to) - await expect(receiverBalance).eq(toGRT('10')) + expect(receiverBalance).eq(toGRT('10')) return tx } it('reverts when called by an account that is not the gateway', async function () { @@ -438,7 +433,7 @@ describe('L2GraphTokenGateway', () => { callHookData, ) await expect(tx).revertedWith( - "function selector was not recognized and there's no fallback function", + 'function selector was not recognized and there\'s no fallback function', ) }) }) diff --git a/packages/contracts/test/unit/l2/l2Staking.test.ts b/packages/contracts/test/unit/l2/l2Staking.test.ts index cf28dc872..9394a6116 100644 --- a/packages/contracts/test/unit/l2/l2Staking.test.ts +++ b/packages/contracts/test/unit/l2/l2Staking.test.ts @@ -1,6 +1,6 @@ import hre from 'hardhat' import { expect } from 'chai' -import { ethers, ContractTransaction, BigNumber } from 'ethers' +import { BigNumber, ContractTransaction, ethers } from 'ethers' import { defaultAbiCoder, parseEther } from 'ethers/lib/utils' import { NetworkFixture } from '../lib/fixtures' @@ -9,8 +9,8 @@ import { IL2Staking } from '../../../build/types/IL2Staking' import { L2GraphTokenGateway } from '../../../build/types/L2GraphTokenGateway' import { GraphToken } from '../../../build/types/GraphToken' import { - GraphNetworkContracts, deriveChannelKey, + GraphNetworkContracts, helpers, randomHexBytes, toBN, @@ -79,7 +79,7 @@ describe('L2Staking', () => { } before(async function () { - ;[me, other] = await graph.getTestAccounts() + [me, other] = await graph.getTestAccounts() ;({ governor } = await graph.getNamedAccounts()) fixture = new NetworkFixture(graph.provider) @@ -88,14 +88,14 @@ describe('L2Staking', () => { fixtureContracts = await fixture.load(governor, true) grt = fixtureContracts.GraphToken as GraphToken staking = fixtureContracts.Staking as IL2Staking - l2GraphTokenGateway = fixtureContracts.L2GraphTokenGateway as L2GraphTokenGateway + l2GraphTokenGateway = fixtureContracts.L2GraphTokenGateway // Deploy L1 mock l1MockContracts = await fixture.loadMock(false) l1GRTMock = l1MockContracts.GraphToken as GraphToken - l1StakingMock = l1MockContracts.L1Staking as L1Staking - l1GNSMock = l1MockContracts.L1GNS as L1GNS - l1GRTGatewayMock = l1MockContracts.L1GraphTokenGateway as L1GraphTokenGateway + l1StakingMock = l1MockContracts.L1Staking + l1GNSMock = l1MockContracts.L1GNS + l1GRTGatewayMock = l1MockContracts.L1GraphTokenGateway // Deploy L2 arbitrum bridge await fixture.loadL2ArbitrumBridge(governor) diff --git a/packages/contracts/test/unit/lib/fixtures.ts b/packages/contracts/test/unit/lib/fixtures.ts index b66e5bfb7..f65ed5230 100644 --- a/packages/contracts/test/unit/lib/fixtures.ts +++ b/packages/contracts/test/unit/lib/fixtures.ts @@ -1,9 +1,6 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ -import { Signer, Wallet, providers } from 'ethers' +import { providers, Wallet } from 'ethers' -import { BridgeMock } from '../../../build/types/BridgeMock' -import { InboxMock } from '../../../build/types/InboxMock' -import { OutboxMock } from '../../../build/types/OutboxMock' import { Controller } from '../../../build/types/Controller' import { DisputeManager } from '../../../build/types/DisputeManager' import { EpochManager } from '../../../build/types/EpochManager' @@ -23,15 +20,12 @@ import { L2GraphTokenGateway } from '../../../build/types/L2GraphTokenGateway' import { L2GraphToken } from '../../../build/types/L2GraphToken' import { LibExponential } from '../../../build/types/LibExponential' import { - DeployType, - GraphNetworkContracts, configureL1Bridge, configureL2Bridge, - deploy, deployGraphNetwork, deployMockGraphNetwork, + GraphNetworkContracts, helpers, - loadGraphNetworkContracts, } from '@graphprotocol/sdk' import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers' diff --git a/packages/contracts/test/unit/lib/gnsUtils.ts b/packages/contracts/test/unit/lib/gnsUtils.ts index 086231c03..402e0325a 100644 --- a/packages/contracts/test/unit/lib/gnsUtils.ts +++ b/packages/contracts/test/unit/lib/gnsUtils.ts @@ -7,7 +7,7 @@ import { expect } from 'chai' import { L2Curation } from '../../../build/types/L2Curation' import { GraphToken } from '../../../build/types/GraphToken' import { L2GraphToken } from '../../../build/types/L2GraphToken' -import { PublishSubgraph, Subgraph, buildSubgraphId, toBN } from '@graphprotocol/sdk' +import { buildSubgraphId, PublishSubgraph, Subgraph, toBN } from '@graphprotocol/sdk' import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers' // Entities @@ -77,7 +77,8 @@ export const publishNewSubgraph = async ( const owner = await gns.ownerOf(subgraphID) expect(owner).eq(account.address) - return { ...subgraph, id: subgraphID } + // TODO: properly type this + return { ...subgraph, id: subgraphID } as unknown as Subgraph } export const publishNewVersion = async ( @@ -134,7 +135,7 @@ export const publishNewVersion = async ( // Only emits this event if there was actual signal to upgrade if (beforeSubgraph.nSignal.gt(0)) { - txResult + await txResult .emit(gns, 'SubgraphUpgraded') .withArgs(subgraphID, newVSignalEstimate, totalAdjustedUp, newSubgraph.subgraphDeploymentID) } diff --git a/packages/contracts/test/unit/lib/graphTokenTests.ts b/packages/contracts/test/unit/lib/graphTokenTests.ts index a51410e13..77682ada9 100644 --- a/packages/contracts/test/unit/lib/graphTokenTests.ts +++ b/packages/contracts/test/unit/lib/graphTokenTests.ts @@ -1,10 +1,10 @@ import hre from 'hardhat' import { expect } from 'chai' -import { constants, BigNumber, Signature, ethers, Wallet } from 'ethers' +import { BigNumber, constants, ethers, Signature, Wallet } from 'ethers' import { L2GraphToken } from '../../../build/types/L2GraphToken' import { GraphToken } from '../../../build/types/GraphToken' -import { toBN, toGRT, helpers, Permit, signPermit, GraphNetworkContracts } from '@graphprotocol/sdk' +import { GraphNetworkContracts, Permit, signPermit, toBN, toGRT } from '@graphprotocol/sdk' import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers' import { NetworkFixture } from './fixtures' @@ -72,7 +72,7 @@ export function grtTests(isL2: boolean): void { } before(async function () { - ;({ governor } = await graph.getNamedAccounts()) + ({ governor } = await graph.getNamedAccounts()) me = new ethers.Wallet(mePrivateKey, graph.provider) other = new ethers.Wallet(otherPrivateKey, graph.provider) @@ -176,7 +176,7 @@ export function grtTests(isL2: boolean): void { }) describe('mint', function () { - describe('mint', async function () { + describe('mint', function () { it('reject mint if not minter', async function () { const tx = grt.connect(me).mint(me.address, toGRT('100')) await expect(tx).revertedWith('Only minter can call') @@ -203,7 +203,7 @@ export function grtTests(isL2: boolean): void { expect(await grt.isMinter(me.address)).eq(true) }) - describe('mint', async function () { + describe('mint', function () { it('should mint', async function () { const beforeTokens = await grt.balanceOf(me.address) diff --git a/packages/contracts/test/unit/payments/allocationExchange.test.ts b/packages/contracts/test/unit/payments/allocationExchange.test.ts index 87df2a55a..d5b0c69e7 100644 --- a/packages/contracts/test/unit/payments/allocationExchange.test.ts +++ b/packages/contracts/test/unit/payments/allocationExchange.test.ts @@ -43,11 +43,11 @@ describe('AllocationExchange', () => { const graph = hre.graph() - async function createVoucher( + function createVoucher( allocationID: string, amount: BigNumber, signerKey: string, - ): Promise { + ): Voucher { const messageHash = solidityKeccak256(['address', 'uint256'], [allocationID, amount]) const messageHashBytes = arrayify(messageHash) const key = new SigningKey(signerKey) @@ -60,16 +60,16 @@ describe('AllocationExchange', () => { } before(async function () { - ;[indexer] = await graph.getTestAccounts() + [indexer] = await graph.getTestAccounts() ;({ governor, allocationExchangeOwner } = await graph.getNamedAccounts()) authority = Wallet.createRandom() fixture = new NetworkFixture(graph.provider) contracts = await fixture.load(governor) - allocationExchange = contracts.AllocationExchange as AllocationExchange + allocationExchange = contracts.AllocationExchange grt = contracts.GraphToken as GraphToken staking = contracts.Staking as IStaking - epochManager = contracts.EpochManager as EpochManager + epochManager = contracts.EpochManager // Give some funds to the indexer and approve staking contract to use funds on indexer behalf const indexerTokens = toGRT('100000') @@ -211,7 +211,7 @@ describe('AllocationExchange', () => { // Initiate a withdrawal const actualAmount = toGRT('2000') // <- withdraw amount - const voucher = await createVoucher(allocationID, actualAmount, authority.privateKey) + const voucher = createVoucher(allocationID, actualAmount, authority.privateKey) const tx = allocationExchange.connect(allocationExchangeOwner).redeem(voucher) await expect(tx) .emit(allocationExchange, 'AllocationRedeemed') @@ -233,7 +233,7 @@ describe('AllocationExchange', () => { // Initiate a withdrawal const actualAmount = toGRT('2000') // <- withdraw amount - const voucher = await createVoucher(allocationID, actualAmount, authority.privateKey) + const voucher = createVoucher(allocationID, actualAmount, authority.privateKey) // First redeem await allocationExchange.connect(allocationExchangeOwner).redeem(voucher) @@ -256,7 +256,7 @@ describe('AllocationExchange', () => { // Initiate a withdrawal const actualAmount = toGRT('2000') // <- withdraw amount - const voucher = await createVoucher(allocationID, actualAmount, authority.privateKey) + const voucher = createVoucher(allocationID, actualAmount, authority.privateKey) const tx = allocationExchange.connect(allocationExchangeOwner).redeem(voucher) await expect(tx).revertedWith('!collect') }) @@ -264,7 +264,7 @@ describe('AllocationExchange', () => { it('reject redeem voucher not signed by the authority', async function () { // Initiate a withdrawal const actualAmount = toGRT('2000') // <- withdraw amount - const voucher = await createVoucher( + const voucher = createVoucher( randomAddress(), actualAmount, Wallet.createRandom().privateKey, // <-- signed by anon @@ -276,14 +276,14 @@ describe('AllocationExchange', () => { it('reject redeem voucher with empty amount', async function () { // Initiate a withdrawal const actualAmount = toGRT('0') // <- withdraw amount - const voucher = await createVoucher(randomAddress(), actualAmount, authority.privateKey) + const voucher = createVoucher(randomAddress(), actualAmount, authority.privateKey) const tx = allocationExchange.connect(allocationExchangeOwner).redeem(voucher) await expect(tx).revertedWith('Exchange: zero tokens voucher') }) it('reject redeem voucher with invalid signature', async function () { const actualAmount = toGRT('2000') // <- withdraw amount - const voucher = await createVoucher(randomAddress(), actualAmount, authority.privateKey) + const voucher = createVoucher(randomAddress(), actualAmount, authority.privateKey) voucher.signature = '0x1234' const tx = allocationExchange.connect(allocationExchangeOwner).redeem(voucher) await expect(tx).revertedWith('Exchange: invalid signature') diff --git a/packages/contracts/test/unit/rewards/rewards.test.ts b/packages/contracts/test/unit/rewards/rewards.test.ts index eb5baa4a8..1070b9ff3 100644 --- a/packages/contracts/test/unit/rewards/rewards.test.ts +++ b/packages/contracts/test/unit/rewards/rewards.test.ts @@ -1,6 +1,6 @@ import hre from 'hardhat' import { expect } from 'chai' -import { constants, BigNumber } from 'ethers' +import { BigNumber, constants } from 'ethers' import { BigNumber as BN } from 'bignumber.js' import { NetworkFixture } from '../lib/fixtures' @@ -12,13 +12,13 @@ import { RewardsManager } from '../../../build/types/RewardsManager' import { IStaking } from '../../../build/types/IStaking' import { - helpers, + deriveChannelKey, formatGRT, + GraphNetworkContracts, + helpers, randomHexBytes, toBN, toGRT, - deriveChannelKey, - GraphNetworkContracts, } from '@graphprotocol/sdk' import type { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers' @@ -102,7 +102,7 @@ describe('Rewards', () => { return this.accruedByElapsed(nBlocks) } - async accruedByElapsed(nBlocks: BigNumber | number) { + accruedByElapsed(nBlocks: BigNumber | number) { const n = getRewardsPerSignal( new BN(ISSUANCE_PER_BLOCK.toString()), new BN(nBlocks.toString()), @@ -133,17 +133,17 @@ describe('Rewards', () => { } before(async function () { - ;[delegator, curator1, curator2, indexer1, indexer2, oracle, assetHolder] = - await graph.getTestAccounts() + [delegator, curator1, curator2, indexer1, indexer2, oracle, assetHolder] + = await graph.getTestAccounts() ;({ governor } = await graph.getNamedAccounts()) fixture = new NetworkFixture(graph.provider) contracts = await fixture.load(governor) grt = contracts.GraphToken as GraphToken curation = contracts.Curation as Curation - epochManager = contracts.EpochManager as EpochManager + epochManager = contracts.EpochManager staking = contracts.Staking as IStaking - rewardsManager = contracts.RewardsManager as RewardsManager + rewardsManager = contracts.RewardsManager // 200 GRT per block await rewardsManager.connect(governor).setIssuancePerBlock(ISSUANCE_PER_BLOCK) @@ -231,7 +231,7 @@ describe('Rewards', () => { }) }) - context('issuing rewards', async function () { + context('issuing rewards', function () { beforeEach(async function () { // 5% minute rate (4 blocks) await rewardsManager.connect(governor).setIssuancePerBlock(ISSUANCE_PER_BLOCK) @@ -327,8 +327,8 @@ describe('Rewards', () => { await tracker2.snapshot() // Calculate rewards - const rewardsPerSignal1 = await tracker1.accumulated - const rewardsPerSignal2 = await tracker2.accumulated + const rewardsPerSignal1 = tracker1.accumulated + const rewardsPerSignal2 = tracker2.accumulated const expectedRewardsSG1 = rewardsPerSignal1.mul(signalled1).div(WeiPerEther) const expectedRewardsSG2 = rewardsPerSignal2.mul(signalled2).div(WeiPerEther) @@ -994,7 +994,7 @@ describe('Rewards', () => { it('collect query fees with two subgraphs and one allocation', async function () { async function getRewardsAccrual(subgraphs) { const [sg1, sg2] = await Promise.all( - subgraphs.map((sg) => rewardsManager.getAccRewardsForSubgraph(sg)), + subgraphs.map(sg => rewardsManager.getAccRewardsForSubgraph(sg)), ) return { sg1, @@ -1016,14 +1016,14 @@ describe('Rewards', () => { } // snapshot block before any accrual (we substract 1 because accrual starts after the first mint happens) - const b1 = await epochManager.blockNum().then((x) => x.toNumber() - 1) + const b1 = await epochManager.blockNum().then(x => x.toNumber() - 1) // allocate const tokensToAllocate = toGRT('12500') await staking .connect(indexer1) .multicall([ - await staking.populateTransaction.stake(tokensToAllocate).then((tx) => tx.data), + await staking.populateTransaction.stake(tokensToAllocate).then(tx => tx.data), await staking.populateTransaction .allocateFrom( indexer1.address, @@ -1033,7 +1033,7 @@ describe('Rewards', () => { metadata, await channelKey1.generateProof(indexer1.address), ) - .then((tx) => tx.data), + .then(tx => tx.data), ]) // move time fwd @@ -1047,7 +1047,7 @@ describe('Rewards', () => { await helpers.mine() const accrual = await getRewardsAccrual(subgraphs) - const b2 = await epochManager.blockNum().then((x) => x.toNumber()) + const b2 = await epochManager.blockNum().then(x => x.toNumber()) // round comparison because there is a small precision error due to dividing and accrual per signal expect(toRound(accrual.all)).eq(toRound(ISSUANCE_PER_BLOCK.mul(b2 - b1))) diff --git a/packages/contracts/test/unit/serviceRegisty.test.ts b/packages/contracts/test/unit/serviceRegisty.test.ts index 3438762e0..d84b4aa88 100644 --- a/packages/contracts/test/unit/serviceRegisty.test.ts +++ b/packages/contracts/test/unit/serviceRegisty.test.ts @@ -34,11 +34,11 @@ describe('ServiceRegistry', () => { } before(async function () { - ;[governor, indexer, operator] = await graph.getTestAccounts() + [governor, indexer, operator] = await graph.getTestAccounts() ;({ governor } = await graph.getNamedAccounts()) fixture = new NetworkFixture(graph.provider) contracts = await fixture.load(governor) - serviceRegistry = contracts.ServiceRegistry as ServiceRegistry + serviceRegistry = contracts.ServiceRegistry staking = contracts.Staking as IStaking }) diff --git a/packages/contracts/test/unit/staking/allocation.test.ts b/packages/contracts/test/unit/staking/allocation.test.ts index bb9860fbc..92afedca4 100644 --- a/packages/contracts/test/unit/staking/allocation.test.ts +++ b/packages/contracts/test/unit/staking/allocation.test.ts @@ -1,6 +1,6 @@ import hre from 'hardhat' import { expect } from 'chai' -import { constants, BigNumber, PopulatedTransaction, Contract } from 'ethers' +import { BigNumber, constants, Contract, PopulatedTransaction } from 'ethers' import { Curation } from '../../../build/types/Curation' import { EpochManager } from '../../../build/types/EpochManager' @@ -10,8 +10,8 @@ import { LibExponential } from '../../../build/types/LibExponential' import { NetworkFixture } from '../lib/fixtures' import { - GraphNetworkContracts, deriveChannelKey, + GraphNetworkContracts, helpers, isGraphL1ChainId, randomHexBytes, @@ -84,7 +84,6 @@ describe('Staking:Allocation', () => { let governor: SignerWithAddress let indexer: SignerWithAddress let delegator: SignerWithAddress - let slasher: SignerWithAddress let assetHolder: SignerWithAddress let fixture: NetworkFixture @@ -171,7 +170,7 @@ describe('Staking:Allocation', () => { allocationID?: string expectEvent?: boolean } = {}, - ): Promise<{ queryRebates: BigNumber; queryFeesBurnt: BigNumber }> => { + ): Promise<{ queryRebates: BigNumber, queryFeesBurnt: BigNumber }> => { const expectEvent = options.expectEvent ?? true const alloID = options.allocationID ?? allocationID const alloStateBefore = await staking.getAllocationState(alloID) @@ -201,8 +200,8 @@ describe('Staking:Allocation', () => { const queryFees = tokensToCollect.sub(protocolFees).sub(curationFees) - const [alphaNumerator, alphaDenominator, lambdaNumerator, lambdaDenominator] = - await Promise.all([ + const [alphaNumerator, alphaDenominator, lambdaNumerator, lambdaDenominator] + = await Promise.all([ staking.alphaNumerator(), staking.alphaDenominator(), staking.lambdaNumerator(), @@ -367,13 +366,13 @@ describe('Staking:Allocation', () => { // -- Tests -- before(async function () { - ;[me, indexer, delegator, slasher, assetHolder] = await graph.getTestAccounts() + [me, indexer, delegator, assetHolder] = await graph.getTestAccounts() ;({ governor } = await graph.getNamedAccounts()) fixture = new NetworkFixture(graph.provider) contracts = await fixture.load(governor) curation = contracts.Curation as Curation - epochManager = contracts.EpochManager as EpochManager + epochManager = contracts.EpochManager grt = contracts.GraphToken as GraphToken staking = contracts.Staking as IStaking @@ -624,7 +623,7 @@ describe('Staking:Allocation', () => { `> with ${toPercentage(params.curationPercentage)}% curationFees, ${toPercentage( params.protocolPercentage, )}% protocolTax and ${toPercentage(params.queryFeeCut)}% queryFeeCut`, - async function () { + function () { beforeEach(async function () { // Set a protocol fee percentage await staking.connect(governor).setProtocolPercentage(params.protocolPercentage) @@ -860,7 +859,7 @@ describe('Staking:Allocation', () => { }) for (const tokensToAllocate of [toBN(100), toBN(0)]) { - context(`> with ${tokensToAllocate} allocated tokens`, async function () { + context(`> with ${tokensToAllocate.toString()} allocated tokens`, function () { beforeEach(async function () { // Advance to next epoch to avoid creating the allocation // right at the epoch boundary, which would mess up the tests. @@ -994,7 +993,7 @@ describe('Staking:Allocation', () => { ].map(({ allocationID, poi }) => staking.connect(indexer).populateTransaction.closeAllocation(allocationID, poi), ), - ).then((e) => e.map((e: PopulatedTransaction) => e.data)) + ).then(e => e.map((e: PopulatedTransaction) => e.data)) await staking.connect(indexer).multicall(requests) }) }) @@ -1029,7 +1028,7 @@ describe('Staking:Allocation', () => { metadata, await newChannelKey.generateProof(indexer.address), ), - ]).then((e) => e.map((e: PopulatedTransaction) => e.data)) + ]).then(e => e.map((e: PopulatedTransaction) => e.data)) await staking.connect(indexer).multicall(requests) }) }) diff --git a/packages/contracts/test/unit/staking/configuration.test.ts b/packages/contracts/test/unit/staking/configuration.test.ts index e95f65b0e..44f9d5bd0 100644 --- a/packages/contracts/test/unit/staking/configuration.test.ts +++ b/packages/contracts/test/unit/staking/configuration.test.ts @@ -7,7 +7,7 @@ import { IStaking } from '../../../build/types/IStaking' import { NetworkFixture } from '../lib/fixtures' import { GraphProxyAdmin } from '../../../build/types/GraphProxyAdmin' -import { DeployType, GraphNetworkContracts, deploy, toBN, toGRT } from '@graphprotocol/sdk' +import { deploy, DeployType, GraphNetworkContracts, toBN, toGRT } from '@graphprotocol/sdk' import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers' const { AddressZero } = constants @@ -16,12 +16,10 @@ const MAX_PPM = toBN('1000000') describe('Staking:Config', () => { const graph = hre.graph() - const defaults = graph.graphConfig.defaults let me: SignerWithAddress let other: SignerWithAddress let governor: SignerWithAddress - let slasher: SignerWithAddress let fixture: NetworkFixture @@ -30,13 +28,13 @@ describe('Staking:Config', () => { let proxyAdmin: GraphProxyAdmin before(async function () { - ;[me, other, slasher] = await graph.getTestAccounts() + [me, other] = await graph.getTestAccounts() ;({ governor } = await graph.getNamedAccounts()) fixture = new NetworkFixture(graph.provider) contracts = await fixture.load(governor) staking = contracts.Staking as IStaking - proxyAdmin = contracts.GraphProxyAdmin as GraphProxyAdmin + proxyAdmin = contracts.GraphProxyAdmin }) beforeEach(async function () { diff --git a/packages/contracts/test/unit/staking/delegation.test.ts b/packages/contracts/test/unit/staking/delegation.test.ts index 50cf0cbb0..f866be9c6 100644 --- a/packages/contracts/test/unit/staking/delegation.test.ts +++ b/packages/contracts/test/unit/staking/delegation.test.ts @@ -1,6 +1,6 @@ import hre from 'hardhat' import { expect } from 'chai' -import { constants, BigNumber } from 'ethers' +import { BigNumber, constants } from 'ethers' import { EpochManager } from '../../../build/types/EpochManager' import { GraphToken } from '../../../build/types/GraphToken' @@ -8,8 +8,8 @@ import { IStaking } from '../../../build/types/IStaking' import { NetworkFixture } from '../lib/fixtures' import { - GraphNetworkContracts, deriveChannelKey, + GraphNetworkContracts, helpers, randomHexBytes, toBN, @@ -183,13 +183,13 @@ describe('Staking::Delegation', () => { } before(async function () { - ;[me, delegator, delegator2, governor, indexer, indexer2, assetHolder] = - await graph.getTestAccounts() + [me, delegator, delegator2, governor, indexer, indexer2, assetHolder] + = await graph.getTestAccounts() ;({ governor } = await graph.getNamedAccounts()) fixture = new NetworkFixture(graph.provider) contracts = await fixture.load(governor) - epochManager = contracts.EpochManager as EpochManager + epochManager = contracts.EpochManager grt = contracts.GraphToken as GraphToken staking = contracts.Staking as IStaking diff --git a/packages/contracts/test/unit/staking/l2Transfer.test.ts b/packages/contracts/test/unit/staking/l2Transfer.test.ts index b304aa55f..31be6c044 100644 --- a/packages/contracts/test/unit/staking/l2Transfer.test.ts +++ b/packages/contracts/test/unit/staking/l2Transfer.test.ts @@ -1,6 +1,6 @@ import hre from 'hardhat' import { expect } from 'chai' -import { constants, BigNumber } from 'ethers' +import { BigNumber, constants } from 'ethers' import { defaultAbiCoder, parseEther } from 'ethers/lib/utils' import { GraphToken } from '../../../build/types/GraphToken' @@ -13,10 +13,10 @@ import { L1GraphTokenLockTransferToolBadMock } from '../../../build/types/L1Grap import { NetworkFixture } from '../lib/fixtures' import { - DeployType, - GraphNetworkContracts, deploy, + DeployType, deriveChannelKey, + GraphNetworkContracts, helpers, randomHexBytes, toBN, @@ -79,7 +79,7 @@ describe('L1Staking:L2Transfer', () => { } before(async function () { - ;[indexer, delegator, l2Indexer, l2Delegator] = await graph.getTestAccounts() + [indexer, delegator, l2Indexer, l2Delegator] = await graph.getTestAccounts() ;({ governor } = await graph.getNamedAccounts()) fixture = new NetworkFixture(graph.provider) @@ -88,7 +88,7 @@ describe('L1Staking:L2Transfer', () => { fixtureContracts = await fixture.load(governor) grt = fixtureContracts.GraphToken as GraphToken staking = fixtureContracts.L1Staking as unknown as IL1Staking - l1GraphTokenGateway = fixtureContracts.L1GraphTokenGateway as L1GraphTokenGateway + l1GraphTokenGateway = fixtureContracts.L1GraphTokenGateway controller = fixtureContracts.Controller as IController // Deploy L1 arbitrum bridge @@ -96,8 +96,8 @@ describe('L1Staking:L2Transfer', () => { // Deploy L2 mock l2MockContracts = await fixture.loadMock(true) - l2StakingMock = l2MockContracts.L2Staking as L2Staking - l2GRTGatewayMock = l2MockContracts.L2GraphTokenGateway as L2GraphTokenGateway + l2StakingMock = l2MockContracts.L2Staking + l2GRTGatewayMock = l2MockContracts.L2GraphTokenGateway // Configure graph bridge await fixture.configureL1Bridge(governor, fixtureContracts, l2MockContracts) diff --git a/packages/contracts/test/unit/staking/rebate.test.ts b/packages/contracts/test/unit/staking/rebate.test.ts index e05ad9a7c..7eb989fdc 100644 --- a/packages/contracts/test/unit/staking/rebate.test.ts +++ b/packages/contracts/test/unit/staking/rebate.test.ts @@ -4,7 +4,7 @@ import { BigNumber, Contract } from 'ethers' import { LibExponential } from '../../../build/types/LibExponential' -import { formatGRT, helpers, isGraphL1ChainId, toGRT } from '@graphprotocol/sdk' +import { formatGRT, isGraphL1ChainId, toGRT } from '@graphprotocol/sdk' import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers' import { NetworkFixture } from '../lib/fixtures' @@ -94,6 +94,7 @@ export function exponentialRebates( } const exponent = (lambda * stake) / fees + // eslint-disable-next-line no-secrets/no-secrets // LibExponential.MAX_EXPONENT = 15 if (exponent > 15) { return fees @@ -163,7 +164,7 @@ describe('Staking:rebates', () => { } } - async function testRebateParameters(fn, testCases) { + function testRebateParameters(fn, testCases) { // *** Exponential rebates *** // Typical alpha and lambda it('alpha 1 - lambda 0.6', async function () { @@ -209,7 +210,7 @@ describe('Staking:rebates', () => { } before(async function () { - ;({ governor } = await graph.getNamedAccounts()) + ({ governor } = await graph.getNamedAccounts()) fixture = new NetworkFixture(graph.provider) await fixture.load(governor) diff --git a/packages/contracts/test/unit/staking/staking.test.ts b/packages/contracts/test/unit/staking/staking.test.ts index 04775a272..6fe5fdcb0 100644 --- a/packages/contracts/test/unit/staking/staking.test.ts +++ b/packages/contracts/test/unit/staking/staking.test.ts @@ -1,6 +1,6 @@ import hre from 'hardhat' import { expect } from 'chai' -import { constants, BigNumber, Event } from 'ethers' +import { BigNumber, constants, Event } from 'ethers' import { GraphToken } from '../../../build/types/GraphToken' import { IStaking } from '../../../build/types/IStaking' @@ -8,8 +8,8 @@ import { IStaking } from '../../../build/types/IStaking' import { NetworkFixture } from '../lib/fixtures' import { - GraphNetworkContracts, deriveChannelKey, + GraphNetworkContracts, helpers, randomHexBytes, toBN, @@ -84,7 +84,7 @@ describe('Staking:Stakes', () => { } before(async function () { - ;[me, indexer, slasher, fisherman] = await graph.getTestAccounts() + [me, indexer, slasher, fisherman] = await graph.getTestAccounts() ;({ governor } = await graph.getNamedAccounts()) fixture = new NetworkFixture(graph.provider) contracts = await fixture.load(governor) @@ -242,7 +242,6 @@ describe('Staking:Stakes', () => { it('should always increase the thawing period on subsequent unstakes', async function () { const tokensToUnstake = toGRT('10') const tokensToUnstakeSecondTime = toGRT('0.000001') - const thawingPeriod = toBN(await staking.thawingPeriod()) // Unstake (1) const tx1 = await staking.connect(indexer).unstake(tokensToUnstake) @@ -253,9 +252,6 @@ describe('Staking:Stakes', () => { // Move forward before the tokens are unlocked for withdrawal await helpers.mineUpTo(tokensLockedUntil1.sub(5)) - // Calculate locking time for tokens taking into account the previous unstake request - const currentBlock = await helpers.latestBlock() - // Ensure at least 1 block is added (i.e. the weighted average rounds up) const expectedLockedUntil = tokensLockedUntil1.add(1) diff --git a/packages/contracts/test/unit/upgrade/admin.test.ts b/packages/contracts/test/unit/upgrade/admin.test.ts index 65b353970..f18cfa0fa 100644 --- a/packages/contracts/test/unit/upgrade/admin.test.ts +++ b/packages/contracts/test/unit/upgrade/admin.test.ts @@ -10,7 +10,7 @@ import { IStaking } from '../../../build/types/IStaking' import { NetworkFixture } from '../lib/fixtures' import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers' -import { DeployType, GraphNetworkContracts, deploy, loadContractAt } from '@graphprotocol/sdk' +import { deploy, DeployType, GraphNetworkContracts, loadContractAt } from '@graphprotocol/sdk' const { ethers } = hre const { AddressZero } = ethers.constants @@ -29,12 +29,12 @@ describe('Upgrades', () => { let stakingProxy: GraphProxy before(async function () { - ;[me, governor] = await graph.getTestAccounts() + [me, governor] = await graph.getTestAccounts() fixture = new NetworkFixture(graph.provider) contracts = await fixture.load(governor) staking = contracts.Staking as IStaking - proxyAdmin = contracts.GraphProxyAdmin as GraphProxyAdmin + proxyAdmin = contracts.GraphProxyAdmin curation = contracts.Curation as Curation stakingProxy = loadContractAt('GraphProxy', staking.address, undefined, governor) as GraphProxy @@ -59,7 +59,7 @@ describe('Upgrades', () => { it('reject get admin from other than the ProxyAdmin', async function () { await expect(stakingProxy.connect(governor).admin()).revertedWith( - "function selector was not recognized and there's no fallback function", + 'function selector was not recognized and there\'s no fallback function', ) }) }) @@ -72,7 +72,7 @@ describe('Upgrades', () => { it('reject get implementation from other than the ProxyAdmin', async function () { await expect(stakingProxy.implementation()).revertedWith( - "function selector was not recognized and there's no fallback function", + 'function selector was not recognized and there\'s no fallback function', ) }) }) @@ -87,7 +87,7 @@ describe('Upgrades', () => { it('reject get pending implementation from other than the ProxyAdmin', async function () { await expect(stakingProxy.connect(governor).pendingImplementation()).revertedWith( - "function selector was not recognized and there's no fallback function", + 'function selector was not recognized and there\'s no fallback function', ) }) }) @@ -134,7 +134,7 @@ describe('Upgrades', () => { // Due to the transparent proxy we should not be able to upgrade from other than the proxy admin const tx = stakingProxy.connect(governor).upgradeTo(newImplementationAddress) await expect(tx).revertedWith( - "function selector was not recognized and there's no fallback function", + 'function selector was not recognized and there\'s no fallback function', ) }) }) @@ -144,7 +144,7 @@ describe('Upgrades', () => { // Due to the transparent proxy we should not be able to accept upgrades from other than the proxy admin const tx = stakingProxy.connect(governor).acceptUpgrade() await expect(tx).revertedWith( - "function selector was not recognized and there's no fallback function", + 'function selector was not recognized and there\'s no fallback function', ) }) }) @@ -185,7 +185,7 @@ describe('Upgrades', () => { .connect(governor) .changeProxyAdmin(staking.address, otherProxyAdmin.address) await expect(tx).revertedWith( - "function selector was not recognized and there's no fallback function", + 'function selector was not recognized and there\'s no fallback function', ) }) @@ -202,7 +202,7 @@ describe('Upgrades', () => { // Due to the transparent proxy we should not be able to set admin from other than the proxy admin const tx = stakingProxy.connect(governor).setAdmin(me.address) await expect(tx).revertedWith( - "function selector was not recognized and there's no fallback function", + 'function selector was not recognized and there\'s no fallback function', ) }) }) diff --git a/packages/contracts/tsconfig.json b/packages/contracts/tsconfig.json index 791b4375e..60037c936 100644 --- a/packages/contracts/tsconfig.json +++ b/packages/contracts/tsconfig.json @@ -8,5 +8,14 @@ "resolveJsonModule": true, "esModuleInterop": true }, - "include": ["hardhat.config.ts", "index.d.ts", "scripts/**/*.ts", "test/**/*.ts", "tasks/**/*.ts"] + "include": [ + ".solcover.js", + "truffle.js", + "eslint.config.js", + "hardhat.config.ts", + "index.d.ts", + "scripts/**/*.ts", + "test/**/*.ts", + "tasks/**/*.ts" + ] } diff --git a/yarn.lock b/yarn.lock index bbf7d9297..cdb16edb9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -140,15 +140,6 @@ __metadata: languageName: node linkType: hard -"@babel/code-frame@npm:7.12.11": - version: 7.12.11 - resolution: "@babel/code-frame@npm:7.12.11" - dependencies: - "@babel/highlight": "npm:^7.10.4" - checksum: 836ffd155506768e991d6dd8c51db37cad5958ed1c8e0a2329ccd9527165d5c752e943d66a5c3c92ffd45f343419f0742e7636629a529f4fbd5303e3637746b9 - languageName: node - linkType: hard - "@babel/code-frame@npm:^7.0.0, @babel/code-frame@npm:^7.23.5": version: 7.23.5 resolution: "@babel/code-frame@npm:7.23.5" @@ -389,7 +380,7 @@ __metadata: languageName: node linkType: hard -"@babel/highlight@npm:^7.10.4, @babel/highlight@npm:^7.23.4": +"@babel/highlight@npm:^7.23.4": version: 7.23.4 resolution: "@babel/highlight@npm:7.23.4" dependencies: @@ -1396,23 +1387,6 @@ __metadata: languageName: node linkType: hard -"@eslint/eslintrc@npm:^0.4.3": - version: 0.4.3 - resolution: "@eslint/eslintrc@npm:0.4.3" - dependencies: - ajv: "npm:^6.12.4" - debug: "npm:^4.1.1" - espree: "npm:^7.3.0" - globals: "npm:^13.9.0" - ignore: "npm:^4.0.6" - import-fresh: "npm:^3.2.1" - js-yaml: "npm:^3.13.1" - minimatch: "npm:^3.0.4" - strip-json-comments: "npm:^3.1.1" - checksum: 0eed93369f72ef044686d07824742121f9b95153ff34f4614e4e69d64332ee68c84eb70da851a9005bb76b3d1d64ad76c2e6293a808edc0f7dfb883689ca136d - languageName: node - linkType: hard - "@eslint/eslintrc@npm:^2.1.4": version: 2.1.4 resolution: "@eslint/eslintrc@npm:2.1.4" @@ -1437,6 +1411,13 @@ __metadata: languageName: node linkType: hard +"@eslint/js@npm:8.57.0": + version: 8.57.0 + resolution: "@eslint/js@npm:8.57.0" + checksum: 9a518bb8625ba3350613903a6d8c622352ab0c6557a59fe6ff6178bf882bf57123f9d92aa826ee8ac3ee74b9c6203fe630e9ee00efb03d753962dcf65ee4bd94 + languageName: node + linkType: hard + "@ethereum-waffle/chai@npm:^3.4.4": version: 3.4.4 resolution: "@ethereum-waffle/chai@npm:3.4.4" @@ -2666,8 +2647,6 @@ __metadata: "@types/sinon-chai": "npm:^3.2.12" "@types/winston": "npm:^2.4.4" "@types/yargs": "npm:^16.0.0" - "@typescript-eslint/eslint-plugin": "npm:^4.0.0" - "@typescript-eslint/parser": "npm:^4.0.0" "@urql/core": "npm:^2.1.3" arbos-precompiles: "npm:^1.0.2" bignumber.js: "npm:^9.0.0" @@ -2676,10 +2655,8 @@ __metadata: cli-table: "npm:^0.3.6" console-table-printer: "npm:^2.11.1" dotenv: "npm:^9.0.0" - eslint: "npm:^7.24.0" - eslint-config-prettier: "npm:^8.3.0" - eslint-plugin-no-only-tests: "npm:^2.4.0" - eslint-plugin-prettier: "npm:^3.4.0" + eslint: "npm:^8.57.0" + eslint-graph-config: "workspace:^0.0.1" ethereum-waffle: "npm:^3.2.0" ethers: "npm:^5.7.2" form-data: "npm:^4.0.0" @@ -2697,10 +2674,7 @@ __metadata: isomorphic-fetch: "npm:^3.0.0" lint-staged: "npm:^10.5.4" p-queue: "npm:^6.6.1" - prettier: "npm:^2.2.1" - prettier-plugin-solidity: "npm:1.0.0-beta.19" solhint: "npm:^3.3.6" - solhint-plugin-prettier: "npm:^0.0.5" solidity-coverage: "npm:^0.7.16" ts-node: "npm:^10.9.1" typechain: "npm:^5.0.0" @@ -3673,7 +3647,7 @@ __metadata: languageName: node linkType: hard -"@humanwhocodes/config-array@npm:^0.11.13": +"@humanwhocodes/config-array@npm:^0.11.13, @humanwhocodes/config-array@npm:^0.11.14": version: 0.11.14 resolution: "@humanwhocodes/config-array@npm:0.11.14" dependencies: @@ -3684,17 +3658,6 @@ __metadata: languageName: node linkType: hard -"@humanwhocodes/config-array@npm:^0.5.0": - version: 0.5.0 - resolution: "@humanwhocodes/config-array@npm:0.5.0" - dependencies: - "@humanwhocodes/object-schema": "npm:^1.2.0" - debug: "npm:^4.1.1" - minimatch: "npm:^3.0.4" - checksum: 217fac9e03492361825a2bf761d4bb7ec6d10002a10f7314142245eb13ac9d123523d24d5619c3c4159af215c7b3e583ed386108e227014bef4efbf9caca8ccc - languageName: node - linkType: hard - "@humanwhocodes/module-importer@npm:^1.0.1": version: 1.0.1 resolution: "@humanwhocodes/module-importer@npm:1.0.1" @@ -3702,13 +3665,6 @@ __metadata: languageName: node linkType: hard -"@humanwhocodes/object-schema@npm:^1.2.0": - version: 1.2.1 - resolution: "@humanwhocodes/object-schema@npm:1.2.1" - checksum: c3c35fdb70c04a569278351c75553e293ae339684ed75895edc79facc7276e351115786946658d78133130c0cca80e57e2203bc07f8fa7fe7980300e8deef7db - languageName: node - linkType: hard - "@humanwhocodes/object-schema@npm:^2.0.2": version: 2.0.2 resolution: "@humanwhocodes/object-schema@npm:2.0.2" @@ -5375,7 +5331,7 @@ __metadata: languageName: node linkType: hard -"@types/json-schema@npm:*, @types/json-schema@npm:^7.0.12, @types/json-schema@npm:^7.0.7, @types/json-schema@npm:^7.0.9": +"@types/json-schema@npm:*, @types/json-schema@npm:^7.0.12, @types/json-schema@npm:^7.0.9": version: 7.0.15 resolution: "@types/json-schema@npm:7.0.15" checksum: a996a745e6c5d60292f36731dd41341339d4eeed8180bb09226e5c8d23759067692b1d88e5d91d72ee83dfc00d3aca8e7bd43ea120516c17922cbcb7c3e252db @@ -5702,28 +5658,6 @@ __metadata: languageName: node linkType: hard -"@typescript-eslint/eslint-plugin@npm:^4.0.0": - version: 4.33.0 - resolution: "@typescript-eslint/eslint-plugin@npm:4.33.0" - dependencies: - "@typescript-eslint/experimental-utils": "npm:4.33.0" - "@typescript-eslint/scope-manager": "npm:4.33.0" - debug: "npm:^4.3.1" - functional-red-black-tree: "npm:^1.0.1" - ignore: "npm:^5.1.8" - regexpp: "npm:^3.1.0" - semver: "npm:^7.3.5" - tsutils: "npm:^3.21.0" - peerDependencies: - "@typescript-eslint/parser": ^4.0.0 - eslint: ^5.0.0 || ^6.0.0 || ^7.0.0 - peerDependenciesMeta: - typescript: - optional: true - checksum: c1e1e424e257fa6e5e8b18d7ff77e8a983a761f4acc0cd58ebd31de8ec56c8c472689989cff0290eee41457662a1e664b555cf74bfc1b37bdf8c87ccac2a4663 - languageName: node - linkType: hard - "@typescript-eslint/eslint-plugin@npm:^6.8.0": version: 6.21.0 resolution: "@typescript-eslint/eslint-plugin@npm:6.21.0" @@ -5749,22 +5683,6 @@ __metadata: languageName: node linkType: hard -"@typescript-eslint/experimental-utils@npm:4.33.0": - version: 4.33.0 - resolution: "@typescript-eslint/experimental-utils@npm:4.33.0" - dependencies: - "@types/json-schema": "npm:^7.0.7" - "@typescript-eslint/scope-manager": "npm:4.33.0" - "@typescript-eslint/types": "npm:4.33.0" - "@typescript-eslint/typescript-estree": "npm:4.33.0" - eslint-scope: "npm:^5.1.1" - eslint-utils: "npm:^3.0.0" - peerDependencies: - eslint: "*" - checksum: bb2a48c9df21ef06ccbcd083753b8c51b30a46cde67ab56d278b30ad7868d2e07641e51b6f7fb54437dcb7aff134fac44708e730e2b8f6e43027fefe8629bcb9 - languageName: node - linkType: hard - "@typescript-eslint/parser@npm:7.0.2": version: 7.0.2 resolution: "@typescript-eslint/parser@npm:7.0.2" @@ -5783,23 +5701,6 @@ __metadata: languageName: node linkType: hard -"@typescript-eslint/parser@npm:^4.0.0": - version: 4.33.0 - resolution: "@typescript-eslint/parser@npm:4.33.0" - dependencies: - "@typescript-eslint/scope-manager": "npm:4.33.0" - "@typescript-eslint/types": "npm:4.33.0" - "@typescript-eslint/typescript-estree": "npm:4.33.0" - debug: "npm:^4.3.1" - peerDependencies: - eslint: ^5.0.0 || ^6.0.0 || ^7.0.0 - peerDependenciesMeta: - typescript: - optional: true - checksum: d6f91479b2c0d0ff20ac2dbc7540b28c175fd834a220a4f227209f6c74c55401ac6bd41b2bb4cf40b3ba7761075ccded2019bfc6096c2e4f273bd4ae86c44172 - languageName: node - linkType: hard - "@typescript-eslint/parser@npm:^6.8.0": version: 6.21.0 resolution: "@typescript-eslint/parser@npm:6.21.0" @@ -5818,16 +5719,6 @@ __metadata: languageName: node linkType: hard -"@typescript-eslint/scope-manager@npm:4.33.0": - version: 4.33.0 - resolution: "@typescript-eslint/scope-manager@npm:4.33.0" - dependencies: - "@typescript-eslint/types": "npm:4.33.0" - "@typescript-eslint/visitor-keys": "npm:4.33.0" - checksum: 1dfe65777eeb430c1ef778bdad35e6065d4b3075ddb2639d0747d8db93c02eebf6832ba82388a7f80662e0e9f61f1922fe939b53a20889e11fb9f80c4029c6b7 - languageName: node - linkType: hard - "@typescript-eslint/scope-manager@npm:6.21.0": version: 6.21.0 resolution: "@typescript-eslint/scope-manager@npm:6.21.0" @@ -5882,13 +5773,6 @@ __metadata: languageName: node linkType: hard -"@typescript-eslint/types@npm:4.33.0": - version: 4.33.0 - resolution: "@typescript-eslint/types@npm:4.33.0" - checksum: 6c94780a589eca7a75ae2b014f320bc412b50794c39ab04889918bb39a40e72584b65c8c0b035330cb0599579afaa3adccee40701f63cf39c0e89299de199d4b - languageName: node - linkType: hard - "@typescript-eslint/types@npm:6.21.0": version: 6.21.0 resolution: "@typescript-eslint/types@npm:6.21.0" @@ -5903,24 +5787,6 @@ __metadata: languageName: node linkType: hard -"@typescript-eslint/typescript-estree@npm:4.33.0": - version: 4.33.0 - resolution: "@typescript-eslint/typescript-estree@npm:4.33.0" - dependencies: - "@typescript-eslint/types": "npm:4.33.0" - "@typescript-eslint/visitor-keys": "npm:4.33.0" - debug: "npm:^4.3.1" - globby: "npm:^11.0.3" - is-glob: "npm:^4.0.1" - semver: "npm:^7.3.5" - tsutils: "npm:^3.21.0" - peerDependenciesMeta: - typescript: - optional: true - checksum: 67609a7bdd680136765d103dec4b8afb38a17436e8a5cd830da84f62c6153c3acba561da3b9e2140137b1a0bcbbfc19d4256c692f7072acfebcff88db079e22b - languageName: node - linkType: hard - "@typescript-eslint/typescript-estree@npm:6.21.0": version: 6.21.0 resolution: "@typescript-eslint/typescript-estree@npm:6.21.0" @@ -5993,16 +5859,6 @@ __metadata: languageName: node linkType: hard -"@typescript-eslint/visitor-keys@npm:4.33.0": - version: 4.33.0 - resolution: "@typescript-eslint/visitor-keys@npm:4.33.0" - dependencies: - "@typescript-eslint/types": "npm:4.33.0" - eslint-visitor-keys: "npm:^2.0.0" - checksum: 95b3904db6113ef365892567d47365e6af3708e6fa905743426036f99e1b7fd4a275facec5d939afecb618369f9d615e379d39f96b8936f469e75507c41c249c - languageName: node - linkType: hard - "@typescript-eslint/visitor-keys@npm:6.21.0": version: 6.21.0 resolution: "@typescript-eslint/visitor-keys@npm:6.21.0" @@ -6260,7 +6116,7 @@ __metadata: languageName: node linkType: hard -"acorn-jsx@npm:^5.3.1, acorn-jsx@npm:^5.3.2": +"acorn-jsx@npm:^5.3.2": version: 5.3.2 resolution: "acorn-jsx@npm:5.3.2" peerDependencies: @@ -6276,15 +6132,6 @@ __metadata: languageName: node linkType: hard -"acorn@npm:^7.4.0": - version: 7.4.1 - resolution: "acorn@npm:7.4.1" - bin: - acorn: bin/acorn - checksum: bd0b2c2b0f334bbee48828ff897c12bd2eb5898d03bf556dcc8942022cec795ac5bb5b6b585e2de687db6231faf07e096b59a361231dd8c9344d5df5f7f0e526 - languageName: node - linkType: hard - "acorn@npm:^8.11.3, acorn@npm:^8.4.1, acorn@npm:^8.9.0": version: 8.11.3 resolution: "acorn@npm:8.11.3" @@ -6364,7 +6211,7 @@ __metadata: languageName: node linkType: hard -"ajv@npm:^6.10.0, ajv@npm:^6.12.3, ajv@npm:^6.12.4, ajv@npm:^6.12.6": +"ajv@npm:^6.12.3, ajv@npm:^6.12.4, ajv@npm:^6.12.6": version: 6.12.6 resolution: "ajv@npm:6.12.6" dependencies: @@ -9574,7 +9421,7 @@ __metadata: languageName: node linkType: hard -"debug@npm:4, debug@npm:4.3.4, debug@npm:^4.0.1, debug@npm:^4.1.0, debug@npm:^4.1.1, debug@npm:^4.2.0, debug@npm:^4.3.1, debug@npm:^4.3.2, debug@npm:^4.3.3, debug@npm:^4.3.4": +"debug@npm:4, debug@npm:4.3.4, debug@npm:^4.1.0, debug@npm:^4.1.1, debug@npm:^4.2.0, debug@npm:^4.3.1, debug@npm:^4.3.2, debug@npm:^4.3.3, debug@npm:^4.3.4": version: 4.3.4 resolution: "debug@npm:4.3.4" dependencies: @@ -10083,13 +9930,6 @@ __metadata: languageName: node linkType: hard -"emoji-regex@npm:^10.0.0": - version: 10.3.0 - resolution: "emoji-regex@npm:10.3.0" - checksum: b4838e8dcdceb44cf47f59abe352c25ff4fe7857acaf5fb51097c427f6f75b44d052eb907a7a3b86f86bc4eae3a93f5c2b7460abe79c407307e6212d65c91163 - languageName: node - linkType: hard - "emoji-regex@npm:^8.0.0": version: 8.0.0 resolution: "emoji-regex@npm:8.0.0" @@ -10156,7 +9996,7 @@ __metadata: languageName: node linkType: hard -"enquirer@npm:^2.3.0, enquirer@npm:^2.3.5, enquirer@npm:^2.3.6": +"enquirer@npm:^2.3.0, enquirer@npm:^2.3.6": version: 2.4.1 resolution: "enquirer@npm:2.4.1" dependencies: @@ -10397,17 +10237,6 @@ __metadata: languageName: node linkType: hard -"eslint-config-prettier@npm:^8.3.0": - version: 8.10.0 - resolution: "eslint-config-prettier@npm:8.10.0" - peerDependencies: - eslint: ">=7.0.0" - bin: - eslint-config-prettier: bin/cli.js - checksum: 19f8c497d9bdc111a17a61b25ded97217be3755bbc4714477dfe535ed539dddcaf42ef5cf8bb97908b058260cf89a3d7c565cb0be31096cbcd39f4c2fa5fe43c - languageName: node - linkType: hard - "eslint-config-prettier@npm:^9.0.0": version: 9.1.0 resolution: "eslint-config-prettier@npm:9.1.0" @@ -10419,7 +10248,7 @@ __metadata: languageName: node linkType: hard -"eslint-graph-config@workspace:^, eslint-graph-config@workspace:packages/eslint-graph-config": +"eslint-graph-config@workspace:^, eslint-graph-config@workspace:^0.0.1, eslint-graph-config@workspace:packages/eslint-graph-config": version: 0.0.0-use.local resolution: "eslint-graph-config@workspace:packages/eslint-graph-config" dependencies: @@ -10436,13 +10265,6 @@ __metadata: languageName: unknown linkType: soft -"eslint-plugin-no-only-tests@npm:^2.4.0": - version: 2.6.0 - resolution: "eslint-plugin-no-only-tests@npm:2.6.0" - checksum: 23e0a65f7483fac71073535a12567dab1a32fa2fb1e993cac60bbb93409f669ee98a2a296c3a4f862aefa76850a1576c17511cb21e6e2470a58a8c6f9b6f3043 - languageName: node - linkType: hard - "eslint-plugin-no-only-tests@npm:^3.1.0": version: 3.1.0 resolution: "eslint-plugin-no-only-tests@npm:3.1.0" @@ -10459,21 +10281,6 @@ __metadata: languageName: node linkType: hard -"eslint-plugin-prettier@npm:^3.4.0": - version: 3.4.1 - resolution: "eslint-plugin-prettier@npm:3.4.1" - dependencies: - prettier-linter-helpers: "npm:^1.0.0" - peerDependencies: - eslint: ">=5.0.0" - prettier: ">=1.13.0" - peerDependenciesMeta: - eslint-config-prettier: - optional: true - checksum: b2599dd22b5b0d2e3baffc94ba55a33ed525d642125d657fbc8511a2458146bdcc2bc810418713bb0049e37765def92b51213a4467984f4c758807bea224d0c5 - languageName: node - linkType: hard - "eslint-plugin-prettier@npm:^5.0.1": version: 5.1.3 resolution: "eslint-plugin-prettier@npm:5.1.3" @@ -10494,16 +10301,6 @@ __metadata: languageName: node linkType: hard -"eslint-scope@npm:^5.1.1": - version: 5.1.1 - resolution: "eslint-scope@npm:5.1.1" - dependencies: - esrecurse: "npm:^4.3.0" - estraverse: "npm:^4.1.1" - checksum: d30ef9dc1c1cbdece34db1539a4933fe3f9b14e1ffb27ecc85987902ee663ad7c9473bbd49a9a03195a373741e62e2f807c4938992e019b511993d163450e70a - languageName: node - linkType: hard - "eslint-scope@npm:^7.2.2": version: 7.2.2 resolution: "eslint-scope@npm:7.2.2" @@ -10514,40 +10311,6 @@ __metadata: languageName: node linkType: hard -"eslint-utils@npm:^2.1.0": - version: 2.1.0 - resolution: "eslint-utils@npm:2.1.0" - dependencies: - eslint-visitor-keys: "npm:^1.1.0" - checksum: 69521c5d6569384b24093125d037ba238d3d6e54367f7143af9928f5286369e912c26cad5016d730c0ffb9797ac9e83831059d7f1d863f7dc84330eb02414611 - languageName: node - linkType: hard - -"eslint-utils@npm:^3.0.0": - version: 3.0.0 - resolution: "eslint-utils@npm:3.0.0" - dependencies: - eslint-visitor-keys: "npm:^2.0.0" - peerDependencies: - eslint: ">=5" - checksum: 45aa2b63667a8d9b474c98c28af908d0a592bed1a4568f3145cd49fb5d9510f545327ec95561625290313fe126e6d7bdfe3fdbdb6f432689fab6b9497d3bfb52 - languageName: node - linkType: hard - -"eslint-visitor-keys@npm:^1.1.0, eslint-visitor-keys@npm:^1.3.0": - version: 1.3.0 - resolution: "eslint-visitor-keys@npm:1.3.0" - checksum: 10c91fdbbe36810dd4308e57f9a8bc7177188b2a70247e54e3af1fa05ebc66414ae6fd4ce3c6c6821591f43a556e9037bc6b071122e099b5f8b7d2f76df553e3 - languageName: node - linkType: hard - -"eslint-visitor-keys@npm:^2.0.0": - version: 2.1.0 - resolution: "eslint-visitor-keys@npm:2.1.0" - checksum: 9f0e3a2db751d84067d15977ac4b4472efd6b303e369e6ff241a99feac04da758f46d5add022c33d06b53596038dbae4b4aceb27c7e68b8dfc1055b35e495787 - languageName: node - linkType: hard - "eslint-visitor-keys@npm:^3.3.0, eslint-visitor-keys@npm:^3.4.1, eslint-visitor-keys@npm:^3.4.3": version: 3.4.3 resolution: "eslint-visitor-keys@npm:3.4.3" @@ -10555,65 +10318,63 @@ __metadata: languageName: node linkType: hard -"eslint@npm:^7.24.0": - version: 7.32.0 - resolution: "eslint@npm:7.32.0" +"eslint@npm:^8.52.0, eslint@npm:^8.56.0": + version: 8.56.0 + resolution: "eslint@npm:8.56.0" dependencies: - "@babel/code-frame": "npm:7.12.11" - "@eslint/eslintrc": "npm:^0.4.3" - "@humanwhocodes/config-array": "npm:^0.5.0" - ajv: "npm:^6.10.0" + "@eslint-community/eslint-utils": "npm:^4.2.0" + "@eslint-community/regexpp": "npm:^4.6.1" + "@eslint/eslintrc": "npm:^2.1.4" + "@eslint/js": "npm:8.56.0" + "@humanwhocodes/config-array": "npm:^0.11.13" + "@humanwhocodes/module-importer": "npm:^1.0.1" + "@nodelib/fs.walk": "npm:^1.2.8" + "@ungap/structured-clone": "npm:^1.2.0" + ajv: "npm:^6.12.4" chalk: "npm:^4.0.0" cross-spawn: "npm:^7.0.2" - debug: "npm:^4.0.1" + debug: "npm:^4.3.2" doctrine: "npm:^3.0.0" - enquirer: "npm:^2.3.5" escape-string-regexp: "npm:^4.0.0" - eslint-scope: "npm:^5.1.1" - eslint-utils: "npm:^2.1.0" - eslint-visitor-keys: "npm:^2.0.0" - espree: "npm:^7.3.1" - esquery: "npm:^1.4.0" + eslint-scope: "npm:^7.2.2" + eslint-visitor-keys: "npm:^3.4.3" + espree: "npm:^9.6.1" + esquery: "npm:^1.4.2" esutils: "npm:^2.0.2" fast-deep-equal: "npm:^3.1.3" file-entry-cache: "npm:^6.0.1" - functional-red-black-tree: "npm:^1.0.1" - glob-parent: "npm:^5.1.2" - globals: "npm:^13.6.0" - ignore: "npm:^4.0.6" - import-fresh: "npm:^3.0.0" + find-up: "npm:^5.0.0" + glob-parent: "npm:^6.0.2" + globals: "npm:^13.19.0" + graphemer: "npm:^1.4.0" + ignore: "npm:^5.2.0" imurmurhash: "npm:^0.1.4" is-glob: "npm:^4.0.0" - js-yaml: "npm:^3.13.1" + is-path-inside: "npm:^3.0.3" + js-yaml: "npm:^4.1.0" json-stable-stringify-without-jsonify: "npm:^1.0.1" levn: "npm:^0.4.1" lodash.merge: "npm:^4.6.2" - minimatch: "npm:^3.0.4" + minimatch: "npm:^3.1.2" natural-compare: "npm:^1.4.0" - optionator: "npm:^0.9.1" - progress: "npm:^2.0.0" - regexpp: "npm:^3.1.0" - semver: "npm:^7.2.1" - strip-ansi: "npm:^6.0.0" - strip-json-comments: "npm:^3.1.0" - table: "npm:^6.0.9" + optionator: "npm:^0.9.3" + strip-ansi: "npm:^6.0.1" text-table: "npm:^0.2.0" - v8-compile-cache: "npm:^2.0.3" bin: eslint: bin/eslint.js - checksum: 84409f7767556179cb11529f1215f335c7dfccf90419df6147f949f14c347a960c7b569e80ed84011a0b6d10da1ef5046edbbb9b11c3e59aa6696d5217092e93 + checksum: 2be598f7da1339d045ad933ffd3d4742bee610515cd2b0d9a2b8b729395a01d4e913552fff555b559fccaefd89d7b37632825789d1b06470608737ae69ab43fb languageName: node linkType: hard -"eslint@npm:^8.52.0, eslint@npm:^8.56.0": - version: 8.56.0 - resolution: "eslint@npm:8.56.0" +"eslint@npm:^8.57.0": + version: 8.57.0 + resolution: "eslint@npm:8.57.0" dependencies: "@eslint-community/eslint-utils": "npm:^4.2.0" "@eslint-community/regexpp": "npm:^4.6.1" "@eslint/eslintrc": "npm:^2.1.4" - "@eslint/js": "npm:8.56.0" - "@humanwhocodes/config-array": "npm:^0.11.13" + "@eslint/js": "npm:8.57.0" + "@humanwhocodes/config-array": "npm:^0.11.14" "@humanwhocodes/module-importer": "npm:^1.0.1" "@nodelib/fs.walk": "npm:^1.2.8" "@ungap/structured-clone": "npm:^1.2.0" @@ -10649,7 +10410,7 @@ __metadata: text-table: "npm:^0.2.0" bin: eslint: bin/eslint.js - checksum: 2be598f7da1339d045ad933ffd3d4742bee610515cd2b0d9a2b8b729395a01d4e913552fff555b559fccaefd89d7b37632825789d1b06470608737ae69ab43fb + checksum: 00bb96fd2471039a312435a6776fe1fd557c056755eaa2b96093ef3a8508c92c8775d5f754768be6b1dddd09fdd3379ddb231eeb9b6c579ee17ea7d68000a529 languageName: node linkType: hard @@ -10665,17 +10426,6 @@ __metadata: languageName: node linkType: hard -"espree@npm:^7.3.0, espree@npm:^7.3.1": - version: 7.3.1 - resolution: "espree@npm:7.3.1" - dependencies: - acorn: "npm:^7.4.0" - acorn-jsx: "npm:^5.3.1" - eslint-visitor-keys: "npm:^1.3.0" - checksum: f4e81b903f03eaf0e6925cea20571632da427deb6e14ca37e481f72c11f36d7bb4945fe8a2ff15ab22d078d3cd93ee65355fa94de9c27485c356481775f25d85 - languageName: node - linkType: hard - "espree@npm:^9.6.0, espree@npm:^9.6.1": version: 9.6.1 resolution: "espree@npm:9.6.1" @@ -10707,7 +10457,7 @@ __metadata: languageName: node linkType: hard -"esquery@npm:^1.4.0, esquery@npm:^1.4.2": +"esquery@npm:^1.4.2": version: 1.5.0 resolution: "esquery@npm:1.5.0" dependencies: @@ -10732,13 +10482,6 @@ __metadata: languageName: node linkType: hard -"estraverse@npm:^4.1.1": - version: 4.3.0 - resolution: "estraverse@npm:4.3.0" - checksum: 9cb46463ef8a8a4905d3708a652d60122a0c20bb58dec7e0e12ab0e7235123d74214fc0141d743c381813e1b992767e2708194f6f6e0f9fd00c1b4e0887b8b6d - languageName: node - linkType: hard - "estraverse@npm:^5.1.0, estraverse@npm:^5.2.0, estraverse@npm:^5.3.0": version: 5.3.0 resolution: "estraverse@npm:5.3.0" @@ -12668,7 +12411,7 @@ __metadata: languageName: node linkType: hard -"globals@npm:^13.19.0, globals@npm:^13.6.0, globals@npm:^13.9.0": +"globals@npm:^13.19.0": version: 13.24.0 resolution: "globals@npm:13.24.0" dependencies: @@ -13628,14 +13371,7 @@ __metadata: languageName: node linkType: hard -"ignore@npm:^4.0.6": - version: 4.0.6 - resolution: "ignore@npm:4.0.6" - checksum: 836ee7dc7fd9436096e2dba429359dbb9fa0e33d309e2b2d81692f375f6ca82024fc00567f798613d50c6b989e9cd2ad2b065acf116325cde177f02c86b7d4e0 - languageName: node - linkType: hard - -"ignore@npm:^5.1.1, ignore@npm:^5.1.8, ignore@npm:^5.2.0, ignore@npm:^5.2.4": +"ignore@npm:^5.1.1, ignore@npm:^5.2.0, ignore@npm:^5.2.4": version: 5.3.1 resolution: "ignore@npm:5.3.1" checksum: 703f7f45ffb2a27fb2c5a8db0c32e7dee66b33a225d28e8db4e1be6474795f606686a6e3bcc50e1aa12f2042db4c9d4a7d60af3250511de74620fbed052ea4cd @@ -17302,7 +17038,7 @@ __metadata: languageName: node linkType: hard -"optionator@npm:^0.9.1, optionator@npm:^0.9.3": +"optionator@npm:^0.9.3": version: 0.9.3 resolution: "optionator@npm:0.9.3" dependencies: @@ -18190,22 +17926,6 @@ __metadata: languageName: node linkType: hard -"prettier-plugin-solidity@npm:1.0.0-beta.19": - version: 1.0.0-beta.19 - resolution: "prettier-plugin-solidity@npm:1.0.0-beta.19" - dependencies: - "@solidity-parser/parser": "npm:^0.14.0" - emoji-regex: "npm:^10.0.0" - escape-string-regexp: "npm:^4.0.0" - semver: "npm:^7.3.5" - solidity-comments-extractor: "npm:^0.0.7" - string-width: "npm:^4.2.3" - peerDependencies: - prettier: ^2.3.0 - checksum: f0fcfb61afeb3c9cda4bc0d49ddb81a730faa4398dd06459d39d1a93b345a2ab9eeb227b4f68c6278b19f053e4b4ac4ab239889691ac7924f620407ef698a426 - languageName: node - linkType: hard - "prettier-plugin-solidity@npm:^1.3.1": version: 1.3.1 resolution: "prettier-plugin-solidity@npm:1.3.1" @@ -18219,7 +17939,7 @@ __metadata: languageName: node linkType: hard -"prettier@npm:^2.1.2, prettier@npm:^2.2.1, prettier@npm:^2.7.1, prettier@npm:^2.8.3": +"prettier@npm:^2.1.2, prettier@npm:^2.7.1, prettier@npm:^2.8.3": version: 2.8.8 resolution: "prettier@npm:2.8.8" bin: @@ -18272,13 +17992,6 @@ __metadata: languageName: node linkType: hard -"progress@npm:^2.0.0": - version: 2.0.3 - resolution: "progress@npm:2.0.3" - checksum: 1697e07cb1068055dbe9fe858d242368ff5d2073639e652b75a7eb1f2a1a8d4afd404d719de23c7b48481a6aa0040686310e2dac2f53d776daa2176d3f96369c - languageName: node - linkType: hard - "prom-client@npm:14.0.1": version: 14.0.1 resolution: "prom-client@npm:14.0.1" @@ -18934,13 +18647,6 @@ __metadata: languageName: node linkType: hard -"regexpp@npm:^3.1.0": - version: 3.2.0 - resolution: "regexpp@npm:3.2.0" - checksum: d1da82385c8754a1681416b90b9cca0e21b4a2babef159099b88f640637d789c69011d0bc94705dacab85b81133e929d027d85210e8b8b03f8035164dbc14710 - languageName: node - linkType: hard - "regexpu-core@npm:^2.0.0": version: 2.0.0 resolution: "regexpu-core@npm:2.0.0" @@ -19567,7 +19273,7 @@ __metadata: languageName: node linkType: hard -"semver@npm:7.6.0, semver@npm:^7.2.1, semver@npm:^7.3.4, semver@npm:^7.3.5, semver@npm:^7.5.2, semver@npm:^7.5.3, semver@npm:^7.5.4": +"semver@npm:7.6.0, semver@npm:^7.3.4, semver@npm:^7.3.5, semver@npm:^7.5.2, semver@npm:^7.5.3, semver@npm:^7.5.4": version: 7.6.0 resolution: "semver@npm:7.6.0" dependencies: @@ -20228,18 +19934,6 @@ __metadata: languageName: unknown linkType: soft -"solhint-plugin-prettier@npm:^0.0.5": - version: 0.0.5 - resolution: "solhint-plugin-prettier@npm:0.0.5" - dependencies: - prettier-linter-helpers: "npm:^1.0.0" - peerDependencies: - prettier: ^1.15.0 || ^2.0.0 - prettier-plugin-solidity: ^1.0.0-alpha.14 - checksum: 3dd40c9e7d7c0cf9a36816cb185f75ea12b51b976e13568ab3d4e914c3160d75b6b8fe5b18bf33c06e4a17f7dcc9d25a22dfe1f3fb9a27c4911e6d41234ef5e2 - languageName: node - linkType: hard - "solhint-plugin-prettier@npm:^0.1.0": version: 0.1.0 resolution: "solhint-plugin-prettier@npm:0.1.0" @@ -20293,13 +19987,6 @@ __metadata: languageName: node linkType: hard -"solidity-comments-extractor@npm:^0.0.7": - version: 0.0.7 - resolution: "solidity-comments-extractor@npm:0.0.7" - checksum: 57fb166ff71812404288ae1a386bb9bbb6330662aedc3b45d89f6f0ce51ee0e36c9f4b9d4fd363c2b37fbf607e42df088e734c532fb93e2f345601b429813d9e - languageName: node - linkType: hard - "solidity-comments-extractor@npm:^0.0.8": version: 0.0.8 resolution: "solidity-comments-extractor@npm:0.0.8" @@ -20839,7 +20526,7 @@ __metadata: languageName: node linkType: hard -"strip-json-comments@npm:3.1.1, strip-json-comments@npm:^3.1.0, strip-json-comments@npm:^3.1.1": +"strip-json-comments@npm:3.1.1, strip-json-comments@npm:^3.1.1": version: 3.1.1 resolution: "strip-json-comments@npm:3.1.1" checksum: 9681a6257b925a7fa0f285851c0e613cc934a50661fa7bb41ca9cbbff89686bb4a0ee366e6ecedc4daafd01e83eee0720111ab294366fe7c185e935475ebcecd @@ -20954,7 +20641,7 @@ __metadata: languageName: node linkType: hard -"table@npm:^6.0.9, table@npm:^6.8.0, table@npm:^6.8.1": +"table@npm:^6.8.0, table@npm:^6.8.1": version: 6.8.1 resolution: "table@npm:6.8.1" dependencies: @@ -21412,7 +21099,7 @@ __metadata: languageName: node linkType: hard -"tslib@npm:^1.11.1, tslib@npm:^1.8.1, tslib@npm:^1.9.0, tslib@npm:^1.9.3": +"tslib@npm:^1.11.1, tslib@npm:^1.9.0, tslib@npm:^1.9.3": version: 1.14.1 resolution: "tslib@npm:1.14.1" checksum: 69ae09c49eea644bc5ebe1bca4fa4cc2c82b7b3e02f43b84bd891504edf66dbc6b2ec0eef31a957042de2269139e4acff911e6d186a258fb14069cd7f6febce2 @@ -21447,17 +21134,6 @@ __metadata: languageName: node linkType: hard -"tsutils@npm:^3.21.0": - version: 3.21.0 - resolution: "tsutils@npm:3.21.0" - dependencies: - tslib: "npm:^1.8.1" - peerDependencies: - typescript: ">=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta" - checksum: 02f19e458ec78ead8fffbf711f834ad8ecd2cc6ade4ec0320790713dccc0a412b99e7fd907c4cda2a1dc602c75db6f12e0108e87a5afad4b2f9e90a24cabd5a2 - languageName: node - linkType: hard - "tty-table@npm:^4.1.5": version: 4.2.3 resolution: "tty-table@npm:4.2.3" @@ -22176,13 +21852,6 @@ __metadata: languageName: node linkType: hard -"v8-compile-cache@npm:^2.0.3": - version: 2.4.0 - resolution: "v8-compile-cache@npm:2.4.0" - checksum: 387851192545e7f4d691ba674de90890bba76c0f08ee4909ab862377f556221e75b3a361466490e201203401d64d7795f889882bdabc98b6f3c0bf1038a535be - languageName: node - linkType: hard - "validate-npm-package-license@npm:^3.0.1": version: 3.0.4 resolution: "validate-npm-package-license@npm:3.0.4" From 41a4c97a59250e2e02c2b253fc31c19ef6d92c6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Thu, 7 Mar 2024 17:44:00 -0300 Subject: [PATCH 5/9] chore(contracts): lint sol files with graph config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- .../contracts/contracts/arbitrum/IBridge.sol | 7 +- .../contracts/contracts/arbitrum/IOutbox.sol | 3 +- .../contracts/bancor/BancorFormula.sol | 54 +---- .../contracts/contracts/curation/Curation.sol | 101 ++------ .../contracts/curation/ICuration.sol | 21 +- .../contracts/contracts/discovery/GNS.sol | 149 +++--------- .../contracts/contracts/discovery/IGNS.sol | 58 +---- .../contracts/discovery/IServiceRegistry.sol | 6 +- .../contracts/contracts/discovery/L1GNS.sol | 38 +-- .../contracts/discovery/ServiceRegistry.sol | 12 +- .../contracts/discovery/SubgraphNFT.sol | 21 +- .../discovery/SubgraphNFTDescriptor.sol | 8 +- .../discovery/erc1056/EthereumDIDRegistry.sol | 89 ++------ .../erc1056/IEthereumDIDRegistry.sol | 7 +- .../contracts/disputes/DisputeManager.sol | 122 ++-------- .../contracts/disputes/IDisputeManager.sol | 8 +- .../contracts/epochs/EpochManager.sol | 5 +- .../contracts/gateway/GraphTokenGateway.sol | 5 +- .../contracts/gateway/ICallhookReceiver.sol | 6 +- .../contracts/gateway/L1GraphTokenGateway.sol | 36 +-- .../contracts/governance/Controller.sol | 11 +- .../contracts/l2/curation/IL2Curation.sol | 17 +- .../contracts/l2/curation/L2Curation.sol | 140 +++--------- .../contracts/l2/discovery/L2GNS.sol | 70 +----- .../l2/gateway/L2GraphTokenGateway.sol | 20 +- .../contracts/l2/staking/IL2StakingBase.sol | 6 +- .../contracts/l2/staking/L2Staking.sol | 30 +-- .../l2/token/GraphTokenUpgradeable.sol | 15 +- .../contracts/payments/AllocationExchange.sol | 14 +- .../contracts/rewards/IRewardsManager.sol | 13 +- .../contracts/rewards/RewardsManager.sol | 112 +++------ .../contracts/staking/IL1StakingBase.sol | 4 +- .../contracts/staking/IStakingBase.sol | 5 +- .../contracts/staking/IStakingExtension.sol | 42 +--- .../contracts/contracts/staking/L1Staking.sol | 65 +----- .../contracts/contracts/staking/Staking.sol | 108 ++------- .../contracts/staking/StakingExtension.sol | 105 ++------- .../contracts/staking/libs/Exponential.sol | 5 +- .../contracts/staking/libs/LibFixedMath.sol | 54 ++--- .../contracts/staking/libs/MathUtils.sol | 5 +- .../contracts/staking/libs/Stakes.sol | 15 +- .../contracts/tests/CallhookReceiverMock.sol | 6 +- .../L1GraphTokenLockTransferToolBadMock.sol | 5 +- .../L1GraphTokenLockTransferToolMock.sol | 5 +- .../contracts/tests/LegacyGNSMock.sol | 6 +- .../contracts/tests/arbitrum/BridgeMock.sol | 9 +- .../contracts/tests/arbitrum/InboxMock.sol | 12 +- .../contracts/tests/arbitrum/OutboxMock.sol | 6 +- .../contracts/contracts/tests/ens/IENS.sol | 8 +- .../contracts/tests/ens/IPublicResolver.sol | 6 +- .../contracts/contracts/token/GraphToken.sol | 15 +- .../contracts/upgrades/GraphProxy.sol | 9 +- .../contracts/upgrades/GraphProxyAdmin.sol | 5 +- .../contracts/upgrades/GraphProxyStorage.sol | 11 +- .../contracts/upgrades/GraphUpgradeable.sol | 8 +- .../contracts/contracts/utils/TokenUtils.sol | 12 +- packages/contracts/package.json | 13 +- packages/contracts/prettier.config.js | 2 + packages/contracts/tsconfig.json | 1 + packages/solhint-graph-config/README.md | 2 +- yarn.lock | 216 +++++++++++++++++- 61 files changed, 560 insertions(+), 1409 deletions(-) create mode 100644 packages/contracts/prettier.config.js diff --git a/packages/contracts/contracts/arbitrum/IBridge.sol b/packages/contracts/contracts/arbitrum/IBridge.sol index ff78253fc..536ee075b 100644 --- a/packages/contracts/contracts/arbitrum/IBridge.sol +++ b/packages/contracts/contracts/arbitrum/IBridge.sol @@ -35,12 +35,7 @@ interface IBridge { bytes32 messageDataHash ); - event BridgeCallTriggered( - address indexed outbox, - address indexed destAddr, - uint256 amount, - bytes data - ); + event BridgeCallTriggered(address indexed outbox, address indexed destAddr, uint256 amount, bytes data); event InboxToggle(address indexed inbox, bool enabled); diff --git a/packages/contracts/contracts/arbitrum/IOutbox.sol b/packages/contracts/contracts/arbitrum/IOutbox.sol index 687c86abf..2e4f05bd5 100644 --- a/packages/contracts/contracts/arbitrum/IOutbox.sol +++ b/packages/contracts/contracts/arbitrum/IOutbox.sol @@ -51,8 +51,7 @@ interface IOutbox { function l2ToL1OutputId() external view returns (bytes32); - function processOutgoingMessages(bytes calldata sendsData, uint256[] calldata sendLengths) - external; + function processOutgoingMessages(bytes calldata sendsData, uint256[] calldata sendLengths) external; function outboxEntryExists(uint256 batchNum) external view returns (bool); } diff --git a/packages/contracts/contracts/bancor/BancorFormula.sol b/packages/contracts/contracts/bancor/BancorFormula.sol index 9cb41a502..689eebaba 100644 --- a/packages/contracts/contracts/bancor/BancorFormula.sol +++ b/packages/contracts/contracts/bancor/BancorFormula.sol @@ -324,9 +324,7 @@ contract BancorFormula { uint256 _amount ) public view returns (uint256) { // validate input - require( - _supply > 0 && _reserveBalance > 0 && _totalRatio > 1 && _totalRatio <= MAX_RATIO * 2 - ); + require(_supply > 0 && _reserveBalance > 0 && _totalRatio > 1 && _totalRatio <= MAX_RATIO * 2); // special case for 0 amount if (_amount == 0) return 0; @@ -364,11 +362,7 @@ contract BancorFormula { ) public view returns (uint256) { // validate input require( - _supply > 0 && - _reserveBalance > 0 && - _totalRatio > 1 && - _totalRatio <= MAX_RATIO * 2 && - _amount <= _supply + _supply > 0 && _reserveBalance > 0 && _totalRatio > 1 && _totalRatio <= MAX_RATIO * 2 && _amount <= _supply ); // special case for 0 amount @@ -407,12 +401,7 @@ contract BancorFormula { * This functions assumes that "_expN < 2 ^ 256 / log(MAX_NUM - 1)", otherwise the multiplication should be replaced with a "safeMul". * Since we rely on unsigned-integer arithmetic and "base < 1" ==> "log(base) < 0", this function does not support "_baseN < _baseD". */ - function power( - uint256 _baseN, - uint256 _baseD, - uint32 _expN, - uint32 _expD - ) internal view returns (uint256, uint8) { + function power(uint256 _baseN, uint256 _baseD, uint32 _expN, uint32 _expD) internal view returns (uint256, uint8) { require(_baseN < MAX_NUM); uint256 baseLog; @@ -428,10 +417,7 @@ contract BancorFormula { return (optimalExp(baseLogTimesExp), MAX_PRECISION); } else { uint8 precision = findPositionInMaxExpArray(baseLogTimesExp); - return ( - generalExp(baseLogTimesExp >> (MAX_PRECISION - precision), precision), - precision - ); + return (generalExp(baseLogTimesExp >> (MAX_PRECISION - precision), precision), precision); } } @@ -642,37 +628,21 @@ contract BancorFormula { z = y = x - FIXED_1; w = (y * y) / FIXED_1; - res += - (z * (0x100000000000000000000000000000000 - y)) / - 0x100000000000000000000000000000000; + res += (z * (0x100000000000000000000000000000000 - y)) / 0x100000000000000000000000000000000; z = (z * w) / FIXED_1; // add y^01 / 01 - y^02 / 02 - res += - (z * (0x0aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa - y)) / - 0x200000000000000000000000000000000; + res += (z * (0x0aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa - y)) / 0x200000000000000000000000000000000; z = (z * w) / FIXED_1; // add y^03 / 03 - y^04 / 04 - res += - (z * (0x099999999999999999999999999999999 - y)) / - 0x300000000000000000000000000000000; + res += (z * (0x099999999999999999999999999999999 - y)) / 0x300000000000000000000000000000000; z = (z * w) / FIXED_1; // add y^05 / 05 - y^06 / 06 - res += - (z * (0x092492492492492492492492492492492 - y)) / - 0x400000000000000000000000000000000; + res += (z * (0x092492492492492492492492492492492 - y)) / 0x400000000000000000000000000000000; z = (z * w) / FIXED_1; // add y^07 / 07 - y^08 / 08 - res += - (z * (0x08e38e38e38e38e38e38e38e38e38e38e - y)) / - 0x500000000000000000000000000000000; + res += (z * (0x08e38e38e38e38e38e38e38e38e38e38e - y)) / 0x500000000000000000000000000000000; z = (z * w) / FIXED_1; // add y^09 / 09 - y^10 / 10 - res += - (z * (0x08ba2e8ba2e8ba2e8ba2e8ba2e8ba2e8b - y)) / - 0x600000000000000000000000000000000; + res += (z * (0x08ba2e8ba2e8ba2e8ba2e8ba2e8ba2e8b - y)) / 0x600000000000000000000000000000000; z = (z * w) / FIXED_1; // add y^11 / 11 - y^12 / 12 - res += - (z * (0x089d89d89d89d89d89d89d89d89d89d89 - y)) / - 0x700000000000000000000000000000000; + res += (z * (0x089d89d89d89d89d89d89d89d89d89d89 - y)) / 0x700000000000000000000000000000000; z = (z * w) / FIXED_1; // add y^13 / 13 - y^14 / 14 - res += - (z * (0x088888888888888888888888888888888 - y)) / - 0x800000000000000000000000000000000; // add y^15 / 15 - y^16 / 16 + res += (z * (0x088888888888888888888888888888888 - y)) / 0x800000000000000000000000000000000; // add y^15 / 15 - y^16 / 16 return res; } diff --git a/packages/contracts/contracts/curation/Curation.sol b/packages/contracts/contracts/curation/Curation.sol index 487bf8a4c..bd3032046 100644 --- a/packages/contracts/contracts/curation/Curation.sol +++ b/packages/contracts/contracts/curation/Curation.sol @@ -57,12 +57,7 @@ contract Curation is CurationV2Storage, GraphUpgradeable { * @dev Emitted when `curator` burned `signal` for a `subgraphDeploymentID`. * The curator will receive `tokens` according to the value of the bonding curve. */ - event Burned( - address indexed curator, - bytes32 indexed subgraphDeploymentID, - uint256 tokens, - uint256 signal - ); + event Burned(address indexed curator, bytes32 indexed subgraphDeploymentID, uint256 tokens, uint256 signal); /** * @dev Emitted when `tokens` amount were collected for `subgraphDeploymentID` as part of fees @@ -113,11 +108,7 @@ contract Curation is CurationV2Storage, GraphUpgradeable { * @notice Update the minimum deposit amount to `_minimumCurationDeposit` * @param _minimumCurationDeposit Minimum amount of tokens required deposit */ - function setMinimumCurationDeposit(uint256 _minimumCurationDeposit) - external - override - onlyGovernor - { + function setMinimumCurationDeposit(uint256 _minimumCurationDeposit) external override onlyGovernor { _setMinimumCurationDeposit(_minimumCurationDeposit); } @@ -149,10 +140,7 @@ contract Curation is CurationV2Storage, GraphUpgradeable { require(msg.sender == address(staking()), "Caller must be the staking contract"); // Must be curated to accept tokens - require( - isCurated(_subgraphDeploymentID), - "Subgraph deployment must be curated to collect fees" - ); + require(isCurated(_subgraphDeploymentID), "Subgraph deployment must be curated to collect fees"); // Collect new funds into reserve CurationPool storage curationPool = pools[_subgraphDeploymentID]; @@ -193,9 +181,7 @@ contract Curation is CurationV2Storage, GraphUpgradeable { // If no signal token for the pool - create one if (address(curationPool.gcs) == address(0)) { // Use a minimal proxy to reduce gas cost - IGraphCurationToken gcs = IGraphCurationToken( - ClonesUpgradeable.clone(curationTokenMaster) - ); + IGraphCurationToken gcs = IGraphCurationToken(ClonesUpgradeable.clone(curationTokenMaster)); gcs.initialize(address(this)); curationPool.gcs = gcs; } @@ -238,10 +224,7 @@ contract Curation is CurationV2Storage, GraphUpgradeable { // Validations require(_signalIn != 0, "Cannot burn zero signal"); - require( - getCuratorSignal(curator, _subgraphDeploymentID) >= _signalIn, - "Cannot burn more signal than you own" - ); + require(getCuratorSignal(curator, _subgraphDeploymentID) >= _signalIn, "Cannot burn more signal than you own"); // Get the amount of tokens to refund based on returned signal uint256 tokensOut = signalToTokens(_subgraphDeploymentID, _signalIn); @@ -277,12 +260,7 @@ contract Curation is CurationV2Storage, GraphUpgradeable { * @param _subgraphDeploymentID Subgraph deployment curation poool * @return Amount of token reserves in the curation pool */ - function getCurationPoolTokens(bytes32 _subgraphDeploymentID) - external - view - override - returns (uint256) - { + function getCurationPoolTokens(bytes32 _subgraphDeploymentID) external view override returns (uint256) { return pools[_subgraphDeploymentID].tokens; } @@ -301,12 +279,7 @@ contract Curation is CurationV2Storage, GraphUpgradeable { * @param _subgraphDeploymentID Subgraph deployment curation pool * @return Amount of signal owned by a curator for the subgraph deployment */ - function getCuratorSignal(address _curator, bytes32 _subgraphDeploymentID) - public - view - override - returns (uint256) - { + function getCuratorSignal(address _curator, bytes32 _subgraphDeploymentID) public view override returns (uint256) { IGraphCurationToken gcs = pools[_subgraphDeploymentID].gcs; return (address(gcs) == address(0)) ? 0 : gcs.balanceOf(_curator); } @@ -316,12 +289,7 @@ contract Curation is CurationV2Storage, GraphUpgradeable { * @param _subgraphDeploymentID Subgraph deployment curation poool * @return Amount of signal minted for the subgraph deployment */ - function getCurationPoolSignal(bytes32 _subgraphDeploymentID) - public - view - override - returns (uint256) - { + function getCurationPoolSignal(bytes32 _subgraphDeploymentID) public view override returns (uint256) { IGraphCurationToken gcs = pools[_subgraphDeploymentID].gcs; return (address(gcs) == address(0)) ? 0 : gcs.totalSupply(); } @@ -334,12 +302,10 @@ contract Curation is CurationV2Storage, GraphUpgradeable { * @return Amount of signal that can be bought * @return Amount of tokens that will be burned as curation tax */ - function tokensToSignal(bytes32 _subgraphDeploymentID, uint256 _tokensIn) - public - view - override - returns (uint256, uint256) - { + function tokensToSignal( + bytes32 _subgraphDeploymentID, + uint256 _tokensIn + ) public view override returns (uint256, uint256) { // NOTE: We're aware that this function rounds down and tax can be 0 for small amounts // of tokens but since minimumCurationDeposit is 1 GRT tax will always be greater than 0. uint256 curationTax = _tokensIn.mul(uint256(curationTaxPercentage)).div(MAX_PPM); @@ -353,20 +319,13 @@ contract Curation is CurationV2Storage, GraphUpgradeable { * @param _tokensIn Amount of tokens used to mint signal * @return Amount of signal that can be bought with tokens */ - function _tokensToSignal(bytes32 _subgraphDeploymentID, uint256 _tokensIn) - private - view - returns (uint256) - { + function _tokensToSignal(bytes32 _subgraphDeploymentID, uint256 _tokensIn) private view returns (uint256) { // Get curation pool tokens and signal CurationPool memory curationPool = pools[_subgraphDeploymentID]; // Init curation pool if (curationPool.tokens == 0) { - require( - _tokensIn >= minimumCurationDeposit, - "Curation deposit is below minimum required" - ); + require(_tokensIn >= minimumCurationDeposit, "Curation deposit is below minimum required"); return BancorFormula(bondingCurve) .calculatePurchaseReturn( @@ -393,22 +352,11 @@ contract Curation is CurationV2Storage, GraphUpgradeable { * @param _signalIn Amount of signal to burn * @return Amount of tokens to get for the specified amount of signal */ - function signalToTokens(bytes32 _subgraphDeploymentID, uint256 _signalIn) - public - view - override - returns (uint256) - { + function signalToTokens(bytes32 _subgraphDeploymentID, uint256 _signalIn) public view override returns (uint256) { CurationPool memory curationPool = pools[_subgraphDeploymentID]; uint256 curationPoolSignal = getCurationPoolSignal(_subgraphDeploymentID); - require( - curationPool.tokens != 0, - "Subgraph deployment must be curated to perform calculations" - ); - require( - curationPoolSignal >= _signalIn, - "Signal must be above or equal to signal issued in the curation pool" - ); + require(curationPool.tokens != 0, "Subgraph deployment must be curated to perform calculations"); + require(curationPoolSignal >= _signalIn, "Signal must be above or equal to signal issued in the curation pool"); return BancorFormula(bondingCurve).calculateSaleReturn( @@ -427,10 +375,7 @@ contract Curation is CurationV2Storage, GraphUpgradeable { function _setDefaultReserveRatio(uint32 _defaultReserveRatio) private { // Reserve Ratio must be within 0% to 100% (inclusive, in PPM) require(_defaultReserveRatio != 0, "Default reserve ratio must be > 0"); - require( - _defaultReserveRatio <= MAX_PPM, - "Default reserve ratio cannot be higher than MAX_PPM" - ); + require(_defaultReserveRatio <= MAX_PPM, "Default reserve ratio cannot be higher than MAX_PPM"); defaultReserveRatio = _defaultReserveRatio; emit ParameterUpdated("defaultReserveRatio"); @@ -453,10 +398,7 @@ contract Curation is CurationV2Storage, GraphUpgradeable { * @param _percentage Curation tax charged when depositing GRT tokens in PPM */ function _setCurationTaxPercentage(uint32 _percentage) private { - require( - _percentage <= MAX_PPM, - "Curation tax percentage must be below or equal to MAX_PPM" - ); + require(_percentage <= MAX_PPM, "Curation tax percentage must be below or equal to MAX_PPM"); curationTaxPercentage = _percentage; emit ParameterUpdated("curationTaxPercentage"); @@ -468,10 +410,7 @@ contract Curation is CurationV2Storage, GraphUpgradeable { */ function _setCurationTokenMaster(address _curationTokenMaster) private { require(_curationTokenMaster != address(0), "Token master must be non-empty"); - require( - AddressUpgradeable.isContract(_curationTokenMaster), - "Token master must be a contract" - ); + require(AddressUpgradeable.isContract(_curationTokenMaster), "Token master must be a contract"); curationTokenMaster = _curationTokenMaster; emit ParameterUpdated("curationTokenMaster"); diff --git a/packages/contracts/contracts/curation/ICuration.sol b/packages/contracts/contracts/curation/ICuration.sol index dffff46cd..d92aa9c69 100644 --- a/packages/contracts/contracts/curation/ICuration.sol +++ b/packages/contracts/contracts/curation/ICuration.sol @@ -56,11 +56,7 @@ interface ICuration { * @param _tokensOutMin Expected minimum amount of tokens to receive * @return Tokens returned */ - function burn( - bytes32 _subgraphDeploymentID, - uint256 _signalIn, - uint256 _tokensOutMin - ) external returns (uint256); + function burn(bytes32 _subgraphDeploymentID, uint256 _signalIn, uint256 _tokensOutMin) external returns (uint256); /** * @notice Assign Graph Tokens collected as curation fees to the curation pool reserve. @@ -84,10 +80,7 @@ interface ICuration { * @param _subgraphDeploymentID Subgraph deployment curation pool * @return Amount of signal owned by a curator for the subgraph deployment */ - function getCuratorSignal(address _curator, bytes32 _subgraphDeploymentID) - external - view - returns (uint256); + function getCuratorSignal(address _curator, bytes32 _subgraphDeploymentID) external view returns (uint256); /** * @notice Get the amount of signal in a curation pool. @@ -111,10 +104,7 @@ interface ICuration { * @return Amount of signal that can be bought * @return Amount of tokens that will be burned as curation tax */ - function tokensToSignal(bytes32 _subgraphDeploymentID, uint256 _tokensIn) - external - view - returns (uint256, uint256); + function tokensToSignal(bytes32 _subgraphDeploymentID, uint256 _tokensIn) external view returns (uint256, uint256); /** * @notice Calculate number of tokens to get when burning signal from a curation pool. @@ -122,10 +112,7 @@ interface ICuration { * @param _signalIn Amount of signal to burn * @return Amount of tokens to get for the specified amount of signal */ - function signalToTokens(bytes32 _subgraphDeploymentID, uint256 _signalIn) - external - view - returns (uint256); + function signalToTokens(bytes32 _subgraphDeploymentID, uint256 _signalIn) external view returns (uint256); /** * @notice Tax charged when curators deposit funds. diff --git a/packages/contracts/contracts/discovery/GNS.sol b/packages/contracts/contracts/discovery/GNS.sol index 1430288cc..3cbb9ca8a 100644 --- a/packages/contracts/contracts/discovery/GNS.sol +++ b/packages/contracts/contracts/discovery/GNS.sol @@ -100,11 +100,7 @@ abstract contract GNS is GNSV3Storage, GraphUpgradeable, IGNS, Multicall { /** * @dev Emitted when a subgraph is created. */ - event SubgraphPublished( - uint256 indexed subgraphID, - bytes32 indexed subgraphDeploymentID, - uint32 reserveRatio - ); + event SubgraphPublished(uint256 indexed subgraphID, bytes32 indexed subgraphDeploymentID, uint32 reserveRatio); /** * @dev Emitted when a subgraph is upgraded to point to a new @@ -126,12 +122,7 @@ abstract contract GNS is GNSV3Storage, GraphUpgradeable, IGNS, Multicall { /** * @dev Emitted when a curator withdraws GRT from a deprecated subgraph */ - event GRTWithdrawn( - uint256 indexed subgraphID, - address indexed curator, - uint256 nSignalBurnt, - uint256 withdrawnGRT - ); + event GRTWithdrawn(uint256 indexed subgraphID, address indexed curator, uint256 nSignalBurnt, uint256 withdrawnGRT); /** * @dev Emitted when the counterpart (L1/L2) GNS address is updated @@ -230,11 +221,10 @@ abstract contract GNS is GNSV3Storage, GraphUpgradeable, IGNS, Multicall { * @param _subgraphID Subgraph ID * @param _subgraphMetadata IPFS hash for the subgraph metadata */ - function updateSubgraphMetadata(uint256 _subgraphID, bytes32 _subgraphMetadata) - external - override - onlySubgraphAuth(_subgraphID) - { + function updateSubgraphMetadata( + uint256 _subgraphID, + bytes32 _subgraphMetadata + ) external override onlySubgraphAuth(_subgraphID) { _setSubgraphMetadata(_subgraphID, _subgraphMetadata); } @@ -311,31 +301,18 @@ abstract contract GNS is GNSV3Storage, GraphUpgradeable, IGNS, Multicall { if (subgraphData.nSignal != 0) { // Burn all version signal in the name pool for tokens (w/no slippage protection) // Sell all signal from the old deployment - uint256 tokens = curation.burn( - subgraphData.subgraphDeploymentID, - subgraphData.vSignal, - 0 - ); + uint256 tokens = curation.burn(subgraphData.subgraphDeploymentID, subgraphData.vSignal, 0); // Take the owner cut of the curation tax, add it to the total // Upgrade is only callable by the owner, we assume then that msg.sender = owner address subgraphOwner = msg.sender; - uint256 tokensWithTax = _chargeOwnerTax( - tokens, - subgraphOwner, - curation.curationTaxPercentage() - ); + uint256 tokensWithTax = _chargeOwnerTax(tokens, subgraphOwner, curation.curationTaxPercentage()); // Update pool: constant nSignal, vSignal can change (w/no slippage protection) // Buy all signal from the new deployment (subgraphData.vSignal, ) = curation.mint(_subgraphDeploymentID, tokensWithTax, 0); - emit SubgraphUpgraded( - _subgraphID, - subgraphData.vSignal, - tokensWithTax, - _subgraphDeploymentID - ); + emit SubgraphUpgraded(_subgraphID, subgraphData.vSignal, tokensWithTax, _subgraphDeploymentID); } // Update target deployment @@ -350,22 +327,13 @@ abstract contract GNS is GNSV3Storage, GraphUpgradeable, IGNS, Multicall { * Can only be done by the subgraph owner. * @param _subgraphID Subgraph ID */ - function deprecateSubgraph(uint256 _subgraphID) - external - override - notPaused - onlySubgraphAuth(_subgraphID) - { + function deprecateSubgraph(uint256 _subgraphID) external override notPaused onlySubgraphAuth(_subgraphID) { // Subgraph check SubgraphData storage subgraphData = _getSubgraphOrRevert(_subgraphID); // Burn signal only if it has any available if (subgraphData.nSignal != 0) { - subgraphData.withdrawableGRT = curation().burn( - subgraphData.subgraphDeploymentID, - subgraphData.vSignal, - 0 - ); + subgraphData.withdrawableGRT = curation().burn(subgraphData.subgraphDeploymentID, subgraphData.vSignal, 0); } // Deprecate the subgraph and do cleanup @@ -431,10 +399,7 @@ abstract contract GNS is GNSV3Storage, GraphUpgradeable, IGNS, Multicall { // Curator balance checks address curator = msg.sender; uint256 curatorNSignal = subgraphData.curatorNSignal[curator]; - require( - _nSignal <= curatorNSignal, - "GNS: Curator cannot withdraw more nSignal than they have" - ); + require(_nSignal <= curatorNSignal, "GNS: Curator cannot withdraw more nSignal than they have"); // Get tokens for name signal amount to burn uint256 vSignal = nSignalToVSignal(_subgraphID, _nSignal); @@ -474,9 +439,7 @@ abstract contract GNS is GNSV3Storage, GraphUpgradeable, IGNS, Multicall { // Move the signal subgraphData.curatorNSignal[curator] = subgraphData.curatorNSignal[curator].sub(_amount); - subgraphData.curatorNSignal[_recipient] = subgraphData.curatorNSignal[_recipient].add( - _amount - ); + subgraphData.curatorNSignal[_recipient] = subgraphData.curatorNSignal[_recipient].add(_amount); emit SignalTransferred(_subgraphID, curator, _recipient, _amount); } @@ -499,9 +462,7 @@ abstract contract GNS is GNSV3Storage, GraphUpgradeable, IGNS, Multicall { require(curatorNSignal != 0, "GNS: No signal to withdraw GRT"); // Get curator share of tokens to be withdrawn - uint256 tokensOut = curatorNSignal.mul(subgraphData.withdrawableGRT).div( - subgraphData.nSignal - ); + uint256 tokensOut = curatorNSignal.mul(subgraphData.withdrawableGRT).div(subgraphData.nSignal); subgraphData.curatorNSignal[curator] = 0; subgraphData.nSignal = subgraphData.nSignal.sub(curatorNSignal); subgraphData.withdrawableGRT = subgraphData.withdrawableGRT.sub(tokensOut); @@ -518,22 +479,14 @@ abstract contract GNS is GNSV3Storage, GraphUpgradeable, IGNS, Multicall { * @param _subgraphNumber The sequence number of the created subgraph * @param _subgraphMetadata IPFS hash for the subgraph metadata */ - function migrateLegacySubgraph( - address _graphAccount, - uint256 _subgraphNumber, - bytes32 _subgraphMetadata - ) external { + function migrateLegacySubgraph(address _graphAccount, uint256 _subgraphNumber, bytes32 _subgraphMetadata) external { // Must be an existing legacy subgraph - bool legacySubgraphExists = legacySubgraphData[_graphAccount][_subgraphNumber] - .subgraphDeploymentID != 0; + bool legacySubgraphExists = legacySubgraphData[_graphAccount][_subgraphNumber].subgraphDeploymentID != 0; require(legacySubgraphExists == true, "GNS: Subgraph does not exist"); // Must not be a claimed subgraph uint256 subgraphID = _buildLegacySubgraphID(_graphAccount, _subgraphNumber); - require( - legacySubgraphKeys[subgraphID].account == address(0), - "GNS: Subgraph was already claimed" - ); + require(legacySubgraphKeys[subgraphID].account == address(0), "GNS: Subgraph was already claimed"); // Store a reference for a legacy subgraph legacySubgraphKeys[subgraphID] = IGNS.LegacySubgraphKey({ @@ -592,16 +545,10 @@ abstract contract GNS is GNSV3Storage, GraphUpgradeable, IGNS, Multicall { * @param _tokensIn Tokens being exchanged for subgraph signal * @return Amount of subgraph signal and curation tax */ - function tokensToNSignal(uint256 _subgraphID, uint256 _tokensIn) - public - view - override - returns ( - uint256, - uint256, - uint256 - ) - { + function tokensToNSignal( + uint256 _subgraphID, + uint256 _tokensIn + ) public view override returns (uint256, uint256, uint256) { SubgraphData storage subgraphData = _getSubgraphData(_subgraphID); (uint256 vSignal, uint256 curationTax) = curation().tokensToSignal( subgraphData.subgraphDeploymentID, @@ -617,12 +564,7 @@ abstract contract GNS is GNSV3Storage, GraphUpgradeable, IGNS, Multicall { * @param _nSignalIn Subgraph signal being exchanged for tokens * @return Amount of tokens returned for an amount of subgraph signal */ - function nSignalToTokens(uint256 _subgraphID, uint256 _nSignalIn) - public - view - override - returns (uint256, uint256) - { + function nSignalToTokens(uint256 _subgraphID, uint256 _nSignalIn) public view override returns (uint256, uint256) { // Get subgraph or revert if not published // It does not make sense to convert signal from a disabled or non-existing one SubgraphData storage subgraphData = _getSubgraphOrRevert(_subgraphID); @@ -637,12 +579,7 @@ abstract contract GNS is GNSV3Storage, GraphUpgradeable, IGNS, Multicall { * @param _vSignalIn Amount of subgraph deployment signal to exchange for subgraph signal * @return Amount of subgraph signal that can be bought */ - function vSignalToNSignal(uint256 _subgraphID, uint256 _vSignalIn) - public - view - override - returns (uint256) - { + function vSignalToNSignal(uint256 _subgraphID, uint256 _vSignalIn) public view override returns (uint256) { SubgraphData storage subgraphData = _getSubgraphData(_subgraphID); // Handle initialization by using 1:1 version to name signal @@ -659,12 +596,7 @@ abstract contract GNS is GNSV3Storage, GraphUpgradeable, IGNS, Multicall { * @param _nSignalIn Subgraph signal being exchanged for subgraph deployment signal * @return Amount of subgraph deployment signal that can be returned */ - function nSignalToVSignal(uint256 _subgraphID, uint256 _nSignalIn) - public - view - override - returns (uint256) - { + function nSignalToVSignal(uint256 _subgraphID, uint256 _nSignalIn) public view override returns (uint256) { SubgraphData storage subgraphData = _getSubgraphData(_subgraphID); return subgraphData.vSignal.mul(_nSignalIn).div(subgraphData.nSignal); } @@ -675,12 +607,7 @@ abstract contract GNS is GNSV3Storage, GraphUpgradeable, IGNS, Multicall { * @param _curator Curator address * @return Amount of subgraph signal owned by a curator */ - function getCuratorSignal(uint256 _subgraphID, address _curator) - public - view - override - returns (uint256) - { + function getCuratorSignal(uint256 _subgraphID, address _curator) public view override returns (uint256) { return _getSubgraphData(_subgraphID).curatorNSignal[_curator]; } @@ -699,12 +626,7 @@ abstract contract GNS is GNSV3Storage, GraphUpgradeable, IGNS, Multicall { * @return account Account that created the subgraph (or 0 if it's not a legacy subgraph) * @return seqID Sequence number for the subgraph */ - function getLegacySubgraphKey(uint256 _subgraphID) - public - view - override - returns (address account, uint256 seqID) - { + function getLegacySubgraphKey(uint256 _subgraphID) public view override returns (address account, uint256 seqID) { LegacySubgraphKey storage legacySubgraphKey = legacySubgraphKeys[_subgraphID]; account = legacySubgraphKey.account; seqID = legacySubgraphKey.accountSeqID; @@ -822,12 +744,7 @@ abstract contract GNS is GNSV3Storage, GraphUpgradeable, IGNS, Multicall { * @param _subgraphID Subgraph ID * @return Subgraph Data */ - function _getSubgraphData(uint256 _subgraphID) - internal - view - virtual - returns (SubgraphData storage) - { + function _getSubgraphData(uint256 _subgraphID) internal view virtual returns (SubgraphData storage) { // If there is a legacy subgraph created return it LegacySubgraphKey storage legacySubgraphKey = legacySubgraphKeys[_subgraphID]; if (legacySubgraphKey.account != address(0)) { @@ -851,11 +768,7 @@ abstract contract GNS is GNSV3Storage, GraphUpgradeable, IGNS, Multicall { * @param _subgraphID Subgraph ID * @return Subgraph Data */ - function _getSubgraphOrRevert(uint256 _subgraphID) - internal - view - returns (SubgraphData storage) - { + function _getSubgraphOrRevert(uint256 _subgraphID) internal view returns (SubgraphData storage) { SubgraphData storage subgraphData = _getSubgraphData(_subgraphID); require(_isPublished(subgraphData) == true, "GNS: Must be active"); return subgraphData; @@ -867,11 +780,7 @@ abstract contract GNS is GNSV3Storage, GraphUpgradeable, IGNS, Multicall { * Subgraph ID is the keccak hash of account+seqID * @return Subgraph ID */ - function _buildLegacySubgraphID(address _account, uint256 _seqID) - internal - pure - returns (uint256) - { + function _buildLegacySubgraphID(address _account, uint256 _seqID) internal pure returns (uint256) { return uint256(keccak256(abi.encodePacked(_account, _seqID))); } diff --git a/packages/contracts/contracts/discovery/IGNS.sol b/packages/contracts/contracts/discovery/IGNS.sol index c3a6e0378..9267c70d2 100644 --- a/packages/contracts/contracts/discovery/IGNS.sol +++ b/packages/contracts/contracts/discovery/IGNS.sol @@ -87,11 +87,7 @@ interface IGNS { * @param _subgraphDeploymentID Subgraph deployment ID of the new version * @param _versionMetadata IPFS hash for the subgraph version metadata */ - function publishNewVersion( - uint256 _subgraphID, - bytes32 _subgraphDeploymentID, - bytes32 _versionMetadata - ) external; + function publishNewVersion(uint256 _subgraphID, bytes32 _subgraphDeploymentID, bytes32 _versionMetadata) external; /** * @notice Deprecate a subgraph. The bonding curve is destroyed, the vSignal is burned, and the GNS @@ -109,11 +105,7 @@ interface IGNS { * @param _tokensIn The amount of tokens the nameCurator wants to deposit * @param _nSignalOutMin Expected minimum amount of name signal to receive */ - function mintSignal( - uint256 _subgraphID, - uint256 _tokensIn, - uint256 _nSignalOutMin - ) external; + function mintSignal(uint256 _subgraphID, uint256 _tokensIn, uint256 _nSignalOutMin) external; /** * @notice Burn signal for a subgraph and return the GRT. @@ -121,11 +113,7 @@ interface IGNS { * @param _nSignal The amount of nSignal the nameCurator wants to burn * @param _tokensOutMin Expected minimum amount of tokens to receive */ - function burnSignal( - uint256 _subgraphID, - uint256 _nSignal, - uint256 _tokensOutMin - ) external; + function burnSignal(uint256 _subgraphID, uint256 _nSignal, uint256 _tokensOutMin) external; /** * @notice Move subgraph signal from sender to `_recipient` @@ -133,11 +121,7 @@ interface IGNS { * @param _recipient Address to send the signal to * @param _amount The amount of nSignal to transfer */ - function transferSignal( - uint256 _subgraphID, - address _recipient, - uint256 _amount - ) external; + function transferSignal(uint256 _subgraphID, address _recipient, uint256 _amount) external; /** * @notice Withdraw tokens from a deprecated subgraph. @@ -176,14 +160,7 @@ interface IGNS { * @param _tokensIn Tokens being exchanged for subgraph signal * @return Amount of subgraph signal and curation tax */ - function tokensToNSignal(uint256 _subgraphID, uint256 _tokensIn) - external - view - returns ( - uint256, - uint256, - uint256 - ); + function tokensToNSignal(uint256 _subgraphID, uint256 _tokensIn) external view returns (uint256, uint256, uint256); /** * @notice Calculate tokens returned for an amount of subgraph signal. @@ -191,10 +168,7 @@ interface IGNS { * @param _nSignalIn Subgraph signal being exchanged for tokens * @return Amount of tokens returned for an amount of subgraph signal */ - function nSignalToTokens(uint256 _subgraphID, uint256 _nSignalIn) - external - view - returns (uint256, uint256); + function nSignalToTokens(uint256 _subgraphID, uint256 _nSignalIn) external view returns (uint256, uint256); /** * @notice Calculate subgraph signal to be returned for an amount of subgraph deployment signal. @@ -202,10 +176,7 @@ interface IGNS { * @param _vSignalIn Amount of subgraph deployment signal to exchange for subgraph signal * @return Amount of subgraph signal that can be bought */ - function vSignalToNSignal(uint256 _subgraphID, uint256 _vSignalIn) - external - view - returns (uint256); + function vSignalToNSignal(uint256 _subgraphID, uint256 _vSignalIn) external view returns (uint256); /** * @notice Calculate subgraph deployment signal to be returned for an amount of subgraph signal. @@ -213,10 +184,7 @@ interface IGNS { * @param _nSignalIn Subgraph signal being exchanged for subgraph deployment signal * @return Amount of subgraph deployment signal that can be returned */ - function nSignalToVSignal(uint256 _subgraphID, uint256 _nSignalIn) - external - view - returns (uint256); + function nSignalToVSignal(uint256 _subgraphID, uint256 _nSignalIn) external view returns (uint256); /** * @notice Get the amount of subgraph signal a curator has. @@ -224,10 +192,7 @@ interface IGNS { * @param _curator Curator address * @return Amount of subgraph signal owned by a curator */ - function getCuratorSignal(uint256 _subgraphID, address _curator) - external - view - returns (uint256); + function getCuratorSignal(uint256 _subgraphID, address _curator) external view returns (uint256); /** * @notice Return whether a subgraph is published. @@ -249,8 +214,5 @@ interface IGNS { * @return account Account that created the subgraph (or 0 if it's not a legacy subgraph) * @return seqID Sequence number for the subgraph */ - function getLegacySubgraphKey(uint256 _subgraphID) - external - view - returns (address account, uint256 seqID); + function getLegacySubgraphKey(uint256 _subgraphID) external view returns (address account, uint256 seqID); } diff --git a/packages/contracts/contracts/discovery/IServiceRegistry.sol b/packages/contracts/contracts/discovery/IServiceRegistry.sol index 25eb07477..da284a409 100644 --- a/packages/contracts/contracts/discovery/IServiceRegistry.sol +++ b/packages/contracts/contracts/discovery/IServiceRegistry.sol @@ -10,11 +10,7 @@ interface IServiceRegistry { function register(string calldata _url, string calldata _geohash) external; - function registerFor( - address _indexer, - string calldata _url, - string calldata _geohash - ) external; + function registerFor(address _indexer, string calldata _url, string calldata _geohash) external; function unregister() external; diff --git a/packages/contracts/contracts/discovery/L1GNS.sol b/packages/contracts/contracts/discovery/L1GNS.sol index a2d15e1a7..31e9b0fb3 100644 --- a/packages/contracts/contracts/discovery/L1GNS.sol +++ b/packages/contracts/contracts/discovery/L1GNS.sol @@ -60,10 +60,7 @@ contract L1GNS is GNS, L1GNSV1Storage { uint256 _maxSubmissionCost ) external payable notPartialPaused { require(!subgraphTransferredToL2[_subgraphID], "ALREADY_DONE"); - require( - msg.value == _maxSubmissionCost.add(_maxGas.mul(_gasPriceBid)), - "INVALID_ETH_VALUE" - ); + require(msg.value == _maxSubmissionCost.add(_maxGas.mul(_gasPriceBid)), "INVALID_ETH_VALUE"); SubgraphData storage subgraphData = _getSubgraphOrRevert(_subgraphID); // This is just like onlySubgraphAuth, but we want it to run after the subgraphTransferredToL2 check @@ -71,11 +68,7 @@ contract L1GNS is GNS, L1GNSV1Storage { require(ownerOf(_subgraphID) == msg.sender, "GNS: Must be authorized"); subgraphTransferredToL2[_subgraphID] = true; - uint256 curationTokens = curation().burn( - subgraphData.subgraphDeploymentID, - subgraphData.vSignal, - 0 - ); + uint256 curationTokens = curation().burn(subgraphData.subgraphDeploymentID, subgraphData.vSignal, 0); subgraphData.disabled = true; subgraphData.vSignal = 0; @@ -93,19 +86,9 @@ contract L1GNS is GNS, L1GNSV1Storage { subgraphData.nSignal = totalSignal.sub(ownerNSignal); subgraphData.withdrawableGRT = curationTokens.sub(tokensForL2); - bytes memory extraData = abi.encode( - uint8(IL2GNS.L1MessageCodes.RECEIVE_SUBGRAPH_CODE), - _subgraphID, - _l2Owner - ); + bytes memory extraData = abi.encode(uint8(IL2GNS.L1MessageCodes.RECEIVE_SUBGRAPH_CODE), _subgraphID, _l2Owner); - _sendTokensAndMessageToL2GNS( - tokensForL2, - _maxGas, - _gasPriceBid, - _maxSubmissionCost, - extraData - ); + _sendTokensAndMessageToL2GNS(tokensForL2, _maxGas, _gasPriceBid, _maxSubmissionCost, extraData); subgraphData.__DEPRECATED_reserveRatio = 0; _burnNFT(_subgraphID); @@ -138,10 +121,7 @@ contract L1GNS is GNS, L1GNSV1Storage { uint256 _maxSubmissionCost ) external payable notPartialPaused { require(subgraphTransferredToL2[_subgraphID], "!TRANSFERRED"); - require( - msg.value == _maxSubmissionCost.add(_maxGas.mul(_gasPriceBid)), - "INVALID_ETH_VALUE" - ); + require(msg.value == _maxSubmissionCost.add(_maxGas.mul(_gasPriceBid)), "INVALID_ETH_VALUE"); // The Arbitrum bridge will check this too, we just check here for an early exit require(_maxSubmissionCost != 0, "NO_SUBMISSION_COST"); @@ -165,13 +145,7 @@ contract L1GNS is GNS, L1GNSV1Storage { subgraphData.withdrawableGRT = withdrawableGRT.sub(tokensForL2); // Send the tokens and data to L2 using the L1GraphTokenGateway - _sendTokensAndMessageToL2GNS( - tokensForL2, - _maxGas, - _gasPriceBid, - _maxSubmissionCost, - extraData - ); + _sendTokensAndMessageToL2GNS(tokensForL2, _maxGas, _gasPriceBid, _maxSubmissionCost, extraData); emit CuratorBalanceSentToL2(_subgraphID, msg.sender, _beneficiary, tokensForL2); } diff --git a/packages/contracts/contracts/discovery/ServiceRegistry.sol b/packages/contracts/contracts/discovery/ServiceRegistry.sol index 228210bf1..1eb1393d3 100644 --- a/packages/contracts/contracts/discovery/ServiceRegistry.sol +++ b/packages/contracts/contracts/discovery/ServiceRegistry.sol @@ -49,11 +49,7 @@ contract ServiceRegistry is ServiceRegistryV1Storage, GraphUpgradeable, IService * @param _url URL of the indexer service * @param _geohash Geohash of the indexer service location */ - function registerFor( - address _indexer, - string calldata _url, - string calldata _geohash - ) external override { + function registerFor(address _indexer, string calldata _url, string calldata _geohash) external override { _register(_indexer, _url, _geohash); } @@ -63,11 +59,7 @@ contract ServiceRegistry is ServiceRegistryV1Storage, GraphUpgradeable, IService * @param _url URL of the indexer service * @param _geohash Geohash of the indexer service location */ - function _register( - address _indexer, - string calldata _url, - string calldata _geohash - ) private { + function _register(address _indexer, string calldata _url, string calldata _geohash) private { require(_isAuth(_indexer), "!auth"); require(bytes(_url).length > 0, "Service must specify a URL"); diff --git a/packages/contracts/contracts/discovery/SubgraphNFT.sol b/packages/contracts/contracts/discovery/SubgraphNFT.sol index c6dadaa81..3c514718c 100644 --- a/packages/contracts/contracts/discovery/SubgraphNFT.sol +++ b/packages/contracts/contracts/discovery/SubgraphNFT.sol @@ -114,11 +114,7 @@ contract SubgraphNFT is Governed, ERC721, ISubgraphNFT { * @param _tokenId ID of the NFT * @param _subgraphMetadata IPFS hash for the metadata */ - function setSubgraphMetadata(uint256 _tokenId, bytes32 _subgraphMetadata) - external - override - onlyMinter - { + function setSubgraphMetadata(uint256 _tokenId, bytes32 _subgraphMetadata) external override onlyMinter { require(_exists(_tokenId), "ERC721Metadata: URI set of nonexistent token"); _subgraphMetadataHashes[_tokenId] = _subgraphMetadata; emit SubgraphMetadataUpdated(_tokenId, _subgraphMetadata); @@ -127,24 +123,13 @@ contract SubgraphNFT is Governed, ERC721, ISubgraphNFT { // -- NFT display -- /// @inheritdoc ERC721 - function tokenURI(uint256 _tokenId) - public - view - override(ERC721, ISubgraphNFT) - returns (string memory) - { + function tokenURI(uint256 _tokenId) public view override(ERC721, ISubgraphNFT) returns (string memory) { require(_exists(_tokenId), "ERC721Metadata: URI query for nonexistent token"); // Delegates rendering of the metadata to the token descriptor if existing // This allows for some flexibility in adapting the token URI if (address(tokenDescriptor) != address(0)) { - return - tokenDescriptor.tokenURI( - minter, - _tokenId, - baseURI(), - _subgraphMetadataHashes[_tokenId] - ); + return tokenDescriptor.tokenURI(minter, _tokenId, baseURI(), _subgraphMetadataHashes[_tokenId]); } // Default token URI diff --git a/packages/contracts/contracts/discovery/SubgraphNFTDescriptor.sol b/packages/contracts/contracts/discovery/SubgraphNFTDescriptor.sol index 751db2353..81f6da696 100644 --- a/packages/contracts/contracts/discovery/SubgraphNFTDescriptor.sol +++ b/packages/contracts/contracts/discovery/SubgraphNFTDescriptor.sol @@ -9,14 +9,12 @@ import "./ISubgraphNFTDescriptor.sol"; contract SubgraphNFTDescriptor is ISubgraphNFTDescriptor { /// @inheritdoc ISubgraphNFTDescriptor function tokenURI( - address, /* _minter */ - uint256, /* _tokenId */ + address /* _minter */, + uint256 /* _tokenId */, string calldata _baseURI, bytes32 _subgraphMetadata ) external pure override returns (string memory) { - bytes memory b58 = Base58Encoder.encode( - abi.encodePacked(Base58Encoder.sha256MultiHash, _subgraphMetadata) - ); + bytes memory b58 = Base58Encoder.encode(abi.encodePacked(Base58Encoder.sha256MultiHash, _subgraphMetadata)); if (bytes(_baseURI).length == 0) { return string(b58); } diff --git a/packages/contracts/contracts/discovery/erc1056/EthereumDIDRegistry.sol b/packages/contracts/contracts/discovery/erc1056/EthereumDIDRegistry.sol index dce0e830a..e8545dd4a 100644 --- a/packages/contracts/contracts/discovery/erc1056/EthereumDIDRegistry.sol +++ b/packages/contracts/contracts/discovery/erc1056/EthereumDIDRegistry.sol @@ -62,21 +62,13 @@ contract EthereumDIDRegistry { return signer; } - function validDelegate( - address identity, - bytes32 delegateType, - address delegate - ) public view returns (bool) { + function validDelegate(address identity, bytes32 delegateType, address delegate) public view returns (bool) { uint256 validity = delegates[identity][keccak256(abi.encode(delegateType))][delegate]; /* solium-disable-next-line security/no-block-members*/ return (validity > block.timestamp); } - function changeOwner( - address identity, - address actor, - address newOwner - ) internal onlyOwner(identity, actor) { + function changeOwner(address identity, address actor, address newOwner) internal onlyOwner(identity, actor) { owners[identity] = newOwner; emit DIDOwnerChanged(identity, newOwner, changed[identity]); changed[identity] = block.number; @@ -86,13 +78,7 @@ contract EthereumDIDRegistry { changeOwner(identity, msg.sender, newOwner); } - function changeOwnerSigned( - address identity, - uint8 sigV, - bytes32 sigR, - bytes32 sigS, - address newOwner - ) public { + function changeOwnerSigned(address identity, uint8 sigV, bytes32 sigR, bytes32 sigS, address newOwner) public { bytes32 hash = keccak256( abi.encodePacked( bytes1(0x19), @@ -115,9 +101,7 @@ contract EthereumDIDRegistry { uint256 validity ) internal onlyOwner(identity, actor) { /* solium-disable-next-line security/no-block-members*/ - delegates[identity][keccak256(abi.encode(delegateType))][delegate] = - block.timestamp + - validity; + delegates[identity][keccak256(abi.encode(delegateType))][delegate] = block.timestamp + validity; emit DIDDelegateChanged( identity, delegateType, @@ -129,12 +113,7 @@ contract EthereumDIDRegistry { changed[identity] = block.number; } - function addDelegate( - address identity, - bytes32 delegateType, - address delegate, - uint256 validity - ) public { + function addDelegate(address identity, bytes32 delegateType, address delegate, uint256 validity) public { addDelegate(identity, msg.sender, delegateType, delegate, validity); } @@ -160,13 +139,7 @@ contract EthereumDIDRegistry { validity ) ); - addDelegate( - identity, - checkSignature(identity, sigV, sigR, sigS, hash), - delegateType, - delegate, - validity - ); + addDelegate(identity, checkSignature(identity, sigV, sigR, sigS, hash), delegateType, delegate, validity); } function revokeDelegate( @@ -178,21 +151,11 @@ contract EthereumDIDRegistry { /* solium-disable-next-line security/no-block-members*/ delegates[identity][keccak256(abi.encode(delegateType))][delegate] = block.timestamp; /* solium-disable-next-line security/no-block-members*/ - emit DIDDelegateChanged( - identity, - delegateType, - delegate, - block.timestamp, - changed[identity] - ); + emit DIDDelegateChanged(identity, delegateType, delegate, block.timestamp, changed[identity]); changed[identity] = block.number; } - function revokeDelegate( - address identity, - bytes32 delegateType, - address delegate - ) public { + function revokeDelegate(address identity, bytes32 delegateType, address delegate) public { revokeDelegate(identity, msg.sender, delegateType, delegate); } @@ -216,12 +179,7 @@ contract EthereumDIDRegistry { delegate ) ); - revokeDelegate( - identity, - checkSignature(identity, sigV, sigR, sigS, hash), - delegateType, - delegate - ); + revokeDelegate(identity, checkSignature(identity, sigV, sigR, sigS, hash), delegateType, delegate); } function setAttribute( @@ -232,22 +190,11 @@ contract EthereumDIDRegistry { uint256 validity ) internal onlyOwner(identity, actor) { /* solium-disable-next-line security/no-block-members*/ - emit DIDAttributeChanged( - identity, - name, - value, - block.timestamp + validity, - changed[identity] - ); + emit DIDAttributeChanged(identity, name, value, block.timestamp + validity, changed[identity]); changed[identity] = block.number; } - function setAttribute( - address identity, - bytes32 name, - bytes memory value, - uint256 validity - ) public { + function setAttribute(address identity, bytes32 name, bytes memory value, uint256 validity) public { setAttribute(identity, msg.sender, name, value, validity); } @@ -273,13 +220,7 @@ contract EthereumDIDRegistry { validity ) ); - setAttribute( - identity, - checkSignature(identity, sigV, sigR, sigS, hash), - name, - value, - validity - ); + setAttribute(identity, checkSignature(identity, sigV, sigR, sigS, hash), name, value, validity); } function revokeAttribute( @@ -292,11 +233,7 @@ contract EthereumDIDRegistry { changed[identity] = block.number; } - function revokeAttribute( - address identity, - bytes32 name, - bytes memory value - ) public { + function revokeAttribute(address identity, bytes32 name, bytes memory value) public { revokeAttribute(identity, msg.sender, name, value); } diff --git a/packages/contracts/contracts/discovery/erc1056/IEthereumDIDRegistry.sol b/packages/contracts/contracts/discovery/erc1056/IEthereumDIDRegistry.sol index 10a383f85..8de69f304 100644 --- a/packages/contracts/contracts/discovery/erc1056/IEthereumDIDRegistry.sol +++ b/packages/contracts/contracts/discovery/erc1056/IEthereumDIDRegistry.sol @@ -5,10 +5,5 @@ pragma solidity ^0.7.6; interface IEthereumDIDRegistry { function identityOwner(address identity) external view returns (address); - function setAttribute( - address identity, - bytes32 name, - bytes calldata value, - uint256 validity - ) external; + function setAttribute(address identity, bytes32 name, bytes calldata value, uint256 validity) external; } diff --git a/packages/contracts/contracts/disputes/DisputeManager.sol b/packages/contracts/contracts/disputes/DisputeManager.sol index 8122b86b7..6700ec341 100644 --- a/packages/contracts/contracts/disputes/DisputeManager.sol +++ b/packages/contracts/contracts/disputes/DisputeManager.sol @@ -42,13 +42,10 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa // -- EIP-712 -- bytes32 private constant DOMAIN_TYPE_HASH = - keccak256( - "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract,bytes32 salt)" - ); + keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract,bytes32 salt)"); bytes32 private constant DOMAIN_NAME_HASH = keccak256("Graph Protocol"); bytes32 private constant DOMAIN_VERSION_HASH = keccak256("0"); - bytes32 private constant DOMAIN_SALT = - 0xa070ffb1cd7409649bf77822cce74495468e06dbfaef09556838bf188679b9c2; + bytes32 private constant DOMAIN_SALT = 0xa070ffb1cd7409649bf77822cce74495468e06dbfaef09556838bf188679b9c2; bytes32 private constant RECEIPT_TYPE_HASH = keccak256("Receipt(bytes32 requestCID,bytes32 responseCID,bytes32 subgraphDeploymentID)"); @@ -126,12 +123,7 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa * @dev Emitted when arbitrator draw a `disputeID` for `indexer` created by `fisherman`. * The event emits the amount `tokens` used as deposit and returned to the fisherman. */ - event DisputeDrawn( - bytes32 indexed disputeID, - address indexed indexer, - address indexed fisherman, - uint256 tokens - ); + event DisputeDrawn(bytes32 indexed disputeID, address indexed indexer, address indexed fisherman, uint256 tokens); /** * @dev Emitted when two disputes are in conflict to link them. @@ -156,10 +148,7 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa modifier onlyPendingDispute(bytes32 _disputeID) { require(isDisputeCreated(_disputeID), "Dispute does not exist"); - require( - disputes[_disputeID].status == IDisputeManager.DisputeStatus.Pending, - "Dispute must be pending" - ); + require(disputes[_disputeID].status == IDisputeManager.DisputeStatus.Pending, "Dispute must be pending"); _; } @@ -268,11 +257,7 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa * @param _qryPercentage Percentage slashing for query disputes * @param _idxPercentage Percentage slashing for indexing disputes */ - function setSlashingPercentage(uint32 _qryPercentage, uint32 _idxPercentage) - external - override - onlyGovernor - { + function setSlashingPercentage(uint32 _qryPercentage, uint32 _idxPercentage) external override onlyGovernor { _setSlashingPercentage(_qryPercentage, _idxPercentage); } @@ -349,12 +334,7 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa * @param _attestation Attestation * @return Indexer address */ - function getAttestationIndexer(Attestation memory _attestation) - public - view - override - returns (address) - { + function getAttestationIndexer(Attestation memory _attestation) public view override returns (address) { // Get attestation signer. Indexers signs with the allocationID address allocationID = _recoverAttestationSigner(_attestation); @@ -374,11 +354,7 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa * @param _attestationData Attestation bytes submitted by the fisherman * @param _deposit Amount of tokens staked as deposit */ - function createQueryDispute(bytes calldata _attestationData, uint256 _deposit) - external - override - returns (bytes32) - { + function createQueryDispute(bytes calldata _attestationData, uint256 _deposit) external override returns (bytes32) { // Get funds from submitter _pullSubmitterDeposit(_deposit); @@ -415,25 +391,12 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa Attestation memory attestation2 = _parseAttestation(_attestationData2); // Test that attestations are conflicting - require( - areConflictingAttestations(attestation1, attestation2), - "Attestations must be in conflict" - ); + require(areConflictingAttestations(attestation1, attestation2), "Attestations must be in conflict"); // Create the disputes // The deposit is zero for conflicting attestations - bytes32 dID1 = _createQueryDisputeWithAttestation( - fisherman, - 0, - attestation1, - _attestationData1 - ); - bytes32 dID2 = _createQueryDisputeWithAttestation( - fisherman, - 0, - attestation2, - _attestationData2 - ); + bytes32 dID1 = _createQueryDisputeWithAttestation(fisherman, 0, attestation1, _attestationData1); + bytes32 dID2 = _createQueryDisputeWithAttestation(fisherman, 0, attestation2, _attestationData2); // Store the linked disputes to be resolved disputes[dID1].relatedDisputeID = dID2; @@ -512,11 +475,7 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa * @param _allocationID The allocation to dispute * @param _deposit Amount of tokens staked as deposit */ - function createIndexingDispute(address _allocationID, uint256 _deposit) - external - override - returns (bytes32) - { + function createIndexingDispute(address _allocationID, uint256 _deposit) external override returns (bytes32) { // Get funds from submitter _pullSubmitterDeposit(_deposit); @@ -573,23 +532,14 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa * @notice Accept a dispute with ID `_disputeID` * @param _disputeID ID of the dispute to be accepted */ - function acceptDispute(bytes32 _disputeID) - external - override - onlyArbitrator - onlyPendingDispute(_disputeID) - { + function acceptDispute(bytes32 _disputeID) external override onlyArbitrator onlyPendingDispute(_disputeID) { Dispute storage dispute = disputes[_disputeID]; // store the dispute status dispute.status = IDisputeManager.DisputeStatus.Accepted; // Slash - (, uint256 tokensToReward) = _slashIndexer( - dispute.indexer, - dispute.fisherman, - dispute.disputeType - ); + (, uint256 tokensToReward) = _slashIndexer(dispute.indexer, dispute.fisherman, dispute.disputeType); // Give the fisherman their deposit back TokenUtils.pushTokens(graphToken(), dispute.fisherman, dispute.deposit); @@ -598,12 +548,7 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa rejectDispute(dispute.relatedDisputeID); } - emit DisputeAccepted( - _disputeID, - dispute.indexer, - dispute.fisherman, - dispute.deposit.add(tokensToReward) - ); + emit DisputeAccepted(_disputeID, dispute.indexer, dispute.fisherman, dispute.deposit.add(tokensToReward)); } /** @@ -611,12 +556,7 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa * @notice Reject a dispute with ID `_disputeID` * @param _disputeID ID of the dispute to be rejected */ - function rejectDispute(bytes32 _disputeID) - public - override - onlyArbitrator - onlyPendingDispute(_disputeID) - { + function rejectDispute(bytes32 _disputeID) public override onlyArbitrator onlyPendingDispute(_disputeID) { Dispute storage dispute = disputes[_disputeID]; // store dispute status @@ -639,12 +579,7 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa * @notice Ignore a dispute with ID `_disputeID` * @param _disputeID ID of the dispute to be disregarded */ - function drawDispute(bytes32 _disputeID) - public - override - onlyArbitrator - onlyPendingDispute(_disputeID) - { + function drawDispute(bytes32 _disputeID) public override onlyArbitrator onlyPendingDispute(_disputeID) { Dispute storage dispute = disputes[_disputeID]; // Return deposit to the fisherman @@ -667,8 +602,7 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa function _isDisputeInConflict(Dispute memory _dispute) private view returns (bool) { bytes32 relatedID = _dispute.relatedDisputeID; // this is so the check returns false when rejecting the related dispute. - return - relatedID != 0 && disputes[relatedID].status == IDisputeManager.DisputeStatus.Pending; + return relatedID != 0 && disputes[relatedID].status == IDisputeManager.DisputeStatus.Pending; } /** @@ -718,9 +652,7 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa uint256 slashableAmount = staking.getIndexerStakedTokens(_indexer); // slashable tokens // Get slash amount - slashAmount = _getSlashingPercentageForDisputeType(_disputeType).mul(slashableAmount).div( - MAX_PPM - ); + slashAmount = _getSlashingPercentageForDisputeType(_disputeType).mul(slashableAmount).div(MAX_PPM); require(slashAmount > 0, "Dispute has zero tokens to slash"); // Get rewards amount @@ -736,11 +668,7 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa * @param _disputeType Dispute type * @return Slashing percentage to use for the dispute type */ - function _getSlashingPercentageForDisputeType(DisputeType _disputeType) - private - view - returns (uint256) - { + function _getSlashingPercentageForDisputeType(DisputeType _disputeType) private view returns (uint256) { if (_disputeType == DisputeType.QueryDispute) return uint256(qrySlashingPercentage); if (_disputeType == DisputeType.IndexingDispute) return uint256(idxSlashingPercentage); return 0; @@ -751,11 +679,7 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa * @param _attestation The attestation struct * @return Signer address */ - function _recoverAttestationSigner(Attestation memory _attestation) - private - view - returns (address) - { + function _recoverAttestationSigner(Attestation memory _attestation) private view returns (address) { // Obtain the hash of the fully-encoded message, per EIP-712 encoding Receipt memory receipt = Receipt( _attestation.requestCID, @@ -766,11 +690,7 @@ contract DisputeManager is DisputeManagerV1Storage, GraphUpgradeable, IDisputeMa // Obtain the signer of the fully-encoded EIP-712 message hash // NOTE: The signer of the attestation is the indexer that served the request - return - ECDSA.recover( - messageHash, - abi.encodePacked(_attestation.r, _attestation.s, _attestation.v) - ); + return ECDSA.recover(messageHash, abi.encodePacked(_attestation.r, _attestation.s, _attestation.v)); } /** diff --git a/packages/contracts/contracts/disputes/IDisputeManager.sol b/packages/contracts/contracts/disputes/IDisputeManager.sol index 9c872f890..8c6668371 100644 --- a/packages/contracts/contracts/disputes/IDisputeManager.sol +++ b/packages/contracts/contracts/disputes/IDisputeManager.sol @@ -74,18 +74,14 @@ interface IDisputeManager { // -- Dispute -- - function createQueryDispute(bytes calldata _attestationData, uint256 _deposit) - external - returns (bytes32); + function createQueryDispute(bytes calldata _attestationData, uint256 _deposit) external returns (bytes32); function createQueryDisputeConflict( bytes calldata _attestationData1, bytes calldata _attestationData2 ) external returns (bytes32, bytes32); - function createIndexingDispute(address _allocationID, uint256 _deposit) - external - returns (bytes32); + function createIndexingDispute(address _allocationID, uint256 _deposit) external returns (bytes32); function acceptDispute(bytes32 _disputeID) external; diff --git a/packages/contracts/contracts/epochs/EpochManager.sol b/packages/contracts/contracts/epochs/EpochManager.sol index 3f022d4af..281b63896 100644 --- a/packages/contracts/contracts/epochs/EpochManager.sol +++ b/packages/contracts/contracts/epochs/EpochManager.sol @@ -93,10 +93,7 @@ contract EpochManager is EpochManagerV1Storage, GraphUpgradeable, IEpochManager uint256 currentBlock = blockNum(); require(_block < currentBlock, "Can only retrieve past block hashes"); - require( - currentBlock < 256 || _block >= currentBlock - 256, - "Can only retrieve hashes for last 256 blocks" - ); + require(currentBlock < 256 || _block >= currentBlock - 256, "Can only retrieve hashes for last 256 blocks"); return blockhash(_block); } diff --git a/packages/contracts/contracts/gateway/GraphTokenGateway.sol b/packages/contracts/contracts/gateway/GraphTokenGateway.sol index ca2ad4c95..fb992afc2 100644 --- a/packages/contracts/contracts/gateway/GraphTokenGateway.sol +++ b/packages/contracts/contracts/gateway/GraphTokenGateway.sol @@ -19,10 +19,7 @@ abstract contract GraphTokenGateway is GraphUpgradeable, Pausable, Managed, ITok * @dev Check if the caller is the Controller's governor or this contract's pause guardian. */ modifier onlyGovernorOrGuardian() { - require( - msg.sender == controller.getGovernor() || msg.sender == pauseGuardian, - "Only Governor or Guardian" - ); + require(msg.sender == controller.getGovernor() || msg.sender == pauseGuardian, "Only Governor or Guardian"); _; } diff --git a/packages/contracts/contracts/gateway/ICallhookReceiver.sol b/packages/contracts/contracts/gateway/ICallhookReceiver.sol index ff0fbfab1..885b0cdb2 100644 --- a/packages/contracts/contracts/gateway/ICallhookReceiver.sol +++ b/packages/contracts/contracts/gateway/ICallhookReceiver.sol @@ -15,9 +15,5 @@ interface ICallhookReceiver { * @param _amount Amount of tokens that were transferred * @param _data ABI-encoded callhook data */ - function onTokenTransfer( - address _from, - uint256 _amount, - bytes calldata _data - ) external; + function onTokenTransfer(address _from, uint256 _amount, bytes calldata _data) external; } diff --git a/packages/contracts/contracts/gateway/L1GraphTokenGateway.sol b/packages/contracts/contracts/gateway/L1GraphTokenGateway.sol index cfa71e6a0..7fad927ad 100644 --- a/packages/contracts/contracts/gateway/L1GraphTokenGateway.sol +++ b/packages/contracts/contracts/gateway/L1GraphTokenGateway.sol @@ -207,10 +207,7 @@ contract L1GraphTokenGateway is Initializable, GraphTokenGateway, L1ArbitrumMess * @param _l2IssuancePerBlock New issuancePerBlock that has been set in L2 * @param _updateBlockNum L1 Block number at which issuancePerBlock was updated in L2 */ - function updateL2MintAllowance(uint256 _l2IssuancePerBlock, uint256 _updateBlockNum) - external - onlyGovernor - { + function updateL2MintAllowance(uint256 _l2IssuancePerBlock, uint256 _updateBlockNum) external onlyGovernor { require(_updateBlockNum < block.number, "BLOCK_MUST_BE_PAST"); require(_updateBlockNum > lastL2MintAllowanceUpdateBlock, "BLOCK_MUST_BE_INCREMENTING"); accumulatedL2MintAllowanceSnapshot = accumulatedL2MintAllowanceAtBlock(_updateBlockNum); @@ -290,30 +287,15 @@ contract L1GraphTokenGateway is Initializable, GraphTokenGateway, L1ArbitrumMess { bytes memory extraData; (from, maxSubmissionCost, extraData) = _parseOutboundData(_data); - require( - extraData.length == 0 || callhookAllowlist[msg.sender] == true, - "CALL_HOOK_DATA_NOT_ALLOWED" - ); + require(extraData.length == 0 || callhookAllowlist[msg.sender] == true, "CALL_HOOK_DATA_NOT_ALLOWED"); require(maxSubmissionCost != 0, "NO_SUBMISSION_COST"); outboundCalldata = getOutboundCalldata(_l1Token, from, _to, _amount, extraData); } { - L2GasParams memory gasParams = L2GasParams( - maxSubmissionCost, - _maxGas, - _gasPriceBid - ); + L2GasParams memory gasParams = L2GasParams(maxSubmissionCost, _maxGas, _gasPriceBid); // transfer tokens to escrow token.transferFrom(from, escrow, _amount); - seqNum = sendTxToL2( - inbox, - l2Counterpart, - from, - msg.value, - 0, - gasParams, - outboundCalldata - ); + seqNum = sendTxToL2(inbox, l2Counterpart, from, msg.value, 0, gasParams, outboundCalldata); } } emit DepositInitiated(_l1Token, from, _to, seqNum, _amount); @@ -425,15 +407,7 @@ contract L1GraphTokenGateway is Initializable, GraphTokenGateway, L1ArbitrumMess * @return Base ether value required to keep retryable ticket alive * @return Additional data sent to L2 */ - function _parseOutboundData(bytes calldata _data) - private - view - returns ( - address, - uint256, - bytes memory - ) - { + function _parseOutboundData(bytes calldata _data) private view returns (address, uint256, bytes memory) { address from; uint256 maxSubmissionCost; bytes memory extraData; diff --git a/packages/contracts/contracts/governance/Controller.sol b/packages/contracts/contracts/governance/Controller.sol index bc287d2be..affb29a05 100644 --- a/packages/contracts/contracts/governance/Controller.sol +++ b/packages/contracts/contracts/governance/Controller.sol @@ -32,10 +32,7 @@ contract Controller is Governed, Pausable, IController { * @dev Check if the caller is the governor or pause guardian. */ modifier onlyGovernorOrGuardian() { - require( - msg.sender == governor || msg.sender == pauseGuardian, - "Only Governor or Guardian can call" - ); + require(msg.sender == governor || msg.sender == pauseGuardian, "Only Governor or Guardian can call"); _; } @@ -53,11 +50,7 @@ contract Controller is Governed, Pausable, IController { * @param _id Contract id (keccak256 hash of contract name) * @param _contractAddress Contract address */ - function setContractProxy(bytes32 _id, address _contractAddress) - external - override - onlyGovernor - { + function setContractProxy(bytes32 _id, address _contractAddress) external override onlyGovernor { require(_contractAddress != address(0), "Contract address must be set"); _registry[_id] = _contractAddress; emit SetContractProxy(_id, _contractAddress); diff --git a/packages/contracts/contracts/l2/curation/IL2Curation.sol b/packages/contracts/contracts/l2/curation/IL2Curation.sol index 235eec28a..bbbfd82ff 100644 --- a/packages/contracts/contracts/l2/curation/IL2Curation.sol +++ b/packages/contracts/contracts/l2/curation/IL2Curation.sol @@ -14,9 +14,7 @@ interface IL2Curation { * @param _tokensIn Amount of Graph Tokens to deposit * @return Signal minted */ - function mintTaxFree(bytes32 _subgraphDeploymentID, uint256 _tokensIn) - external - returns (uint256); + function mintTaxFree(bytes32 _subgraphDeploymentID, uint256 _tokensIn) external returns (uint256); /** * @notice Calculate amount of signal that can be bought with tokens in a curation pool, @@ -25,10 +23,7 @@ interface IL2Curation { * @param _tokensIn Amount of tokens used to mint signal * @return Amount of signal that can be bought */ - function tokensToSignalNoTax(bytes32 _subgraphDeploymentID, uint256 _tokensIn) - external - view - returns (uint256); + function tokensToSignalNoTax(bytes32 _subgraphDeploymentID, uint256 _tokensIn) external view returns (uint256); /** * @notice Calculate the amount of tokens that would be recovered if minting signal with @@ -38,8 +33,8 @@ interface IL2Curation { * @param _tokensIn Amount of tokens used to mint signal * @return Amount of tokens that would be recovered after minting and burning signal */ - function tokensToSignalToTokensNoTax(bytes32 _subgraphDeploymentID, uint256 _tokensIn) - external - view - returns (uint256); + function tokensToSignalToTokensNoTax( + bytes32 _subgraphDeploymentID, + uint256 _tokensIn + ) external view returns (uint256); } diff --git a/packages/contracts/contracts/l2/curation/L2Curation.sol b/packages/contracts/contracts/l2/curation/L2Curation.sol index 0da3ce768..4d51bf3f1 100644 --- a/packages/contracts/contracts/l2/curation/L2Curation.sol +++ b/packages/contracts/contracts/l2/curation/L2Curation.sol @@ -59,12 +59,7 @@ contract L2Curation is CurationV2Storage, GraphUpgradeable, IL2Curation { * @dev Emitted when `curator` burned `signal` for a `subgraphDeploymentID`. * The curator will receive `tokens` according to the value of the bonding curve. */ - event Burned( - address indexed curator, - bytes32 indexed subgraphDeploymentID, - uint256 tokens, - uint256 signal - ); + event Burned(address indexed curator, bytes32 indexed subgraphDeploymentID, uint256 tokens, uint256 signal); /** * @dev Emitted when `tokens` amount were collected for `subgraphDeploymentID` as part of fees @@ -116,11 +111,7 @@ contract L2Curation is CurationV2Storage, GraphUpgradeable, IL2Curation { * @notice Update the minimum deposit amount to `_minimumCurationDeposit` * @param _minimumCurationDeposit Minimum amount of tokens required deposit */ - function setMinimumCurationDeposit(uint256 _minimumCurationDeposit) - external - override - onlyGovernor - { + function setMinimumCurationDeposit(uint256 _minimumCurationDeposit) external override onlyGovernor { _setMinimumCurationDeposit(_minimumCurationDeposit); } @@ -152,10 +143,7 @@ contract L2Curation is CurationV2Storage, GraphUpgradeable, IL2Curation { require(msg.sender == address(staking()), "Caller must be the staking contract"); // Must be curated to accept tokens - require( - isCurated(_subgraphDeploymentID), - "Subgraph deployment must be curated to collect fees" - ); + require(isCurated(_subgraphDeploymentID), "Subgraph deployment must be curated to collect fees"); // Collect new funds into reserve CurationPool storage curationPool = pools[_subgraphDeploymentID]; @@ -196,9 +184,7 @@ contract L2Curation is CurationV2Storage, GraphUpgradeable, IL2Curation { // If no signal token for the pool - create one if (address(curationPool.gcs) == address(0)) { // Use a minimal proxy to reduce gas cost - IGraphCurationToken gcs = IGraphCurationToken( - ClonesUpgradeable.clone(curationTokenMaster) - ); + IGraphCurationToken gcs = IGraphCurationToken(ClonesUpgradeable.clone(curationTokenMaster)); gcs.initialize(address(this)); curationPool.gcs = gcs; } @@ -232,13 +218,10 @@ contract L2Curation is CurationV2Storage, GraphUpgradeable, IL2Curation { * @param _tokensIn Amount of Graph Tokens to deposit * @return Signal minted */ - function mintTaxFree(bytes32 _subgraphDeploymentID, uint256 _tokensIn) - external - override - notPartialPaused - onlyGNS - returns (uint256) - { + function mintTaxFree( + bytes32 _subgraphDeploymentID, + uint256 _tokensIn + ) external override notPartialPaused onlyGNS returns (uint256) { // Need to deposit some funds require(_tokensIn != 0, "Cannot deposit zero tokens"); @@ -256,9 +239,7 @@ contract L2Curation is CurationV2Storage, GraphUpgradeable, IL2Curation { // If no signal token for the pool - create one if (address(curationPool.gcs) == address(0)) { // Use a minimal proxy to reduce gas cost - IGraphCurationToken gcs = IGraphCurationToken( - ClonesUpgradeable.clone(curationTokenMaster) - ); + IGraphCurationToken gcs = IGraphCurationToken(ClonesUpgradeable.clone(curationTokenMaster)); gcs.initialize(address(this)); curationPool.gcs = gcs; } @@ -299,10 +280,7 @@ contract L2Curation is CurationV2Storage, GraphUpgradeable, IL2Curation { // Validations require(_signalIn != 0, "Cannot burn zero signal"); - require( - getCuratorSignal(curator, _subgraphDeploymentID) >= _signalIn, - "Cannot burn more signal than you own" - ); + require(getCuratorSignal(curator, _subgraphDeploymentID) >= _signalIn, "Cannot burn more signal than you own"); // Get the amount of tokens to refund based on returned signal uint256 tokensOut = signalToTokens(_subgraphDeploymentID, _signalIn); @@ -337,12 +315,7 @@ contract L2Curation is CurationV2Storage, GraphUpgradeable, IL2Curation { * @param _subgraphDeploymentID Subgraph deployment curation poool * @return Amount of token reserves in the curation pool */ - function getCurationPoolTokens(bytes32 _subgraphDeploymentID) - external - view - override - returns (uint256) - { + function getCurationPoolTokens(bytes32 _subgraphDeploymentID) external view override returns (uint256) { return pools[_subgraphDeploymentID].tokens; } @@ -361,12 +334,7 @@ contract L2Curation is CurationV2Storage, GraphUpgradeable, IL2Curation { * @param _subgraphDeploymentID Subgraph deployment curation pool * @return Amount of signal owned by a curator for the subgraph deployment */ - function getCuratorSignal(address _curator, bytes32 _subgraphDeploymentID) - public - view - override - returns (uint256) - { + function getCuratorSignal(address _curator, bytes32 _subgraphDeploymentID) public view override returns (uint256) { IGraphCurationToken gcs = pools[_subgraphDeploymentID].gcs; return (address(gcs) == address(0)) ? 0 : gcs.balanceOf(_curator); } @@ -376,12 +344,7 @@ contract L2Curation is CurationV2Storage, GraphUpgradeable, IL2Curation { * @param _subgraphDeploymentID Subgraph deployment curation poool * @return Amount of signal minted for the subgraph deployment */ - function getCurationPoolSignal(bytes32 _subgraphDeploymentID) - public - view - override - returns (uint256) - { + function getCurationPoolSignal(bytes32 _subgraphDeploymentID) public view override returns (uint256) { IGraphCurationToken gcs = pools[_subgraphDeploymentID].gcs; return (address(gcs) == address(0)) ? 0 : gcs.totalSupply(); } @@ -394,18 +357,13 @@ contract L2Curation is CurationV2Storage, GraphUpgradeable, IL2Curation { * @return Amount of signal that can be bought * @return Amount of GRT that would be subtracted as curation tax */ - function tokensToSignal(bytes32 _subgraphDeploymentID, uint256 _tokensIn) - public - view - override - returns (uint256, uint256) - { + function tokensToSignal( + bytes32 _subgraphDeploymentID, + uint256 _tokensIn + ) public view override returns (uint256, uint256) { // Calculate tokens after tax first, subtract that from the tokens in // to get the curation tax to avoid rounding down to zero. - uint256 tokensAfterCurationTax = uint256(MAX_PPM) - .sub(curationTaxPercentage) - .mul(_tokensIn) - .div(MAX_PPM); + uint256 tokensAfterCurationTax = uint256(MAX_PPM).sub(curationTaxPercentage).mul(_tokensIn).div(MAX_PPM); uint256 curationTax = _tokensIn.sub(tokensAfterCurationTax); uint256 signalOut = _tokensToSignal(_subgraphDeploymentID, tokensAfterCurationTax); return (signalOut, curationTax); @@ -418,12 +376,10 @@ contract L2Curation is CurationV2Storage, GraphUpgradeable, IL2Curation { * @param _tokensIn Amount of tokens used to mint signal * @return Amount of signal that can be bought */ - function tokensToSignalNoTax(bytes32 _subgraphDeploymentID, uint256 _tokensIn) - public - view - override - returns (uint256) - { + function tokensToSignalNoTax( + bytes32 _subgraphDeploymentID, + uint256 _tokensIn + ) public view override returns (uint256) { return _tokensToSignal(_subgraphDeploymentID, _tokensIn); } @@ -435,12 +391,10 @@ contract L2Curation is CurationV2Storage, GraphUpgradeable, IL2Curation { * @param _tokensIn Amount of tokens used to mint signal * @return Amount of tokens that would be recovered after minting and burning signal */ - function tokensToSignalToTokensNoTax(bytes32 _subgraphDeploymentID, uint256 _tokensIn) - external - view - override - returns (uint256) - { + function tokensToSignalToTokensNoTax( + bytes32 _subgraphDeploymentID, + uint256 _tokensIn + ) external view override returns (uint256) { require(_tokensIn != 0, "Can't calculate with 0 tokens"); uint256 signal = _tokensToSignal(_subgraphDeploymentID, _tokensIn); CurationPool memory curationPool = pools[_subgraphDeploymentID]; @@ -455,22 +409,11 @@ contract L2Curation is CurationV2Storage, GraphUpgradeable, IL2Curation { * @param _signalIn Amount of signal to burn * @return Amount of tokens to get for an amount of signal */ - function signalToTokens(bytes32 _subgraphDeploymentID, uint256 _signalIn) - public - view - override - returns (uint256) - { + function signalToTokens(bytes32 _subgraphDeploymentID, uint256 _signalIn) public view override returns (uint256) { CurationPool memory curationPool = pools[_subgraphDeploymentID]; uint256 curationPoolSignal = getCurationPoolSignal(_subgraphDeploymentID); - require( - curationPool.tokens != 0, - "Subgraph deployment must be curated to perform calculations" - ); - require( - curationPoolSignal >= _signalIn, - "Signal must be above or equal to signal issued in the curation pool" - ); + require(curationPool.tokens != 0, "Subgraph deployment must be curated to perform calculations"); + require(curationPoolSignal >= _signalIn, "Signal must be above or equal to signal issued in the curation pool"); return curationPool.tokens.mul(_signalIn).div(curationPoolSignal); } @@ -492,10 +435,7 @@ contract L2Curation is CurationV2Storage, GraphUpgradeable, IL2Curation { * @param _percentage Curation tax percentage charged when depositing GRT tokens */ function _setCurationTaxPercentage(uint32 _percentage) private { - require( - _percentage <= MAX_PPM, - "Curation tax percentage must be below or equal to MAX_PPM" - ); + require(_percentage <= MAX_PPM, "Curation tax percentage must be below or equal to MAX_PPM"); curationTaxPercentage = _percentage; emit ParameterUpdated("curationTaxPercentage"); @@ -507,10 +447,7 @@ contract L2Curation is CurationV2Storage, GraphUpgradeable, IL2Curation { */ function _setCurationTokenMaster(address _curationTokenMaster) private { require(_curationTokenMaster != address(0), "Token master must be non-empty"); - require( - AddressUpgradeable.isContract(_curationTokenMaster), - "Token master must be a contract" - ); + require(AddressUpgradeable.isContract(_curationTokenMaster), "Token master must be a contract"); curationTokenMaster = _curationTokenMaster; emit ParameterUpdated("curationTokenMaster"); @@ -533,25 +470,16 @@ contract L2Curation is CurationV2Storage, GraphUpgradeable, IL2Curation { * @param _tokensIn Amount of tokens used to mint signal * @return Amount of signal that can be bought with tokens */ - function _tokensToSignal(bytes32 _subgraphDeploymentID, uint256 _tokensIn) - private - view - returns (uint256) - { + function _tokensToSignal(bytes32 _subgraphDeploymentID, uint256 _tokensIn) private view returns (uint256) { // Get curation pool tokens and signal CurationPool memory curationPool = pools[_subgraphDeploymentID]; // Init curation pool if (curationPool.tokens == 0) { - require( - _tokensIn >= minimumCurationDeposit, - "Curation deposit is below minimum required" - ); + require(_tokensIn >= minimumCurationDeposit, "Curation deposit is below minimum required"); return SIGNAL_PER_MINIMUM_DEPOSIT.add( - SIGNAL_PER_MINIMUM_DEPOSIT.mul(_tokensIn.sub(minimumCurationDeposit)).div( - minimumCurationDeposit - ) + SIGNAL_PER_MINIMUM_DEPOSIT.mul(_tokensIn.sub(minimumCurationDeposit)).div(minimumCurationDeposit) ); } diff --git a/packages/contracts/contracts/l2/discovery/L2GNS.sol b/packages/contracts/contracts/l2/discovery/L2GNS.sol index f2c4c9a83..34d47d400 100644 --- a/packages/contracts/contracts/l2/discovery/L2GNS.sol +++ b/packages/contracts/contracts/l2/discovery/L2GNS.sol @@ -91,10 +91,7 @@ contract L2GNS is GNS, L2GNSV1Storage, IL2GNS { bytes calldata _data ) external override notPartialPaused onlyL2Gateway { require(_from == counterpartGNSAddress, "ONLY_L1_GNS_THROUGH_BRIDGE"); - (uint8 code, uint256 l1SubgraphID, address beneficiary) = abi.decode( - _data, - (uint8, uint256, address) - ); + (uint8 code, uint256 l1SubgraphID, address beneficiary) = abi.decode(_data, (uint8, uint256, address)); if (code == uint8(L1MessageCodes.RECEIVE_SUBGRAPH_CODE)) { _receiveSubgraphFromL1(l1SubgraphID, beneficiary, _amount); @@ -138,10 +135,7 @@ contract L2GNS is GNS, L2GNSV1Storage, IL2GNS { { // This can't revert because the bridge ensures that _tokensIn is > 0, // and the minimum curation in L2 is 1 wei GRT - uint256 tokensAfter = curation.tokensToSignalToTokensNoTax( - _subgraphDeploymentID, - tokens - ); + uint256 tokensAfter = curation.tokensToSignalToTokensNoTax(_subgraphDeploymentID, tokens); roundingError = tokens.sub(tokensAfter).mul(MAX_PPM).div(tokens); } if (roundingError <= MAX_ROUNDING_ERROR) { @@ -151,11 +145,7 @@ contract L2GNS is GNS, L2GNSV1Storage, IL2GNS { emit SubgraphUpgraded(_l2SubgraphID, vSignal, tokens, _subgraphDeploymentID); } else { graphToken().transfer(msg.sender, tokens); - emit CuratorBalanceReturnedToBeneficiary( - getUnaliasedL1SubgraphID(_l2SubgraphID), - msg.sender, - tokens - ); + emit CuratorBalanceReturnedToBeneficiary(getUnaliasedL1SubgraphID(_l2SubgraphID), msg.sender, tokens); emit SubgraphUpgraded(_l2SubgraphID, vSignal, 0, _subgraphDeploymentID); } @@ -209,31 +199,18 @@ contract L2GNS is GNS, L2GNSV1Storage, IL2GNS { if (subgraphData.nSignal != 0) { // Burn all version signal in the name pool for tokens (w/no slippage protection) // Sell all signal from the old deployment - uint256 tokens = curation.burn( - subgraphData.subgraphDeploymentID, - subgraphData.vSignal, - 0 - ); + uint256 tokens = curation.burn(subgraphData.subgraphDeploymentID, subgraphData.vSignal, 0); // Take the owner cut of the curation tax, add it to the total // Upgrade is only callable by the owner, we assume then that msg.sender = owner address subgraphOwner = msg.sender; - uint256 tokensWithTax = _chargeOwnerTax( - tokens, - subgraphOwner, - curation.curationTaxPercentage() - ); + uint256 tokensWithTax = _chargeOwnerTax(tokens, subgraphOwner, curation.curationTaxPercentage()); // Update pool: constant nSignal, vSignal can change (w/no slippage protection) // Buy all signal from the new deployment (subgraphData.vSignal, ) = curation.mint(_subgraphDeploymentID, tokensWithTax, 0); - emit SubgraphUpgraded( - _subgraphID, - subgraphData.vSignal, - tokensWithTax, - _subgraphDeploymentID - ); + emit SubgraphUpgraded(_subgraphID, subgraphData.vSignal, tokensWithTax, _subgraphDeploymentID); } // Update target deployment @@ -256,12 +233,7 @@ contract L2GNS is GNS, L2GNSV1Storage, IL2GNS { * @param _l2SubgraphID L2 subgraph ID * @return L1subgraph ID */ - function getUnaliasedL1SubgraphID(uint256 _l2SubgraphID) - public - pure - override - returns (uint256) - { + function getUnaliasedL1SubgraphID(uint256 _l2SubgraphID) public pure override returns (uint256) { return _l2SubgraphID - SUBGRAPH_ID_ALIAS_OFFSET; } @@ -273,11 +245,7 @@ contract L2GNS is GNS, L2GNSV1Storage, IL2GNS { * @param _subgraphOwner Owner of the subgraph * @param _tokens Tokens to be deposited in the subgraph */ - function _receiveSubgraphFromL1( - uint256 _l1SubgraphID, - address _subgraphOwner, - uint256 _tokens - ) internal { + function _receiveSubgraphFromL1(uint256 _l1SubgraphID, address _subgraphOwner, uint256 _tokens) internal { uint256 l2SubgraphID = getAliasedL2SubgraphID(_l1SubgraphID); SubgraphData storage subgraphData = _getSubgraphData(l2SubgraphID); IL2GNS.SubgraphL2TransferData storage transferData = subgraphL2TransferData[l2SubgraphID]; @@ -307,11 +275,7 @@ contract L2GNS is GNS, L2GNSV1Storage, IL2GNS { * @param _curator Curator address * @param _tokensIn The amount of tokens the nameCurator wants to deposit */ - function _mintSignalFromL1( - uint256 _l1SubgraphID, - address _curator, - uint256 _tokensIn - ) internal { + function _mintSignalFromL1(uint256 _l1SubgraphID, address _curator, uint256 _tokensIn) internal { uint256 l2SubgraphID = getAliasedL2SubgraphID(_l1SubgraphID); IL2GNS.SubgraphL2TransferData storage transferData = subgraphL2TransferData[l2SubgraphID]; SubgraphData storage subgraphData = _getSubgraphData(l2SubgraphID); @@ -321,10 +285,7 @@ contract L2GNS is GNS, L2GNSV1Storage, IL2GNS { if (transferData.l2Done && !subgraphData.disabled) { // This can't revert because the bridge ensures that _tokensIn is > 0, // and the minimum curation in L2 is 1 wei GRT - uint256 tokensAfter = curation.tokensToSignalToTokensNoTax( - subgraphData.subgraphDeploymentID, - _tokensIn - ); + uint256 tokensAfter = curation.tokensToSignalToTokensNoTax(subgraphData.subgraphDeploymentID, _tokensIn); roundingError = _tokensIn.sub(tokensAfter).mul(MAX_PPM).div(_tokensIn); } // If subgraph transfer wasn't finished, we should send the tokens to the curator @@ -339,9 +300,7 @@ contract L2GNS is GNS, L2GNSV1Storage, IL2GNS { // Update pools subgraphData.vSignal = subgraphData.vSignal.add(vSignal); subgraphData.nSignal = subgraphData.nSignal.add(nSignal); - subgraphData.curatorNSignal[_curator] = subgraphData.curatorNSignal[_curator].add( - nSignal - ); + subgraphData.curatorNSignal[_curator] = subgraphData.curatorNSignal[_curator].add(nSignal); emit SignalMinted(l2SubgraphID, _curator, nSignal, vSignal, _tokensIn); emit CuratorBalanceReceived(_l1SubgraphID, l2SubgraphID, _curator, _tokensIn); @@ -355,12 +314,7 @@ contract L2GNS is GNS, L2GNSV1Storage, IL2GNS { * @param _subgraphID Subgraph ID * @return Subgraph Data */ - function _getSubgraphData(uint256 _subgraphID) - internal - view - override - returns (SubgraphData storage) - { + function _getSubgraphData(uint256 _subgraphID) internal view override returns (SubgraphData storage) { // Return new subgraph type return subgraphs[_subgraphID]; } diff --git a/packages/contracts/contracts/l2/gateway/L2GraphTokenGateway.sol b/packages/contracts/contracts/l2/gateway/L2GraphTokenGateway.sol index 03417a59a..be8f212b8 100644 --- a/packages/contracts/contracts/l2/gateway/L2GraphTokenGateway.sol +++ b/packages/contracts/contracts/l2/gateway/L2GraphTokenGateway.sol @@ -39,12 +39,7 @@ contract L2GraphTokenGateway is GraphTokenGateway, L2ArbitrumMessenger, Reentran } /// Emitted when an incoming transfer is finalized, i.e. tokens were deposited from L1 to L2 - event DepositFinalized( - address indexed l1Token, - address indexed from, - address indexed to, - uint256 amount - ); + event DepositFinalized(address indexed l1Token, address indexed from, address indexed to, uint256 amount); /// Emitted when an outbound transfer is initiated, i.e. tokens are being withdrawn from L2 back to L1 event WithdrawalInitiated( @@ -68,10 +63,7 @@ contract L2GraphTokenGateway is GraphTokenGateway, L2ArbitrumMessenger, Reentran * gateway on L1. */ modifier onlyL1Counterpart() { - require( - msg.sender == AddressAliasHelper.applyL1ToL2Alias(l1Counterpart), - "ONLY_COUNTERPART_GATEWAY" - ); + require(msg.sender == AddressAliasHelper.applyL1ToL2Alias(l1Counterpart), "ONLY_COUNTERPART_GATEWAY"); _; } @@ -216,13 +208,7 @@ contract L2GraphTokenGateway is GraphTokenGateway, L2ArbitrumMessenger, Reentran 0, outboundCalldata.from, l1Counterpart, - getOutboundCalldata( - _l1Token, - outboundCalldata.from, - _to, - _amount, - outboundCalldata.extraData - ) + getOutboundCalldata(_l1Token, outboundCalldata.from, _to, _amount, outboundCalldata.extraData) ); // we don't need to track exitNums (b/c we have no fast exits) so we always use 0 diff --git a/packages/contracts/contracts/l2/staking/IL2StakingBase.sol b/packages/contracts/contracts/l2/staking/IL2StakingBase.sol index 8b8cd92ab..6f701ec89 100644 --- a/packages/contracts/contracts/l2/staking/IL2StakingBase.sol +++ b/packages/contracts/contracts/l2/staking/IL2StakingBase.sol @@ -10,9 +10,5 @@ import { ICallhookReceiver } from "../../gateway/ICallhookReceiver.sol"; * @dev Note it includes only the L2-specific functionality, not the full IStaking interface. */ interface IL2StakingBase is ICallhookReceiver { - event TransferredDelegationReturnedToDelegator( - address indexed indexer, - address indexed delegator, - uint256 amount - ); + event TransferredDelegationReturnedToDelegator(address indexed indexer, address indexed delegator, uint256 amount); } diff --git a/packages/contracts/contracts/l2/staking/L2Staking.sol b/packages/contracts/contracts/l2/staking/L2Staking.sol index 7e561b990..3f9d28e5a 100644 --- a/packages/contracts/contracts/l2/staking/L2Staking.sol +++ b/packages/contracts/contracts/l2/staking/L2Staking.sol @@ -28,12 +28,7 @@ contract L2Staking is Staking, IL2StakingBase { * This is copied from IStakingExtension, but we can't inherit from it because we * don't implement the full interface here. */ - event StakeDelegated( - address indexed indexer, - address indexed delegator, - uint256 tokens, - uint256 shares - ); + event StakeDelegated(address indexed indexer, address indexed delegator, uint256 tokens, uint256 shares); /** * @dev Checks that the sender is the L2GraphTokenGateway as configured on the Controller. @@ -92,10 +87,7 @@ contract L2Staking is Staking, IL2StakingBase { * @param _amount Amount of tokens that were transferred * @param _indexerData struct containing the indexer's address */ - function _receiveIndexerStake( - uint256 _amount, - IL2Staking.ReceiveIndexerStakeData memory _indexerData - ) internal { + function _receiveIndexerStake(uint256 _amount, IL2Staking.ReceiveIndexerStakeData memory _indexerData) internal { address _indexer = _indexerData.indexer; // Deposit tokens into the indexer stake __stakes[_indexer].deposit(_amount); @@ -116,10 +108,7 @@ contract L2Staking is Staking, IL2StakingBase { * @param _amount Amount of tokens that were transferred * @param _delegationData struct containing the delegator's address and the indexer's address */ - function _receiveDelegation( - uint256 _amount, - IL2Staking.ReceiveDelegationData memory _delegationData - ) internal { + function _receiveDelegation(uint256 _amount, IL2Staking.ReceiveDelegationData memory _delegationData) internal { // Get the delegation pool of the indexer DelegationPool storage pool = __delegationPools[_delegationData.indexer]; Delegation storage delegation = pool.delegators[_delegationData.delegator]; @@ -132,11 +121,7 @@ contract L2Staking is Staking, IL2StakingBase { // or if the amount is under the minimum delegation (which could be part of a rounding attack), // return the tokens to the delegator graphToken().transfer(_delegationData.delegator, _amount); - emit TransferredDelegationReturnedToDelegator( - _delegationData.indexer, - _delegationData.delegator, - _amount - ); + emit TransferredDelegationReturnedToDelegator(_delegationData.indexer, _delegationData.delegator, _amount); } else { // Update the delegation pool pool.tokens = pool.tokens.add(_amount); @@ -145,12 +130,7 @@ contract L2Staking is Staking, IL2StakingBase { // Update the individual delegation delegation.shares = delegation.shares.add(shares); - emit StakeDelegated( - _delegationData.indexer, - _delegationData.delegator, - _amount, - shares - ); + emit StakeDelegated(_delegationData.indexer, _delegationData.delegator, _amount, shares); } } } diff --git a/packages/contracts/contracts/l2/token/GraphTokenUpgradeable.sol b/packages/contracts/contracts/l2/token/GraphTokenUpgradeable.sol index 3f7882b5c..0f5cf0ecb 100644 --- a/packages/contracts/contracts/l2/token/GraphTokenUpgradeable.sol +++ b/packages/contracts/contracts/l2/token/GraphTokenUpgradeable.sol @@ -30,21 +30,16 @@ abstract contract GraphTokenUpgradeable is GraphUpgradeable, Governed, ERC20Burn /// @dev Hash of the EIP-712 Domain type bytes32 private immutable DOMAIN_TYPE_HASH = - keccak256( - "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract,bytes32 salt)" - ); + keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract,bytes32 salt)"); /// @dev Hash of the EIP-712 Domain name bytes32 private immutable DOMAIN_NAME_HASH = keccak256("Graph Token"); /// @dev Hash of the EIP-712 Domain version bytes32 private immutable DOMAIN_VERSION_HASH = keccak256("0"); /// @dev EIP-712 Domain salt - bytes32 private immutable DOMAIN_SALT = - 0xe33842a7acd1d5a1d28f25a931703e5605152dc48d64dc4716efdae1f5659591; // Randomly generated salt + bytes32 private immutable DOMAIN_SALT = 0xe33842a7acd1d5a1d28f25a931703e5605152dc48d64dc4716efdae1f5659591; // Randomly generated salt /// @dev Hash of the EIP-712 permit type bytes32 private immutable PERMIT_TYPEHASH = - keccak256( - "Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)" - ); + keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); // -- State -- @@ -94,9 +89,7 @@ abstract contract GraphTokenUpgradeable is GraphUpgradeable, Governed, ERC20Burn abi.encodePacked( "\x19\x01", DOMAIN_SEPARATOR, - keccak256( - abi.encode(PERMIT_TYPEHASH, _owner, _spender, _value, nonces[_owner], _deadline) - ) + keccak256(abi.encode(PERMIT_TYPEHASH, _owner, _spender, _value, nonces[_owner], _deadline)) ) ); diff --git a/packages/contracts/contracts/payments/AllocationExchange.sol b/packages/contracts/contracts/payments/AllocationExchange.sol index 6a45d03ad..3a05112fe 100644 --- a/packages/contracts/contracts/payments/AllocationExchange.sol +++ b/packages/contracts/contracts/payments/AllocationExchange.sol @@ -31,7 +31,7 @@ contract AllocationExchange is Governed { // -- Constants -- - uint256 private constant MAX_UINT256 = 2**256 - 1; + uint256 private constant MAX_UINT256 = 2 ** 256 - 1; uint256 private constant SIGNATURE_LENGTH = 65; // -- State -- @@ -56,12 +56,7 @@ contract AllocationExchange is Governed { * @param _governor Account capable of withdrawing funds and setting the authority * @param _authority Account that can sign the vouchers that this contract will redeem */ - constructor( - IGraphToken _graphToken, - IStaking _staking, - address _governor, - address _authority - ) { + constructor(IGraphToken _graphToken, IStaking _staking, address _governor, address _authority) { require(_governor != address(0), "Exchange: governor must be set"); Governed._initialize(_governor); @@ -148,10 +143,7 @@ contract AllocationExchange is Governed { require(_voucher.signature.length == SIGNATURE_LENGTH, "Exchange: invalid signature"); // Already redeemed check - require( - !allocationsRedeemed[_voucher.allocationID], - "Exchange: allocation already redeemed" - ); + require(!allocationsRedeemed[_voucher.allocationID], "Exchange: allocation already redeemed"); // Signature check bytes32 messageHash = keccak256(abi.encodePacked(_voucher.allocationID, _voucher.amount)); diff --git a/packages/contracts/contracts/rewards/IRewardsManager.sol b/packages/contracts/contracts/rewards/IRewardsManager.sol index 87d3c2455..4c062e774 100644 --- a/packages/contracts/contracts/rewards/IRewardsManager.sol +++ b/packages/contracts/contracts/rewards/IRewardsManager.sol @@ -25,8 +25,7 @@ interface IRewardsManager { function setDenied(bytes32 _subgraphDeploymentID, bool _deny) external; - function setDeniedMany(bytes32[] calldata _subgraphDeploymentID, bool[] calldata _deny) - external; + function setDeniedMany(bytes32[] calldata _subgraphDeploymentID, bool[] calldata _deny) external; function isDenied(bytes32 _subgraphDeploymentID) external view returns (bool); @@ -36,15 +35,9 @@ interface IRewardsManager { function getAccRewardsPerSignal() external view returns (uint256); - function getAccRewardsForSubgraph(bytes32 _subgraphDeploymentID) - external - view - returns (uint256); + function getAccRewardsForSubgraph(bytes32 _subgraphDeploymentID) external view returns (uint256); - function getAccRewardsPerAllocatedToken(bytes32 _subgraphDeploymentID) - external - view - returns (uint256, uint256); + function getAccRewardsPerAllocatedToken(bytes32 _subgraphDeploymentID) external view returns (uint256, uint256); function getRewards(address _allocationID) external view returns (uint256); diff --git a/packages/contracts/contracts/rewards/RewardsManager.sol b/packages/contracts/contracts/rewards/RewardsManager.sol index f7b7f6384..03cadacb0 100644 --- a/packages/contracts/contracts/rewards/RewardsManager.sol +++ b/packages/contracts/contracts/rewards/RewardsManager.sol @@ -38,12 +38,7 @@ contract RewardsManager is RewardsManagerV4Storage, GraphUpgradeable, IRewardsMa /** * @dev Emitted when rewards are assigned to an indexer. */ - event RewardsAssigned( - address indexed indexer, - address indexed allocationID, - uint256 epoch, - uint256 amount - ); + event RewardsAssigned(address indexed indexer, address indexed allocationID, uint256 epoch, uint256 amount); /** * @dev Emitted when rewards are denied to an indexer. @@ -58,10 +53,7 @@ contract RewardsManager is RewardsManagerV4Storage, GraphUpgradeable, IRewardsMa // -- Modifiers -- modifier onlySubgraphAvailabilityOracle() { - require( - msg.sender == address(subgraphAvailabilityOracle), - "Caller must be the subgraph availability oracle" - ); + require(msg.sender == address(subgraphAvailabilityOracle), "Caller must be the subgraph availability oracle"); _; } @@ -103,11 +95,7 @@ contract RewardsManager is RewardsManagerV4Storage, GraphUpgradeable, IRewardsMa * @dev Sets the subgraph oracle allowed to denegate distribution of rewards to subgraphs. * @param _subgraphAvailabilityOracle Address of the subgraph availability oracle */ - function setSubgraphAvailabilityOracle(address _subgraphAvailabilityOracle) - external - override - onlyGovernor - { + function setSubgraphAvailabilityOracle(address _subgraphAvailabilityOracle) external override onlyGovernor { subgraphAvailabilityOracle = _subgraphAvailabilityOracle; emit ParameterUpdated("subgraphAvailabilityOracle"); } @@ -120,8 +108,7 @@ contract RewardsManager is RewardsManagerV4Storage, GraphUpgradeable, IRewardsMa function setMinimumSubgraphSignal(uint256 _minimumSubgraphSignal) external override { // Caller can be the SAO or the governor require( - msg.sender == address(subgraphAvailabilityOracle) || - msg.sender == controller.getGovernor(), + msg.sender == address(subgraphAvailabilityOracle) || msg.sender == controller.getGovernor(), "Not authorized" ); minimumSubgraphSignal = _minimumSubgraphSignal; @@ -136,11 +123,7 @@ contract RewardsManager is RewardsManagerV4Storage, GraphUpgradeable, IRewardsMa * @param _subgraphDeploymentID Subgraph deployment ID * @param _deny Whether to set the subgraph as denied for claiming rewards or not */ - function setDenied(bytes32 _subgraphDeploymentID, bool _deny) - external - override - onlySubgraphAvailabilityOracle - { + function setDenied(bytes32 _subgraphDeploymentID, bool _deny) external override onlySubgraphAvailabilityOracle { _setDenied(_subgraphDeploymentID, _deny); } @@ -150,11 +133,10 @@ contract RewardsManager is RewardsManagerV4Storage, GraphUpgradeable, IRewardsMa * @param _subgraphDeploymentID Array of subgraph deployment ID * @param _deny Array of denied status for claiming rewards for each subgraph */ - function setDeniedMany(bytes32[] calldata _subgraphDeploymentID, bool[] calldata _deny) - external - override - onlySubgraphAvailabilityOracle - { + function setDeniedMany( + bytes32[] calldata _subgraphDeploymentID, + bool[] calldata _deny + ) external override onlySubgraphAvailabilityOracle { require(_subgraphDeploymentID.length == _deny.length, "!length"); for (uint256 i = 0; i < _subgraphDeploymentID.length; i++) { _setDenied(_subgraphDeploymentID[i], _deny[i]); @@ -233,12 +215,7 @@ contract RewardsManager is RewardsManagerV4Storage, GraphUpgradeable, IRewardsMa * @param _subgraphDeploymentID Subgraph deployment * @return Accumulated rewards for subgraph */ - function getAccRewardsForSubgraph(bytes32 _subgraphDeploymentID) - public - view - override - returns (uint256) - { + function getAccRewardsForSubgraph(bytes32 _subgraphDeploymentID) public view override returns (uint256) { Subgraph storage subgraph = subgraphs[_subgraphDeploymentID]; // Get tokens signalled on the subgraph @@ -246,10 +223,9 @@ contract RewardsManager is RewardsManagerV4Storage, GraphUpgradeable, IRewardsMa // Only accrue rewards if over a threshold uint256 newRewards = (subgraphSignalledTokens >= minimumSubgraphSignal) // Accrue new rewards since last snapshot - ? getAccRewardsPerSignal() - .sub(subgraph.accRewardsPerSignalSnapshot) - .mul(subgraphSignalledTokens) - .div(FIXED_POINT_SCALING_FACTOR) + ? getAccRewardsPerSignal().sub(subgraph.accRewardsPerSignalSnapshot).mul(subgraphSignalledTokens).div( + FIXED_POINT_SCALING_FACTOR + ) : 0; return subgraph.accRewardsForSubgraph.add(newRewards); } @@ -260,12 +236,9 @@ contract RewardsManager is RewardsManagerV4Storage, GraphUpgradeable, IRewardsMa * @return Accumulated rewards per allocated token for the subgraph * @return Accumulated rewards for subgraph */ - function getAccRewardsPerAllocatedToken(bytes32 _subgraphDeploymentID) - public - view - override - returns (uint256, uint256) - { + function getAccRewardsPerAllocatedToken( + bytes32 _subgraphDeploymentID + ) public view override returns (uint256, uint256) { Subgraph storage subgraph = subgraphs[_subgraphDeploymentID]; uint256 accRewardsForSubgraph = getAccRewardsForSubgraph(_subgraphDeploymentID); @@ -274,20 +247,15 @@ contract RewardsManager is RewardsManagerV4Storage, GraphUpgradeable, IRewardsMa subgraph.accRewardsForSubgraphSnapshot ); - uint256 subgraphAllocatedTokens = staking().getSubgraphAllocatedTokens( - _subgraphDeploymentID - ); + uint256 subgraphAllocatedTokens = staking().getSubgraphAllocatedTokens(_subgraphDeploymentID); if (subgraphAllocatedTokens == 0) { return (0, accRewardsForSubgraph); } - uint256 newRewardsPerAllocatedToken = newRewardsForSubgraph - .mul(FIXED_POINT_SCALING_FACTOR) - .div(subgraphAllocatedTokens); - return ( - subgraph.accRewardsPerAllocatedToken.add(newRewardsPerAllocatedToken), - accRewardsForSubgraph + uint256 newRewardsPerAllocatedToken = newRewardsForSubgraph.mul(FIXED_POINT_SCALING_FACTOR).div( + subgraphAllocatedTokens ); + return (subgraph.accRewardsPerAllocatedToken.add(newRewardsPerAllocatedToken), accRewardsForSubgraph); } // -- Updates -- @@ -311,11 +279,7 @@ contract RewardsManager is RewardsManagerV4Storage, GraphUpgradeable, IRewardsMa * @param _subgraphDeploymentID Subgraph deployment * @return Accumulated rewards for subgraph */ - function onSubgraphSignalUpdate(bytes32 _subgraphDeploymentID) - external - override - returns (uint256) - { + function onSubgraphSignalUpdate(bytes32 _subgraphDeploymentID) external override returns (uint256) { // Called since `total signalled GRT` will change updateAccRewardsPerSignal(); @@ -334,16 +298,11 @@ contract RewardsManager is RewardsManagerV4Storage, GraphUpgradeable, IRewardsMa * @param _subgraphDeploymentID Subgraph deployment * @return Accumulated rewards per allocated token for a subgraph */ - function onSubgraphAllocationUpdate(bytes32 _subgraphDeploymentID) - public - override - returns (uint256) - { + function onSubgraphAllocationUpdate(bytes32 _subgraphDeploymentID) public override returns (uint256) { Subgraph storage subgraph = subgraphs[_subgraphDeploymentID]; - ( - uint256 accRewardsPerAllocatedToken, - uint256 accRewardsForSubgraph - ) = getAccRewardsPerAllocatedToken(_subgraphDeploymentID); + (uint256 accRewardsPerAllocatedToken, uint256 accRewardsForSubgraph) = getAccRewardsPerAllocatedToken( + _subgraphDeploymentID + ); subgraph.accRewardsPerAllocatedToken = accRewardsPerAllocatedToken; subgraph.accRewardsForSubgraphSnapshot = accRewardsForSubgraph; return subgraph.accRewardsPerAllocatedToken; @@ -362,15 +321,8 @@ contract RewardsManager is RewardsManagerV4Storage, GraphUpgradeable, IRewardsMa IStaking.Allocation memory alloc = staking().getAllocation(_allocationID); - (uint256 accRewardsPerAllocatedToken, ) = getAccRewardsPerAllocatedToken( - alloc.subgraphDeploymentID - ); - return - _calcRewards( - alloc.tokens, - alloc.accRewardsPerAllocatedToken, - accRewardsPerAllocatedToken - ); + (uint256 accRewardsPerAllocatedToken, ) = getAccRewardsPerAllocatedToken(alloc.subgraphDeploymentID); + return _calcRewards(alloc.tokens, alloc.accRewardsPerAllocatedToken, accRewardsPerAllocatedToken); } /** @@ -402,9 +354,7 @@ contract RewardsManager is RewardsManagerV4Storage, GraphUpgradeable, IRewardsMa require(msg.sender == address(staking), "Caller must be the staking contract"); IStaking.Allocation memory alloc = staking.getAllocation(_allocationID); - uint256 accRewardsPerAllocatedToken = onSubgraphAllocationUpdate( - alloc.subgraphDeploymentID - ); + uint256 accRewardsPerAllocatedToken = onSubgraphAllocationUpdate(alloc.subgraphDeploymentID); // Do not do rewards on denied subgraph deployments ID if (isDenied(alloc.subgraphDeploymentID)) { @@ -413,11 +363,7 @@ contract RewardsManager is RewardsManagerV4Storage, GraphUpgradeable, IRewardsMa } // Calculate rewards accrued by this allocation - uint256 rewards = _calcRewards( - alloc.tokens, - alloc.accRewardsPerAllocatedToken, - accRewardsPerAllocatedToken - ); + uint256 rewards = _calcRewards(alloc.tokens, alloc.accRewardsPerAllocatedToken, accRewardsPerAllocatedToken); if (rewards > 0) { // Mint directly to staking contract for the reward amount // The staking contract will do bookkeeping of the reward and diff --git a/packages/contracts/contracts/staking/IL1StakingBase.sol b/packages/contracts/contracts/staking/IL1StakingBase.sol index 58749a247..fad2136c2 100644 --- a/packages/contracts/contracts/staking/IL1StakingBase.sol +++ b/packages/contracts/contracts/staking/IL1StakingBase.sol @@ -39,9 +39,7 @@ interface IL1StakingBase { * @dev This function can only be called by the governor. * @param _l1GraphTokenLockTransferTool Address of the L1GraphTokenLockTransferTool contract */ - function setL1GraphTokenLockTransferTool( - IL1GraphTokenLockTransferTool _l1GraphTokenLockTransferTool - ) external; + function setL1GraphTokenLockTransferTool(IL1GraphTokenLockTransferTool _l1GraphTokenLockTransferTool) external; /** * @notice Send an indexer's stake to L2. diff --git a/packages/contracts/contracts/staking/IStakingBase.sol b/packages/contracts/contracts/staking/IStakingBase.sol index 5f1dec63c..b30d00499 100644 --- a/packages/contracts/contracts/staking/IStakingBase.sol +++ b/packages/contracts/contracts/staking/IStakingBase.sol @@ -380,8 +380,5 @@ interface IStakingBase is IStakingData { * @param _subgraphDeploymentID Deployment ID for the subgraph * @return Total tokens allocated to subgraph */ - function getSubgraphAllocatedTokens(bytes32 _subgraphDeploymentID) - external - view - returns (uint256); + function getSubgraphAllocatedTokens(bytes32 _subgraphDeploymentID) external view returns (uint256); } diff --git a/packages/contracts/contracts/staking/IStakingExtension.sol b/packages/contracts/contracts/staking/IStakingExtension.sol index 36e6dce92..6a60dc9eb 100644 --- a/packages/contracts/contracts/staking/IStakingExtension.sol +++ b/packages/contracts/contracts/staking/IStakingExtension.sol @@ -32,12 +32,7 @@ interface IStakingExtension is IStakingData { * @dev Emitted when `delegator` delegated `tokens` to the `indexer`, the delegator * gets `shares` for the delegation pool proportionally to the tokens staked. */ - event StakeDelegated( - address indexed indexer, - address indexed delegator, - uint256 tokens, - uint256 shares - ); + event StakeDelegated(address indexed indexer, address indexed delegator, uint256 tokens, uint256 shares); /** * @dev Emitted when `delegator` undelegated `tokens` from `indexer`. @@ -54,22 +49,13 @@ interface IStakingExtension is IStakingData { /** * @dev Emitted when `delegator` withdrew delegated `tokens` from `indexer`. */ - event StakeDelegatedWithdrawn( - address indexed indexer, - address indexed delegator, - uint256 tokens - ); + event StakeDelegatedWithdrawn(address indexed indexer, address indexed delegator, uint256 tokens); /** * @dev Emitted when `indexer` was slashed for a total of `tokens` amount. * Tracks `reward` amount of tokens given to `beneficiary`. */ - event StakeSlashed( - address indexed indexer, - uint256 tokens, - uint256 reward, - address beneficiary - ); + event StakeSlashed(address indexed indexer, uint256 tokens, uint256 reward, address beneficiary); /** * @dev Emitted when `caller` set `slasher` address as `allowed` to slash stakes. @@ -139,12 +125,7 @@ interface IStakingExtension is IStakingData { * @param _reward Amount of reward tokens to send to a beneficiary * @param _beneficiary Address of a beneficiary to receive a reward for the slashing */ - function slash( - address _indexer, - uint256 _tokens, - uint256 _reward, - address _beneficiary - ) external; + function slash(address _indexer, uint256 _tokens, uint256 _reward, address _beneficiary) external; /** * @notice Return the delegation from a delegator to an indexer. @@ -152,10 +133,7 @@ interface IStakingExtension is IStakingData { * @param _delegator Address of the delegator * @return Delegation data */ - function getDelegation(address _indexer, address _delegator) - external - view - returns (Delegation memory); + function getDelegation(address _indexer, address _delegator) external view returns (Delegation memory); /** * @notice Return whether the delegator has delegated to the indexer. @@ -170,10 +148,7 @@ interface IStakingExtension is IStakingData { * @param _delegation Delegation of tokens from delegator to indexer * @return Amount of tokens to withdraw */ - function getWithdraweableDelegatedTokens(Delegation memory _delegation) - external - view - returns (uint256); + function getWithdraweableDelegatedTokens(Delegation memory _delegation) external view returns (uint256); /** * @notice Getter for the delegationRatio, i.e. the delegation capacity multiplier: @@ -313,8 +288,5 @@ interface IStakingExtension is IStakingData { * @param _allocationID Allocation ID for which to query the allocation information * @return The specified allocation, as an IStakingData.Allocation struct */ - function allocations(address _allocationID) - external - view - returns (IStakingData.Allocation memory); + function allocations(address _allocationID) external view returns (IStakingData.Allocation memory); } diff --git a/packages/contracts/contracts/staking/L1Staking.sol b/packages/contracts/contracts/staking/L1Staking.sol index cf9bca304..df4e145bd 100644 --- a/packages/contracts/contracts/staking/L1Staking.sol +++ b/packages/contracts/contracts/staking/L1Staking.sol @@ -31,10 +31,7 @@ contract L1Staking is Staking, L1StakingV1Storage, IL1StakingBase { * transfer of stake/delegation for vesting lock wallets. */ receive() external payable { - require( - msg.sender == address(l1GraphTokenLockTransferTool), - "Only transfer tool can send ETH" - ); + require(msg.sender == address(l1GraphTokenLockTransferTool), "Only transfer tool can send ETH"); } /** @@ -73,19 +70,8 @@ contract L1Staking is Staking, L1StakingV1Storage, IL1StakingBase { uint256 _gasPriceBid, uint256 _maxSubmissionCost ) external payable override notPartialPaused { - require( - msg.value == _maxSubmissionCost.add(_gasPriceBid.mul(_maxGas)), - "INVALID_ETH_AMOUNT" - ); - _transferStakeToL2( - msg.sender, - _l2Beneficiary, - _amount, - _maxGas, - _gasPriceBid, - _maxSubmissionCost, - msg.value - ); + require(msg.value == _maxSubmissionCost.add(_gasPriceBid.mul(_maxGas)), "INVALID_ETH_AMOUNT"); + _transferStakeToL2(msg.sender, _l2Beneficiary, _amount, _maxGas, _gasPriceBid, _maxSubmissionCost, msg.value); } /** @@ -118,15 +104,7 @@ contract L1Staking is Staking, L1StakingV1Storage, IL1StakingBase { uint256 ethAmount = _maxSubmissionCost.add(_maxGas.mul(_gasPriceBid)); l1GraphTokenLockTransferTool.pullETH(msg.sender, ethAmount); require(address(this).balance == balance.add(ethAmount), "ETH TRANSFER FAILED"); - _transferStakeToL2( - msg.sender, - l2Beneficiary, - _amount, - _maxGas, - _gasPriceBid, - _maxSubmissionCost, - ethAmount - ); + _transferStakeToL2(msg.sender, l2Beneficiary, _amount, _maxGas, _gasPriceBid, _maxSubmissionCost, ethAmount); } /** @@ -152,10 +130,7 @@ contract L1Staking is Staking, L1StakingV1Storage, IL1StakingBase { uint256 _gasPriceBid, uint256 _maxSubmissionCost ) external payable override notPartialPaused { - require( - msg.value == _maxSubmissionCost.add(_gasPriceBid.mul(_maxGas)), - "INVALID_ETH_AMOUNT" - ); + require(msg.value == _maxSubmissionCost.add(_gasPriceBid.mul(_maxGas)), "INVALID_ETH_AMOUNT"); _transferDelegationToL2( msg.sender, _indexer, @@ -216,11 +191,7 @@ contract L1Staking is Staking, L1StakingV1Storage, IL1StakingBase { * and can be withdrawn with `withdrawDelegated()` immediately after calling this. * @param _indexer Address of the indexer (in L1, before transferring to L2) */ - function unlockDelegationToTransferredIndexer(address _indexer) - external - override - notPartialPaused - { + function unlockDelegationToTransferredIndexer(address _indexer) external override notPartialPaused { require( indexerTransferredToL2[_indexer] != address(0) && __stakes[_indexer].tokensStaked == 0, "indexer not transferred" @@ -269,10 +240,7 @@ contract L1Staking is Staking, L1StakingV1Storage, IL1StakingBase { require(_l2Beneficiary != address(0), "l2Beneficiary == 0"); if (indexerTransferredToL2[_indexer] != address(0)) { - require( - indexerTransferredToL2[_indexer] == _l2Beneficiary, - "l2Beneficiary != previous" - ); + require(indexerTransferredToL2[_indexer] == _l2Beneficiary, "l2Beneficiary != previous"); } else { indexerTransferredToL2[_indexer] = _l2Beneficiary; require(_amount >= __minimumIndexerStake, "!minimumIndexerStake sent"); @@ -292,10 +260,7 @@ contract L1Staking is Staking, L1StakingV1Storage, IL1StakingBase { } else { // require that the indexer has enough stake to cover all allocations uint256 tokensDelegatedCap = indexerStake.tokensStaked.mul(uint256(__delegationRatio)); - uint256 tokensDelegatedCapacity = MathUtils.min( - delegationPool.tokens, - tokensDelegatedCap - ); + uint256 tokensDelegatedCapacity = MathUtils.min(delegationPool.tokens, tokensDelegatedCap); require( indexerStake.tokensUsed() <= indexerStake.tokensStaked.add(tokensDelegatedCapacity), "! allocation capacity" @@ -310,14 +275,7 @@ contract L1Staking is Staking, L1StakingV1Storage, IL1StakingBase { abi.encode(functionData) ); - _sendTokensAndMessageToL2Staking( - _amount, - _maxGas, - _gasPriceBid, - _maxSubmissionCost, - _ethAmount, - extraData - ); + _sendTokensAndMessageToL2Staking(_amount, _maxGas, _gasPriceBid, _maxSubmissionCost, _ethAmount, extraData); emit IndexerStakeTransferredToL2(_indexer, _l2Beneficiary, _amount); } @@ -369,10 +327,7 @@ contract L1Staking is Staking, L1StakingV1Storage, IL1StakingBase { IL2Staking.ReceiveDelegationData memory functionData; functionData.indexer = indexerTransferredToL2[_indexer]; functionData.delegator = _l2Beneficiary; - extraData = abi.encode( - uint8(IL2Staking.L1MessageCodes.RECEIVE_DELEGATION_CODE), - abi.encode(functionData) - ); + extraData = abi.encode(uint8(IL2Staking.L1MessageCodes.RECEIVE_DELEGATION_CODE), abi.encode(functionData)); } _sendTokensAndMessageToL2Staking( diff --git a/packages/contracts/contracts/staking/Staking.sol b/packages/contracts/contracts/staking/Staking.sol index b82c17bdf..e9da34440 100644 --- a/packages/contracts/contracts/staking/Staking.sol +++ b/packages/contracts/contracts/staking/Staking.sol @@ -212,12 +212,7 @@ abstract contract Staking is StakingV4Storage, GraphUpgradeable, IStakingBase, M uint32 _lambdaNumerator, uint32 _lambdaDenominator ) external override onlyGovernor { - _setRebateParameters( - _alphaNumerator, - _alphaDenominator, - _lambdaNumerator, - _lambdaDenominator - ); + _setRebateParameters(_alphaNumerator, _alphaDenominator, _lambdaNumerator, _lambdaDenominator); } /** @@ -384,12 +379,7 @@ abstract contract Staking is StakingV4Storage, GraphUpgradeable, IStakingBase, M // -- Collect curation fees -- // Only if the subgraph deployment is curated - curationFees = _collectCurationFees( - graphToken, - subgraphDeploymentID, - queryFees, - __curationPercentage - ); + curationFees = _collectCurationFees(graphToken, subgraphDeploymentID, queryFees, __curationPercentage); queryFees = queryFees.sub(curationFees); // -- Process rebate reward -- @@ -478,12 +468,7 @@ abstract contract Staking is StakingV4Storage, GraphUpgradeable, IStakingBase, M * @param _allocationID Address used as allocation identifier * @return Allocation data */ - function getAllocation(address _allocationID) - external - view - override - returns (Allocation memory) - { + function getAllocation(address _allocationID) external view override returns (Allocation memory) { return __allocations[_allocationID]; } @@ -492,12 +477,7 @@ abstract contract Staking is StakingV4Storage, GraphUpgradeable, IStakingBase, M * @param _allocationID Allocation identifier * @return AllocationState enum with the state of the allocation */ - function getAllocationState(address _allocationID) - external - view - override - returns (AllocationState) - { + function getAllocationState(address _allocationID) external view override returns (AllocationState) { return _getAllocationState(_allocationID); } @@ -506,12 +486,7 @@ abstract contract Staking is StakingV4Storage, GraphUpgradeable, IStakingBase, M * @param _subgraphDeploymentID Deployment ID for the subgraph * @return Total tokens allocated to subgraph */ - function getSubgraphAllocatedTokens(bytes32 _subgraphDeploymentID) - external - view - override - returns (uint256) - { + function getSubgraphAllocatedTokens(bytes32 _subgraphDeploymentID) external view override returns (uint256) { return __subgraphAllocations[_subgraphDeploymentID]; } @@ -563,9 +538,7 @@ abstract contract Staking is StakingV4Storage, GraphUpgradeable, IStakingBase, M Stakes.Indexer memory indexerStake = __stakes[_indexer]; uint256 tokensDelegated = __delegationPools[_indexer].tokens; - uint256 tokensDelegatedCap = indexerStake.tokensSecureStake().mul( - uint256(__delegationRatio) - ); + uint256 tokensDelegatedCap = indexerStake.tokensSecureStake().mul(uint256(__delegationRatio)); uint256 tokensDelegatedCapacity = MathUtils.min(tokensDelegated, tokensDelegatedCap); return indexerStake.tokensAvailableWithDelegation(tokensDelegatedCapacity); @@ -661,11 +634,7 @@ abstract contract Staking is StakingV4Storage, GraphUpgradeable, IStakingBase, M * @param _indexingRewardCut Percentage of indexing rewards left for delegators * @param _queryFeeCut Percentage of query fees left for delegators */ - function _setDelegationParameters( - address _indexer, - uint32 _indexingRewardCut, - uint32 _queryFeeCut - ) internal { + function _setDelegationParameters(address _indexer, uint32 _indexingRewardCut, uint32 _queryFeeCut) internal { // Incentives must be within bounds require(_queryFeeCut <= MAX_PPM, ">queryFeeCut"); require(_indexingRewardCut <= MAX_PPM, ">indexingRewardCut"); @@ -690,10 +659,7 @@ abstract contract Staking is StakingV4Storage, GraphUpgradeable, IStakingBase, M */ function _stake(address _indexer, uint256 _tokens) internal { // Ensure minimum stake - require( - __stakes[_indexer].tokensSecureStake().add(_tokens) >= __minimumIndexerStake, - "!minimumIndexerStake" - ); + require(__stakes[_indexer].tokensSecureStake().add(_tokens) >= __minimumIndexerStake, "!minimumIndexerStake"); // Deposit tokens into the indexer stake __stakes[_indexer].deposit(_tokens); @@ -750,10 +716,7 @@ abstract contract Staking is StakingV4Storage, GraphUpgradeable, IStakingBase, M bytes32 digest = ECDSA.toEthSignedMessageHash(messageHash); require(ECDSA.recover(digest, _proof) == _allocationID, "!proof"); - require( - __stakes[_indexer].tokensSecureStake() >= __minimumIndexerStake, - "!minimumIndexerStake" - ); + require(__stakes[_indexer].tokensSecureStake() >= __minimumIndexerStake, "!minimumIndexerStake"); if (_tokens > 0) { // Needs to have free capacity not used for other purposes to allocate require(getIndexerCapacity(_indexer) >= _tokens, "!capacity"); @@ -784,9 +747,9 @@ abstract contract Staking is StakingV4Storage, GraphUpgradeable, IStakingBase, M // Track total allocations per subgraph // Used for rewards calculations - __subgraphAllocations[alloc.subgraphDeploymentID] = __subgraphAllocations[ - alloc.subgraphDeploymentID - ].add(alloc.tokens); + __subgraphAllocations[alloc.subgraphDeploymentID] = __subgraphAllocations[alloc.subgraphDeploymentID].add( + alloc.tokens + ); } emit AllocationCreated( @@ -845,9 +808,9 @@ abstract contract Staking is StakingV4Storage, GraphUpgradeable, IStakingBase, M // Track total allocations per subgraph // Used for rewards calculations - __subgraphAllocations[alloc.subgraphDeploymentID] = __subgraphAllocations[ - alloc.subgraphDeploymentID - ].sub(alloc.tokens); + __subgraphAllocations[alloc.subgraphDeploymentID] = __subgraphAllocations[alloc.subgraphDeploymentID].sub( + alloc.tokens + ); } emit AllocationClosed( @@ -869,10 +832,7 @@ abstract contract Staking is StakingV4Storage, GraphUpgradeable, IStakingBase, M * @param _tokens Total tokens received used to calculate the amount of fees to collect * @return Amount of delegation rewards */ - function _collectDelegationQueryRewards(address _indexer, uint256 _tokens) - private - returns (uint256) - { + function _collectDelegationQueryRewards(address _indexer, uint256 _tokens) private returns (uint256) { uint256 delegationRewards = 0; DelegationPool storage pool = __delegationPools[_indexer]; if (pool.tokens > 0 && pool.queryFeeCut < MAX_PPM) { @@ -890,10 +850,7 @@ abstract contract Staking is StakingV4Storage, GraphUpgradeable, IStakingBase, M * @param _tokens Total tokens received used to calculate the amount of fees to collect * @return Amount of delegation rewards */ - function _collectDelegationIndexingRewards(address _indexer, uint256 _tokens) - private - returns (uint256) - { + function _collectDelegationIndexingRewards(address _indexer, uint256 _tokens) private returns (uint256) { uint256 delegationRewards = 0; DelegationPool storage pool = __delegationPools[_indexer]; if (pool.tokens > 0 && pool.indexingRewardCut < MAX_PPM) { @@ -929,10 +886,7 @@ abstract contract Staking is StakingV4Storage, GraphUpgradeable, IStakingBase, M if (isCurationEnabled && curation.isCurated(_subgraphDeploymentID)) { // Calculate the tokens after curation fees first, and subtact that, // to prevent curation fees from rounding down to zero - uint256 tokensAfterCurationFees = uint256(MAX_PPM) - .sub(_curationPercentage) - .mul(_tokens) - .div(MAX_PPM); + uint256 tokensAfterCurationFees = uint256(MAX_PPM).sub(_curationPercentage).mul(_tokens).div(MAX_PPM); uint256 curationFees = _tokens.sub(tokensAfterCurationFees); if (curationFees > 0) { // Transfer and call collect() @@ -954,11 +908,7 @@ abstract contract Staking is StakingV4Storage, GraphUpgradeable, IStakingBase, M * @param _percentage Percentage of tokens to burn as tax * @return Amount of tax charged */ - function _collectTax( - IGraphToken _graphToken, - uint256 _tokens, - uint256 _percentage - ) private returns (uint256) { + function _collectTax(IGraphToken _graphToken, uint256 _tokens, uint256 _percentage) private returns (uint256) { // Calculate tokens after tax first, and subtract that, // to prevent the tax from rounding down to zero uint256 tokensAfterTax = uint256(MAX_PPM).sub(_percentage).mul(_tokens).div(MAX_PPM); @@ -1004,12 +954,7 @@ abstract contract Staking is StakingV4Storage, GraphUpgradeable, IStakingBase, M uint256 indexerRewards = totalRewards.sub(delegationRewards); // Send the indexer rewards - _sendRewards( - graphToken(), - indexerRewards, - _indexer, - __rewardsDestination[_indexer] == address(0) - ); + _sendRewards(graphToken(), indexerRewards, _indexer, __rewardsDestination[_indexer] == address(0)); } /** @@ -1019,12 +964,7 @@ abstract contract Staking is StakingV4Storage, GraphUpgradeable, IStakingBase, M * @param _beneficiary Address of the beneficiary of rewards * @param _restake Whether to restake or not */ - function _sendRewards( - IGraphToken _graphToken, - uint256 _amount, - address _beneficiary, - bool _restake - ) private { + function _sendRewards(IGraphToken _graphToken, uint256 _amount, address _beneficiary, bool _restake) private { if (_amount == 0) return; if (_restake) { @@ -1033,11 +973,7 @@ abstract contract Staking is StakingV4Storage, GraphUpgradeable, IStakingBase, M } else { // Transfer funds to the beneficiary's designated rewards destination if set address destination = __rewardsDestination[_beneficiary]; - TokenUtils.pushTokens( - _graphToken, - destination == address(0) ? _beneficiary : destination, - _amount - ); + TokenUtils.pushTokens(_graphToken, destination == address(0) ? _beneficiary : destination, _amount); } } diff --git a/packages/contracts/contracts/staking/StakingExtension.sol b/packages/contracts/contracts/staking/StakingExtension.sol index 08839ca2a..ee38364b5 100644 --- a/packages/contracts/contracts/staking/StakingExtension.sol +++ b/packages/contracts/contracts/staking/StakingExtension.sol @@ -82,11 +82,7 @@ contract StakingExtension is StakingV4Storage, GraphUpgradeable, IStakingExtensi * @dev This function is only callable by the governor * @param _delegationUnbondingPeriod Period in epochs to wait for token withdrawals after undelegating */ - function setDelegationUnbondingPeriod(uint32 _delegationUnbondingPeriod) - external - override - onlyGovernor - { + function setDelegationUnbondingPeriod(uint32 _delegationUnbondingPeriod) external override onlyGovernor { _setDelegationUnbondingPeriod(_delegationUnbondingPeriod); } @@ -107,12 +103,7 @@ contract StakingExtension is StakingV4Storage, GraphUpgradeable, IStakingExtensi * @param _tokens Amount of tokens to delegate * @return Amount of shares issued from the delegation pool */ - function delegate(address _indexer, uint256 _tokens) - external - override - notPartialPaused - returns (uint256) - { + function delegate(address _indexer, uint256 _tokens) external override notPartialPaused returns (uint256) { address delegator = msg.sender; // Transfer tokens to delegate to this contract @@ -128,12 +119,7 @@ contract StakingExtension is StakingV4Storage, GraphUpgradeable, IStakingExtensi * @param _shares Amount of shares to return and undelegate tokens * @return Amount of tokens returned for the shares of the delegation pool */ - function undelegate(address _indexer, uint256 _shares) - external - override - notPartialPaused - returns (uint256) - { + function undelegate(address _indexer, uint256 _shares) external override notPartialPaused returns (uint256) { return _undelegate(msg.sender, _indexer, _shares); } @@ -143,12 +129,7 @@ contract StakingExtension is StakingV4Storage, GraphUpgradeable, IStakingExtensi * @param _indexer Withdraw available tokens delegated to indexer * @param _newIndexer Re-delegate to indexer address if non-zero, withdraw if zero address */ - function withdrawDelegated(address _indexer, address _newIndexer) - external - override - notPaused - returns (uint256) - { + function withdrawDelegated(address _indexer, address _newIndexer) external override notPaused returns (uint256) { return _withdrawDelegated(msg.sender, _indexer, _newIndexer); } @@ -211,12 +192,7 @@ contract StakingExtension is StakingV4Storage, GraphUpgradeable, IStakingExtensi * @param _delegator Address of the delegator * @return Delegation data */ - function getDelegation(address _indexer, address _delegator) - external - view - override - returns (Delegation memory) - { + function getDelegation(address _indexer, address _delegator) external view override returns (Delegation memory) { return __delegationPools[_indexer].delegators[_delegator]; } @@ -254,12 +230,7 @@ contract StakingExtension is StakingV4Storage, GraphUpgradeable, IStakingExtensi * @param _indexer Address of the indexer for which to query the delegation pool * @return Delegation pool as a DelegationPoolReturn struct */ - function delegationPools(address _indexer) - external - view - override - returns (DelegationPoolReturn memory) - { + function delegationPools(address _indexer) external view override returns (DelegationPoolReturn memory) { DelegationPool storage pool = __delegationPools[_indexer]; return DelegationPoolReturn( @@ -289,12 +260,7 @@ contract StakingExtension is StakingV4Storage, GraphUpgradeable, IStakingExtensi * @param _maybeOperator The address that may or may not be an operator * @return True if the operator is authorized to operate on behalf of the indexer */ - function operatorAuth(address _indexer, address _maybeOperator) - external - view - override - returns (bool) - { + function operatorAuth(address _indexer, address _maybeOperator) external view override returns (bool) { return __operatorAuth[_indexer][_maybeOperator]; } @@ -304,12 +270,7 @@ contract StakingExtension is StakingV4Storage, GraphUpgradeable, IStakingExtensi * @param _subgraphDeploymentId The subgraph deployment for which to query the allocations * @return The amount of tokens allocated to the subgraph deployment */ - function subgraphAllocations(bytes32 _subgraphDeploymentId) - external - view - override - returns (uint256) - { + function subgraphAllocations(bytes32 _subgraphDeploymentId) external view override returns (uint256) { return __subgraphAllocations[_subgraphDeploymentId]; } @@ -418,12 +379,7 @@ contract StakingExtension is StakingV4Storage, GraphUpgradeable, IStakingExtensi * @param _allocationID Allocation ID for which to query the allocation information * @return The specified allocation, as an IStakingData.Allocation struct */ - function allocations(address _allocationID) - external - view - override - returns (IStakingData.Allocation memory) - { + function allocations(address _allocationID) external view override returns (IStakingData.Allocation memory) { return __allocations[_allocationID]; } @@ -442,12 +398,7 @@ contract StakingExtension is StakingV4Storage, GraphUpgradeable, IStakingExtensi * @param _delegation Delegation of tokens from delegator to indexer * @return Amount of tokens to withdraw */ - function getWithdraweableDelegatedTokens(Delegation memory _delegation) - public - view - override - returns (uint256) - { + function getWithdraweableDelegatedTokens(Delegation memory _delegation) public view override returns (uint256) { // There must be locked tokens and period passed uint256 currentEpoch = epochManager().currentEpoch(); if (_delegation.tokensLockedUntil > 0 && currentEpoch >= _delegation.tokensLockedUntil) { @@ -495,11 +446,7 @@ contract StakingExtension is StakingV4Storage, GraphUpgradeable, IStakingExtensi * @param _tokens Amount of tokens to delegate * @return Amount of shares issued of the delegation pool */ - function _delegate( - address _delegator, - address _indexer, - uint256 _tokens - ) private returns (uint256) { + function _delegate(address _delegator, address _indexer, uint256 _tokens) private returns (uint256) { // Only allow delegations over a minimum, to prevent rounding attacks require(_tokens >= MINIMUM_DELEGATION, "!minimum-delegation"); // Only delegate to non-empty address @@ -516,9 +463,7 @@ contract StakingExtension is StakingV4Storage, GraphUpgradeable, IStakingExtensi uint256 delegatedTokens = _tokens.sub(delegationTax); // Calculate shares to issue - uint256 shares = (pool.tokens == 0) - ? delegatedTokens - : delegatedTokens.mul(pool.shares).div(pool.tokens); + uint256 shares = (pool.tokens == 0) ? delegatedTokens : delegatedTokens.mul(pool.shares).div(pool.tokens); require(shares > 0, "!shares"); // Update the delegation pool @@ -540,11 +485,7 @@ contract StakingExtension is StakingV4Storage, GraphUpgradeable, IStakingExtensi * @param _shares Amount of shares to return and undelegate tokens * @return Amount of tokens returned for the shares of the delegation pool */ - function _undelegate( - address _delegator, - address _indexer, - uint256 _shares - ) private returns (uint256) { + function _undelegate(address _delegator, address _indexer, uint256 _shares) private returns (uint256) { // Can only undelegate a non-zero amount of shares require(_shares > 0, "!shares"); @@ -581,17 +522,9 @@ contract StakingExtension is StakingV4Storage, GraphUpgradeable, IStakingExtensi require(remainingDelegation >= MINIMUM_DELEGATION, "!minimum-delegation"); } delegation.tokensLocked = delegation.tokensLocked.add(tokens); - delegation.tokensLockedUntil = epochManager().currentEpoch().add( - __delegationUnbondingPeriod - ); - - emit StakeDelegatedLocked( - _indexer, - _delegator, - tokens, - _shares, - delegation.tokensLockedUntil - ); + delegation.tokensLockedUntil = epochManager().currentEpoch().add(__delegationUnbondingPeriod); + + emit StakeDelegatedLocked(_indexer, _delegator, tokens, _shares, delegation.tokensLockedUntil); return tokens; } @@ -642,11 +575,7 @@ contract StakingExtension is StakingV4Storage, GraphUpgradeable, IStakingExtensi * @param _percentage Percentage of tokens to burn as tax * @return Amount of tax charged */ - function _collectTax( - IGraphToken _graphToken, - uint256 _tokens, - uint256 _percentage - ) private returns (uint256) { + function _collectTax(IGraphToken _graphToken, uint256 _tokens, uint256 _percentage) private returns (uint256) { uint256 tax = uint256(_percentage).mul(_tokens).div(MAX_PPM); TokenUtils.burnTokens(_graphToken, tax); // Burn tax if any return tax; diff --git a/packages/contracts/contracts/staking/libs/Exponential.sol b/packages/contracts/contracts/staking/libs/Exponential.sol index 303b6790b..c9370342e 100644 --- a/packages/contracts/contracts/staking/libs/Exponential.sol +++ b/packages/contracts/contracts/staking/libs/Exponential.sol @@ -54,10 +54,7 @@ library LibExponential { } // Compute `1 - alpha * exp ^(-exponent)` - int256 factor = LibFixedMath.sub( - LibFixedMath.one(), - LibFixedMath.mul(alpha, LibFixedMath.exp(-exponent)) - ); + int256 factor = LibFixedMath.sub(LibFixedMath.one(), LibFixedMath.mul(alpha, LibFixedMath.exp(-exponent))); // Weight the fees by the factor return LibFixedMath.uintMul(factor, fees); diff --git a/packages/contracts/contracts/staking/libs/LibFixedMath.sol b/packages/contracts/contracts/staking/libs/LibFixedMath.sol index b8e5e39a5..ae8c9b69e 100644 --- a/packages/contracts/contracts/staking/libs/LibFixedMath.sol +++ b/packages/contracts/contracts/staking/libs/LibFixedMath.sol @@ -24,24 +24,20 @@ pragma solidity ^0.7.6; /// @dev Signed, fixed-point, 127-bit precision math library. library LibFixedMath { // 1 - int256 private constant FIXED_1 = - int256(0x0000000000000000000000000000000080000000000000000000000000000000); + int256 private constant FIXED_1 = int256(0x0000000000000000000000000000000080000000000000000000000000000000); // 2**255 - int256 private constant MIN_FIXED_VAL = - int256(0x8000000000000000000000000000000000000000000000000000000000000000); + int256 private constant MIN_FIXED_VAL = int256(0x8000000000000000000000000000000000000000000000000000000000000000); // 1^2 (in fixed-point) int256 private constant FIXED_1_SQUARED = int256(0x4000000000000000000000000000000000000000000000000000000000000000); // 1 int256 private constant LN_MAX_VAL = FIXED_1; // e ^ -63.875 - int256 private constant LN_MIN_VAL = - int256(0x0000000000000000000000000000000000000000000000000000000733048c5a); + int256 private constant LN_MIN_VAL = int256(0x0000000000000000000000000000000000000000000000000000000733048c5a); // 0 int256 private constant EXP_MAX_VAL = 0; // -63.875 - int256 private constant EXP_MIN_VAL = - -int256(0x0000000000000000000000000000001ff0000000000000000000000000000000); + int256 private constant EXP_MIN_VAL = -int256(0x0000000000000000000000000000001ff0000000000000000000000000000000); /// @dev Get one as a fixed-point number. function one() internal pure returns (int256 f) { @@ -72,11 +68,7 @@ library LibFixedMath { } /// @dev Performs (a * n) / d, without scaling for precision. - function mulDiv( - int256 a, - int256 n, - int256 d - ) internal pure returns (int256 c) { + function mulDiv(int256 a, int256 n, int256 d) internal pure returns (int256 c) { c = _div(_mul(a, n), d); } @@ -172,65 +164,47 @@ library LibFixedMath { // e ^ -32 if (x <= int256(0x00000000000000000000000000000000000000000001c8464f76164760000000)) { r -= int256(0x0000000000000000000000000000001000000000000000000000000000000000); // - 32 - x = - (x * FIXED_1) / - int256(0x00000000000000000000000000000000000000000001c8464f76164760000000); // / e ^ -32 + x = (x * FIXED_1) / int256(0x00000000000000000000000000000000000000000001c8464f76164760000000); // / e ^ -32 } // e ^ -16 if (x <= int256(0x00000000000000000000000000000000000000f1aaddd7742e90000000000000)) { r -= int256(0x0000000000000000000000000000000800000000000000000000000000000000); // - 16 - x = - (x * FIXED_1) / - int256(0x00000000000000000000000000000000000000f1aaddd7742e90000000000000); // / e ^ -16 + x = (x * FIXED_1) / int256(0x00000000000000000000000000000000000000f1aaddd7742e90000000000000); // / e ^ -16 } // e ^ -8 if (x <= int256(0x00000000000000000000000000000000000afe10820813d78000000000000000)) { r -= int256(0x0000000000000000000000000000000400000000000000000000000000000000); // - 8 - x = - (x * FIXED_1) / - int256(0x00000000000000000000000000000000000afe10820813d78000000000000000); // / e ^ -8 + x = (x * FIXED_1) / int256(0x00000000000000000000000000000000000afe10820813d78000000000000000); // / e ^ -8 } // e ^ -4 if (x <= int256(0x0000000000000000000000000000000002582ab704279ec00000000000000000)) { r -= int256(0x0000000000000000000000000000000200000000000000000000000000000000); // - 4 - x = - (x * FIXED_1) / - int256(0x0000000000000000000000000000000002582ab704279ec00000000000000000); // / e ^ -4 + x = (x * FIXED_1) / int256(0x0000000000000000000000000000000002582ab704279ec00000000000000000); // / e ^ -4 } // e ^ -2 if (x <= int256(0x000000000000000000000000000000001152aaa3bf81cc000000000000000000)) { r -= int256(0x0000000000000000000000000000000100000000000000000000000000000000); // - 2 - x = - (x * FIXED_1) / - int256(0x000000000000000000000000000000001152aaa3bf81cc000000000000000000); // / e ^ -2 + x = (x * FIXED_1) / int256(0x000000000000000000000000000000001152aaa3bf81cc000000000000000000); // / e ^ -2 } // e ^ -1 if (x <= int256(0x000000000000000000000000000000002f16ac6c59de70000000000000000000)) { r -= int256(0x0000000000000000000000000000000080000000000000000000000000000000); // - 1 - x = - (x * FIXED_1) / - int256(0x000000000000000000000000000000002f16ac6c59de70000000000000000000); // / e ^ -1 + x = (x * FIXED_1) / int256(0x000000000000000000000000000000002f16ac6c59de70000000000000000000); // / e ^ -1 } // e ^ -0.5 if (x <= int256(0x000000000000000000000000000000004da2cbf1be5828000000000000000000)) { r -= int256(0x0000000000000000000000000000000040000000000000000000000000000000); // - 0.5 - x = - (x * FIXED_1) / - int256(0x000000000000000000000000000000004da2cbf1be5828000000000000000000); // / e ^ -0.5 + x = (x * FIXED_1) / int256(0x000000000000000000000000000000004da2cbf1be5828000000000000000000); // / e ^ -0.5 } // e ^ -0.25 if (x <= int256(0x0000000000000000000000000000000063afbe7ab2082c000000000000000000)) { r -= int256(0x0000000000000000000000000000000020000000000000000000000000000000); // - 0.25 - x = - (x * FIXED_1) / - int256(0x0000000000000000000000000000000063afbe7ab2082c000000000000000000); // / e ^ -0.25 + x = (x * FIXED_1) / int256(0x0000000000000000000000000000000063afbe7ab2082c000000000000000000); // / e ^ -0.25 } // e ^ -0.125 if (x <= int256(0x0000000000000000000000000000000070f5a893b608861e1f58934f97aea57d)) { r -= int256(0x0000000000000000000000000000000010000000000000000000000000000000); // - 0.125 - x = - (x * FIXED_1) / - int256(0x0000000000000000000000000000000070f5a893b608861e1f58934f97aea57d); // / e ^ -0.125 + x = (x * FIXED_1) / int256(0x0000000000000000000000000000000070f5a893b608861e1f58934f97aea57d); // / e ^ -0.125 } // `x` is now our residual in the range of 1 <= x <= 2 (or close enough). diff --git a/packages/contracts/contracts/staking/libs/MathUtils.sol b/packages/contracts/contracts/staking/libs/MathUtils.sol index c20a1c3b0..0fb20389a 100644 --- a/packages/contracts/contracts/staking/libs/MathUtils.sol +++ b/packages/contracts/contracts/staking/libs/MathUtils.sol @@ -27,10 +27,7 @@ library MathUtils { uint256 valueB, uint256 weightB ) internal pure returns (uint256) { - return - valueA.mul(weightA).add(valueB.mul(weightB)).add(weightA.add(weightB).sub(1)).div( - weightA.add(weightB) - ); + return valueA.mul(weightA).add(valueB.mul(weightB)).add(weightA.add(weightB).sub(1)).div(weightA.add(weightB)); } /** diff --git a/packages/contracts/contracts/staking/libs/Stakes.sol b/packages/contracts/contracts/staking/libs/Stakes.sol index 38b5f5daa..b0524b14c 100644 --- a/packages/contracts/contracts/staking/libs/Stakes.sol +++ b/packages/contracts/contracts/staking/libs/Stakes.sol @@ -65,11 +65,7 @@ library Stakes { * @param _tokens Amount of tokens to unstake * @param _period Period in blocks that need to pass before withdrawal */ - function lockTokens( - Stakes.Indexer storage stake, - uint256 _tokens, - uint256 _period - ) internal { + function lockTokens(Stakes.Indexer storage stake, uint256 _tokens, uint256 _period) internal { // Take into account period averaging for multiple unstake requests uint256 lockingPeriod = _period; if (stake.tokensLocked > 0) { @@ -158,11 +154,10 @@ library Stakes { * @param _delegatedCapacity Amount of tokens used from delegators to calculate availability * @return Token amount */ - function tokensAvailableWithDelegation(Stakes.Indexer memory stake, uint256 _delegatedCapacity) - internal - pure - returns (uint256) - { + function tokensAvailableWithDelegation( + Stakes.Indexer memory stake, + uint256 _delegatedCapacity + ) internal pure returns (uint256) { uint256 tokensCapacity = stake.tokensStaked.add(_delegatedCapacity); uint256 _tokensUsed = stake.tokensUsed(); // If more tokens are used than the current capacity, the indexer is overallocated. diff --git a/packages/contracts/contracts/tests/CallhookReceiverMock.sol b/packages/contracts/contracts/tests/CallhookReceiverMock.sol index 1e71cf86f..e2418f3c8 100644 --- a/packages/contracts/contracts/tests/CallhookReceiverMock.sol +++ b/packages/contracts/contracts/tests/CallhookReceiverMock.sol @@ -18,11 +18,7 @@ contract CallhookReceiverMock is ICallhookReceiver { * @param _amount Amount of tokens that were transferred * @param _data ABI-encoded callhook data */ - function onTokenTransfer( - address _from, - uint256 _amount, - bytes calldata _data - ) external override { + function onTokenTransfer(address _from, uint256 _amount, bytes calldata _data) external override { uint256 foo; uint256 bar; (foo, bar) = abi.decode(_data, (uint256, uint256)); diff --git a/packages/contracts/contracts/tests/L1GraphTokenLockTransferToolBadMock.sol b/packages/contracts/contracts/tests/L1GraphTokenLockTransferToolBadMock.sol index 2dcb6e53a..f540b1b96 100644 --- a/packages/contracts/contracts/tests/L1GraphTokenLockTransferToolBadMock.sol +++ b/packages/contracts/contracts/tests/L1GraphTokenLockTransferToolBadMock.sol @@ -12,10 +12,7 @@ contract L1GraphTokenLockTransferToolBadMock { // Sends 1 wei less than requested function pullETH(address _l1Wallet, uint256 _amount) external { - require( - l2WalletAddress[_l1Wallet] != address(0), - "L1GraphTokenLockTransferToolMock: unknown L1 wallet" - ); + require(l2WalletAddress[_l1Wallet] != address(0), "L1GraphTokenLockTransferToolMock: unknown L1 wallet"); (bool success, ) = payable(msg.sender).call{ value: _amount - 1 }(""); require(success, "L1GraphTokenLockTransferToolMock: ETH pull failed"); } diff --git a/packages/contracts/contracts/tests/L1GraphTokenLockTransferToolMock.sol b/packages/contracts/contracts/tests/L1GraphTokenLockTransferToolMock.sol index 7a786beed..a1321d62f 100644 --- a/packages/contracts/contracts/tests/L1GraphTokenLockTransferToolMock.sol +++ b/packages/contracts/contracts/tests/L1GraphTokenLockTransferToolMock.sol @@ -11,10 +11,7 @@ contract L1GraphTokenLockTransferToolMock { } function pullETH(address _l1Wallet, uint256 _amount) external { - require( - l2WalletAddress[_l1Wallet] != address(0), - "L1GraphTokenLockTransferToolMock: unknown L1 wallet" - ); + require(l2WalletAddress[_l1Wallet] != address(0), "L1GraphTokenLockTransferToolMock: unknown L1 wallet"); (bool success, ) = payable(msg.sender).call{ value: _amount }(""); require(success, "L1GraphTokenLockTransferToolMock: ETH pull failed"); } diff --git a/packages/contracts/contracts/tests/LegacyGNSMock.sol b/packages/contracts/contracts/tests/LegacyGNSMock.sol index 0e1e94be4..b2b4088b9 100644 --- a/packages/contracts/contracts/tests/LegacyGNSMock.sol +++ b/packages/contracts/contracts/tests/LegacyGNSMock.sol @@ -28,11 +28,7 @@ contract LegacyGNSMock is L1GNS { * @param subgraphID Subgraph ID * @return subgraphDeploymentID Subgraph deployment ID */ - function getSubgraphDeploymentID(uint256 subgraphID) - external - view - returns (bytes32 subgraphDeploymentID) - { + function getSubgraphDeploymentID(uint256 subgraphID) external view returns (bytes32 subgraphDeploymentID) { IGNS.SubgraphData storage subgraph = _getSubgraphData(subgraphID); subgraphDeploymentID = subgraph.subgraphDeploymentID; } diff --git a/packages/contracts/contracts/tests/arbitrum/BridgeMock.sol b/packages/contracts/contracts/tests/arbitrum/BridgeMock.sol index 4f2848288..77be89b4e 100644 --- a/packages/contracts/contracts/tests/arbitrum/BridgeMock.sol +++ b/packages/contracts/contracts/tests/arbitrum/BridgeMock.sol @@ -33,14 +33,7 @@ contract BridgeMock is IBridge { ) external payable override returns (uint256) { messageIndex = messageIndex + 1; inboxAccs.push(keccak256(abi.encodePacked(inbox, _kind, _sender, _messageDataHash))); - emit MessageDelivered( - messageIndex, - inboxAccs[messageIndex - 1], - msg.sender, - _kind, - _sender, - _messageDataHash - ); + emit MessageDelivered(messageIndex, inboxAccs[messageIndex - 1], msg.sender, _kind, _sender, _messageDataHash); return messageIndex; } diff --git a/packages/contracts/contracts/tests/arbitrum/InboxMock.sol b/packages/contracts/contracts/tests/arbitrum/InboxMock.sol index b600ec3ac..57af6941c 100644 --- a/packages/contracts/contracts/tests/arbitrum/InboxMock.sol +++ b/packages/contracts/contracts/tests/arbitrum/InboxMock.sol @@ -171,11 +171,7 @@ contract InboxMock is IInbox { * @param _messageData Encoded message data * @return Message number returned by the bridge */ - function _deliverMessage( - uint8 _kind, - address _sender, - bytes memory _messageData - ) internal returns (uint256) { + function _deliverMessage(uint8 _kind, address _sender, bytes memory _messageData) internal returns (uint256) { uint256 msgNum = deliverToBridge(_kind, _sender, keccak256(_messageData)); emit InboxMessageDelivered(msgNum, _messageData); return msgNum; @@ -188,11 +184,7 @@ contract InboxMock is IInbox { * @param _messageDataHash keccak256 hash of the encoded message data * @return Message number returned by the bridge */ - function deliverToBridge( - uint8 _kind, - address _sender, - bytes32 _messageDataHash - ) internal returns (uint256) { + function deliverToBridge(uint8 _kind, address _sender, bytes32 _messageDataHash) internal returns (uint256) { return bridge.deliverMessageToInbox{ value: msg.value }(_kind, _sender, _messageDataHash); } } diff --git a/packages/contracts/contracts/tests/arbitrum/OutboxMock.sol b/packages/contracts/contracts/tests/arbitrum/OutboxMock.sol index a529a975a..92b9bb246 100644 --- a/packages/contracts/contracts/tests/arbitrum/OutboxMock.sol +++ b/packages/contracts/contracts/tests/arbitrum/OutboxMock.sol @@ -136,11 +136,7 @@ contract OutboxMock is IOutbox { * @param _amount Callvalue for the function call * @param _data Calldata for the function call */ - function executeBridgeCall( - address _destAddr, - uint256 _amount, - bytes memory _data - ) internal { + function executeBridgeCall(address _destAddr, uint256 _amount, bytes memory _data) internal { (bool success, bytes memory returndata) = bridge.executeCall(_destAddr, _amount, _data); if (!success) { if (returndata.length > 0) { diff --git a/packages/contracts/contracts/tests/ens/IENS.sol b/packages/contracts/contracts/tests/ens/IENS.sol index 9de0b357c..f03cb651c 100644 --- a/packages/contracts/contracts/tests/ens/IENS.sol +++ b/packages/contracts/contracts/tests/ens/IENS.sol @@ -5,11 +5,5 @@ interface IENS { function owner(bytes32 node) external view returns (address); // Must call setRecord, not setOwner, We must namehash it ourselves as well - function setSubnodeRecord( - bytes32 node, - bytes32 label, - address owner, - address resolver, - uint64 ttl - ) external; + function setSubnodeRecord(bytes32 node, bytes32 label, address owner, address resolver, uint64 ttl) external; } diff --git a/packages/contracts/contracts/tests/ens/IPublicResolver.sol b/packages/contracts/contracts/tests/ens/IPublicResolver.sol index 7f0676837..06ce2243b 100644 --- a/packages/contracts/contracts/tests/ens/IPublicResolver.sol +++ b/packages/contracts/contracts/tests/ens/IPublicResolver.sol @@ -4,9 +4,5 @@ pragma solidity ^0.7.6; interface IPublicResolver { function text(bytes32 node, string calldata key) external view returns (string memory); - function setText( - bytes32 node, - string calldata key, - string calldata value - ) external; + function setText(bytes32 node, string calldata key, string calldata value) external; } diff --git a/packages/contracts/contracts/token/GraphToken.sol b/packages/contracts/contracts/token/GraphToken.sol index 2b354e57c..53496b9a5 100644 --- a/packages/contracts/contracts/token/GraphToken.sol +++ b/packages/contracts/contracts/token/GraphToken.sol @@ -29,17 +29,12 @@ contract GraphToken is Governed, ERC20, ERC20Burnable { // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-712.md#definition-of-domainseparator bytes32 private constant DOMAIN_TYPE_HASH = - keccak256( - "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract,bytes32 salt)" - ); + keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract,bytes32 salt)"); bytes32 private constant DOMAIN_NAME_HASH = keccak256("Graph Token"); bytes32 private constant DOMAIN_VERSION_HASH = keccak256("0"); - bytes32 private constant DOMAIN_SALT = - 0x51f3d585afe6dfeb2af01bba0889a36c1db03beec88c6a4d0c53817069026afa; // Randomly generated salt + bytes32 private constant DOMAIN_SALT = 0x51f3d585afe6dfeb2af01bba0889a36c1db03beec88c6a4d0c53817069026afa; // Randomly generated salt bytes32 private constant PERMIT_TYPEHASH = - keccak256( - "Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)" - ); + keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); // -- State -- @@ -106,9 +101,7 @@ contract GraphToken is Governed, ERC20, ERC20Burnable { abi.encodePacked( "\x19\x01", DOMAIN_SEPARATOR, - keccak256( - abi.encode(PERMIT_TYPEHASH, _owner, _spender, _value, nonces[_owner], _deadline) - ) + keccak256(abi.encode(PERMIT_TYPEHASH, _owner, _spender, _value, nonces[_owner], _deadline)) ) ); nonces[_owner] = nonces[_owner].add(1); diff --git a/packages/contracts/contracts/upgrades/GraphProxy.sol b/packages/contracts/contracts/upgrades/GraphProxy.sol index d3f6eacec..7d227b065 100644 --- a/packages/contracts/contracts/upgrades/GraphProxy.sol +++ b/packages/contracts/contracts/upgrades/GraphProxy.sol @@ -47,13 +47,8 @@ contract GraphProxy is GraphProxyStorage, IGraphProxy { */ constructor(address _impl, address _admin) { assert(ADMIN_SLOT == bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1)); - assert( - IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1) - ); - assert( - PENDING_IMPLEMENTATION_SLOT == - bytes32(uint256(keccak256("eip1967.proxy.pendingImplementation")) - 1) - ); + assert(IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)); + assert(PENDING_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.pendingImplementation")) - 1)); _setAdmin(_admin); _setPendingImplementation(_impl); diff --git a/packages/contracts/contracts/upgrades/GraphProxyAdmin.sol b/packages/contracts/contracts/upgrades/GraphProxyAdmin.sol index d96dbd449..7d809d5ec 100644 --- a/packages/contracts/contracts/upgrades/GraphProxyAdmin.sol +++ b/packages/contracts/contracts/upgrades/GraphProxyAdmin.sol @@ -86,10 +86,7 @@ contract GraphProxyAdmin is Governed { * @param _implementation Address of the implementation accepting the proxy. * @param _proxy Address of the proxy being accepted. */ - function acceptProxy(GraphUpgradeable _implementation, IGraphProxy _proxy) - external - onlyGovernor - { + function acceptProxy(GraphUpgradeable _implementation, IGraphProxy _proxy) external onlyGovernor { _implementation.acceptProxy(_proxy); } diff --git a/packages/contracts/contracts/upgrades/GraphProxyStorage.sol b/packages/contracts/contracts/upgrades/GraphProxyStorage.sol index b308c0a0c..05b922647 100644 --- a/packages/contracts/contracts/upgrades/GraphProxyStorage.sol +++ b/packages/contracts/contracts/upgrades/GraphProxyStorage.sol @@ -14,8 +14,7 @@ abstract contract GraphProxyStorage { * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ - bytes32 internal constant IMPLEMENTATION_SLOT = - 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; + bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Storage slot with the address of the pending implementation. @@ -30,8 +29,7 @@ abstract contract GraphProxyStorage { * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is * validated in the constructor. */ - bytes32 internal constant ADMIN_SLOT = - 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; + bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Emitted when pendingImplementation is changed. @@ -45,10 +43,7 @@ abstract contract GraphProxyStorage { * @dev Emitted when pendingImplementation is accepted, * which means contract implementation is updated. */ - event ImplementationUpdated( - address indexed oldImplementation, - address indexed newImplementation - ); + event ImplementationUpdated(address indexed oldImplementation, address indexed newImplementation); /** * @dev Emitted when the admin account has changed. diff --git a/packages/contracts/contracts/upgrades/GraphUpgradeable.sol b/packages/contracts/contracts/upgrades/GraphUpgradeable.sol index 92ce80ad7..862f7e7d5 100644 --- a/packages/contracts/contracts/upgrades/GraphUpgradeable.sol +++ b/packages/contracts/contracts/upgrades/GraphUpgradeable.sol @@ -14,8 +14,7 @@ abstract contract GraphUpgradeable { * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ - bytes32 internal constant IMPLEMENTATION_SLOT = - 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; + bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Check if the caller is the proxy admin. @@ -60,10 +59,7 @@ abstract contract GraphUpgradeable { * @param _proxy Proxy to accept * @param _data Calldata for the initialization function call (including selector) */ - function acceptProxyAndCall(IGraphProxy _proxy, bytes calldata _data) - external - onlyProxyAdmin(_proxy) - { + function acceptProxyAndCall(IGraphProxy _proxy, bytes calldata _data) external onlyProxyAdmin(_proxy) { _proxy.acceptUpgradeAndCall(_data); } } diff --git a/packages/contracts/contracts/utils/TokenUtils.sol b/packages/contracts/contracts/utils/TokenUtils.sol index cbb23ce97..265f918a5 100644 --- a/packages/contracts/contracts/utils/TokenUtils.sol +++ b/packages/contracts/contracts/utils/TokenUtils.sol @@ -11,11 +11,7 @@ library TokenUtils { * @param _from Address sending the tokens * @param _amount Amount of tokens to transfer */ - function pullTokens( - IGraphToken _graphToken, - address _from, - uint256 _amount - ) internal { + function pullTokens(IGraphToken _graphToken, address _from, uint256 _amount) internal { if (_amount > 0) { require(_graphToken.transferFrom(_from, address(this), _amount), "!transfer"); } @@ -27,11 +23,7 @@ library TokenUtils { * @param _to Address receiving the tokens * @param _amount Amount of tokens to transfer */ - function pushTokens( - IGraphToken _graphToken, - address _to, - uint256 _amount - ) internal { + function pushTokens(IGraphToken _graphToken, address _to, uint256 _amount) internal { if (_amount > 0) { require(_graphToken.transfer(_to, _amount), "!transfer"); } diff --git a/packages/contracts/package.json b/packages/contracts/package.json index 48d52d57d..656b14121 100644 --- a/packages/contracts/package.json +++ b/packages/contracts/package.json @@ -68,7 +68,10 @@ "isomorphic-fetch": "^3.0.0", "lint-staged": "^10.5.4", "p-queue": "^6.6.1", - "solhint": "^3.3.6", + "prettier": "^3.2.5", + "prettier-plugin-solidity": "^1.3.1", + "solhint": "^4.1.1", + "solhint-graph-config": "workspace:^0.0.1", "solidity-coverage": "^0.7.16", "ts-node": "^10.9.1", "typechain": "^5.0.0", @@ -91,12 +94,8 @@ "test:coverage": "scripts/coverage", "test:upgrade": "scripts/upgrade", "lint": "yarn lint:ts && yarn lint:sol", - "lint:fix": "yarn lint:ts && yarn lint:sol:fix", "lint:ts": "eslint '**/*.{js,ts}' --fix", - "lint:sol": "solhint 'contracts/**/*.sol'", - "lint:sol:fix": "yarn prettier:sol && solhint --fix 'contracts/**/*.sol'", - "prettier": "yarn prettier:ts && yarn prettier:sol", - "prettier:sol": "prettier --write 'contracts/**/*.sol'", + "lint:sol": "prettier --write 'contracts/**/*.sol' && solhint --fix --noPrompt contracts/**/*.sol --config node_modules/solhint-graph-config/index.js", "analyze": "scripts/analyze", "myth": "scripts/myth", "flatten": "scripts/flatten && scripts/clean", @@ -106,7 +105,7 @@ }, "lint-staged": { "contracts/**/*.sol": [ - "yarn lint:sol:fix" + "yarn lint:sol" ], "**/*.ts": [ "yarn lint:ts" diff --git a/packages/contracts/prettier.config.js b/packages/contracts/prettier.config.js new file mode 100644 index 000000000..5b8e866f2 --- /dev/null +++ b/packages/contracts/prettier.config.js @@ -0,0 +1,2 @@ +const prettierGraphConfig = require('solhint-graph-config/prettier') +module.exports = prettierGraphConfig diff --git a/packages/contracts/tsconfig.json b/packages/contracts/tsconfig.json index 60037c936..a12f7de23 100644 --- a/packages/contracts/tsconfig.json +++ b/packages/contracts/tsconfig.json @@ -12,6 +12,7 @@ ".solcover.js", "truffle.js", "eslint.config.js", + "prettier.config.js", "hardhat.config.ts", "index.d.ts", "scripts/**/*.ts", diff --git a/packages/solhint-graph-config/README.md b/packages/solhint-graph-config/README.md index 48f05f269..7a724946b 100644 --- a/packages/solhint-graph-config/README.md +++ b/packages/solhint-graph-config/README.md @@ -25,7 +25,7 @@ Run `solhint` with `node_modules/solhint-graph-config/index.js` as the configura { "scripts": { - "lint": "solhint --fix contracts/**/*.sol --config node_modules/solhint-graph-config/index.js" + "lint": "solhint --fix --noPrompt contracts/**/*.sol --config node_modules/solhint-graph-config/index.js" } } diff --git a/yarn.lock b/yarn.lock index cdb16edb9..105d1827e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2674,7 +2674,10 @@ __metadata: isomorphic-fetch: "npm:^3.0.0" lint-staged: "npm:^10.5.4" p-queue: "npm:^6.6.1" - solhint: "npm:^3.3.6" + prettier: "npm:^3.2.5" + prettier-plugin-solidity: "npm:^1.3.1" + solhint: "npm:^4.1.1" + solhint-graph-config: "workspace:^0.0.1" solidity-coverage: "npm:^0.7.16" ts-node: "npm:^10.9.1" typechain: "npm:^5.0.0" @@ -4704,6 +4707,33 @@ __metadata: languageName: node linkType: hard +"@pnpm/config.env-replace@npm:^1.1.0": + version: 1.1.0 + resolution: "@pnpm/config.env-replace@npm:1.1.0" + checksum: 4cfc4a5c49ab3d0c6a1f196cfd4146374768b0243d441c7de8fa7bd28eaab6290f514b98490472cc65dbd080d34369447b3e9302585e1d5c099befd7c8b5e55f + languageName: node + linkType: hard + +"@pnpm/network.ca-file@npm:^1.0.1": + version: 1.0.2 + resolution: "@pnpm/network.ca-file@npm:1.0.2" + dependencies: + graceful-fs: "npm:4.2.10" + checksum: 95f6e0e38d047aca3283550719155ce7304ac00d98911e4ab026daedaf640a63bd83e3d13e17c623fa41ac72f3801382ba21260bcce431c14fbbc06430ecb776 + languageName: node + linkType: hard + +"@pnpm/npm-conf@npm:^2.1.0": + version: 2.2.2 + resolution: "@pnpm/npm-conf@npm:2.2.2" + dependencies: + "@pnpm/config.env-replace": "npm:^1.1.0" + "@pnpm/network.ca-file": "npm:^1.0.1" + config-chain: "npm:^1.1.11" + checksum: 71393dcfce85603fddd8484b486767163000afab03918303253ae97992615b91d25942f83751366cb40ad2ee32b0ae0a033561de9d878199a024286ff98b0296 + languageName: node + linkType: hard + "@prettier/sync@npm:^0.3.0": version: 0.3.0 resolution: "@prettier/sync@npm:0.3.0" @@ -4917,6 +4947,13 @@ __metadata: languageName: node linkType: hard +"@sindresorhus/is@npm:^5.2.0": + version: 5.6.0 + resolution: "@sindresorhus/is@npm:5.6.0" + checksum: 66727344d0c92edde5760b5fd1f8092b717f2298a162a5f7f29e4953e001479927402d9d387e245fb9dc7d3b37c72e335e93ed5875edfc5203c53be8ecba1b52 + languageName: node + linkType: hard + "@smithy/types@npm:^2.9.1": version: 2.10.0 resolution: "@smithy/types@npm:2.10.0" @@ -5304,7 +5341,7 @@ __metadata: languageName: node linkType: hard -"@types/http-cache-semantics@npm:*": +"@types/http-cache-semantics@npm:*, @types/http-cache-semantics@npm:^4.0.2": version: 4.0.4 resolution: "@types/http-cache-semantics@npm:4.0.4" checksum: 51b72568b4b2863e0fe8d6ce8aad72a784b7510d72dc866215642da51d84945a9459fa89f49ec48f1e9a1752e6a78e85a4cda0ded06b1c73e727610c925f9ce6 @@ -8144,6 +8181,28 @@ __metadata: languageName: node linkType: hard +"cacheable-lookup@npm:^7.0.0": + version: 7.0.0 + resolution: "cacheable-lookup@npm:7.0.0" + checksum: 63a9c144c5b45cb5549251e3ea774c04d63063b29e469f7584171d059d3a88f650f47869a974e2d07de62116463d742c287a81a625e791539d987115cb081635 + languageName: node + linkType: hard + +"cacheable-request@npm:^10.2.8": + version: 10.2.14 + resolution: "cacheable-request@npm:10.2.14" + dependencies: + "@types/http-cache-semantics": "npm:^4.0.2" + get-stream: "npm:^6.0.1" + http-cache-semantics: "npm:^4.1.1" + keyv: "npm:^4.5.3" + mimic-response: "npm:^4.0.0" + normalize-url: "npm:^8.0.0" + responselike: "npm:^3.0.0" + checksum: 41b6658db369f20c03128227ecd219ca7ac52a9d24fc0f499cc9aa5d40c097b48b73553504cebd137024d957c0ddb5b67cf3ac1439b136667f3586257763f88d + languageName: node + linkType: hard + "cacheable-request@npm:^6.0.0": version: 6.1.0 resolution: "cacheable-request@npm:6.1.0" @@ -8956,6 +9015,16 @@ __metadata: languageName: node linkType: hard +"config-chain@npm:^1.1.11": + version: 1.1.13 + resolution: "config-chain@npm:1.1.13" + dependencies: + ini: "npm:^1.3.4" + proto-list: "npm:~1.2.1" + checksum: 39d1df18739d7088736cc75695e98d7087aea43646351b028dfabd5508d79cf6ef4c5bcd90471f52cd87ae470d1c5490c0a8c1a292fbe6ee9ff688061ea0963e + languageName: node + linkType: hard + "consola@npm:^2.15.0": version: 2.15.3 resolution: "consola@npm:2.15.3" @@ -9521,6 +9590,13 @@ __metadata: languageName: node linkType: hard +"deep-extend@npm:^0.6.0": + version: 0.6.0 + resolution: "deep-extend@npm:0.6.0" + checksum: 1c6b0abcdb901e13a44c7d699116d3d4279fdb261983122a3783e7273844d5f2537dc2e1c454a23fcf645917f93fbf8d07101c1d03c015a87faa662755212566 + languageName: node + linkType: hard + "deep-is@npm:^0.1.3, deep-is@npm:~0.1.3": version: 0.1.4 resolution: "deep-is@npm:0.1.4" @@ -11862,6 +11938,13 @@ __metadata: languageName: node linkType: hard +"form-data-encoder@npm:^2.1.2": + version: 2.1.4 + resolution: "form-data-encoder@npm:2.1.4" + checksum: 4c06ae2b79ad693a59938dc49ebd020ecb58e4584860a90a230f80a68b026483b022ba5e4143cff06ae5ac8fd446a0b500fabc87bbac3d1f62f2757f8dabcaf7 + languageName: node + linkType: hard + "form-data@npm:^2.2.0": version: 2.5.1 resolution: "form-data@npm:2.5.1" @@ -12534,6 +12617,32 @@ __metadata: languageName: node linkType: hard +"got@npm:^12.1.0": + version: 12.6.1 + resolution: "got@npm:12.6.1" + dependencies: + "@sindresorhus/is": "npm:^5.2.0" + "@szmarczak/http-timer": "npm:^5.0.1" + cacheable-lookup: "npm:^7.0.0" + cacheable-request: "npm:^10.2.8" + decompress-response: "npm:^6.0.0" + form-data-encoder: "npm:^2.1.2" + get-stream: "npm:^6.0.1" + http2-wrapper: "npm:^2.1.10" + lowercase-keys: "npm:^3.0.0" + p-cancelable: "npm:^3.0.0" + responselike: "npm:^3.0.0" + checksum: 2fe97fcbd7a9ffc7c2d0ecf59aca0a0562e73a7749cadada9770eeb18efbdca3086262625fb65590594edc220a1eca58fab0d26b0c93c2f9a008234da71ca66b + languageName: node + linkType: hard + +"graceful-fs@npm:4.2.10": + version: 4.2.10 + resolution: "graceful-fs@npm:4.2.10" + checksum: 4223a833e38e1d0d2aea630c2433cfb94ddc07dfc11d511dbd6be1d16688c5be848acc31f9a5d0d0ddbfb56d2ee5a6ae0278aceeb0ca6a13f27e06b9956fb952 + languageName: node + linkType: hard + "graceful-fs@npm:^4.1.11, graceful-fs@npm:^4.1.2, graceful-fs@npm:^4.1.5, graceful-fs@npm:^4.1.6, graceful-fs@npm:^4.1.9, graceful-fs@npm:^4.2.0, graceful-fs@npm:^4.2.4, graceful-fs@npm:^4.2.6": version: 4.2.11 resolution: "graceful-fs@npm:4.2.11" @@ -13475,7 +13584,7 @@ __metadata: languageName: node linkType: hard -"ini@npm:^1.3.4, ini@npm:^1.3.5": +"ini@npm:^1.3.4, ini@npm:^1.3.5, ini@npm:~1.3.0": version: 1.3.8 resolution: "ini@npm:1.3.8" checksum: ec93838d2328b619532e4f1ff05df7909760b6f66d9c9e2ded11e5c1897d6f2f9980c54dd638f88654b00919ce31e827040631eab0a3969e4d1abefa0719516a @@ -14912,6 +15021,15 @@ __metadata: languageName: node linkType: hard +"latest-version@npm:^7.0.0": + version: 7.0.0 + resolution: "latest-version@npm:7.0.0" + dependencies: + package-json: "npm:^8.1.0" + checksum: 68045f5e419e005c12e595ae19687dd88317dd0108b83a8773197876622c7e9d164fe43aacca4f434b2cba105c92848b89277f658eabc5d50e81fb743bbcddb1 + languageName: node + linkType: hard + "lcid@npm:^1.0.0": version: 1.0.0 resolution: "lcid@npm:1.0.0" @@ -15948,6 +16066,13 @@ __metadata: languageName: node linkType: hard +"mimic-response@npm:^4.0.0": + version: 4.0.0 + resolution: "mimic-response@npm:4.0.0" + checksum: 761d788d2668ae9292c489605ffd4fad220f442fbae6832adce5ebad086d691e906a6d5240c290293c7a11e99fbdbbef04abbbed498bf8699a4ee0f31315e3fb + languageName: node + linkType: hard + "min-document@npm:^2.19.0": version: 2.19.0 resolution: "min-document@npm:2.19.0" @@ -16777,6 +16902,13 @@ __metadata: languageName: node linkType: hard +"normalize-url@npm:^8.0.0": + version: 8.0.0 + resolution: "normalize-url@npm:8.0.0" + checksum: 09582d56acd562d89849d9239852c2aff225c72be726556d6883ff36de50006803d32a023c10e917bcc1c55f73f3bb16434f67992fe9b61906a3db882192753c + languageName: node + linkType: hard + "npm-run-path@npm:^4.0.0, npm-run-path@npm:^4.0.1": version: 4.0.1 resolution: "npm-run-path@npm:4.0.1" @@ -17256,6 +17388,18 @@ __metadata: languageName: node linkType: hard +"package-json@npm:^8.1.0": + version: 8.1.1 + resolution: "package-json@npm:8.1.1" + dependencies: + got: "npm:^12.1.0" + registry-auth-token: "npm:^5.0.1" + registry-url: "npm:^6.0.0" + semver: "npm:^7.3.7" + checksum: 83b057878bca229033aefad4ef51569b484e63a65831ddf164dc31f0486817e17ffcb58c819c7af3ef3396042297096b3ffc04e107fd66f8f48756f6d2071c8f + languageName: node + linkType: hard + "packet-reader@npm:1.0.0": version: 1.0.0 resolution: "packet-reader@npm:1.0.0" @@ -18068,6 +18212,13 @@ __metadata: languageName: node linkType: hard +"proto-list@npm:~1.2.1": + version: 1.2.4 + resolution: "proto-list@npm:1.2.4" + checksum: b9179f99394ec8a68b8afc817690185f3b03933f7b46ce2e22c1930dc84b60d09f5ad222beab4e59e58c6c039c7f7fcf620397235ef441a356f31f9744010e12 + languageName: node + linkType: hard + "protocol-buffers-schema@npm:^3.3.1": version: 3.6.0 resolution: "protocol-buffers-schema@npm:3.6.0" @@ -18411,6 +18562,20 @@ __metadata: languageName: node linkType: hard +"rc@npm:1.2.8": + version: 1.2.8 + resolution: "rc@npm:1.2.8" + dependencies: + deep-extend: "npm:^0.6.0" + ini: "npm:~1.3.0" + minimist: "npm:^1.2.0" + strip-json-comments: "npm:~2.0.1" + bin: + rc: ./cli.js + checksum: 24a07653150f0d9ac7168e52943cc3cb4b7a22c0e43c7dff3219977c2fdca5a2760a304a029c20811a0e79d351f57d46c9bde216193a0f73978496afc2b85b15 + languageName: node + linkType: hard + "react-native-fs@npm:2.20.0": version: 2.20.0 resolution: "react-native-fs@npm:2.20.0" @@ -18658,6 +18823,24 @@ __metadata: languageName: node linkType: hard +"registry-auth-token@npm:^5.0.1": + version: 5.0.2 + resolution: "registry-auth-token@npm:5.0.2" + dependencies: + "@pnpm/npm-conf": "npm:^2.1.0" + checksum: 20fc2225681cc54ae7304b31ebad5a708063b1949593f02dfe5fb402bc1fc28890cecec6497ea396ba86d6cca8a8480715926dfef8cf1f2f11e6f6cc0a1b4bde + languageName: node + linkType: hard + +"registry-url@npm:^6.0.0": + version: 6.0.1 + resolution: "registry-url@npm:6.0.1" + dependencies: + rc: "npm:1.2.8" + checksum: 66e2221c8113fc35ee9d23fe58cb516fc8d556a189fb8d6f1011a02efccc846c4c9b5075b4027b99a5d5c9ad1345ac37f297bea3c0ca30d607ec8084bf561b90 + languageName: node + linkType: hard + "regjsgen@npm:^0.2.0": version: 0.2.0 resolution: "regjsgen@npm:0.2.0" @@ -18925,6 +19108,15 @@ __metadata: languageName: node linkType: hard +"responselike@npm:^3.0.0": + version: 3.0.0 + resolution: "responselike@npm:3.0.0" + dependencies: + lowercase-keys: "npm:^3.0.0" + checksum: 8af27153f7e47aa2c07a5f2d538cb1e5872995f0e9ff77def858ecce5c3fe677d42b824a62cde502e56d275ab832b0a8bd350d5cd6b467ac0425214ac12ae658 + languageName: node + linkType: hard + "restore-cursor@npm:^3.1.0": version: 3.1.0 resolution: "restore-cursor@npm:3.1.0" @@ -19273,7 +19465,7 @@ __metadata: languageName: node linkType: hard -"semver@npm:7.6.0, semver@npm:^7.3.4, semver@npm:^7.3.5, semver@npm:^7.5.2, semver@npm:^7.5.3, semver@npm:^7.5.4": +"semver@npm:7.6.0, semver@npm:^7.3.4, semver@npm:^7.3.5, semver@npm:^7.3.7, semver@npm:^7.5.2, semver@npm:^7.5.3, semver@npm:^7.5.4": version: 7.6.0 resolution: "semver@npm:7.6.0" dependencies: @@ -19947,9 +20139,9 @@ __metadata: languageName: node linkType: hard -"solhint@npm:^3.3.6": - version: 3.6.2 - resolution: "solhint@npm:3.6.2" +"solhint@npm:^4.1.1": + version: 4.1.1 + resolution: "solhint@npm:4.1.1" dependencies: "@solidity-parser/parser": "npm:^0.16.0" ajv: "npm:^6.12.6" @@ -19962,6 +20154,7 @@ __metadata: glob: "npm:^8.0.3" ignore: "npm:^5.2.4" js-yaml: "npm:^4.1.0" + latest-version: "npm:^7.0.0" lodash: "npm:^4.17.21" pluralize: "npm:^8.0.0" prettier: "npm:^2.8.3" @@ -19974,7 +20167,7 @@ __metadata: optional: true bin: solhint: solhint.js - checksum: db250dc141e92ca33a9adee11b01232dfa3883f053d781f30cd471c22af6d551e8b9ff839b7f1abbe9c0618204b0891b63fa3814ae049d824f98a4c5bb32b42b + checksum: b4bdb21bdc13f7ba3436d571a30cae6cb8dfb58ab1387df8bef25eeca25c8fbb3f625c49a5dddea41f8361aaeb4d8e2e9f986f580663ddd4574fd3d5de5f66c9 languageName: node linkType: hard @@ -20533,6 +20726,13 @@ __metadata: languageName: node linkType: hard +"strip-json-comments@npm:~2.0.1": + version: 2.0.1 + resolution: "strip-json-comments@npm:2.0.1" + checksum: b509231cbdee45064ff4f9fd73609e2bcc4e84a4d508e9dd0f31f70356473fde18abfb5838c17d56fb236f5a06b102ef115438de0600b749e818a35fbbc48c43 + languageName: node + linkType: hard + "supports-color@npm:8.1.1": version: 8.1.1 resolution: "supports-color@npm:8.1.1" From 659bca5b38568cbc4ec38ef13be38787e68f39ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Fri, 8 Mar 2024 16:24:23 -0300 Subject: [PATCH 6/9] chore: fix github action paths MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- .github/workflows/{ci.yml => ci-contracts.yml} | 6 ++++-- .github/workflows/ci-token-dist.yml | 2 +- .github/workflows/{e2e.yml => e2e-contracts.yml} | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) rename .github/workflows/{ci.yml => ci-contracts.yml} (86%) rename .github/workflows/{e2e.yml => e2e-contracts.yml} (95%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci-contracts.yml similarity index 86% rename from .github/workflows/ci.yml rename to .github/workflows/ci-contracts.yml index ba93fac60..388bb8521 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci-contracts.yml @@ -1,4 +1,4 @@ -name: CI +name: CI - packages/contracts env: CI: true @@ -23,7 +23,9 @@ jobs: - name: Set up environment uses: ./.github/actions/setup - name: Run tests - run: yarn test:coverage + run: | + pushd packages/contracts + yarn test:coverage - name: Upload coverage report uses: codecov/codecov-action@v3 with: diff --git a/.github/workflows/ci-token-dist.yml b/.github/workflows/ci-token-dist.yml index 7751a4c38..76922ff9d 100644 --- a/.github/workflows/ci-token-dist.yml +++ b/.github/workflows/ci-token-dist.yml @@ -1,4 +1,4 @@ -name: CI +name: CI - packages/token-distribution env: CI: true diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e-contracts.yml similarity index 95% rename from .github/workflows/e2e.yml rename to .github/workflows/e2e-contracts.yml index 74a9523b4..46a6387ca 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e-contracts.yml @@ -1,4 +1,4 @@ -name: E2E +name: E2E - packages/contracts env: CI: true @@ -41,4 +41,5 @@ jobs: sed -i'' -e 's/^\(.*dev.period.*\)/# \1/' docker-compose.yaml ./test-node.bash --init --batchposters 0 --redundantsequencers 0 --detach popd + pushd packages/contracts L1_NETWORK=localnitrol1 L2_NETWORK=localnitrol2 yarn test:e2e From d5506e3812138075e7b76dbd0b06c4a70b3b474f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Fri, 8 Mar 2024 16:51:59 -0300 Subject: [PATCH 7/9] fix: disable linting rule that was messing up e2e tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- packages/contracts/tasks/migrate/nitro.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/contracts/tasks/migrate/nitro.ts b/packages/contracts/tasks/migrate/nitro.ts index a399b5002..1539757b9 100644 --- a/packages/contracts/tasks/migrate/nitro.ts +++ b/packages/contracts/tasks/migrate/nitro.ts @@ -55,7 +55,8 @@ task('migrate:nitro:address-book', 'Write arbitrum addresses to address book') const deployment = JSON.parse(fs.readFileSync(taskArgs.deploymentFile, 'utf-8')) const addressBook = { - 1337: { + // eslint-disable-next-line @stylistic/quote-props + '1337': { L1GatewayRouter: { address: deployment.l2Network.tokenBridge.l1GatewayRouter, }, @@ -63,7 +64,8 @@ task('migrate:nitro:address-book', 'Write arbitrum addresses to address book') address: deployment.l2Network.ethBridge.inbox, }, }, - 412346: { + // eslint-disable-next-line @stylistic/quote-props + '412346': { L2GatewayRouter: { address: deployment.l2Network.tokenBridge.l2GatewayRouter, }, From d73e774e8e5585177df5b39cfb88035acdf15244 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Fri, 8 Mar 2024 17:16:18 -0300 Subject: [PATCH 8/9] fix(contracts): pin arbitrum sdk to version compatible with e2e nitro node MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- packages/contracts/package.json | 2 +- packages/contracts/tasks/migrate/nitro.ts | 6 ++---- yarn.lock | 4 ++-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/packages/contracts/package.json b/packages/contracts/package.json index 656b14121..a98022d22 100644 --- a/packages/contracts/package.json +++ b/packages/contracts/package.json @@ -17,7 +17,7 @@ "console-table-printer": "^2.11.1" }, "devDependencies": { - "@arbitrum/sdk": "^3.0.0", + "@arbitrum/sdk": "^3.1.13", "@defi-wonderland/smock": "^2.0.7", "@ethersproject/experimental": "^5.6.0", "@graphprotocol/common-ts": "^1.8.3", diff --git a/packages/contracts/tasks/migrate/nitro.ts b/packages/contracts/tasks/migrate/nitro.ts index 1539757b9..a399b5002 100644 --- a/packages/contracts/tasks/migrate/nitro.ts +++ b/packages/contracts/tasks/migrate/nitro.ts @@ -55,8 +55,7 @@ task('migrate:nitro:address-book', 'Write arbitrum addresses to address book') const deployment = JSON.parse(fs.readFileSync(taskArgs.deploymentFile, 'utf-8')) const addressBook = { - // eslint-disable-next-line @stylistic/quote-props - '1337': { + 1337: { L1GatewayRouter: { address: deployment.l2Network.tokenBridge.l1GatewayRouter, }, @@ -64,8 +63,7 @@ task('migrate:nitro:address-book', 'Write arbitrum addresses to address book') address: deployment.l2Network.ethBridge.inbox, }, }, - // eslint-disable-next-line @stylistic/quote-props - '412346': { + 412346: { L2GatewayRouter: { address: deployment.l2Network.tokenBridge.l2GatewayRouter, }, diff --git a/yarn.lock b/yarn.lock index 105d1827e..c83ba4c80 100644 --- a/yarn.lock +++ b/yarn.lock @@ -34,7 +34,7 @@ __metadata: languageName: node linkType: hard -"@arbitrum/sdk@npm:^3.0.0, @arbitrum/sdk@npm:^3.1.12": +"@arbitrum/sdk@npm:^3.1.12, @arbitrum/sdk@npm:^3.1.13": version: 3.3.0 resolution: "@arbitrum/sdk@npm:3.3.0" dependencies: @@ -2621,7 +2621,7 @@ __metadata: version: 0.0.0-use.local resolution: "@graphprotocol/contracts@workspace:packages/contracts" dependencies: - "@arbitrum/sdk": "npm:^3.0.0" + "@arbitrum/sdk": "npm:^3.1.13" "@defi-wonderland/smock": "npm:^2.0.7" "@ethersproject/experimental": "npm:^5.6.0" "@graphprotocol/common-ts": "npm:^1.8.3" From eae9315d61549c0f2a7f7f15cec2b24fc96b3848 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Fri, 8 Mar 2024 17:31:12 -0300 Subject: [PATCH 9/9] fix: pin arbitrum sdk version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- packages/contracts/package.json | 2 +- packages/sdk/package.json | 2 +- yarn.lock | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/contracts/package.json b/packages/contracts/package.json index a98022d22..4e95a8f3c 100644 --- a/packages/contracts/package.json +++ b/packages/contracts/package.json @@ -17,7 +17,7 @@ "console-table-printer": "^2.11.1" }, "devDependencies": { - "@arbitrum/sdk": "^3.1.13", + "@arbitrum/sdk": "~3.1.13", "@defi-wonderland/smock": "^2.0.7", "@ethersproject/experimental": "^5.6.0", "@graphprotocol/common-ts": "^1.8.3", diff --git a/packages/sdk/package.json b/packages/sdk/package.json index b71c98c1d..18497431e 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -18,7 +18,7 @@ "author": "tomas@edgeandnode.com", "license": "MIT", "dependencies": { - "@arbitrum/sdk": "^3.1.12", + "@arbitrum/sdk": "~3.1.13", "@ethersproject/experimental": "^5.7.0", "@graphprotocol/common-ts": "^2.0.7", "@graphprotocol/contracts": "workspace:^6.2.0", diff --git a/yarn.lock b/yarn.lock index c83ba4c80..da96ff202 100644 --- a/yarn.lock +++ b/yarn.lock @@ -34,16 +34,16 @@ __metadata: languageName: node linkType: hard -"@arbitrum/sdk@npm:^3.1.12, @arbitrum/sdk@npm:^3.1.13": - version: 3.3.0 - resolution: "@arbitrum/sdk@npm:3.3.0" +"@arbitrum/sdk@npm:~3.1.13": + version: 3.1.13 + resolution: "@arbitrum/sdk@npm:3.1.13" dependencies: "@ethersproject/address": "npm:^5.0.8" "@ethersproject/bignumber": "npm:^5.1.1" "@ethersproject/bytes": "npm:^5.0.8" async-mutex: "npm:^0.4.0" ethers: "npm:^5.1.0" - checksum: 4b5b7563a1a469c040d7be4dd8eecd210551fb47f68f41babd86c351d143234501682d8466d59b28289350b81fd76ad5dbb82bcf8582d74a99fa52ef7f25aab4 + checksum: d314665b9a7e18a9854071f40105053d0b267c74f3b09367a072778333255571523138702d5b2212a7d5b5b4eaf210afd5a6cb7582a4e00c77d3a5af76d4275b languageName: node linkType: hard @@ -2621,7 +2621,7 @@ __metadata: version: 0.0.0-use.local resolution: "@graphprotocol/contracts@workspace:packages/contracts" dependencies: - "@arbitrum/sdk": "npm:^3.1.13" + "@arbitrum/sdk": "npm:~3.1.13" "@defi-wonderland/smock": "npm:^2.0.7" "@ethersproject/experimental": "npm:^5.6.0" "@graphprotocol/common-ts": "npm:^1.8.3" @@ -2704,7 +2704,7 @@ __metadata: version: 0.0.0-use.local resolution: "@graphprotocol/sdk@workspace:packages/sdk" dependencies: - "@arbitrum/sdk": "npm:^3.1.12" + "@arbitrum/sdk": "npm:~3.1.13" "@ethersproject/experimental": "npm:^5.7.0" "@graphprotocol/common-ts": "npm:^2.0.7" "@graphprotocol/contracts": "workspace:^6.2.0"