Skip to content

Commit

Permalink
Fixes (opengsn#996)
Browse files Browse the repository at this point in the history
* Fix "BigNumber.toString does not accept any parameters" warning

* Bump TypeScript version to 5.2.2

* Bump denedencies, 'eslint' version, and run 'eslint --fix'

* Fix lint
  • Loading branch information
forshtat authored Sep 24, 2023
1 parent d88a341 commit 9e3aa12
Show file tree
Hide file tree
Showing 158 changed files with 2,742 additions and 2,457 deletions.
5 changes: 3 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module.exports = {
],
// This is needed to add configuration to rules with type information
parser: '@typescript-eslint/parser',
plugins: ["@typescript-eslint"],
parserOptions: {
// The 'tsconfig.packages.json' is needed to add not-compiled files to the project
project: ['./tsconfig.json', './tsconfig.packages.json']
Expand Down Expand Up @@ -52,15 +53,15 @@ module.exports = {
// otherwise it will raise an error in every JavaScript file
files: ['*.ts'],
rules: {
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/prefer-ts-expect-error': 'off',
// allow using '${val}' with numbers, bool and null types
'@typescript-eslint/restrict-template-expressions': [
'error',
{
allowNumber: true,
allowBoolean: true,
allowNullish: true,
allowNullable: true
allowNullish: true
}
]
}
Expand Down
22 changes: 12 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,19 @@
"@types/chai": "^4.2.12",
"@types/mocha": "^8.2.0",
"@types/web3": "1.0.20",
"@typescript-eslint/eslint-plugin": "^4.8.1",
"@typescript-eslint/parser": "^4.8.1",
"@typescript-eslint/eslint-plugin": "^6.7.2",
"@typescript-eslint/typescript-estree": "^6.7.2",
"@typescript-eslint/parser": "^6.7.2",
"bn.js": "^5.2.0",
"depcheck": "^1.4.3",
"eslint": "^7.13.0",
"eslint-config-standard": "14.1.1",
"eslint-config-standard-with-typescript": "18.0.2",
"eslint-plugin-import": "2.21.2",
"eslint-plugin-node": "11.1.0",
"eslint-plugin-promise": "4.2.1",
"eslint-plugin-standard": "4.0.1",
"eslint": "^8.50.0",
"eslint-config-standard": "^17.1.0",
"eslint-config-standard-with-typescript": "^39.1.0",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-n": "^16.1.0",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-standard": "^5.0.0",
"ethereumjs-abi": "^0.6.8",
"ethers": "^6.6.5",
"ethers-v6": "npm:ethers@^6.6.5",
Expand All @@ -101,7 +103,7 @@
"ts-node": "8.6.2",
"ts-loader": "^9.4.4",
"typechain": "^8.3.1",
"typescript": "^4.7.4",
"typescript": "^5.2.2",
"verdaccio": "^5.13.3",
"web3": "^1.7.3",
"web3-core": "^1.7.3",
Expand Down
26 changes: 14 additions & 12 deletions packages/cli/src/CommandsLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ import HDWalletProvider from '@truffle/hdwallet-provider'
import Web3 from 'web3'
import ow from 'ow'
import { BigNumber } from '@ethersproject/bignumber'
import { Contract } from 'web3-eth-contract'
import { Transaction, TypedTransaction } from '@ethereumjs/tx'
import { type Contract } from 'web3-eth-contract'
import { Transaction, type TypedTransaction } from '@ethereumjs/tx'
import { Web3Provider } from '@ethersproject/providers'
import { fromWei, toHex } from 'web3-utils'

import {
Address,
type Address,
ContractInteractor,
GSNContractsDeployment,
type GSNContractsDeployment,
HttpClient,
HttpWrapper,
IntString,
LoggerInterface,
PenalizerConfiguration,
RelayHubConfiguration,
type IntString,
type LoggerInterface,
type PenalizerConfiguration,
type RelayHubConfiguration,
constants,
defaultEnvironment,
ether,
Expand All @@ -38,8 +38,8 @@ import Paymaster from './compiled/TestPaymasterEverythingAccepted.json'
import Forwarder from './compiled/Forwarder.json'
import TestWrappedNativeToken from './compiled/TestWrappedNativeToken.json'

import { KeyManager } from '@opengsn/relay/dist/KeyManager'
import { ServerConfigParams } from '@opengsn/relay/dist/ServerConfigParams'
import { type KeyManager } from '@opengsn/relay/dist/KeyManager'
import { type ServerConfigParams } from '@opengsn/relay/dist/ServerConfigParams'
import { defaultGsnConfig } from '@opengsn/provider'
import { Forwarder__factory } from '@opengsn/contracts/types/ethers-contracts'

Expand Down Expand Up @@ -288,7 +288,7 @@ export class CommandsLogic {
const relayHubAddress = response.relayHubAddress
await this.contractInteractor._resolveDeploymentFromRelayHub(relayHubAddress)

const relayHub = await this.contractInteractor.relayHubInstance
const relayHub = this.contractInteractor.relayHubInstance
const stakeManagerAddress = await relayHub.getStakeManager()
const stakeManager = await this.contractInteractor._createStakeManager(stakeManagerAddress)
const { stake, unstakeDelay, owner, token } = (await stakeManager.getStakeInfo(relayAddress))[0]
Expand Down Expand Up @@ -368,7 +368,9 @@ export class CommandsLogic {
}
const stakeValue = stakeParam.sub(toBN(stake.toString()))
this.logger.info(`Staking relayer ${formatToken(stakeValue)}` +
stake.toString() === '0' ? '' : ` (already has ${formatToken(stake)})`)
stake.toString() === '0'
? ''
: ` (already has ${formatToken(stake)})`)

const tokenBalance = await stakingTokenContract.balanceOf(options.from)
if (tokenBalance.lt(stakeValue.toString()) && options.wrap) {
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/ForwarderUtil.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Contract, CallOverrides } from '@ethersproject/contracts'
import { Contract, type CallOverrides } from '@ethersproject/contracts'
import { Web3Provider } from '@ethersproject/providers'

import { GsnDomainSeparatorType, GsnRequestType, LoggerInterface } from '@opengsn/common'
import { IForwarder } from '@opengsn/contracts/types/ethers-contracts'
import { GsnDomainSeparatorType, GsnRequestType, type LoggerInterface } from '@opengsn/common'
import { type IForwarder } from '@opengsn/contracts/types/ethers-contracts'

interface TruffleContract {
contract: any
Expand Down
18 changes: 9 additions & 9 deletions packages/cli/src/GsnTestEnvironment.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import net from 'net'
import {
Address,
type Address,
ContractInteractor,
GSNContractsDeployment,
LoggerInterface,
type GSNContractsDeployment,
type LoggerInterface,
RelayCallGasLimitCalculationHelper,
constants,
defaultEnvironment,
Expand All @@ -13,7 +13,7 @@ import {

import { StaticJsonRpcProvider } from '@ethersproject/providers'

import { CommandsLogic, RegisterOptions } from './CommandsLogic'
import { CommandsLogic, type RegisterOptions } from './CommandsLogic'
import { KeyManager } from '@opengsn/relay/dist/KeyManager'

import { getNetworkUrl, loadDeployment, supportedNetworks } from './utils'
Expand All @@ -26,16 +26,16 @@ import Web3 from 'web3'

import {
configureServer,
ServerConfigParams,
type ServerConfigParams,
serverDefaultConfiguration,
ServerDependencies
type ServerDependencies
} from '@opengsn/relay/dist/ServerConfigParams'
import { createServerLogger } from '@opengsn/logger/dist/ServerWinstonLogger'
import { TransactionManager } from '@opengsn/relay/dist/TransactionManager'
import { GasPriceFetcher } from '@opengsn/relay/dist/GasPriceFetcher'

import { GSNConfig } from '@opengsn/provider/dist/GSNConfigurator'
import { GSNUnresolvedConstructorInput } from '@opengsn/provider/dist/RelayClient'
import { type GSNConfig } from '@opengsn/provider/dist/GSNConfigurator'
import { type GSNUnresolvedConstructorInput } from '@opengsn/provider/dist/RelayClient'
import { ReputationStoreManager } from '@opengsn/relay/dist/ReputationStoreManager'
import { ReputationManager } from '@opengsn/relay/dist/ReputationManager'

Expand Down Expand Up @@ -153,7 +153,7 @@ class GsnTestEnvironmentClass {
sleepCount: 5,
stake: '1',
funds: ether('5'),
relayUrl: relayUrl,
relayUrl,
gasPrice: 1e9.toString(),
unstakeDelay: '15000'
}
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/gsn-deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
} from '../utils'
import { toHex, toWei } from 'web3-utils'
import { createCommandsLogger } from '@opengsn/logger/dist/CommandsWinstonLogger'
import { Environment, environments, EnvironmentsKeys } from '@opengsn/common'
import { type Environment, environments, EnvironmentsKeys } from '@opengsn/common'

gsnCommander(['n', 'f', 'm', 'g', 'l'])
.option('-w, --workdir <directory>', 'relative work directory (defaults to build/gsn/)', 'build/gsn')
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/gsn-relayer-register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { BigNumber } from '@ethersproject/bignumber'

import { ether } from '@opengsn/common'

import { CommandsLogic, RegisterOptions } from '../CommandsLogic'
import { CommandsLogic, type RegisterOptions } from '../CommandsLogic'
import { getNetworkUrl, gsnCommander, getMnemonic } from '../utils'
import { toWei } from 'web3-utils'
import { createCommandsLogger } from '@opengsn/logger/dist/CommandsWinstonLogger'
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/gsn-relayer-withdraw.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BigNumber } from '@ethersproject/bignumber'

import { CommandsLogic, WithdrawOptions } from '../CommandsLogic'
import { CommandsLogic, type WithdrawOptions } from '../CommandsLogic'
import { gsnCommander, getKeystorePath, getServerConfig } from '../utils'
import { createCommandsLogger } from '@opengsn/logger/dist/CommandsWinstonLogger'
import { KeyManager } from '@opengsn/relay/dist/KeyManager'
Expand Down
10 changes: 5 additions & 5 deletions packages/cli/src/commands/gsn-send-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ import * as bip39 from 'ethereum-cryptography/bip39'
import Web3 from 'web3'
import commander from 'commander'
import fs from 'fs'
import { PrefixedHexString } from 'ethereumjs-util'
import { type PrefixedHexString } from 'ethereumjs-util'
import { StaticJsonRpcProvider } from '@ethersproject/providers'
import { hdkey as EthereumHDKey } from 'ethereumjs-wallet'
import { toHex, toWei } from 'web3-utils'
import { HttpProvider } from 'web3-core'
import { type HttpProvider } from 'web3-core'

import {
Address,
LoggerInterface
type Address,
type LoggerInterface
} from '@opengsn/common'

import { GSNConfig, GSNDependencies, GSNUnresolvedConstructorInput, RelayProvider } from '@opengsn/provider'
import { type GSNConfig, type GSNDependencies, type GSNUnresolvedConstructorInput, RelayProvider } from '@opengsn/provider'
import { createCommandsLogger } from '@opengsn/logger/dist/CommandsWinstonLogger'

import { getMnemonic, getNetworkUrl, gsnCommander } from '../utils'
Expand Down
8 changes: 4 additions & 4 deletions packages/cli/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// TODO: allow reading network URLs from 'truffle-config.js'
import commander, { CommanderStatic } from 'commander'
import commander, { type CommanderStatic } from 'commander'
import fs from 'fs'
import path from 'path'

import { Address, RelayHubConfiguration, GSNContractsDeployment, LoggerInterface } from '@opengsn/common'
import { type Address, type RelayHubConfiguration, type GSNContractsDeployment, type LoggerInterface } from '@opengsn/common'

import { ServerConfigParams } from '@opengsn/relay/dist/ServerConfigParams'
import { type ServerConfigParams } from '@opengsn/relay/dist/ServerConfigParams'

const cliInfuraId = '$INFURA_ID'
export const networks = new Map<string, string>([
Expand Down Expand Up @@ -35,7 +35,7 @@ export function supportedNetworks (): string[] {
return Array.from(networks.keys())
}

export function getNetworkUrl (network: string, env: { [key: string]: string | undefined } = process.env): string {
export function getNetworkUrl (network: string, env: Record<string, string | undefined> = process.env): string {
const net = networks.get(network)
if (net == null) {
const match = network.match(/^(https?:\/\/.*)/) ?? []
Expand Down
6 changes: 3 additions & 3 deletions packages/common/src/AmountRequired.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { BigNumber } from '@ethersproject/bignumber'

import { ERC20TokenMetadata } from './ContractInteractor'
import { LoggerInterface } from './LoggerInterface'
import { type ERC20TokenMetadata } from './ContractInteractor'
import { type LoggerInterface } from './LoggerInterface'
import { boolString, formatTokenAmount, isSameAddress } from './Utils'
import { constants } from './Constants'
import { Address } from './types/Aliases'
import { type Address } from './types/Aliases'

const ether: ERC20TokenMetadata = {
tokenAddress: constants.ZERO_ADDRESS,
Expand Down
12 changes: 6 additions & 6 deletions packages/common/src/ConfigResponse.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {
Address,
IntString,
NpmLogLevel
type Address,
type IntString,
type NpmLogLevel
} from './types/Aliases'
import { PaymasterType } from './environments/OfficialPaymasterDeployments'
import { Environment } from './environments/Environments'
import { EIP712Domain } from './EIP712/TypedRequestData'
import { type PaymasterType } from './environments/OfficialPaymasterDeployments'
import { type Environment } from './environments/Environments'
import { type EIP712Domain } from './EIP712/TypedRequestData'

export interface LoggerConfiguration {
logLevel: NpmLogLevel
Expand Down
Loading

0 comments on commit 9e3aa12

Please sign in to comment.