Skip to content

Commit

Permalink
chore(js): lint the code
Browse files Browse the repository at this point in the history
  • Loading branch information
danijelTxFusion committed Jan 24, 2024
1 parent d7d2637 commit 412fa47
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 28 deletions.
8 changes: 4 additions & 4 deletions js/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# zkSync Era JavaScript Examples

Examples are made to demonstrate how [zksync-ethers](https://github.com/zksync-sdk/zksync-ethers)
Examples are made to demonstrate how [zksync-ethers](https://github.com/zksync-sdk/zksync-ethers)
SDK can be used for development. The examples demonstrate how to:

1. Deposit ETH from Ethereum to zkSync Era.
2. Transfer ETH on zkSync Era.
2. Transfer ETH on zkSync Era.
3. Withdraw ETH from zkSync Era to Ethereum.
4. Deploy a smart contract using create opcode.
5. Deploy a smart contract with constructor using create opcode.
Expand All @@ -21,12 +21,12 @@ SDK can be used for development. The examples demonstrate how to:
16. Use paymaster to pay fee with token.

Smart contract deployment use already generated bytecodes and ABIs and go bindings.
There is a [user guide](../solidity/README.md) on how those artifacts
There is a [user guide](../solidity/README.md) on how those artifacts
are generated. Same approach can be used to generate required artifact
for other smart contracts.

## Setup

```shell
yarn install
```
```
28 changes: 8 additions & 20 deletions js/tests/contract_factory.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import * as chai from "chai";
import "./custom-matchers";
import { Provider, types, ContractFactory, Wallet, Contract } from "zksync-ethers";
import {ethers, Typed} from "ethers";
import { ethers, Typed } from "ethers";

const { expect } = chai;


describe("ContractFactory", () => {
const PRIVATE_KEY = "0x7726827caac94a7f9e1b160f7ea819f172f7b6f9d2a97f992c38edeab82d4110";

Expand All @@ -21,7 +20,7 @@ describe("ContractFactory", () => {
const bytecode: string = conf.contracts["Storage.sol:Storage"].bin;

const factory = new ContractFactory(abi, bytecode, wallet);
const storage = await factory.deploy() as Contract;
const storage = (await factory.deploy()) as Contract;

const code = await provider.getCode(await storage.getAddress());
expect(code).not.to.be.null;
Expand All @@ -42,7 +41,7 @@ describe("ContractFactory", () => {
const bytecode: string = conf.contracts["Incrementer.sol:Incrementer"].bin;

const factory = new ContractFactory(abi, bytecode, wallet);
const incrementer = await factory.deploy(2) as Contract;
const incrementer = (await factory.deploy(2)) as Contract;

const code = await provider.getCode(await incrementer.getAddress());
expect(code).not.to.be.null;
Expand Down Expand Up @@ -92,12 +91,7 @@ describe("ContractFactory", () => {
const abi = conf.abi;
const bytecode: string = conf.bytecode;

const accountFactory = new ContractFactory(
abi,
bytecode,
wallet,
"createAccount",
);
const accountFactory = new ContractFactory(abi, bytecode, wallet, "createAccount");
const paymasterContract = await accountFactory.deploy(await provider.l2TokenAddress(l1DAI));

const code = await provider.getCode(await paymasterContract.getAddress());
Expand Down Expand Up @@ -190,16 +184,10 @@ describe("ContractFactory", () => {
const abi = conf.abi;
const bytecode: string = conf.bytecode;

const factory = new ContractFactory(
abi,
bytecode,
wallet,
"create2Account",
);
const account = await factory.deploy(
await provider.l2TokenAddress(l1DAI),
{ customData: { salt: ethers.hexlify(ethers.randomBytes(32)) } },
);
const factory = new ContractFactory(abi, bytecode, wallet, "create2Account");
const account = await factory.deploy(await provider.l2TokenAddress(l1DAI), {
customData: { salt: ethers.hexlify(ethers.randomBytes(32)) },
});

const code = await provider.getCode(await account.getAddress());
expect(code).not.to.be.null;
Expand Down
8 changes: 4 additions & 4 deletions js/tests/paymaster.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as chai from "chai";
import "./custom-matchers";
import {ContractFactory, Provider, types, utils, Wallet} from "zksync-ethers";
import {Contract, ethers, Typed} from "ethers";
import { ContractFactory, Provider, types, utils, Wallet } from "zksync-ethers";
import { Contract, ethers, Typed } from "ethers";

const {expect} = chai;
const { expect } = chai;

describe("Paymaster", () => {
const PRIVATE_KEY = "0x7726827caac94a7f9e1b160f7ea819f172f7b6f9d2a97f992c38edeab82d4110";
Expand Down Expand Up @@ -95,7 +95,7 @@ describe("Paymaster", () => {
expect(walletBalanceBeforeTx - walletBalanceAfterTx >= BigInt(0)).to.be.true;
expect(
walletTokenBalanceAfterTx ==
walletTokenBalanceBeforeTx - BigInt(MINIMAL_ALLOWANCE) + BigInt(MINT_AMOUNT),
walletTokenBalanceBeforeTx - BigInt(MINIMAL_ALLOWANCE) + BigInt(MINT_AMOUNT),
).to.be.true;
}).timeout(30_000);
});

0 comments on commit 412fa47

Please sign in to comment.