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

feat: Add l1 token address endpoint #1031

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
96ec5cb
feat: add l1 token address endpoint
fkrause98 Feb 2, 2024
ecbf36d
fix: address PR comments, test target
fkrause98 Feb 15, 2024
513903c
lint: cargo fmt
fkrause98 Feb 15, 2024
dcaa5eb
feat: address pr comments for EN config
fkrause98 Feb 16, 2024
260ab9c
chore: zk fmt
fkrause98 Feb 16, 2024
f151919
Merge branch 'kl-factory' into base-token-addr-endpoint
fkrause98 Mar 1, 2024
3c355a0
Merge branch 'kl-factory' into base-token-addr-endpoint
fkrause98 Mar 5, 2024
c10fba5
fix: pr comments
fkrause98 Mar 5, 2024
cebb35b
fix: more pr comments
fkrause98 Mar 7, 2024
aa317d2
nit: remove FromStr trait import
fkrause98 Mar 7, 2024
86d9370
Merge branch 'kl-factory' into base-token-addr-endpoint
fkrause98 Mar 8, 2024
c0843dd
feat: Use 0x..00 when eth is base token
fkrause98 Mar 8, 2024
b274827
fix: remove unnecessary FromStr and Address imports
fkrause98 Mar 8, 2024
479bff7
fix: use ETHEREUM_ADDRESS constant
fkrause98 Mar 8, 2024
a78f686
fix: cargo test build
fkrause98 Mar 8, 2024
edc04d3
chore: zk fmt
fkrause98 Mar 8, 2024
f544652
feat: Handle Web3Error::NotImplemented on EN
fkrause98 Mar 11, 2024
ffa9e11
Merge branch 'kl-factory' into base-token-addr-endpoint
fkrause98 Mar 11, 2024
cb6b373
Merge branch 'kl-factory' into base-token-addr-endpoint
fkrause98 Mar 15, 2024
28f6523
feat: Handle Web3Error::NotImplemented after merge
fkrause98 Mar 15, 2024
9cd48b7
fix: update protobuf config
fkrause98 Mar 15, 2024
6cb4a51
update contracts submodule
juan518munoz Apr 5, 2024
f4b67c0
fix path
juan518munoz Apr 5, 2024
712bcd2
Merge remote-tracking branch 'matter-labs/kl-factory' into kl-factory
juan518munoz Apr 5, 2024
fb39e9e
fix first zk test i server
juan518munoz Apr 5, 2024
0ffd1fe
Merge branch 'kl-factory' into base-token-addr-endpoint
fkrause98 Apr 5, 2024
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
3 changes: 3 additions & 0 deletions core/lib/web3_decl/src/namespaces/zks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,7 @@ pub trait ZksNamespace {
keys: Vec<H256>,
l1_batch_number: L1BatchNumber,
) -> RpcResult<Proof>;

#[method(name = "getBaseTokenL1Address")]
async fn get_base_token_l1_address(&self) -> RpcResult<Address>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use zksync_web3_decl::{
use crate::api_server::web3::{backend_jsonrpsee::into_jsrpc_error, ZksNamespace};

#[async_trait]

mationorato marked this conversation as resolved.
Show resolved Hide resolved
impl ZksNamespaceServer for ZksNamespace {
async fn estimate_fee(&self, req: CallRequest) -> RpcResult<Fee> {
self.estimate_fee_impl(req).await.map_err(into_jsrpc_error)
Expand Down Expand Up @@ -172,4 +173,10 @@ impl ZksNamespaceServer for ZksNamespace {
.await
.map_err(into_jsrpc_error)
}

async fn get_base_token_l1_address(&self) -> RpcResult<Address> {
self.get_base_token_l1_address_impl()
.await
.map_err(into_jsrpc_error)
}
}
16 changes: 13 additions & 3 deletions core/lib/zksync_core/src/api_server/web3/namespaces/zks.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{collections::HashMap, convert::TryInto};
use std::{collections::HashMap, convert::TryInto, env, str::FromStr};

use bigdecimal::{BigDecimal, Zero};
use zksync_dal::StorageProcessor;
Expand All @@ -16,8 +16,8 @@ use zksync_types::{
l2_to_l1_log::L2ToL1Log,
tokens::ETHEREUM_ADDRESS,
transaction_request::CallRequest,
AccountTreeId, L1BatchNumber, MiniblockNumber, StorageKey, Transaction, L1_MESSENGER_ADDRESS,
L2_ETH_TOKEN_ADDRESS, REQUIRED_L1_TO_L2_GAS_PER_PUBDATA_BYTE, U256, U64,
AccountTreeId, L1BatchNumber, MiniblockNumber, StorageKey, Transaction, H160,
L1_MESSENGER_ADDRESS, L2_ETH_TOKEN_ADDRESS, REQUIRED_L1_TO_L2_GAS_PER_PUBDATA_BYTE, U256, U64,
};
use zksync_utils::{address_to_h256, ratio_to_big_decimal_normalized};
use zksync_web3_decl::{
Expand Down Expand Up @@ -646,4 +646,14 @@ impl ZksNamespace {
storage_proof,
})
}

#[tracing::instrument(skip_all)]
pub async fn get_base_token_l1_address_impl(&self) -> Result<Address, Web3Error> {
const METHOD_NAME: &str = "get_base_token_l1_address_impl";
mationorato marked this conversation as resolved.
Show resolved Hide resolved
let l1_token_env_var = env::var("CONTRACTS_BASE_TOKEN_ADDR")
.map_err(|_err| internal_error(METHOD_NAME, "Missing env variable for base token"))?;
Ok(H160::from_str(&l1_token_env_var).map_err(|_err| {
internal_error(METHOD_NAME, "Set value for base token is not an address")
})?)
}
mationorato marked this conversation as resolved.
Show resolved Hide resolved
}
2 changes: 1 addition & 1 deletion core/lib/zksync_core/src/api_server/web3/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use zksync_config::configs::{api::Web3JsonRpcConfig, chain::NetworkConfig, Contr
use zksync_dal::{ConnectionPool, StorageProcessor};
use zksync_types::{
api, l2::L2Tx, transaction_request::CallRequest, Address, L1BatchNumber, L1ChainId, L2ChainId,
MiniblockNumber, H256, U256, U64,
MiniblockNumber, H160, H256, U256, U64,
};
use zksync_web3_decl::{error::Web3Error, types::Filter};

Expand Down
Loading