Skip to content

Commit

Permalink
fix: lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
skimaharvey committed Oct 4, 2023
1 parent a492824 commit 78059d9
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 34 deletions.
16 changes: 4 additions & 12 deletions tests/LSP17Extentions/Extension4337/4337.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
Expand All @@ -36,6 +34,7 @@ describe('4337', function () {
before('before', async function () {
const provider = ethers.provider;
deployer = provider.getSigner();
const deployerAddress = await deployer.getAddress();

[
bundler,
Expand All @@ -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);

Expand All @@ -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 =
Expand Down
2 changes: 1 addition & 1 deletion tests/LSP17Extentions/helpers/Create2Factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
17 changes: 8 additions & 9 deletions tests/LSP17Extentions/helpers/UserOp.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
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';
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) {
Expand Down Expand Up @@ -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
Expand All @@ -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);
}
}
Expand Down Expand Up @@ -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,
);
}
Expand All @@ -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,
Expand Down
16 changes: 8 additions & 8 deletions tests/LSP17Extentions/helpers/solidityTypes.ts
Original file line number Diff line number Diff line change
@@ -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;
9 changes: 5 additions & 4 deletions tests/LSP17Extentions/helpers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 78059d9

Please sign in to comment.