From 78059d9f2d4626836cedbccf07fa86953cebd7a6 Mon Sep 17 00:00:00 2001 From: maxvia87 Date: Wed, 4 Oct 2023 16:08:36 +0200 Subject: [PATCH] fix: lint issues --- .../LSP17Extentions/Extension4337/4337.test.ts | 16 ++++------------ tests/LSP17Extentions/helpers/Create2Factory.ts | 2 +- tests/LSP17Extentions/helpers/UserOp.ts | 17 ++++++++--------- tests/LSP17Extentions/helpers/solidityTypes.ts | 16 ++++++++-------- tests/LSP17Extentions/helpers/utils.ts | 9 +++++---- 5 files changed, 26 insertions(+), 34 deletions(-) diff --git a/tests/LSP17Extentions/Extension4337/4337.test.ts b/tests/LSP17Extentions/Extension4337/4337.test.ts index 900342491..9097ba32b 100644 --- a/tests/LSP17Extentions/Extension4337/4337.test.ts +++ b/tests/LSP17Extentions/Extension4337/4337.test.ts @@ -6,7 +6,6 @@ import { EntryPoint__factory, EntryPoint } from '@account-abstraction/contracts' import { parseEther } from 'ethers/lib/utils'; import { expect } from 'chai'; import { - Extension4337, Extension4337__factory, LSP6KeyManager, LSP6KeyManager__factory, @@ -22,7 +21,6 @@ describe('4337', function () { let bundler: SignerWithAddress; let deployer: Signer; let universalProfile: UniversalProfile; - let universalProfileWithExtension: Extension4337; let universalProfileAddress: string; let keyManager: LSP6KeyManager; let entryPoint: EntryPoint; @@ -36,6 +34,7 @@ describe('4337', function () { before('before', async function () { const provider = ethers.provider; deployer = provider.getSigner(); + const deployerAddress = await deployer.getAddress(); [ bundler, @@ -53,16 +52,13 @@ describe('4337', function () { // transfer ownership to keyManager await universalProfile.transferOwnership(keyManager.address); + const dataKey = - ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + - (await deployer.getAddress()).slice(2); + ERC725YDataKeys.LSP6['AddressPermissions:Permissions'] + deployerAddress.slice(2); await universalProfile.setData(dataKey, ALL_PERMISSIONS); - const acceptOwnershipBytes = universalProfile.interface.encodeFunctionData( - 'acceptOwnership', - [], - ); + const acceptOwnershipBytes = universalProfile.interface.encodeFunctionData('acceptOwnership'); await keyManager.execute(acceptOwnershipBytes); expect(await universalProfile.owner()).to.eq(keyManager.address); @@ -85,10 +81,6 @@ describe('4337', function () { '00000000000000000000000000000000'; await universalProfile.setData(extensionDataKey, extension4337.address); - universalProfileWithExtension = Extension4337__factory.connect( - universalProfile.address, - deployer, - ); // give permissions to controllers const dataKeyWithPermission4337 = diff --git a/tests/LSP17Extentions/helpers/Create2Factory.ts b/tests/LSP17Extentions/helpers/Create2Factory.ts index fa1bd5e1e..b740d2042 100644 --- a/tests/LSP17Extentions/helpers/Create2Factory.ts +++ b/tests/LSP17Extentions/helpers/Create2Factory.ts @@ -39,7 +39,7 @@ export class Create2Factory { await this.deployFactory(); if (typeof initCode !== 'string') { // eslint-disable-next-line @typescript-eslint/no-base-to-string - initCode = (initCode as TransactionRequest).data!.toString(); + initCode = (initCode as TransactionRequest).data.toString(); } const addr = Create2Factory.getDeployedAddress(initCode, salt); diff --git a/tests/LSP17Extentions/helpers/UserOp.ts b/tests/LSP17Extentions/helpers/UserOp.ts index fac137c9a..fcbd6af90 100644 --- a/tests/LSP17Extentions/helpers/UserOp.ts +++ b/tests/LSP17Extentions/helpers/UserOp.ts @@ -1,5 +1,5 @@ import { arrayify, defaultAbiCoder, hexDataSlice, keccak256 } from 'ethers/lib/utils'; -import { BigNumber, Contract, Signer, Wallet } from 'ethers'; +import { BigNumber, Wallet } from 'ethers'; import { AddressZero, callDataCost, rethrow } from './utils'; import { ecsign, toRpcSig, keccak256 as keccak256_buffer } from 'ethereumjs-util'; import { UserOperation } from './UserOperation'; @@ -7,7 +7,6 @@ import { Create2Factory } from './Create2Factory'; import { EntryPoint } from '@account-abstraction/contracts'; import { ethers } from 'ethers'; import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'; -import { UniversalProfile } from '../../../types'; export function packUserOp(op: UserOperation, forSignature = true): string { if (forSignature) { @@ -181,8 +180,8 @@ export async function fillUserOp( const op1 = { ...op }; const provider = entryPoint?.provider; if (op.initCode != null) { - const initAddr = hexDataSlice(op1.initCode!, 0, 20); - const initCallData = hexDataSlice(op1.initCode!, 20); + const initAddr = hexDataSlice(op1.initCode, 0, 20); + const initCallData = hexDataSlice(op1.initCode, 20); if (op1.nonce == null) op1.nonce = 0; if (op1.sender == null) { // hack: if the init contract is our known deployer, then we know what the address would be, without a view call @@ -193,8 +192,8 @@ export async function fillUserOp( } else { // console.log('\t== not our deployer. our=', Create2Factory.contractAddress, 'got', initAddr) if (provider == null) throw new Error('no entrypoint/provider'); - op1.sender = await entryPoint!.callStatic - .getSenderAddress(op1.initCode!) + op1.sender = await entryPoint.callStatic + .getSenderAddress(op1.initCode) .catch((e) => e.errorArgs.sender); } } @@ -236,7 +235,7 @@ export async function fillUserOp( if (op1.maxFeePerGas == null) { if (provider == null) throw new Error('must have entryPoint to autofill maxFeePerGas'); const block = await provider.getBlock('latest'); - op1.maxFeePerGas = block.baseFeePerGas!.add( + op1.maxFeePerGas = block.baseFeePerGas.add( op1.maxPriorityFeePerGas ?? DefaultsForUserOp.maxPriorityFeePerGas, ); } @@ -261,8 +260,8 @@ export async function fillAndSign( const provider = entryPoint?.provider; const op2 = await fillUserOp(op, signer, entryPoint); - const chainId = await provider!.getNetwork().then((net) => net.chainId); - const message = arrayify(getUserOpHash(op2, entryPoint!.address, chainId)); + const chainId = await provider.getNetwork().then((net) => net.chainId); + const message = arrayify(getUserOpHash(op2, entryPoint.address, chainId)); return { ...op2, diff --git a/tests/LSP17Extentions/helpers/solidityTypes.ts b/tests/LSP17Extentions/helpers/solidityTypes.ts index 5026ef9e3..5663a0166 100644 --- a/tests/LSP17Extentions/helpers/solidityTypes.ts +++ b/tests/LSP17Extentions/helpers/solidityTypes.ts @@ -1,10 +1,10 @@ // define the same export types as used by export typechain/ethers -import { BigNumberish } from 'ethers' -import { BytesLike } from '@ethersproject/bytes' +import { BigNumberish } from 'ethers'; +import { BytesLike } from '@ethersproject/bytes'; -export type address = string -export type uint256 = BigNumberish -export type uint = BigNumberish -export type uint48 = BigNumberish -export type bytes = BytesLike -export type bytes32 = BytesLike +export type address = string; +export type uint256 = BigNumberish; +export type uint = BigNumberish; +export type uint48 = BigNumberish; +export type bytes = BytesLike; +export type bytes32 = BytesLike; diff --git a/tests/LSP17Extentions/helpers/utils.ts b/tests/LSP17Extentions/helpers/utils.ts index af0e1a4b7..c6ec32f27 100644 --- a/tests/LSP17Extentions/helpers/utils.ts +++ b/tests/LSP17Extentions/helpers/utils.ts @@ -49,17 +49,18 @@ const panicCodes: { [key: number]: string } = { // - attempt to parse revert data (needed for geth) // use with ".catch(rethrow())", so that current source file/line is meaningful. export function rethrow(): (e: Error) => void { - const callerStack = new Error() - .stack!.replace(/Error.*\n.*at.*\n/, '') + const callerStack = new Error().stack + .replace(/Error.*\n.*at.*\n/, '') .replace(/.*at.* \(internal[\s\S]*/, ''); + // eslint-disable-next-line if (arguments[0] != null) { throw new Error('must use .catch(rethrow()), and NOT .catch(rethrow)'); } return function (e: Error) { - const solstack = e.stack!.match(/((?:.* at .*\.sol.*\n)+)/); + const solstack = e.stack.match(/((?:.* at .*\.sol.*\n)+)/); const stack = (solstack != null ? solstack[1] : '') + callerStack; - // const regex = new RegExp('error=.*"data":"(.*?)"').compile() + const found = /error=.*?"data":"(.*?)"/.exec(e.message); let message: string; if (found != null) {