Skip to content

Commit af53bdf

Browse files
authoredAug 19, 2024··
Update Package Dependencies (#810)
This PR updates package dependencies and solves some lints that (may) have come up from the newer packages.
1 parent 9ec11a1 commit af53bdf

14 files changed

+1940
-1987
lines changed
 

‎.eslintrc.js

-18
This file was deleted.

‎.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: safe-smart-account
22
on: [push, pull_request]
33
env:
4-
NODE_VERSION: 18.17.1
4+
NODE_VERSION: 20.16.0
55

66
jobs:
77
lint-solidity:

‎contracts/test/ERC20Token.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ contract ERC20Token is ERC20 {
1111
/**
1212
* @dev Constructor that sets the name and symbol of the token and mints an initial supply to the contract deployer.
1313
*/
14-
constructor() public ERC20("TestToken", "TT") {
14+
constructor() ERC20("TestToken", "TT") {
1515
_mint(msg.sender, 1000000000000000);
1616
}
1717
}

‎eslint.config.mjs

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import eslint from "@eslint/js";
2+
import tseslint from "typescript-eslint";
3+
import prettier from "eslint-plugin-prettier/recommended";
4+
import noOnlyTests from "eslint-plugin-no-only-tests";
5+
6+
export default [
7+
eslint.configs.recommended,
8+
...tseslint.configs.recommended,
9+
{
10+
rules: {
11+
"@typescript-eslint/no-explicit-any": "warn",
12+
"@typescript-eslint/no-unused-expressions": "off",
13+
"@typescript-eslint/no-unused-vars": ["error", { ignoreRestSiblings: true }],
14+
},
15+
plugins: {
16+
noOnlyTests,
17+
},
18+
},
19+
prettier,
20+
];

‎package-lock.json

+1,866-1,922
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+18-17
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
"build": "hardhat compile",
1818
"build:ts": "rimraf dist && tsc -p tsconfig.prod.json",
1919
"build:ts:dev": "rimraf dist && tsc -p tsconfig.json",
20-
"test": "hardhat test && npm run test:SafeToL2Setup:L1",
20+
"test": "hardhat test && npm run test:L1",
2121
"test:parallel": "hardhat test --parallel",
22-
"test:SafeToL2Setup:L1": "HARDHAT_CHAIN_ID=1 hardhat test --grep \"SafeToL2Setup\"",
22+
"test:L1": "HARDHAT_CHAIN_ID=1 hardhat test --grep '@L1'",
2323
"coverage": "hardhat coverage",
2424
"codesize": "hardhat codesize",
2525
"benchmark": "npm run test benchmark/*.ts",
@@ -52,31 +52,32 @@
5252
"url": "https://github.com/safe-global/safe-smart-account/issues"
5353
},
5454
"devDependencies": {
55+
"@eslint/js": "^9.9.0",
5556
"@nomicfoundation/hardhat-toolbox": "^5.0.0",
5657
"@openzeppelin/contracts": "^3.4.0",
5758
"@safe-global/mock-contract": "^4.1.0",
58-
"@safe-global/safe-singleton-factory": "^1.0.24",
59-
"@types/chai": "^4.3.14",
60-
"@types/mocha": "^10.0.6",
61-
"@types/node": "^20.12.7",
62-
"@types/yargs": "^17.0.32",
63-
"@typescript-eslint/eslint-plugin": "^7.8.0",
64-
"@typescript-eslint/parser": "^7.8.0",
65-
"debug": "^4.3.4",
59+
"@safe-global/safe-singleton-factory": "^1.0.31",
60+
"@types/chai": "^4.3.17",
61+
"@types/mocha": "^10.0.7",
62+
"@types/node": "^20.14.15",
63+
"@types/yargs": "^17.0.33",
64+
"debug": "^4.3.6",
6665
"dotenv": "^16.4.5",
67-
"eslint": "^8.57.0",
66+
"eslint": "^9.9.0",
6867
"eslint-config-prettier": "^9.1.0",
6968
"eslint-plugin-no-only-tests": "^3.1.0",
70-
"eslint-plugin-prettier": "^5.1.3",
71-
"hardhat": "^2.22.6",
69+
"eslint-plugin-prettier": "^5.2.1",
70+
"hardhat": "^2.22.8",
7271
"hardhat-deploy": "^0.12.4",
73-
"husky": "^9.0.11",
74-
"prettier": "^3.2.5",
72+
"husky": "^9.1.4",
73+
"prettier": "^3.3.3",
7574
"prettier-plugin-solidity": "^1.3.1",
75+
"rimraf": "^6.0.1",
7676
"solc": "0.7.6",
77-
"solhint": "^4.5.4",
77+
"solhint": "^5.0.3",
7878
"ts-node": "^10.9.2",
79-
"typescript": "^5.4.5",
79+
"typescript": "^5.5.4",
80+
"typescript-eslint": "^8.1.0",
8081
"yargs": "^17.7.2"
8182
}
8283
}

