Skip to content

Commit

Permalink
fix(gateway): erc20 workaround for gateway upgrade (#3511)
Browse files Browse the repository at this point in the history
## What ❔

<!-- What are the changes this PR brings about? -->
<!-- Example: This PR adds a PR template to the repo. -->
<!-- (For bigger PRs adding more context is appreciated) -->

## Why ❔

<!-- Why are these changes done? What goal do they contribute to? What
are the principles behind them? -->
<!-- Example: PR templates ensure PR reviewers, observers, and future
iterators are in context about the evolution of repos. -->

## Checklist

<!-- Check your PR fulfills the following items. -->
<!-- For draft PRs check the boxes as you complete them. -->

- [ ] PR title corresponds to the body of PR (we generate changelog
entries from PRs).
- [ ] Tests for the changes have been added / updated.
- [ ] Documentation comments have been added / updated.
- [ ] Code has been formatted via `zkstack dev fmt` and `zkstack dev
lint`.
  • Loading branch information
StanislavBreadless authored Jan 21, 2025
1 parent 2b896dc commit c140ba8
Showing 1 changed file with 4 additions and 23 deletions.
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

0 comments on commit c140ba8

Please sign in to comment.