Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
alekseysidorov committed Dec 28, 2020
1 parent 176362d commit 84cc2b9
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
9 changes: 9 additions & 0 deletions core/lib/types/src/tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ impl TokenLike {
// Otherwise interpret a string as the token symbol.
Self::Symbol(value.to_string())
}

/// Checks if the token is Ethereum.
pub fn is_eth(&self) -> bool {
match self {
TokenLike::Symbol(symbol) => symbol == "ETH",
TokenLike::Address(address) => *address == Address::zero(),
TokenLike::Id(id) => *id == 0,
}
}
}

/// Token supported in zkSync protocol
Expand Down
2 changes: 1 addition & 1 deletion core/tests/loadtest/config/localhost_lite.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
address = '0x36615cf349d7f6344891b1e7ca7c72883f5dc049'
private_key = '0x7726827caac94a7f9e1b160f7ea819f172f7b6f9d2a97f992c38edeab82d4110'
# The name of the token used for testing.
token_name = 'ETH'
token_name = 'wBTC'

[network]
# Network kind used for testing.
Expand Down
7 changes: 7 additions & 0 deletions core/tests/loadtest/src/test_wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ impl TestWallet {
.await
.store_address(inner.address());

if !token_name.is_eth() {
eth_provider
.approve_erc20_token_deposits(token_name.clone())
.await
.expect("Unable to approve ERC20 token");
}

Self {
monitor,
inner,
Expand Down
8 changes: 2 additions & 6 deletions sdk/zksync-rs/src/tokens_cache.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::collections::HashMap;
use zksync_types::{Address, Token, TokenLike};
use zksync_types::{Token, TokenLike};

#[derive(Debug, Clone)]
pub struct TokensCache {
Expand All @@ -24,10 +24,6 @@ impl TokensCache {
}

pub fn is_eth(&self, token: TokenLike) -> bool {
match token {
TokenLike::Symbol(symbol) => symbol == "ETH",
TokenLike::Address(address) => address == Address::zero(),
TokenLike::Id(id) => id == 0,
}
token.is_eth()
}
}

0 comments on commit 84cc2b9

Please sign in to comment.