‎src/utils/execution.ts

+18-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Signer, BigNumberish, BaseContract, ethers } from "ethers";
22
import { AddressZero } from "@ethersproject/constants";
33
import { Safe } from "../../typechain-types";
4+
import { PayableOverrides } from "../../typechain-types/common";
45

56
export const EIP_DOMAIN = {
67
EIP712Domain: [
@@ -175,15 +176,27 @@ export const buildSignatureBytes = (signatures: SafeSignature[]): string => {
175176
return signatureBytes + dynamicBytes;
176177
};
177178

178-
export const logGas = async (message: string, tx: Promise<any>, skip?: boolean): Promise<any> => {
179+
export const logGas = async (
180+
message: string,
181+
tx: Promise<ethers.TransactionResponse>,
182+
skip?: boolean,
183+
): Promise<ethers.TransactionResponse> => {
179184
return tx.then(async (result) => {
180185
const receipt = await result.wait();
186+
if (receipt === null) {
187+
throw new Error("transaction not mined");
188+
}
181189
if (!skip) console.log(" Used", receipt.gasUsed, `gas for >${message}<`);
182190
return result;
183191
});
184192
};
185193

186-
export const executeTx = async (safe: Safe, safeTx: SafeTransaction, signatures: SafeSignature[], overrides?: any): Promise<any> => {
194+
export const executeTx = async (
195+
safe: Safe,
196+
safeTx: SafeTransaction,
197+
signatures: SafeSignature[],
198+
overrides?: PayableOverrides,
199+
): Promise<ethers.ContractTransactionResponse> => {
187200
const signatureBytes = buildSignatureBytes(signatures);
188201
return safe.execTransaction(
189202
safeTx.to,
@@ -203,7 +216,7 @@ export const executeTx = async (safe: Safe, safeTx: SafeTransaction, signatures:
203216
export const buildContractCall = async (
204217
contract: BaseContract,
205218
method: string,
206-
params: any[],
219+
params: unknown[],
207220
nonce: BigNumberish,
208221
delegateCall?: boolean,
209222
overrides?: Partial<SafeTransaction>,
@@ -224,7 +237,7 @@ export const buildContractCall = async (
224237
);
225238
};
226239

227-
export const executeTxWithSigners = async (safe: Safe, tx: SafeTransaction, signers: Signer[], overrides?: any) => {
240+
export const executeTxWithSigners = async (safe: Safe, tx: SafeTransaction, signers: Signer[], overrides?: PayableOverrides) => {
228241
const safeAddress = await safe.getAddress();
229242
const sigs = await Promise.all(signers.map((signer) => safeSignTypedData(signer, safeAddress, tx)));
230243
return executeTx(safe, tx, sigs, overrides);
@@ -234,7 +247,7 @@ export const executeContractCallWithSigners = async (
234247
safe: Safe,
235248
contract: BaseContract,
236249
method: string,
237-
params: any[],
250+
params: unknown[],
238251
signers: Signer[],
239252
delegateCall?: boolean,
240253
overrides?: Partial<SafeTransaction>,

‎src/utils/solc.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
import solc from "solc";
22

3-
const solcCache: Record<string, any> = {};
3+
export interface Solc {
4+
compile(input: string): string;
5+
}
46

5-
export const loadSolc = async (version: string): Promise<any> => {
7+
const solcCache: Record<string, Solc> = {};
8+
9+
export const loadSolc = async (version: string): Promise<Solc> => {
610
return await new Promise((resolve, reject) => {
711
if (solcCache[version] !== undefined) resolve(solcCache[version]);
812
else
9-
solc.loadRemoteVersion(`v${version}`, (error: any, soljson: any) => {
13+
solc.loadRemoteVersion(`v${version}`, (error: Error, soljson: Solc) => {
1014
solcCache[version] = soljson;
1115
return error ? reject(error) : resolve(soljson);
1216
});

‎test/core/Safe.Execution.spec.ts

+5-15
Original file line numberDiff line numberDiff line change
@@ -205,13 +205,8 @@ describe("Safe", () => {
205205
const userBalance = await hre.ethers.provider.getBalance(user2.address);
206206
expect(await hre.ethers.provider.getBalance(safeAddress)).to.be.eq(ethers.parseEther("1"));
207207

208-
let executedTx: any;
209-
await expect(
210-
executeTx(safe, tx, [await safeApproveHash(user1, safe, tx, true)]).then((tx) => {
211-
executedTx = tx;
212-
return tx;
213-
}),
214-
).to.emit(safe, "ExecutionSuccess");
208+
const executedTx = await executeTx(safe, tx, [await safeApproveHash(user1, safe, tx, true)]);
209+
await expect(executedTx).to.emit(safe, "ExecutionSuccess");
215210

216211
const receipt = await hre.ethers.provider.getTransactionReceipt(executedTx!.hash);
217212
const receiptLogs = receipt?.logs ?? [];
@@ -249,13 +244,8 @@ describe("Safe", () => {
249244
const userBalance = await hre.ethers.provider.getBalance(user2.address);
250245
await expect(await hre.ethers.provider.getBalance(safeAddress)).to.eq(ethers.parseEther("1"));
251246

252-
let executedTx: any;
253-
await expect(
254-
executeTx(safe, tx, [await safeApproveHash(user1, safe, tx, true)]).then((tx) => {
255-
executedTx = tx;
256-
return tx;
257-
}),
258-
).to.emit(safe, "ExecutionFailure");
247+
const executedTx = await executeTx(safe, tx, [await safeApproveHash(user1, safe, tx, true)]);
248+
await expect(executedTx).to.emit(safe, "ExecutionFailure");
259249
const receipt = await hre.ethers.provider.getTransactionReceipt(executedTx!.hash);
260250
const receiptLogs = receipt?.logs ?? [];
261251
const logIndex = receiptLogs.length - 1;
@@ -345,7 +335,7 @@ describe("Safe", () => {
345335
for (const log of receiptLogs) {
346336
try {
347337
parsedLogs.push(nativeTokenReceiver.interface.decodeEventLog("BreadReceived", log.data, log.topics));
348-
} catch (e) {
338+
} catch {
349339
continue;
350340
}
351341
}

‎test/handlers/CompatibilityFallbackHandler.spec.ts

-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ describe("CompatibilityFallbackHandler", () => {
172172
});
173173

174174
describe("simulate", () => {
175-
// eslint-disable-next-line @typescript-eslint/no-empty-function
176175
it.skip("can be called for any Safe", async () => {});
177176

178177
it("should revert changes", async () => {

‎test/libraries/SafeToL2Setup.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ describe("SafeToL2Setup", () => {
217217
}
218218
});
219219

220-
it("should be a noop when the chain id is 1", async () => {
220+
it("should be a noop when the chain id is 1 [@L1]", async () => {
221221
const {
222222
safeSingleton,
223223
safeL2,

‎test/migration/UpgradeFromSafe111.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe("Upgrade from Safe 1.1.1", () => {
2222
const factory = await getFactory();
2323
const saltNonce = 42;
2424
const proxyAddress = await calculateProxyAddress(factory, singleton111, "0x", saltNonce);
25-
await factory.createProxyWithNonce(singleton111, "0x", saltNonce).then((tx: any) => tx.wait());
25+
await factory.createProxyWithNonce(singleton111, "0x", saltNonce).then((tx) => tx.wait());
2626

2727
const safe = await hre.ethers.getContractAt("Safe", proxyAddress);
2828
await safe.setup([user1.address], 1, AddressZero, "0x", mockAddress, AddressZero, 0, AddressZero);

‎test/migration/UpgradeFromSafe120.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ describe("Upgrade from Safe 1.2.0", () => {
2323
const factory = await getFactory();
2424
const saltNonce = 42;
2525
const proxyAddress = await calculateProxyAddress(factory, singleton120, "0x", saltNonce);
26-
await factory.createProxyWithNonce(singleton120, "0x", saltNonce).then((tx: any) => tx.wait());
26+
await factory.createProxyWithNonce(singleton120, "0x", saltNonce).then((tx) => tx.wait());
2727

2828
const safe = await hre.ethers.getContractAt("Safe", proxyAddress);
2929
await safe.setup([user1.address], 1, AddressZero, "0x", mockAddress, AddressZero, 0, AddressZero);

‎test/utils/setup.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ export const getSafeTemplateWithSingleton = async (singleton: Contract | Safe, s
142142
const singletonAddress = await singleton.getAddress();
143143
const factory = await getFactory();
144144
const template = await factory.createProxyWithNonce.staticCall(singletonAddress, "0x", saltNumber);
145-
await factory.createProxyWithNonce(singletonAddress, "0x", saltNumber).then((tx: any) => tx.wait());
145+
await factory.createProxyWithNonce(singletonAddress, "0x", saltNumber).then((tx) => tx.wait());
146146
return singleton.attach(template) as Safe | SafeL2;
147147
};
148148

0 commit comments

Comments
 (0)
Please sign in to comment.