Skip to content

Commit

Permalink
Format with prettier with printWidth: 80 and trailingCommas: 'all' (#175
Browse files Browse the repository at this point in the history
)

This PR formats the entire codebase with `printWidth: 80` and `tralingComma: all`.
  • Loading branch information
dule-git committed Feb 5, 2024
1 parent 25904b9 commit 81636c0
Show file tree
Hide file tree
Showing 34 changed files with 998 additions and 401 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,5 @@ typings/
.env
.idea
.vscode
**/.DS_Store
**/.DS_Store
examples/contract-verification/.openzeppelin/
5 changes: 3 additions & 2 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"proseWrap": "never",
"printWidth": 120
}
"printWidth": 80,
"trailingComma": "all"
}
10 changes: 9 additions & 1 deletion config/eslint/eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,16 @@ module.exports = {
plugins: [
"eslint-plugin-import",
"@typescript-eslint",
"prettier",
],
rules: {
"prettier/prettier": [
"error",
{
"printWidth": 80,
"trailingComma": "all"
}
],
"@typescript-eslint/adjacent-overload-signatures": "error",
"@typescript-eslint/array-type": [
"error",
Expand Down Expand Up @@ -213,4 +221,4 @@ module.exports = {
"use-isnan": "error",
"no-restricted-imports": ["error"],
},
};
};
25 changes: 18 additions & 7 deletions examples/contract-verification/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,22 @@ import "@nomicfoundation/hardhat-ethers";
import { HardhatUserConfig } from "hardhat/config";
import * as dotenv from "dotenv";

const { TENDERLY_PRIVATE_VERIFICATION, TENDERLY_AUTOMATIC_VERIFICATION } = process.env;
const { TENDERLY_PRIVATE_VERIFICATION, TENDERLY_AUTOMATIC_VERIFICATION } =
process.env;

const privateVerification = TENDERLY_PRIVATE_VERIFICATION === "true";
const automaticVerifications = TENDERLY_AUTOMATIC_VERIFICATION === "true";

console.log("Using private verification? ", privateVerification, TENDERLY_PRIVATE_VERIFICATION);
console.log("Using automatic verification? ", automaticVerifications, TENDERLY_AUTOMATIC_VERIFICATION);
console.log(
"Using private verification? ",
privateVerification,
TENDERLY_PRIVATE_VERIFICATION,
);
console.log(
"Using automatic verification? ",
automaticVerifications,
TENDERLY_AUTOMATIC_VERIFICATION,
);

tdly.setup({ automaticVerifications });

Expand All @@ -19,21 +28,23 @@ dotenv.config();
const config: HardhatUserConfig = {
solidity: "0.8.17",
networks: {
my_tenderly_fork_1: { // or any other name
my_tenderly_fork_1: {
// or any other name
url: `${process.env.TENDERLY_FORK_RPC_URL ?? ""}`,
},
my_tenderly_devnet_1: { // or any other name
my_tenderly_devnet_1: {
// or any other name
url: `${process.env.TENDERLY_DEVNET_RPC_URL_1 ?? ""}`,
},
my_tenderly_devnet_2: { // or any other name
my_tenderly_devnet_2: {
// or any other name
url: `${process.env.TENDERLY_DEVNET_RPC_URL_2 ?? ""}`,
},
sepolia: {
url: `${process.env.SEPOLIA_URL ?? ""}`,
accounts: [process.env.SEPOLIA_PRIVATE_KEY ?? ""],
},
},

tenderly: {
project: process.env.TENDERLY_PROJECT ?? "",
username: process.env.TENDERLY_USERNAME ?? "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { HttpNetworkConfig } from "hardhat/types";
import { deployCalculator, deployMaths } from "./maths-deployment-ethers";

export async function main() {
const forkID = `${(network.config as HttpNetworkConfig).url}`.split("/").pop() ?? "";
const forkID =
`${(network.config as HttpNetworkConfig).url}`.split("/").pop() ?? "";

// 📐 Maths
const mathsAddress = await deployMaths();
Expand All @@ -26,15 +27,24 @@ export async function main() {
sources: {
"contracts/Calculator.sol": {
name: "Calculator",
code: readFileSync("contracts/Calculator.sol", "utf-8").toString(),
code: readFileSync(
"contracts/Calculator.sol",
"utf-8",
).toString(),
},
"hardhat/console.sol": {
name: "console",
code: readFileSync("node_modules/hardhat/console.sol", "utf-8").toString(),
code: readFileSync(
"node_modules/hardhat/console.sol",
"utf-8",
).toString(),
},
"contracts/libraries/Maths.sol": {
name: "Maths",
code: readFileSync("contracts/libraries/Maths.sol", "utf-8").toString(),
code: readFileSync(
"contracts/libraries/Maths.sol",
"utf-8",
).toString(),
},
},
// solidity format compiler with a little modification at libraries param
Expand Down Expand Up @@ -66,7 +76,7 @@ export async function main() {
},
process.env.TENDERLY_PROJECT ?? "",
process.env.TENDERLY_USERNAME ?? "",
forkID
forkID,
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,17 @@ export async function main() {
},
"hardhat/console.sol": {
name: "console",
code: readFileSync("node_modules/hardhat/console.sol", "utf-8").toString(),
code: readFileSync(
"node_modules/hardhat/console.sol",
"utf-8",
).toString(),
},
"contracts/libraries/Maths.sol": {
name: "Maths",
code: readFileSync("contracts/libraries/Maths.sol", "utf-8").toString(),
code: readFileSync(
"contracts/libraries/Maths.sol",
"utf-8",
).toString(),
},
},
// solidity format compiler with a little modification at libraries param
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ export async function deployCalculator(mathsAddress: string) {
});
calculator = await calculator.waitForDeployment();

console.log("🧮[ethers] {Calculator} deployed to", await calculator.getAddress());
console.log(
"🧮[ethers] {Calculator} deployed to",
await calculator.getAddress(),
);
return await calculator.getAddress();
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ import { network, ethers, tenderly } from "hardhat";
import { HttpNetworkConfig } from "hardhat/types";

export async function main() {
const forkID = `${(network.config as HttpNetworkConfig).url}`.split("/").pop() ?? "";
const forkID =
`${(network.config as HttpNetworkConfig).url}`.split("/").pop() ?? "";

console.log("🖖🏽[ethers] Deploying and Verifying Greeter in Tenderly");

let greeter = await ethers.deployContract("Greeter", ["Hello, Manual Hardhat on Fork !"]);
let greeter = await ethers.deployContract("Greeter", [
"Hello, Manual Hardhat on Fork !",
]);

greeter = await greeter.waitForDeployment();
const greeterAddress = await greeter.getAddress();
Expand All @@ -25,7 +28,10 @@ export async function main() {
},
"hardhat/console.sol": {
name: "console",
code: readFileSync("node_modules/hardhat/console.sol", "utf-8").toString(),
code: readFileSync(
"node_modules/hardhat/console.sol",
"utf-8",
).toString(),
},
},
// solidity format compiler with a little modification at libraries param
Expand All @@ -48,7 +54,7 @@ export async function main() {
},
process.env.TENDERLY_PROJECT ?? "",
process.env.TENDERLY_USERNAME ?? "",
forkID
forkID,
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import { ethers, tenderly } from "hardhat";
export async function main() {
console.log("🖖🏽[ethers] Deploying and Verifying Greeter in Tenderly");
// deploy stuff but later pretend it's been deployed ages ago on Ropsten.
let greeter = await ethers.deployContract("Greeter", ["Hello, Manual Hardhat!"]);
let greeter = await ethers.deployContract("Greeter", [
"Hello, Manual Hardhat!",
]);

greeter = await greeter.waitForDeployment();
const greeterAddress = await greeter.getAddress();
Expand All @@ -26,7 +28,10 @@ export async function main() {
},
"hardhat/console.sol": {
name: "console",
code: readFileSync("node_modules/hardhat/console.sol", "utf-8").toString(),
code: readFileSync(
"node_modules/hardhat/console.sol",
"utf-8",
).toString(),
},
},
// solidity format compiler with a little modification at libraries param
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import { ethers, tenderly } from "hardhat";
async function main() {
console.log("🖖🏽[ethers] Deploying and Verifying Greeter in Tenderly");

let greeter = await ethers.deployContract("Greeter", ["Hello, Manual Hardhat!"]);
let greeter = await ethers.deployContract("Greeter", [
"Hello, Manual Hardhat!",
]);

greeter = await greeter.waitForDeployment();
const address = await greeter.getAddress();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"build": "yarn --cwd packages/tenderly-core run build && yarn --cwd packages/tenderly-hardhat run build",
"lint:fix": "wsrun --exclude-missing --stages lint:fix && yarn prettier --write",
"prettier": "prettier *.md \"{docs,.github}/**/*.{md,yml}\"",
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
"format": "prettier --write \"**/*.{ts,tsx}\"",
"changeset": "changeset",
"release": "changeset publish",
"version-packages": "changeset version"
Expand Down
59 changes: 36 additions & 23 deletions packages/tenderly-core/src/internal/cli/commands/LoginCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,50 @@ import commander from "commander";
import { logger } from "../../../utils/logger";

import { isAccessTokenSet, setAccessToken } from "../../../utils/config";
import { TENDERLY_API_BASE_URL, TENDERLY_DASHBOARD_BASE_URL } from "../../../common/constants";
import {
TENDERLY_API_BASE_URL,
TENDERLY_DASHBOARD_BASE_URL,
} from "../../../common/constants";

export const LoginCommand = new commander.Command("login").description("login to Tenderly").action(async () => {
logger.info("Trying to login to Tenderly.");
export const LoginCommand = new commander.Command("login")
.description("login to Tenderly")
.action(async () => {
logger.info("Trying to login to Tenderly.");

if (isAccessTokenSet()) {
logger.debug("Access token is already set. Checking if access token overwrite is needed.");
const response = await prompts({
type: "confirm",
name: "overwrite",
message: "Access token already set. Would you like to overwrite it?",
});
if (!response.overwrite) {
logger.debug("Access token overwrite skipped. Trying to login with the existing token.");
return;
if (isAccessTokenSet()) {
logger.debug(
"Access token is already set. Checking if access token overwrite is needed.",
);
const response = await prompts({
type: "confirm",
name: "overwrite",
message: "Access token already set. Would you like to overwrite it?",
});
if (!response.overwrite) {
logger.debug(
"Access token overwrite skipped. Trying to login with the existing token.",
);
return;
}
}
}

logger.info("Access token not set.");
const accessToken = await promptAccessToken();
logger.info("Access token not set.");
const accessToken = await promptAccessToken();

logger.debug("Access token accepted. Trying to log in.");
setAccessToken(accessToken);
logger.debug("Access token accepted. Trying to log in.");
setAccessToken(accessToken);

console.log("Successfully logged in to Tenderly.");
logger.info("Successfully logged in to Tenderly.");
});
console.log("Successfully logged in to Tenderly.");
logger.info("Successfully logged in to Tenderly.");
});

async function promptAccessToken(): Promise<string> {
console.log(`Redirecting to ${TENDERLY_DASHBOARD_BASE_URL}/account/authorization`);
logger.debug(`Redirecting to ${TENDERLY_DASHBOARD_BASE_URL}/account/authorization`);
console.log(
`Redirecting to ${TENDERLY_DASHBOARD_BASE_URL}/account/authorization`,
);
logger.debug(
`Redirecting to ${TENDERLY_DASHBOARD_BASE_URL}/account/authorization`,
);
await open(`${TENDERLY_DASHBOARD_BASE_URL}/account/authorization`);

logger.info("Requesting access token.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ export const NetworksCommand = new commander.Command("networks")
const filteredNetworks = networks.filter(isNotExcluded);
filteredNetworks.sort((a, b) => a.sort_order - b.sort_order);

const logCompliantNetworks = convertToLogCompliantNetworks(filteredNetworks);
const logCompliantNetworks =
convertToLogCompliantNetworks(filteredNetworks);
logger.silly("Obtained filtered public networks:", logCompliantNetworks);

const table = new Table({
Expand All @@ -36,19 +37,24 @@ export const NetworksCommand = new commander.Command("networks")
...(await Promise.all(
filteredNetworks.map(async (network) => {
if (verbose) {
const blockNumber = await tenderlyService.getLatestBlockNumber(network.ethereum_network_id);
const blockNumber = await tenderlyService.getLatestBlockNumber(
network.ethereum_network_id,
);
return [network.ethereum_network_id, network.name, blockNumber];
} else {
return [network.ethereum_network_id, network.name];
}
})
))
}),
)),
);
logger.silly("Networks table:", table);

console.log(table.toString());
});

function isNotExcluded(element: TenderlyNetwork): boolean {
return element.metadata.exclude_from_listing === undefined || element.metadata.exclude_from_listing === false;
return (
element.metadata.exclude_from_listing === undefined ||
element.metadata.exclude_from_listing === false
);
}
Loading

0 comments on commit 81636c0

Please sign in to comment.