Skip to content

Commit

Permalink
lints
Browse files Browse the repository at this point in the history
  • Loading branch information
StanislavBreadless committed Dec 3, 2021
1 parent bbb23ca commit 2ebbc59
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 41 deletions.
5 changes: 2 additions & 3 deletions core/bin/zksync_api/src/api_server/rpc_server/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Built-in uses
use std::{
collections::{HashMap, HashSet},
convert::TryFrom,
time::Instant,
};

Expand Down Expand Up @@ -139,8 +138,8 @@ fn get_call_with_ip_if_needed(

let description = methods_with_ip.get(&call.method);

let description = if description.is_some() {
description.unwrap()
let description = if let Some(description) = description {
description
} else {
return call;
};
Expand Down
1 change: 0 additions & 1 deletion core/bin/zksync_api/src/api_server/tx_sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ use zksync_api_types::{
v02::transaction::{SubmitBatchResponse, Toggle2FA, Toggle2FAResponse, TxHashSerializeWrapper},
TxWithSignature,
};
use zksync_config::ZkSyncConfig;
use zksync_storage::misc::records::Subsidy;
use zksync_storage::{chain::account::records::EthAccountType, ConnectionPool};
use zksync_types::{
Expand Down
5 changes: 2 additions & 3 deletions core/bin/zksync_api/src/fee_ticker/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ fn get_normal_and_subsidy_fee(
.expect("failed to get fee in token");

let batched_fee_in_token =
block_on(ticker.get_batch_from_ticker_in_wei(token.clone(), vec![(tx_type, address)]))
block_on(ticker.get_batch_from_ticker_in_wei(token, vec![(tx_type, address)]))
.expect("failed to get batched fee for token");

assert_eq!(
Expand Down Expand Up @@ -484,9 +484,8 @@ fn test_ticker_subsidy() {

// The subsidy price is more-or-less same in all tokens
let mut scaled_prices: Vec<i64> = vec![];
let tokens: Vec<_> = TestToken::all_tokens().into_iter().take(3).collect();

for token in tokens.clone().into_iter() {
for token in TestToken::all_tokens().into_iter().take(3) {
let price_usd = get_subsidy_token_fee_in_usd(
&mut ticker,
cpk(ChangePubKeyType::CREATE2),
Expand Down
15 changes: 1 addition & 14 deletions core/lib/storage/src/misc/mod.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,11 @@
// Built-in deps
use std::collections::{HashMap, HashSet};
use std::time::Instant;
// External imports
use num::{rational::Ratio, BigUint};

use sqlx::types::BigDecimal;
use thiserror::Error;
// Workspace imports
use zksync_api_types::v02::{
pagination::{PaginationDirection, PaginationQuery},
token::ApiNFT,
};
use zksync_types::{AccountId, Address, Token, TokenId, TokenLike, TokenPrice, NFT};
use zksync_utils::ratio_to_big_decimal;
// Local imports

use self::records::Subsidy;
use crate::utils::address_to_stored_string;
use crate::{QueryResult, StorageProcessor};
use zksync_types::tokens::TokenMarketVolume;

pub mod records;

Expand Down Expand Up @@ -68,7 +55,7 @@ impl<'a, 'c> MiscSchema<'a, 'c> {
.fetch_one(self.0.conn())
.await?
.total
.unwrap_or(BigDecimal::from(0));
.unwrap_or_else(|| BigDecimal::from(0));

metrics::histogram!("sql.token.load_tokens_asc", start.elapsed());
Ok(sum)
Expand Down
1 change: 0 additions & 1 deletion core/lib/storage/src/tests/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use zksync_types::TokenId;
use crate::tests::db_test;
use crate::{misc::records::Subsidy, misc::MiscSchema};
use crate::{QueryResult, StorageProcessor};
use std::time::SystemTime;

fn get_subsidy(name: String, value: u64) -> Subsidy {
// The only fields that matter are `subsidy_type` and `value`
Expand Down
21 changes: 3 additions & 18 deletions core/tests/ts-tests/tests/suits/subsidy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect, use } from 'chai';
import { BigNumber, utils } from 'ethers';
import { Wallet, types } from 'zksync';
import { use } from 'chai';
import { utils } from 'ethers';
import { Wallet } from 'zksync';
import chaiAsPromised from 'chai-as-promised';
import { Tester } from '../tester/tester';
import '../tester/priority-ops';
Expand Down Expand Up @@ -38,25 +38,10 @@ describe.only(`Subsidy tests`, () => {

let tester: Tester;
let alice: Wallet;
let bob: Wallet;
let chuck: Wallet;
let david: Wallet;
let frank: Wallet;
let judy: Wallet;
let chris: Wallet;
let operatorBalance: BigNumber;
let nft: types.NFT;

before('create tester and test wallets', async () => {
tester = await Tester.init('localhost', transport, providerType);
alice = await tester.fundedWallet('5.0');
bob = await tester.emptyWallet();
chuck = await tester.emptyWallet();
david = await tester.fundedWallet('1.0');
frank = await tester.fundedWallet('1.0');
judy = await tester.emptyWallet();
chris = await tester.emptyWallet();
operatorBalance = await tester.operatorBalance(token);
});

after('disconnect tester', async () => {
Expand Down
2 changes: 1 addition & 1 deletion core/tests/ts-tests/tests/tester/misc.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expectThrow, Tester } from './tester';
import { Tester } from './tester';
import { expect } from 'chai';
import { Wallet, types, Create2WalletSigner } from 'zksync';
import { BigNumber, ethers } from 'ethers';
Expand Down

0 comments on commit 2ebbc59

Please sign in to comment.