From 373ffb452757177d0168517bee1bbd4566396691 Mon Sep 17 00:00:00 2001 From: nikola-bozin-txfusion Date: Mon, 30 Oct 2023 21:50:16 +0100 Subject: [PATCH] chai-matchers update iteration 1 --- .../src/internal/changeEtherBalance.ts | 25 +++---- .../src/internal/changeEtherBalances.ts | 12 +-- .../src/internal/changeTokenBalance.ts | 39 +++++----- .../src/internal/misc/account.ts | 8 +- .../src/internal/misc/balance.ts | 7 +- .../src/internal/reverted/reverted.ts | 6 +- .../src/internal/reverted/revertedWith.ts | 2 +- .../reverted/revertedWithCustomError.ts | 2 +- .../internal/reverted/revertedWithPanic.ts | 12 ++- .../reverted/revertedWithoutReason.ts | 2 +- .../src/internal/reverted/utils.ts | 5 +- .../test/changeEtherBalance.ts | 75 +++++++++---------- .../test/changeEtherBalances.ts | 33 ++++---- .../test/changeTokenBalance.ts | 31 ++++---- .../test/reverted/reverted.ts | 10 +-- .../test/reverted/revertedWith.ts | 4 +- .../test/reverted/revertedWithCustomError.ts | 11 ++- .../test/reverted/revertedWithPanic.ts | 9 +-- .../test/reverted/revertedWithoutReason.ts | 4 +- 19 files changed, 142 insertions(+), 155 deletions(-) diff --git a/packages/hardhat-zksync-chai-matchers/src/internal/changeEtherBalance.ts b/packages/hardhat-zksync-chai-matchers/src/internal/changeEtherBalance.ts index fd52e8103..625ebc43f 100644 --- a/packages/hardhat-zksync-chai-matchers/src/internal/changeEtherBalance.ts +++ b/packages/hardhat-zksync-chai-matchers/src/internal/changeEtherBalance.ts @@ -1,5 +1,5 @@ import type { BigNumberish, ethers } from 'ethers'; -import * as zk from 'zksync-web3'; +import * as zk from 'zksync2-js'; import { buildAssert } from '@nomicfoundation/hardhat-chai-matchers/utils'; import { ensure } from '@nomicfoundation/hardhat-chai-matchers/internal/calledOnContract/utils'; @@ -13,22 +13,20 @@ export function supportChangeEtherBalance(Assertion: Chai.AssertionStatic) { function ( this: any, account: Account | string, - balanceChange: BigNumberish, + balanceChange: bigint, options?: { balanceChangeOptions?: BalanceChangeOptions; overrides?: ethers.Overrides; } ) { - const { BigNumber } = require('ethers'); - const negated = this.__flags.negate; const subject = this._obj; - const checkBalanceChange = ([actualChange, address]: [typeof BigNumber, string]) => { + const checkBalanceChange = ([actualChange, address]: [bigint, string]) => { const assert = buildAssert(negated, checkBalanceChange); assert( - actualChange.eq(BigNumber.from(balanceChange)), + actualChange===(balanceChange), `Expected the ether balance of "${address}" to change by ${balanceChange.toString()} wei, but it changed by ${actualChange.toString()} wei`, `Expected the ether balance of "${address}" NOT to change by ${balanceChange.toString()} wei, but it did` ); @@ -55,8 +53,7 @@ export async function getBalanceChange( options?: BalanceChangeOptions, overrides?: ethers.Overrides ) { - const { BigNumber } = await import('ethers'); - const provider = zk.Provider.getDefaultProvider(); + const provider = zk.Provider.getDefaultProvider()!; let txResponse: zk.types.TransactionResponse; @@ -75,19 +72,19 @@ export async function getBalanceChange( const address = await getAddressOf(account); - const balanceAfter = await provider.send('eth_getBalance', [address, `0x${txBlockNumber.toString(16)}`]); + const balanceAfter:bigint = await provider.send('eth_getBalance', [address, `0x${txBlockNumber.toString(16)}`]); - const balanceBefore = await provider.send('eth_getBalance', [address, `0x${(txBlockNumber - 1).toString(16)}`]); + const balanceBefore:bigint = await provider.send('eth_getBalance', [address, `0x${(txBlockNumber - 1).toString(16)}`]); if (options?.includeFee !== true && address === txResponse.from) { const gasPrice = overrides?.maxFeePerGas - ? BigNumber.from(overrides?.maxFeePerGas) + ? (overrides?.maxFeePerGas) : txReceipt.effectiveGasPrice ?? txResponse.gasPrice; const gasUsed = txReceipt.gasUsed; - const txFee = gasPrice.mul(gasUsed); + const txFee:bigint = gasPrice*(gasUsed); - return BigNumber.from(balanceAfter).add(txFee).sub(balanceBefore); + return (balanceAfter)+(txFee)+(balanceBefore); } else { - return BigNumber.from(balanceAfter).sub(balanceBefore); + return balanceAfter-(balanceBefore); } } diff --git a/packages/hardhat-zksync-chai-matchers/src/internal/changeEtherBalances.ts b/packages/hardhat-zksync-chai-matchers/src/internal/changeEtherBalances.ts index 030e81c88..33b5edc56 100644 --- a/packages/hardhat-zksync-chai-matchers/src/internal/changeEtherBalances.ts +++ b/packages/hardhat-zksync-chai-matchers/src/internal/changeEtherBalances.ts @@ -1,5 +1,5 @@ import type { BigNumberish, ethers } from 'ethers'; -import * as zk from 'zksync-web3'; +import * as zk from 'zksync2-js'; import ordinal from 'ordinal'; import { buildAssert } from '@nomicfoundation/hardhat-chai-matchers/utils'; @@ -13,7 +13,7 @@ export function supportChangeEtherBalances(Assertion: Chai.AssertionStatic) { function ( this: any, accounts: Array, - balanceChanges: BigNumberish[], + balanceChanges: bigint[], options?: { balanceChangeOptions?: BalanceChangeOptions; overrides?: ethers.Overrides; @@ -28,15 +28,15 @@ export function supportChangeEtherBalances(Assertion: Chai.AssertionStatic) { subject = subject(); } - const checkBalanceChanges = ([actualChanges, accountAddresses]: [Array, string[]]) => { + const checkBalanceChanges = ([actualChanges, accountAddresses]: [Array, string[]]) => { const assert = buildAssert(negated, checkBalanceChanges); assert( - actualChanges.every((change, ind) => change.eq(BigNumber.from(balanceChanges[ind]))), + actualChanges.every((change, ind) => change===(balanceChanges[ind])), () => { const lines: string[] = []; actualChanges.forEach((change, i) => { - if (!change.eq(BigNumber.from(balanceChanges[i]))) { + if (!(change===balanceChanges[i])) { lines.push( `Expected the ether balance of ${accountAddresses[i]} (the ${ordinal( i + 1 @@ -51,7 +51,7 @@ export function supportChangeEtherBalances(Assertion: Chai.AssertionStatic) { () => { const lines: string[] = []; actualChanges.forEach((change, i) => { - if (change.eq(BigNumber.from(balanceChanges[i]))) { + if (change===balanceChanges[i]) { lines.push( `Expected the ether balance of ${accountAddresses[i]} (the ${ordinal( i + 1 diff --git a/packages/hardhat-zksync-chai-matchers/src/internal/changeTokenBalance.ts b/packages/hardhat-zksync-chai-matchers/src/internal/changeTokenBalance.ts index 022d26b12..5b066f766 100644 --- a/packages/hardhat-zksync-chai-matchers/src/internal/changeTokenBalance.ts +++ b/packages/hardhat-zksync-chai-matchers/src/internal/changeTokenBalance.ts @@ -1,5 +1,4 @@ -import type { BigNumberish, BigNumber, ethers } from 'ethers'; -import * as zk from 'zksync-web3'; +import * as zk from 'zksync2-js'; import { buildAssert } from '@nomicfoundation/hardhat-chai-matchers/utils'; import { ensure } from '@nomicfoundation/hardhat-chai-matchers/internal/calledOnContract/utils'; @@ -7,14 +6,13 @@ import { ensure } from '@nomicfoundation/hardhat-chai-matchers/internal/calledOn import { Account, getAddressOf } from './misc/account'; interface Token extends zk.Contract { - balanceOf(address: string, overrides?: any): Promise; + balanceOf(address: string, overrides?: any): Promise; } export function supportChangeTokenBalance(Assertion: Chai.AssertionStatic) { Assertion.addMethod( 'changeTokenBalance', - function (this: any, token: Token, account: Account | string, balanceChange: BigNumberish) { - const { BigNumber } = require('ethers'); + function (this: any, token: Token, account: Account | string, balanceChange: bigint) { const negated = this.__flags.negate; @@ -25,11 +23,11 @@ export function supportChangeTokenBalance(Assertion: Chai.AssertionStatic) { checkToken(token, 'changeTokenBalance'); - const checkBalanceChange = ([actualChange, address, tokenDescription]: [BigNumber, string, string]) => { + const checkBalanceChange = ([actualChange, address, tokenDescription]: [bigint, string, string]) => { const assert = buildAssert(negated, checkBalanceChange); assert( - actualChange.eq(BigNumber.from(balanceChange)), + actualChange===balanceChange, `Expected the balance of ${tokenDescription} tokens for "${address}" to change by ${balanceChange.toString()}, but it changed by ${actualChange.toString()}`, `Expected the balance of ${tokenDescription} tokens for "${address}" NOT to change by ${balanceChange.toString()}, but it did` ); @@ -50,9 +48,7 @@ export function supportChangeTokenBalance(Assertion: Chai.AssertionStatic) { Assertion.addMethod( 'changeTokenBalances', - function (this: any, token: Token, accounts: Array, balanceChanges: BigNumberish[]) { - const { BigNumber } = require('ethers'); - + function (this: any, token: Token, accounts: Array, balanceChanges: bigint[]) { const negated = this.__flags.negate; let subject = this._obj; @@ -74,14 +70,14 @@ export function supportChangeTokenBalance(Assertion: Chai.AssertionStatic) { const addressesPromise = Promise.all(accounts.map(getAddressOf)); const checkBalanceChanges = ([actualChanges, addresses, tokenDescription]: [ - BigNumber[], + bigint[], string[], string ]) => { const assert = buildAssert(negated, checkBalanceChanges); assert( - actualChanges.every((change, ind) => change.eq(BigNumber.from(balanceChanges[ind]))), + actualChanges.every((change, ind) => change===balanceChanges[ind]), `Expected the balances of ${tokenDescription} tokens for ${addresses as any} to change by ${ balanceChanges as any }, respectively, but they changed by ${actualChanges as any}`, @@ -119,7 +115,7 @@ export async function getBalanceChange( account: Account | string ) { const { BigNumber } = require('ethers'); - const provider = zk.Provider.getDefaultProvider(); + const provider = zk.Provider.getDefaultProvider()!; const txResponse = await transaction; @@ -131,11 +127,12 @@ export async function getBalanceChange( ensure(block.transactions.length === 1, Error, 'Multiple transactions found in block'); const address = await getAddressOf(account); + const tokenAddress = await token.getAddress(); - const balanceAfter = await provider.getBalance(address, txBlockNumber, token.address); - const balanceBefore = await provider.getBalance(address, txBlockNumber - 1, token.address); + const balanceAfter = await provider.getBalance(address as string, txBlockNumber, tokenAddress); + const balanceBefore = await provider.getBalance(address as string, txBlockNumber - 1, tokenAddress); - return BigNumber.from(balanceAfter).sub(balanceBefore); + return balanceAfter-balanceBefore; } let tokenDescriptionsCache: Record = {}; @@ -145,8 +142,10 @@ let tokenDescriptionsCache: Record = {}; * exist, the address of the token is used. */ async function getTokenDescription(token: Token): Promise { - if (tokenDescriptionsCache[token.address] === undefined) { - let tokenDescription = ``; + const tokenAddress = await token.getAddress(); + + if (tokenDescriptionsCache[tokenAddress] === undefined) { + let tokenDescription = ``; try { tokenDescription = await token.symbol(); } catch (e) { @@ -155,10 +154,10 @@ async function getTokenDescription(token: Token): Promise { } catch (e2) {} } - tokenDescriptionsCache[token.address] = tokenDescription; + tokenDescriptionsCache[tokenAddress] = tokenDescription; } - return tokenDescriptionsCache[token.address]; + return tokenDescriptionsCache[tokenAddress]; } // only used by tests diff --git a/packages/hardhat-zksync-chai-matchers/src/internal/misc/account.ts b/packages/hardhat-zksync-chai-matchers/src/internal/misc/account.ts index 8827cdb68..f276fcd81 100644 --- a/packages/hardhat-zksync-chai-matchers/src/internal/misc/account.ts +++ b/packages/hardhat-zksync-chai-matchers/src/internal/misc/account.ts @@ -1,10 +1,10 @@ import assert from 'assert'; -import type { Contract, Signer, Wallet } from 'zksync-web3'; +import type { Contract, Signer, Wallet } from 'zksync2-js'; export type Account = Signer | Wallet | Contract; export function isWalletOrContract(account: Account): account is Contract | Wallet { - const zk = require('zksync-web3'); + const zk = require('zksync2-js'); return account instanceof zk.Contract || account instanceof zk.Wallet; } @@ -13,8 +13,8 @@ export async function getAddressOf(account: Account | string) { assert(/^0x[0-9a-fA-F]{40}$/.test(account), `Invalid address ${account}`); return account; } else if (isWalletOrContract(account)) { - return account.address; + return account.address?account.address:await account.getAddress(); } else { - return account.getAddress(); + return await account.getAddress(); } } diff --git a/packages/hardhat-zksync-chai-matchers/src/internal/misc/balance.ts b/packages/hardhat-zksync-chai-matchers/src/internal/misc/balance.ts index 5e0e6f282..c0c621600 100644 --- a/packages/hardhat-zksync-chai-matchers/src/internal/misc/balance.ts +++ b/packages/hardhat-zksync-chai-matchers/src/internal/misc/balance.ts @@ -1,4 +1,4 @@ -import * as zk from 'zksync-web3'; +import * as zk from 'zksync2-js'; import { Account, getAddressOf } from './account'; @@ -11,14 +11,13 @@ export function getAddresses(accounts: Array) { } export async function getBalances(accounts: Array, blockNumber?: number) { - const { BigNumber } = await import('ethers'); - const provider = zk.Provider.getDefaultProvider(); + const provider = zk.Provider.getDefaultProvider()!; return Promise.all( accounts.map(async (account) => { const address = await getAddressOf(account); const result = await provider.send('eth_getBalance', [address, `0x${blockNumber?.toString(16) ?? 0}`]); - return BigNumber.from(result); + return result }) ); } diff --git a/packages/hardhat-zksync-chai-matchers/src/internal/reverted/reverted.ts b/packages/hardhat-zksync-chai-matchers/src/internal/reverted/reverted.ts index 673ad64a0..0dbdd5997 100644 --- a/packages/hardhat-zksync-chai-matchers/src/internal/reverted/reverted.ts +++ b/packages/hardhat-zksync-chai-matchers/src/internal/reverted/reverted.ts @@ -1,5 +1,5 @@ import { buildAssert } from '@nomicfoundation/hardhat-chai-matchers/utils'; -import * as zk from 'zksync-web3'; +import * as zk from 'zksync2-js'; import { decodeReturnData, getReturnDataFromError } from './utils'; @@ -64,7 +64,7 @@ export function supportReverted(Assertion: Chai.AssertionStatic) { assert( true, undefined, - `Expected transaction NOT to be reverted, but it reverted with panic code ${decodedReturnData.code.toHexString()} (${ + `Expected transaction NOT to be reverted, but it reverted with panic code ${decodedReturnData.code.toString()} (${ decodedReturnData.description })` ); @@ -85,7 +85,7 @@ export function supportReverted(Assertion: Chai.AssertionStatic) { } async function getTransactionReceipt(hash: string) { - const provider = zk.Provider.getDefaultProvider(); + const provider = zk.Provider.getDefaultProvider()!; return provider.getTransactionReceipt(hash); } diff --git a/packages/hardhat-zksync-chai-matchers/src/internal/reverted/revertedWith.ts b/packages/hardhat-zksync-chai-matchers/src/internal/reverted/revertedWith.ts index f3aea48c1..27de094f4 100644 --- a/packages/hardhat-zksync-chai-matchers/src/internal/reverted/revertedWith.ts +++ b/packages/hardhat-zksync-chai-matchers/src/internal/reverted/revertedWith.ts @@ -36,7 +36,7 @@ export function supportRevertedWith(Assertion: Chai.AssertionStatic) { } else if (decodedReturnData.kind === 'Panic') { assert( false, - `Expected transaction to be reverted with reason '${expectedReason}', but it reverted with panic code ${decodedReturnData.code.toHexString()} (${ + `Expected transaction to be reverted with reason '${expectedReason}', but it reverted with panic code ${decodedReturnData.code.toString()} (${ decodedReturnData.description })` ); diff --git a/packages/hardhat-zksync-chai-matchers/src/internal/reverted/revertedWithCustomError.ts b/packages/hardhat-zksync-chai-matchers/src/internal/reverted/revertedWithCustomError.ts index 13f257fc6..8a84e7f09 100644 --- a/packages/hardhat-zksync-chai-matchers/src/internal/reverted/revertedWithCustomError.ts +++ b/packages/hardhat-zksync-chai-matchers/src/internal/reverted/revertedWithCustomError.ts @@ -64,7 +64,7 @@ export function supportRevertedWithCustomError(Assertion: Chai.AssertionStatic, } else if (decodedReturnData.kind === 'Panic') { assert( false, - `Expected transaction to be reverted with custom error '${expectedCustomErrorName}', but it reverted with panic code ${decodedReturnData.code.toHexString()} (${ + `Expected transaction to be reverted with custom error '${expectedCustomErrorName}', but it reverted with panic code ${decodedReturnData.code.toString()} (${ decodedReturnData.description })` ); diff --git a/packages/hardhat-zksync-chai-matchers/src/internal/reverted/revertedWithPanic.ts b/packages/hardhat-zksync-chai-matchers/src/internal/reverted/revertedWithPanic.ts index b2d019d5d..ac8b5b606 100644 --- a/packages/hardhat-zksync-chai-matchers/src/internal/reverted/revertedWithPanic.ts +++ b/packages/hardhat-zksync-chai-matchers/src/internal/reverted/revertedWithPanic.ts @@ -1,5 +1,3 @@ -import type { BigNumber } from 'ethers'; - import { normalizeToBigInt } from 'hardhat/common'; import { panicErrorCodeToReason } from '@nomicfoundation/hardhat-chai-matchers/internal/reverted/panic'; import { buildAssert } from '@nomicfoundation/hardhat-chai-matchers/utils'; @@ -12,7 +10,7 @@ export function supportRevertedWithPanic(Assertion: Chai.AssertionStatic) { const negated = this.__flags.negate; - let expectedCode: BigNumber | undefined; + let expectedCode: bigint | undefined; try { if (expectedCodeArg !== undefined) { const normalizedCode = normalizeToBigInt(expectedCodeArg); @@ -24,7 +22,7 @@ export function supportRevertedWithPanic(Assertion: Chai.AssertionStatic) { ); } - const code: number | undefined = expectedCode as any; + const code: bigint | undefined = expectedCode as any; let description: string | undefined; let formattedPanicCode: string; @@ -61,8 +59,8 @@ export function supportRevertedWithPanic(Assertion: Chai.AssertionStatic) { } else if (decodedReturnData.kind === 'Panic') { if (code !== undefined) { assert( - decodedReturnData.code.eq(code), - `Expected transaction to be reverted with ${formattedPanicCode}, but it reverted with panic code ${decodedReturnData.code.toHexString()} (${ + decodedReturnData.code===(code), + `Expected transaction to be reverted with ${formattedPanicCode}, but it reverted with panic code ${decodedReturnData.code.toString()} (${ decodedReturnData.description })`, `Expected transaction NOT to be reverted with ${formattedPanicCode}, but it was` @@ -71,7 +69,7 @@ export function supportRevertedWithPanic(Assertion: Chai.AssertionStatic) { assert( true, undefined, - `Expected transaction NOT to be reverted with ${formattedPanicCode}, but it reverted with panic code ${decodedReturnData.code.toHexString()} (${ + `Expected transaction NOT to be reverted with ${formattedPanicCode}, but it reverted with panic code ${decodedReturnData.code.toString()} (${ decodedReturnData.description })` ); diff --git a/packages/hardhat-zksync-chai-matchers/src/internal/reverted/revertedWithoutReason.ts b/packages/hardhat-zksync-chai-matchers/src/internal/reverted/revertedWithoutReason.ts index f78241b21..5787a7fce 100644 --- a/packages/hardhat-zksync-chai-matchers/src/internal/reverted/revertedWithoutReason.ts +++ b/packages/hardhat-zksync-chai-matchers/src/internal/reverted/revertedWithoutReason.ts @@ -28,7 +28,7 @@ export function supportRevertedWithoutReason(Assertion: Chai.AssertionStatic) { } else if (decodedReturnData.kind === 'Panic') { assert( false, - `Expected transaction to be reverted without a reason, but it reverted with panic code ${decodedReturnData.code.toHexString()} (${ + `Expected transaction to be reverted without a reason, but it reverted with panic code ${decodedReturnData.code.toString()} (${ decodedReturnData.description })` ); diff --git a/packages/hardhat-zksync-chai-matchers/src/internal/reverted/utils.ts b/packages/hardhat-zksync-chai-matchers/src/internal/reverted/utils.ts index 38bd253e1..706ff2548 100644 --- a/packages/hardhat-zksync-chai-matchers/src/internal/reverted/utils.ts +++ b/packages/hardhat-zksync-chai-matchers/src/internal/reverted/utils.ts @@ -1,4 +1,3 @@ -import type { BigNumber } from 'ethers'; import { AssertionError } from 'chai'; import { panicErrorCodeToReason } from '@nomicfoundation/hardhat-chai-matchers/internal/reverted/panic'; @@ -43,7 +42,7 @@ type DecodedReturnData = } | { kind: 'Panic'; - code: BigNumber; + code: bigint; description: string; } | { @@ -76,7 +75,7 @@ export function decodeReturnData(returnData: string): DecodedReturnData { }; } else if (returnData.startsWith(PANIC_CODE_PREFIX)) { const encodedReason = returnData.slice(PANIC_CODE_PREFIX.length); - let code: BigNumber; + let code: bigint; try { code = abi.decode(["uint256"], `0x${encodedReason}`)[0]; } catch (e: any) { diff --git a/packages/hardhat-zksync-chai-matchers/test/changeEtherBalance.ts b/packages/hardhat-zksync-chai-matchers/test/changeEtherBalance.ts index aeeb060fb..6001dc680 100644 --- a/packages/hardhat-zksync-chai-matchers/test/changeEtherBalance.ts +++ b/packages/hardhat-zksync-chai-matchers/test/changeEtherBalance.ts @@ -1,6 +1,5 @@ import { expect, AssertionError } from 'chai'; -import { BigNumber } from 'ethers'; -import * as zk from 'zksync-web3'; +import * as zk from 'zksync2-js'; import path from 'path'; import util from 'util'; @@ -32,7 +31,7 @@ describe('INTEGRATION: changeEtherBalance matcher', function () { let overrides: {}; beforeEach(async function () { - provider = zk.Provider.getDefaultProvider(); + provider = zk.Provider.getDefaultProvider()!; sender = new zk.Wallet(RICH_WALLET_PK, provider); receiver = zk.Wallet.createRandom(); @@ -86,7 +85,7 @@ describe('INTEGRATION: changeEtherBalance matcher', function () { to: receiver.address, value: 200, }) - ).to.changeEtherBalance(sender, BigInt('-200')); + ).to.changeEtherBalance(sender, '-200'); }); it('Should pass when given a native bigint - zkSync transfer', async () => { @@ -95,7 +94,7 @@ describe('INTEGRATION: changeEtherBalance matcher', function () { to: receiver.address, amount: 200, }) - ).to.changeEtherBalance(sender, BigInt('-200')); + ).to.changeEtherBalance(sender, -200); }); it('Should pass when given an ethers BigNumber', async () => { @@ -104,7 +103,7 @@ describe('INTEGRATION: changeEtherBalance matcher', function () { to: receiver.address, value: 200, }) - ).to.changeEtherBalance(sender, BigNumber.from('-200')); + ).to.changeEtherBalance(sender,-200); }); it('Should pass when given an ethers BigNumber - zkSync transfer', async () => { @@ -113,7 +112,7 @@ describe('INTEGRATION: changeEtherBalance matcher', function () { to: receiver.address, amount: 200, }) - ).to.changeEtherBalance(sender, BigNumber.from('-200')); + ).to.changeEtherBalance(sender, -200); }); it('Should pass when expected balance change is passed as int and is equal to an actual', async () => { @@ -178,7 +177,7 @@ describe('INTEGRATION: changeEtherBalance matcher', function () { to: receiver.address, value: 200, }) - ).to.changeEtherBalance(receiver, BigNumber.from(200)); + ).to.changeEtherBalance(receiver,200); }); it('Should pass when expected balance change is passed as BN and is equal to an actual - zkSync tranfer', async () => { @@ -187,7 +186,7 @@ describe('INTEGRATION: changeEtherBalance matcher', function () { to: receiver.address, amount: 200, }) - ).to.changeEtherBalance(receiver, BigNumber.from(200)); + ).to.changeEtherBalance(receiver,200); }); it('Should pass on negative case when expected balance change is not equal to an actual', async () => { @@ -196,7 +195,7 @@ describe('INTEGRATION: changeEtherBalance matcher', function () { to: receiver.address, value: 200, }) - ).to.not.changeEtherBalance(receiver, BigNumber.from(300)); + ).to.not.changeEtherBalance(receiver,300); }); it('Should pass on negative case when expected balance change is not equal to an actual - zkSync transfer', async () => { @@ -205,7 +204,7 @@ describe('INTEGRATION: changeEtherBalance matcher', function () { to: receiver.address, amount: 200, }) - ).to.not.changeEtherBalance(receiver, BigNumber.from(300)); + ).to.not.changeEtherBalance(receiver,300); }); it('Should throw when expected balance change value was different from an actual', async () => { @@ -215,7 +214,7 @@ describe('INTEGRATION: changeEtherBalance matcher', function () { to: receiver.address, value: 200, }) - ).to.changeEtherBalance(sender, '-500') + ).to.changeEtherBalance(sender, -500) ).to.be.eventually.rejectedWith( AssertionError, `Expected the ether balance of "${sender.address}" to change by -500 wei, but it changed by -200 wei` @@ -287,11 +286,11 @@ describe('INTEGRATION: changeEtherBalance matcher', function () { }) ).to.changeEtherBalance(sender, -200); - const receiverBalanceChange = (await provider.getBalance(receiver.address)).sub( + const receiverBalanceChange = (await provider.getBalance(receiver.address))-( receiverBalanceBefore ); - expect(receiverBalanceChange.toNumber()).to.equal(200); + expect(receiverBalanceChange).to.equal(200); }); it("shouldn't run the transaction twice - zkSync transfer", async function () { @@ -304,11 +303,11 @@ describe('INTEGRATION: changeEtherBalance matcher', function () { }) ).to.changeEtherBalance(sender, -200); - const receiverBalanceChange = (await provider.getBalance(receiver.address)).sub( + const receiverBalanceChange = (await provider.getBalance(receiver.address))-( receiverBalanceBefore ); - expect(receiverBalanceChange.toNumber()).to.equal(200); + expect(receiverBalanceChange).to.equal(200); }); }); @@ -316,7 +315,7 @@ describe('INTEGRATION: changeEtherBalance matcher', function () { it('Should pass when expected balance change is passed as int and is equal to an actual', async () => { await expect(async () => sender.sendTransaction({ - to: contract.address, + to: await contract.getAddress(), value: 200, }) ).to.changeEtherBalance(contract, 200); @@ -325,7 +324,7 @@ describe('INTEGRATION: changeEtherBalance matcher', function () { it('Should pass when expected balance change is passed as int and is equal to an actual - zkSync transfer', async () => { await expect(async () => sender.transfer({ - to: contract.address, + to:await contract.getAddress(), amount: 200, }) ).to.changeEtherBalance(contract, 200); @@ -425,7 +424,7 @@ describe('INTEGRATION: changeEtherBalance matcher', function () { to: receiver.address, value: 200, }) - ).to.changeEtherBalance(receiver, BigNumber.from(200), { overrides }); + ).to.changeEtherBalance(receiver, 200, { overrides }); }); it('Should pass when expected balance change is passed as BN and is equal to an actual - zkSync transfer', async () => { @@ -434,7 +433,7 @@ describe('INTEGRATION: changeEtherBalance matcher', function () { to: receiver.address, amount: 200, }) - ).to.changeEtherBalance(receiver, BigNumber.from(200), { overrides }); + ).to.changeEtherBalance(receiver, 200, { overrides }); }); it('Should pass on negative case when expected balance change is not equal to an actual', async () => { @@ -444,7 +443,7 @@ describe('INTEGRATION: changeEtherBalance matcher', function () { value: 200, ...overrides, }) - ).to.not.changeEtherBalance(receiver, BigNumber.from(300), { overrides }); + ).to.not.changeEtherBalance(receiver, 300, { overrides }); }); it('Should pass on negative case when expected balance change is not equal to an actual - zkSync transfer', async () => { @@ -454,7 +453,7 @@ describe('INTEGRATION: changeEtherBalance matcher', function () { amount: 200, overrides, }) - ).to.not.changeEtherBalance(receiver, BigNumber.from(300), { overrides }); + ).to.not.changeEtherBalance(receiver,300, { overrides }); }); it('Should throw when expected balance change value was different from an actual', async () => { @@ -522,7 +521,7 @@ describe('INTEGRATION: changeEtherBalance matcher', function () { it('Should pass when expected balance change is passed as int and is equal to an actual', async () => { await expect(async () => sender.sendTransaction({ - to: contract.address, + to: await contract.getAddress(), value: 200, ...overrides, }) @@ -532,7 +531,7 @@ describe('INTEGRATION: changeEtherBalance matcher', function () { it('Should pass when expected balance change is passed as int and is equal to an actual - zkSync transfer', async () => { await expect(async () => sender.transfer({ - to: contract.address, + to: await contract.getAddress(), amount: 200, overrides, }) @@ -560,9 +559,9 @@ describe('INTEGRATION: changeEtherBalance matcher', function () { }) ).to.changeEtherBalance(sender, -200, { overrides }); - const receiverBalanceChange = (await provider.getBalance(receiver.address)).sub(receiverBalanceBefore); + const receiverBalanceChange = (await provider.getBalance(receiver.address))-(receiverBalanceBefore); - expect(receiverBalanceChange.toNumber()).to.equal(200); + expect(receiverBalanceChange).to.equal(200); }); it("shouldn't run the transaction twice - zkSync transfer", async function () { @@ -576,9 +575,9 @@ describe('INTEGRATION: changeEtherBalance matcher', function () { }) ).to.changeEtherBalance(sender, -200, { overrides }); - const receiverBalanceChange = (await provider.getBalance(receiver.address)).sub(receiverBalanceBefore); + const receiverBalanceChange = (await provider.getBalance(receiver.address))-(receiverBalanceBefore); - expect(receiverBalanceChange.toNumber()).to.equal(200); + expect(receiverBalanceChange).to.equal(200); }); }); @@ -626,7 +625,7 @@ describe('INTEGRATION: changeEtherBalance matcher', function () { to: receiver.address, value: 200, }) - ).to.changeEtherBalance(sender, BigNumber.from(-200)); + ).to.changeEtherBalance(sender, -200); }); it('Should pass when expected balance change is passed as BN and is equal to an actual - zkSync transfer', async () => { @@ -635,7 +634,7 @@ describe('INTEGRATION: changeEtherBalance matcher', function () { to: receiver.address, amount: 200, }) - ).to.changeEtherBalance(sender, BigNumber.from(-200)); + ).to.changeEtherBalance(sender,-200); }); it('Should pass on negative case when expected balance change is not equal to an actual', async () => { @@ -644,7 +643,7 @@ describe('INTEGRATION: changeEtherBalance matcher', function () { to: receiver.address, value: 200, }) - ).to.not.changeEtherBalance(receiver, BigNumber.from(300)); + ).to.not.changeEtherBalance(receiver, 300); }); it('Should pass on negative case when expected balance change is not equal to an actual - zkSync transfer', async () => { @@ -653,7 +652,7 @@ describe('INTEGRATION: changeEtherBalance matcher', function () { to: receiver.address, amount: 200, }) - ).to.not.changeEtherBalance(receiver, BigNumber.from(300)); + ).to.not.changeEtherBalance(receiver,300); }); it('Should throw when expected balance change value was different from an actual', async () => { @@ -717,7 +716,7 @@ describe('INTEGRATION: changeEtherBalance matcher', function () { it('Should pass when expected balance change is passed as int and is equal to an actual', async () => { await expect( await sender.sendTransaction({ - to: contract.address, + to: await contract.getAddress(), value: 200, }) ).to.changeEtherBalance(contract, 200); @@ -726,7 +725,7 @@ describe('INTEGRATION: changeEtherBalance matcher', function () { it('Should pass when expected balance change is passed as int and is equal to an actual - zkSync transfer', async () => { await expect( await sender.transfer({ - to: contract.address, + to: await contract.getAddress(), amount: 200, }) ).to.changeEtherBalance(contract, 200); @@ -778,7 +777,7 @@ describe('INTEGRATION: changeEtherBalance matcher', function () { to: receiver.address, value: 200, }) - ).to.changeEtherBalance(sender, BigNumber.from(-200)); + ).to.changeEtherBalance(sender, -200); }); it('Should pass when expected balance change is passed as BN and is equal to an actual - zkSync transfer', async () => { @@ -787,7 +786,7 @@ describe('INTEGRATION: changeEtherBalance matcher', function () { to: receiver.address, amount: 200, }) - ).to.changeEtherBalance(sender, BigNumber.from(-200)); + ).to.changeEtherBalance(sender, -200); }); it('Should pass on negative case when expected balance change is not equal to an actual', async () => { @@ -796,7 +795,7 @@ describe('INTEGRATION: changeEtherBalance matcher', function () { to: receiver.address, value: 200, }) - ).to.not.changeEtherBalance(receiver, BigNumber.from(300)); + ).to.not.changeEtherBalance(receiver, 300); }); it('Should pass on negative case when expected balance change is not equal to an actual - zkSync transfer', async () => { @@ -805,7 +804,7 @@ describe('INTEGRATION: changeEtherBalance matcher', function () { to: receiver.address, amount: 200, }) - ).to.not.changeEtherBalance(receiver, BigNumber.from(300)); + ).to.not.changeEtherBalance(receiver,300); }); it('Should throw when expected balance change value was different from an actual', async () => { diff --git a/packages/hardhat-zksync-chai-matchers/test/changeEtherBalances.ts b/packages/hardhat-zksync-chai-matchers/test/changeEtherBalances.ts index c7555ae55..2d054df46 100644 --- a/packages/hardhat-zksync-chai-matchers/test/changeEtherBalances.ts +++ b/packages/hardhat-zksync-chai-matchers/test/changeEtherBalances.ts @@ -1,6 +1,5 @@ import { expect, AssertionError } from 'chai'; -import { BigNumber } from 'ethers'; -import * as zk from 'zksync-web3'; +import * as zk from 'zksync2-js'; import path from 'path'; import util from 'util'; @@ -32,7 +31,7 @@ describe('INTEGRATION: changeEtherBalances matcher', function () { let overrides: {}; beforeEach(async function () { - provider = zk.Provider.getDefaultProvider(); + provider = zk.Provider.getDefaultProvider()!; sender = new zk.Wallet(RICH_WALLET_PK, provider); receiver = zk.Wallet.createRandom(); @@ -54,18 +53,18 @@ describe('INTEGRATION: changeEtherBalances matcher', function () { describe('Transaction Callback', () => { describe('Change balances, one account, one contract', () => { it('Should pass when all expected balance changes are equal to actual values', async () => { - await expect(() => + await expect(async() => sender.sendTransaction({ - to: contract.address, + to: await contract.getAddress(), value: 200, }) ).to.changeEtherBalances([sender, contract], [-200, 200]); }); it('Should pass when all expected balance changes are equal to actual values - zkSync transfer', async () => { - await expect(() => + await expect(async() => sender.transfer({ - to: contract.address, + to:await contract.getAddress(), amount: 200, }) ).to.changeEtherBalances([sender, contract], [-200, 200]); @@ -133,7 +132,7 @@ describe('INTEGRATION: changeEtherBalances matcher', function () { value: 200, gasPrice, }) - ).to.changeEtherBalances([sender, receiver], [BigInt('-200'), BigInt(200)]); + ).to.changeEtherBalances([sender, receiver], [-200, 200]); }); it('Should pass when given native BigInt - zkSync transfer', async () => { @@ -145,7 +144,7 @@ describe('INTEGRATION: changeEtherBalances matcher', function () { gasPrice, }, }) - ).to.changeEtherBalances([sender, receiver], [BigInt('-200'), BigInt(200)]); + ).to.changeEtherBalances([sender, receiver], [-200, 200]); }); it('Should pass when given ethers BigNumber', async () => { @@ -155,7 +154,7 @@ describe('INTEGRATION: changeEtherBalances matcher', function () { value: 200, gasPrice, }) - ).to.changeEtherBalances([sender, receiver], [BigNumber.from('-200'), BigNumber.from(200)]); + ).to.changeEtherBalances([sender, receiver], [-200,200]); }); it('Should pass when given ethers BigNumber - zkSync transfer', async () => { @@ -167,7 +166,7 @@ describe('INTEGRATION: changeEtherBalances matcher', function () { gasPrice, }, }) - ).to.changeEtherBalances([sender, receiver], [BigNumber.from('-200'), BigNumber.from(200)]); + ).to.changeEtherBalances([sender, receiver], [-200, 200]); }); it('Should pass when given a single address', async () => { @@ -327,9 +326,9 @@ describe('INTEGRATION: changeEtherBalances matcher', function () { }) ).to.changeEtherBalances([sender, receiver], [-200, 200]); - const receiverBalanceChange = (await provider.getBalance(receiver.address)).sub(receiverBalanceBefore); + const receiverBalanceChange = (await provider.getBalance(receiver.address))-(receiverBalanceBefore); - expect(receiverBalanceChange.toNumber()).to.equal(200); + expect(receiverBalanceChange).to.equal(200); }); it("shouldn't run the transaction twice - zkSync transfer", async function () { @@ -345,9 +344,9 @@ describe('INTEGRATION: changeEtherBalances matcher', function () { }) ).to.changeEtherBalances([sender, receiver], [-200, 200]); - const receiverBalanceChange = (await provider.getBalance(receiver.address)).sub(receiverBalanceBefore); + const receiverBalanceChange = (await provider.getBalance(receiver.address))-(receiverBalanceBefore); - expect(receiverBalanceChange.toNumber()).to.equal(200); + expect(receiverBalanceChange).to.equal(200); }); }); @@ -356,7 +355,7 @@ describe('INTEGRATION: changeEtherBalances matcher', function () { it('Should pass when all expected balance changes are equal to actual values', async () => { await expect( await sender.sendTransaction({ - to: contract.address, + to: await contract.getAddress(), value: 200, }) ).to.changeEtherBalances([sender, contract], [-200, 200]); @@ -365,7 +364,7 @@ describe('INTEGRATION: changeEtherBalances matcher', function () { it('Should pass when all expected balance changes are equal to actual values - zkSync contract', async () => { await expect( await sender.transfer({ - to: contract.address, + to: await contract.getAddress(), amount: 200, }) ).to.changeEtherBalances([sender, contract], [-200, 200]); diff --git a/packages/hardhat-zksync-chai-matchers/test/changeTokenBalance.ts b/packages/hardhat-zksync-chai-matchers/test/changeTokenBalance.ts index 539db0dc0..10b07bf5c 100644 --- a/packages/hardhat-zksync-chai-matchers/test/changeTokenBalance.ts +++ b/packages/hardhat-zksync-chai-matchers/test/changeTokenBalance.ts @@ -1,7 +1,6 @@ import assert from 'assert'; import { AssertionError, expect } from 'chai'; -import { BigNumber } from 'ethers'; -import * as zk from 'zksync-web3'; +import * as zk from 'zksync2-js'; import path from 'path'; import util from 'util'; @@ -34,7 +33,7 @@ describe('INTEGRATION: changeTokenBalance and changeTokenBalances matchers', fun let mockToken: zk.Contract; beforeEach(async function () { - provider = zk.Provider.getDefaultProvider(); + provider = zk.Provider.getDefaultProvider()!; sender = new zk.Wallet(RICH_WALLET_PK, provider); receiver = zk.Wallet.createRandom(); @@ -143,7 +142,7 @@ describe('INTEGRATION: changeTokenBalance and changeTokenBalances matchers', fun it("doesn't change balance as expected - zkSync transfer", async function () { await expect( expect( - sender.transfer({ to: receiver.address, amount: 2, token: mockToken.address }) + sender.transfer({ to: receiver.address, amount: 2, token: await mockToken.getAddress() }) ).to.changeTokenBalance(mockToken, sender, 1) ).to.be.rejectedWith( AssertionError, @@ -167,7 +166,7 @@ describe('INTEGRATION: changeTokenBalance and changeTokenBalances matchers', fun it('changes balance in the way it was not expected - zkSync transfer', async function () { await expect( expect( - sender.transfer({ to: receiver.address, amount: 1, token: mockToken.address }) + sender.transfer({ to: receiver.address, amount: 1, token: await mockToken.getAddress()}) ).to.not.changeTokenBalance(mockToken, sender, -1) ).to.be.rejectedWith( AssertionError, @@ -188,7 +187,7 @@ describe('INTEGRATION: changeTokenBalance and changeTokenBalances matchers', fun it("the first account doesn't change its balance as expected - zkSync transfer", async function () { await expect( expect( - sender.transfer({ to: receiver.address, amount: 2, token: mockToken.address }) + sender.transfer({ to: receiver.address, amount: 2, token: await mockToken.getAddress() }) ).to.changeTokenBalances(mockToken, [sender, receiver], [1, 2]) ).to.be.rejectedWith(AssertionError); }); @@ -206,7 +205,7 @@ describe('INTEGRATION: changeTokenBalance and changeTokenBalances matchers', fun it("the second account doesn't change its balance as expected - zkSync transfer", async function () { await expect( expect( - sender.transfer({ to: receiver.address, amount: 2, token: mockToken.address }) + sender.transfer({ to: receiver.address, amount: 2, token: await mockToken.getAddress() }) ).to.changeTokenBalances(mockToken, [sender, receiver], [-2, 1]) ).to.be.rejectedWith(AssertionError); }); @@ -224,7 +223,7 @@ describe('INTEGRATION: changeTokenBalance and changeTokenBalances matchers', fun it('neither account changes its balance as expected - zkSync transfer', async function () { await expect( expect( - sender.transfer({ to: receiver.address, amount: 2, token: mockToken.address }) + sender.transfer({ to: receiver.address, amount: 2, token:await mockToken.getAddress()}) ).to.changeTokenBalances(mockToken, [sender, receiver], [1, 1]) ).to.be.rejectedWith(AssertionError); }); @@ -242,7 +241,7 @@ describe('INTEGRATION: changeTokenBalance and changeTokenBalances matchers', fun it('accounts change their balance in the way it was not expected - zkSync transfer', async function () { await expect( expect( - sender.transfer({ to: receiver.address, amount: 2, token: mockToken.address }) + sender.transfer({ to: receiver.address, amount: 2, token: await mockToken.getAddress()}) ).to.not.changeTokenBalances(mockToken, [sender, receiver], [-2, 2]) ).to.be.rejectedWith(AssertionError); }); @@ -457,13 +456,13 @@ describe('INTEGRATION: changeTokenBalance and changeTokenBalances matchers', fun await expect(mockToken.transfer(receiver.address, 50)).to.changeTokenBalance( mockToken, sender, - BigInt(-50) + -50 ); await expect(mockToken.transfer(receiver.address, 50)).to.changeTokenBalances( mockToken, [sender, receiver], - [BigInt(-50), BigInt(50)] + [-50, 50] ); }); @@ -471,13 +470,13 @@ describe('INTEGRATION: changeTokenBalance and changeTokenBalances matchers', fun await expect(mockToken.transfer(receiver.address, 50)).to.changeTokenBalance( mockToken, sender, - BigNumber.from(-50) + -50 ); await expect(mockToken.transfer(receiver.address, 50)).to.changeTokenBalances( mockToken, [sender, receiver], - [BigNumber.from(-50), BigNumber.from(50)] + [-50,50] ); }); @@ -485,13 +484,13 @@ describe('INTEGRATION: changeTokenBalance and changeTokenBalances matchers', fun await expect(mockToken.transfer(receiver.address, 50)).to.changeTokenBalances( mockToken, [sender, receiver], - [BigInt(-50), BigNumber.from(50)] + [-50, 50] ); await expect(mockToken.transfer(receiver.address, 50)).to.changeTokenBalances( mockToken, [sender, receiver], - [BigNumber.from(-50), BigInt(50)] + [-50, 50] ); }); }); @@ -554,7 +553,7 @@ async function runAllAsserts( | (() => Promise), token: zk.Contract, accounts: Array, - balances: Array + balances: Array ) { await expect(expr).to.changeTokenBalances(token, accounts, balances); await expect(expr).to.changeTokenBalances(token, [], []); diff --git a/packages/hardhat-zksync-chai-matchers/test/reverted/reverted.ts b/packages/hardhat-zksync-chai-matchers/test/reverted/reverted.ts index 7b6f581f0..4c92f4de8 100644 --- a/packages/hardhat-zksync-chai-matchers/test/reverted/reverted.ts +++ b/packages/hardhat-zksync-chai-matchers/test/reverted/reverted.ts @@ -1,7 +1,7 @@ import { AssertionError, expect } from 'chai'; import path from 'path'; import util from 'util'; -import * as zk from 'zksync-web3'; +import * as zk from 'zksync2-js'; import * as ethers from 'ethers'; import { Deployer } from '@matterlabs/hardhat-zksync-deploy/src/deployer'; @@ -31,7 +31,7 @@ describe('INTEGRATION: Reverted', function () { let aaDeployer: Deployer; beforeEach('deploy matchers contract', async function () { - provider = zk.Provider.getDefaultProvider(); + provider = zk.Provider.getDefaultProvider()!; wallet1 = new zk.Wallet(RICH_WALLET_1_PK, provider); wallet2 = new zk.Wallet(RICH_WALLET_2_PK, provider); @@ -192,12 +192,12 @@ describe('INTEGRATION: Reverted', function () { gasLimit: gasLimit, gasPrice: gasPrice, chainId: (await provider.getNetwork()).chainId, - nonce: await provider.getTransactionCount(aaAccount.address), + nonce: await provider.getTransactionCount(await aaAccount.getAddress()), type: 113, customData: { gasPerPubdata: zk.utils.DEFAULT_GAS_PER_PUBDATA_LIMIT, } as zk.types.Eip712Meta, - value: ethers.BigNumber.from(0), + value: 0, }; const singedTx = await wallet1.eip712.sign(aaTx); @@ -207,7 +207,7 @@ describe('INTEGRATION: Reverted', function () { customSignature: singedTx, }; - await expect(provider.sendTransaction(zk.utils.serialize(aaTx))).to.be.reverted; + await expect(provider.send(zk.utils.serializeEip712(aaTx),[])).to.be.reverted; }); }); } diff --git a/packages/hardhat-zksync-chai-matchers/test/reverted/revertedWith.ts b/packages/hardhat-zksync-chai-matchers/test/reverted/revertedWith.ts index 7d6cd979c..791a5edd5 100644 --- a/packages/hardhat-zksync-chai-matchers/test/reverted/revertedWith.ts +++ b/packages/hardhat-zksync-chai-matchers/test/reverted/revertedWith.ts @@ -1,5 +1,5 @@ import { AssertionError, expect } from 'chai'; -import * as zk from 'zksync-web3'; +import * as zk from 'zksync2-js'; import path from 'path'; import util from 'util'; @@ -26,7 +26,7 @@ describe('INTEGRATION: Reverted with', function () { let artifact: ZkSyncArtifact; beforeEach('deploy matchers contract', async function () { - provider = zk.Provider.getDefaultProvider(); + provider = zk.Provider.getDefaultProvider()!; wallet = new zk.Wallet(RICH_WALLET_PK, provider); deployer = new Deployer(this.hre, wallet); diff --git a/packages/hardhat-zksync-chai-matchers/test/reverted/revertedWithCustomError.ts b/packages/hardhat-zksync-chai-matchers/test/reverted/revertedWithCustomError.ts index 28a0a3a16..98b205788 100644 --- a/packages/hardhat-zksync-chai-matchers/test/reverted/revertedWithCustomError.ts +++ b/packages/hardhat-zksync-chai-matchers/test/reverted/revertedWithCustomError.ts @@ -1,6 +1,5 @@ import { AssertionError, expect } from 'chai'; -import { BigNumber } from 'ethers'; -import * as zk from 'zksync-web3'; +import * as zk from 'zksync2-js'; import path from 'path'; import util from 'util'; @@ -28,7 +27,7 @@ describe('INTEGRATION: Reverted with custom error', function () { let artifact: ZkSyncArtifact; beforeEach('deploy matchers contract', async function () { - provider = zk.Provider.getDefaultProvider(); + provider = zk.Provider.getDefaultProvider()!; wallet = new zk.Wallet(RICH_WALLET_PK, provider); deployer = new Deployer(this.hre, wallet); @@ -253,15 +252,15 @@ describe('INTEGRATION: Reverted with custom error', function () { it('should work with bigints and bignumbers', async function () { await expect(matchers.revertWithCustomErrorWithUint(1)) .to.be.revertedWithCustomError(matchers, 'CustomErrorWithUint') - .withArgs(BigInt(1)); + .withArgs(1); await expect(matchers.revertWithCustomErrorWithUint(1)) .to.be.revertedWithCustomError(matchers, 'CustomErrorWithUint') - .withArgs(BigNumber.from(1)); + .withArgs(1); await expect(matchers.revertWithCustomErrorWithPair(1, 2)) .to.be.revertedWithCustomError(matchers, 'CustomErrorWithPair') - .withArgs([BigInt(1), BigNumber.from(2)]); + .withArgs([1,2]); }); it('should work with predicates', async function () { diff --git a/packages/hardhat-zksync-chai-matchers/test/reverted/revertedWithPanic.ts b/packages/hardhat-zksync-chai-matchers/test/reverted/revertedWithPanic.ts index 29e6b80e3..d5f77b20f 100644 --- a/packages/hardhat-zksync-chai-matchers/test/reverted/revertedWithPanic.ts +++ b/packages/hardhat-zksync-chai-matchers/test/reverted/revertedWithPanic.ts @@ -1,6 +1,5 @@ import { AssertionError, expect } from 'chai'; -import { BigNumber } from 'ethers'; -import * as zk from 'zksync-web3'; +import * as zk from 'zksync2-js'; import path from 'path'; import util from 'util'; @@ -28,7 +27,7 @@ describe('INTEGRATION: Reverted with panic', function () { let artifact: ZkSyncArtifact; beforeEach('deploy matchers contract', async function () { - provider = zk.Provider.getDefaultProvider(); + provider = zk.Provider.getDefaultProvider()!; wallet = new zk.Wallet(RICH_WALLET_PK, provider); deployer = new Deployer(this.hre, wallet); @@ -213,7 +212,7 @@ describe('INTEGRATION: Reverted with panic', function () { await runSuccessfulAsserts({ matchers, method: 'succeeds', - successfulAssert: (x) => expect(x).not.to.be.revertedWithPanic(BigInt(1)), + successfulAssert: (x) => expect(x).not.to.be.revertedWithPanic(1), }); }); @@ -229,7 +228,7 @@ describe('INTEGRATION: Reverted with panic', function () { await runSuccessfulAsserts({ matchers, method: 'succeeds', - successfulAssert: (x) => expect(x).not.to.be.revertedWithPanic(BigNumber.from(1)), + successfulAssert: (x) => expect(x).not.to.be.revertedWithPanic(1), }); }); }); diff --git a/packages/hardhat-zksync-chai-matchers/test/reverted/revertedWithoutReason.ts b/packages/hardhat-zksync-chai-matchers/test/reverted/revertedWithoutReason.ts index 26ec41137..ac6ad6298 100644 --- a/packages/hardhat-zksync-chai-matchers/test/reverted/revertedWithoutReason.ts +++ b/packages/hardhat-zksync-chai-matchers/test/reverted/revertedWithoutReason.ts @@ -1,5 +1,5 @@ import { AssertionError, expect } from 'chai'; -import * as zk from 'zksync-web3'; +import * as zk from 'zksync2-js'; import path from 'path'; import util from 'util'; @@ -26,7 +26,7 @@ describe('INTEGRATION: Reverted without reason', function () { let artifact: ZkSyncArtifact; beforeEach('deploy matchers contract', async function () { - provider = zk.Provider.getDefaultProvider(); + provider = zk.Provider.getDefaultProvider()!; wallet = new zk.Wallet(RICH_WALLET_PK, provider); deployer = new Deployer(this.hre, wallet);