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

fix(gateway): erc20 workaround for gateway upgrade #3511

Merged
merged 2 commits into from
Jan 21, 2025
Merged
Changes from all 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
27 changes: 4 additions & 23 deletions core/node/eth_watch/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use zksync_types::{
abi::ZkChainSpecificUpgradeData,
api::{ChainAggProof, Log},
ethabi::{self, decode, encode, Contract, ParamType},
web3::{keccak256, BlockId, BlockNumber, CallRequest, Filter, FilterBuilder},
web3::{keccak256, BlockId, BlockNumber, Filter, FilterBuilder},
Address, L1BatchNumber, L2ChainId, SLChainId, H256, L2_NATIVE_TOKEN_VAULT_ADDRESS,
SHARED_BRIDGE_ETHER_TOKEN_ADDRESS, U256, U64,
};
Expand Down Expand Up @@ -511,28 +511,9 @@ where
if base_token_l1_address == SHARED_BRIDGE_ETHER_TOKEN_ADDRESS {
(String::from("Ether"), String::from("ETH"))
} else {
// TODO(EVM-934): support non-standard tokens.
let selectors: [[u8; 4]; 2] = [
ethabi::short_signature("name", &[]),
ethabi::short_signature("symbol", &[]),
];
let types: [ParamType; 2] = [ParamType::String, ParamType::String];

let mut decoded_result = vec![];
for (selector, param_type) in selectors.into_iter().zip(types.into_iter()) {
let request = CallRequest {
to: Some(base_token_l1_address),
data: Some(selector.into()),
..Default::default()
};
let result = self.client.call_contract_function(request, None).await?;
// Base tokens are expected to support erc20 metadata
let mut token = ethabi::decode(&[param_type], &result.0)
.expect("base token does not support erc20 metadata");
decoded_result.push(token.pop().unwrap());
}

(decoded_result[0].to_string(), decoded_result[1].to_string())
// Due to an issue in the upgrade process, the automatically
// deployed wrapped base tokens will contain generic names
(String::from("Base Token"), String::from("BT"))
};

let base_token_asset_id = encode_ntv_asset_id(
Expand Down
Loading