Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: lint packages #625

Merged
merged 5 commits into from
Dec 29, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Here is an overview of the plugins currently available:
| hardhat-zksync-chai-matchers | Extends chai with additional matchers, aiding in testing zkSync-specific features more effectively. |
| hardhat-zksync-toolbox | Offers a suite of zkSync-related Hardhat plugins in one package, enhancing accessibility and efficiency. |
| hardhat-zksync-upgradeable | Enables easier deployment and upgrading of smart contracts on the zkSync network, improving contract lifecycle management. |
| hardhat-zksync-node | Convenient plugin to run the zkSync era-test-node locally. |
| hardhat-zksync-ethers | A zksync-ethers SDK wrapper providing additional methods for accelerated development on zkSync. |

You can find more detailed explanations on how to use hardhat zkSync plugins on our [documentation page](https://v2-docs.zksync.io/api/hardhat/plugins.html#plugins) where each plugin has its own section:
Expand All @@ -33,6 +34,7 @@ You can find more detailed explanations on how to use hardhat zkSync plugins on
[hardhat-zksync-chai-matchers](https://era.zksync.io/docs/tools/hardhat/hardhat-zksync-chai-matchers.html)\
[hardhat-zksync-toolbox](https://era.zksync.io/docs/tools/hardhat/plugins.html)\
[hardhat-zksync-upgradeable](https://era.zksync.io/docs/tools/hardhat/hardhat-zksync-upgradable.html)\
[hardhat-zksync-node](https://era.zksync.io/docs/tools/hardhat/hardhat-zksync-node.html)\
[hardhat-zksync-ethers](https://era.zksync.io/docs/tools/hardhat/hardhat-zksync-ethers.html)


Expand Down
2 changes: 1 addition & 1 deletion examples/basic-example/deploy/002_factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default async function (hre: HardhatRuntimeEnvironment) {

// Call the deployed contract.
const greetingFromContract = await factoryContract.getFooName();
if (greetingFromContract == 'Foo') {
if (greetingFromContract === 'Foo') {
console.info(chalk.green(`Successful greeting from the contract!`));
} else {
throw new Error(`Contract returned unexpected greeting: ${greetingFromContract}`);
Expand Down
15 changes: 7 additions & 8 deletions examples/basic-example/deploy/003_account_abstraction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Deployer } from '@matterlabs/hardhat-zksync-deploy';
import chalk from 'chalk';

export default async function (hre: HardhatRuntimeEnvironment) {
//return;
// return;
console.info(chalk.yellow('Running deploy script for the Account Abstraction'));
// Initialize an Ethereum wallet.
const testMnemonic = 'stuff slice staff easily soup parent arm payment cotton trade scatter struggle';
Expand Down Expand Up @@ -58,15 +58,15 @@ export default async function (hre: HardhatRuntimeEnvironment) {
aaTx = {
...aaTx,
from: multisigAddress,
gasLimit: gasLimit,
gasPrice: gasPrice,
gasLimit,
gasPrice,
chainId: (await provider.getNetwork()).chainId,
nonce: await provider.getTransactionCount(multisigAddress),
type: 113,
customData: {
gasPerPubdata: zk.utils.DEFAULT_GAS_PER_PUBDATA_LIMIT,
} as zk.types.Eip712Meta,
value: ethers.toBigInt(0)
value: ethers.toBigInt(0),
};
const signedTxHash = zk.EIP712Signer.getSignedDigest(aaTx);

Expand All @@ -84,17 +84,16 @@ export default async function (hre: HardhatRuntimeEnvironment) {

console.log(`The multisig's nonce before the first tx is ${await provider.getTransactionCount(multisigAddress)}`);

const serialized = zk.utils.serializeEip712(aaTx)
const serialized = zk.utils.serializeEip712(aaTx);

const tx = await provider.broadcastTransaction(serialized);
await tx.wait();

console.log(`The multisig's nonce after the first tx is ${await provider.getTransactionCount(multisigAddress)}`);
const greetingFromContract = await greeterContract.greet();
if (greetingFromContract === newGreeting) {
console.info(chalk.green('Successfully initiated tx from deployed multisig!'));
} else {
throw new Error(`Contract said something unexpected: ${greetingFromContract}`);
}

}
2 changes: 1 addition & 1 deletion examples/node-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@
"eslint-plugin-import": "2.29.0",
"eslint-plugin-no-only-tests": "3.1.0",
"eslint-plugin-prettier": "5.0.1",
"chai": "^4.3.7",
"mocha": "^10.1.0",
"prettier": "3.1.0",
"rimraf": "^3.0.2",
"ts-node": "^10.6.0",
"typescript": "^5.1.6"
},
"dependencies": {
"chai": "^4.3.7",
"@matterlabs/hardhat-zksync-deploy": "link:../../packages/hardhat-zksync-deploy",
"@matterlabs/hardhat-zksync-solc": "link:../../packages/hardhat-zksync-solc",
"@matterlabs/hardhat-zksync-node": "link:../../packages/hardhat-zksync-node",
Expand Down
30 changes: 15 additions & 15 deletions examples/node-example/test/tests.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { expect } from "chai";
import { Wallet, Provider,Contract } from "zksync-ethers";
import { Deployer } from "@matterlabs/hardhat-zksync-deploy";
import { expect } from 'chai';
import { Wallet, Provider, Contract } from 'zksync-ethers';
import { Deployer } from '@matterlabs/hardhat-zksync-deploy';
import { ZkSyncArtifact } from '@matterlabs/hardhat-zksync-deploy/src/types';
import "@matterlabs/hardhat-zksync-node/dist/type-extensions";
import * as hre from "hardhat";
import '@matterlabs/hardhat-zksync-node/dist/type-extensions';
import * as hre from 'hardhat';

const RICH_PRIVATE_KEY = '0x7726827caac94a7f9e1b160f7ea819f172f7b6f9d2a97f992c38edeab82d4110';

describe("Greeter", function () {
describe('Greeter', function () {
let provider: Provider;
let deployer: Deployer;
let artifact: ZkSyncArtifact;
Expand All @@ -22,20 +22,20 @@ describe("Greeter", function () {
});

// Test the constructor
it("Should set the greeting to the constructor argument", async function () {
expect(await contract.greet()).to.equal("Hello, world!");
it('Should set the greeting to the constructor argument', async function () {
expect(await contract.greet()).to.equal('Hello, world!');
});

// Test the greet() function
it("Should return the current greeting", async function () {
expect(await contract.greet()).to.equal("Hello, world!");
it('Should return the current greeting', async function () {
expect(await contract.greet()).to.equal('Hello, world!');
});

// Test the setGreeting() function
it("Should set a new greeting", async function () {
//Added for preveting nonce errors.
await new Promise(resolve => setTimeout(resolve, 1000));
await contract.setGreeting("Hello, Ethereum!");
expect(await contract.greet()).to.equal("Hello, Ethereum!");
it('Should set a new greeting', async function () {
// Added for preveting nonce errors.
await new Promise((resolve) => setTimeout(resolve, 1000));
await contract.setGreeting('Hello, Ethereum!');
expect(await contract.greet()).to.equal('Hello, Ethereum!');
});
});
4 changes: 2 additions & 2 deletions examples/noninline-libraries-example/deploy/001_deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default async function (hre: HardhatRuntimeEnvironment) {
console.info(chalk.yellow(`Running deploy script for the Test contract`));

// Create zkWallet object
const zkWallet = new zk.Wallet("0x7726827caac94a7f9e1b160f7ea819f172f7b6f9d2a97f992c38edeab82d4110");
const zkWallet = new zk.Wallet('0x7726827caac94a7f9e1b160f7ea819f172f7b6f9d2a97f992c38edeab82d4110');

// // Create deployer object and load desired artifact.
const deployer = new Deployer(hre, zkWallet);
Expand All @@ -23,4 +23,4 @@ export default async function (hre: HardhatRuntimeEnvironment) {
// Show the contract info.
const contractAddress = await greeterContract.getAddress();
console.info(chalk.green(`${artifact.contractName} was deployed to ${contractAddress}!`));
};
}
8 changes: 5 additions & 3 deletions examples/upgradable-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,20 @@
"eslint-plugin-import": "2.29.0",
"eslint-plugin-no-only-tests": "3.1.0",
"eslint-plugin-prettier": "5.0.1",
"hardhat": "^2.19.2",
"prettier": "3.1.0",
"rimraf": "^3.0.2",
"ts-node": "^10.6.0",
"typescript": "^5.1.6",
"zksync-ethers":"^6.0.0"
"typescript": "^5.1.6"
},
"dependencies": {
"zksync-ethers":"^6.0.0",
"hardhat": "^2.19.2",
"@matterlabs/hardhat-zksync-deploy": "link:../../packages/hardhat-zksync-deploy",
"@matterlabs/hardhat-zksync-solc": "link:../../packages/hardhat-zksync-solc",
"@matterlabs/hardhat-zksync-upgradable": "link:../../packages/hardhat-zksync-upgradable",
"@matterlabs/hardhat-zksync-verify": "link:../../packages/hardhat-zksync-verify",
"chalk": "4.1.2",
"ethers": "^6.7.1",
"@openzeppelin/contracts-upgradeable": "^4.9.2",
"zksync": "^0.13.1"
},
Expand Down
2 changes: 1 addition & 1 deletion examples/upgradable-example/scripts/deploy-box-beacon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as hre from 'hardhat';

async function main() {
const contractName = 'Box';
console.info(chalk.yellow('Deploying ' + contractName + '...'));
console.info(chalk.yellow(`Deploying ${contractName}...`));

const testMnemonic = 'stuff slice staff easily soup parent arm payment cotton trade scatter struggle';
const zkWallet = Wallet.fromMnemonic(testMnemonic);
Expand Down
2 changes: 1 addition & 1 deletion examples/upgradable-example/scripts/deploy-box-proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as hre from 'hardhat';

async function main() {
const contractName = 'Box';
console.info(chalk.yellow('Deploying ' + contractName + '...'));
console.info(chalk.yellow(`Deploying ${contractName}...`));

const testMnemonic = 'stuff slice staff easily soup parent arm payment cotton trade scatter struggle';
const zkWallet = Wallet.fromMnemonic(testMnemonic);
Expand Down
2 changes: 1 addition & 1 deletion examples/upgradable-example/scripts/deploy-box-uups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as hre from 'hardhat';

async function main() {
const contractName = 'BoxUups';
console.info(chalk.yellow('Deploying ' + contractName + '...'));
console.info(chalk.yellow(`Deploying ${contractName}...`));

const testMnemonic = 'stuff slice staff easily soup parent arm payment cotton trade scatter struggle';
const zkWallet = Wallet.fromMnemonic(testMnemonic);
Expand Down
17 changes: 8 additions & 9 deletions examples/upgradable-example/scripts/upgrade-box-beacon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Wallet } from 'zksync-ethers';
import * as zk from 'zksync-ethers';
import chalk from 'chalk';
import * as hre from 'hardhat';
import {Contract} from 'ethers'
import { Contract } from 'ethers';

async function main() {
const testMnemonic = 'stuff slice staff easily soup parent arm payment cotton trade scatter struggle';
Expand All @@ -16,26 +16,25 @@ async function main() {
const contract = await deployer.loadArtifact(contractName);
const beacon = await hre.zkUpgrades.deployBeacon(deployer.zkWallet, contract);
await beacon.waitForDeployment();

const beaconAddress = await beacon.getAddress();

const boxBeaconProxy = await hre.zkUpgrades.deployBeaconProxy(deployer.zkWallet,beaconAddress, contract, [42]);
const boxBeaconProxy = await hre.zkUpgrades.deployBeaconProxy(deployer.zkWallet, beaconAddress, contract, [42]);
await boxBeaconProxy.waitForDeployment();

// upgrade beacon

const boxV2Implementation = await deployer.loadArtifact('BoxV2');
await hre.zkUpgrades.upgradeBeacon(deployer.zkWallet,beaconAddress, boxV2Implementation);
console.info(chalk.green('Successfully upgraded beacon Box to BoxV2 on address: ',beaconAddress));
await hre.zkUpgrades.upgradeBeacon(deployer.zkWallet, beaconAddress, boxV2Implementation);
console.info(chalk.green('Successfully upgraded beacon Box to BoxV2 on address: ', beaconAddress));

const attachTo = new zk.ContractFactory<any[],Contract>(
const attachTo = new zk.ContractFactory<any[], Contract>(
boxV2Implementation.abi,
boxV2Implementation.bytecode,
deployer.zkWallet,
deployer.deploymentType
deployer.deploymentType,
);
const upgradedBox = attachTo.attach(await boxBeaconProxy.getAddress());

const upgradedBox = attachTo.attach(await boxBeaconProxy.getAddress());

upgradedBox.connect(zkWallet);
// wait some time before the next call
Expand Down
7 changes: 3 additions & 4 deletions examples/verify-example/test/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { TASK_COMPILE } from "@matterlabs/hardhat-zksync-verify/dist/src/constants";
import { TASK_COMPILE } from '@matterlabs/hardhat-zksync-verify/dist/src/constants';
import { resetHardhatContext } from 'hardhat/plugins-testing';
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { HardhatRuntimeEnvironment } from 'hardhat/types';

export const MOCK_ADDRESS = '0x110eb1e16A63c608787236E728Fa1817C72e6950';
export const WRONG_NUMBER_OF_CONSTRUCTOR_ARGUMENTS_ERROR =
'The number of constructor arguments you provided (0) does not match the number of constructor arguments the contract has been deployed with (1).';
export const CONTRACT_ALREADY_VERIFIED_ERROR = 'This contract is already verified';


declare module 'mocha' {
interface Context {
env: HardhatRuntimeEnvironment;
Expand All @@ -25,4 +24,4 @@ export function useEnvironment(networkName = 'testnet') {
after('Resetting hardhat', function () {
resetHardhatContext();
});
}
}
22 changes: 14 additions & 8 deletions examples/verify-example/test/tests.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import assert from 'assert';
import {
TASK_CHECK_VERIFICATION_STATUS,
} from '@matterlabs/hardhat-zksync-verify/dist/src/constants';
import { TASK_CHECK_VERIFICATION_STATUS } from '@matterlabs/hardhat-zksync-verify/dist/src/constants';

import chalk from 'chalk';
import { CONTRACT_ALREADY_VERIFIED_ERROR, MOCK_ADDRESS, WRONG_NUMBER_OF_CONSTRUCTOR_ARGUMENTS_ERROR, useEnvironment } from './helpers';
import {
CONTRACT_ALREADY_VERIFIED_ERROR,
MOCK_ADDRESS,
WRONG_NUMBER_OF_CONSTRUCTOR_ARGUMENTS_ERROR,
useEnvironment,
} from './helpers';

describe('verify plugin', async function () {
const testnetVerifyURL = 'https://explorer.sepolia.era.zksync.dev/contract_verification';
Expand Down Expand Up @@ -49,7 +52,7 @@ describe('verify plugin', async function () {
constructorArguments: constructorArgs,
});

const success = await this.env.run(TASK_CHECK_VERIFICATION_STATUS, { verificationId: verificationId });
const success = await this.env.run(TASK_CHECK_VERIFICATION_STATUS, { verificationId });

assert.equal(success, true);
});
Expand Down Expand Up @@ -114,7 +117,10 @@ describe('verify plugin', async function () {
const contractName = 'MintingContract';

const factoryContract = await this.env.zksyncEthers.getContractFactory(contractName);
const contract = await factoryContract.deploy('ContractName', 'ContractSymbol', MOCK_ADDRESS, [MOCK_ADDRESS, MOCK_ADDRESS]);
const contract = await factoryContract.deploy('ContractName', 'ContractSymbol', MOCK_ADDRESS, [
MOCK_ADDRESS,
MOCK_ADDRESS,
]);

this.deployedAddress = await contract.getAddress();
console.info(chalk.green(`${contractName} was deployed to ${this.deployedAddress}`));
Expand All @@ -130,7 +136,7 @@ describe('verify plugin', async function () {
constructorArguments: constructorArgs,
});

const success = await this.env.run(TASK_CHECK_VERIFICATION_STATUS, { verificationId: verificationId });
const success = await this.env.run(TASK_CHECK_VERIFICATION_STATUS, { verificationId });

assert.equal(success, true);
});
Expand Down Expand Up @@ -179,4 +185,4 @@ describe('verify plugin', async function () {
console.log('Verification ID: ', verificationId);
});
});
});
});
3 changes: 3 additions & 0 deletions examples/verify-vyper-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"@typescript-eslint/eslint-plugin": "6.13.1",
"@typescript-eslint/parser": "6.13.1",
"eslint": "^8.54.0",
"chalk": "4.1.2",
"eslint-config-prettier": "9.0.0",
"eslint-plugin-import": "2.29.0",
"eslint-plugin-no-only-tests": "3.1.0",
Expand All @@ -30,7 +31,9 @@
"dependencies": {
"@matterlabs/hardhat-zksync-deploy": "link:../../packages/hardhat-zksync-deploy",
"@matterlabs/hardhat-zksync-vyper": "link:../../packages/hardhat-zksync-vyper",
"@matterlabs/hardhat-zksync-verify": "link:../../packages/hardhat-zksync-verify",
"@matterlabs/hardhat-zksync-verify-vyper": "link:../../packages/hardhat-zksync-verify-vyper",
"chalk": "4.1.2",
"@nomiclabs/hardhat-vyper": "^3.0.5",
"ethers": "^6.7.1",
"hardhat": "^2.19.2"
Expand Down
7 changes: 3 additions & 4 deletions examples/verify-vyper-example/test/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { TASK_COMPILE } from "@matterlabs/hardhat-zksync-verify/dist/src/constants";
import { TASK_COMPILE } from '@matterlabs/hardhat-zksync-verify/dist/src/constants';
import { resetHardhatContext } from 'hardhat/plugins-testing';
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { HardhatRuntimeEnvironment } from 'hardhat/types';

export const MOCK_ADDRESS = '0x110eb1e16A63c608787236E728Fa1817C72e6950';
export const WRONG_NUMBER_OF_CONSTRUCTOR_ARGUMENTS_ERROR =
'The number of constructor arguments you provided (2) does not match the number of constructor arguments the contract has been deployed with (0).';
export const CONTRACT_ALREADY_VERIFIED_ERROR = 'This contract is already verified';


declare module 'mocha' {
interface Context {
env: HardhatRuntimeEnvironment;
Expand All @@ -25,4 +24,4 @@ export function useEnvironment(networkName = 'testnet') {
after('Resetting hardhat', function () {
resetHardhatContext();
});
}
}
Loading
Loading