-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Getting URL error, when instantiating with Wallet::with_http_client()
#33
Comments
This error comes from jsonrpsee library, that Wallet uses underneath. |
ok thanks for this, since we cannot modify the jsonrpsee library, i have included some code to force in the default port: use zksync::{
self,
signer::Signer,
wallet::Wallet,
zksync_types::{L2ChainId, PackedEthSignature, H256},
};
use zksync_eth_signer::PrivateKeySigner;
//added this crate: url = "2.3.1"
use url::Url;
const CHAIN: u16 = 280;
const RPC_URL: &str = "https://testnet.era.zksync.dev";
// const RPC_URL: &str = "https://testnet.era.zksync.dev:443";
fn main() {
let mut eth_private_key = H256::default();
eth_private_key.randomize();
let eth_signer = PrivateKeySigner::new(eth_private_key);
let address_from_pk = PackedEthSignature::address_from_private_key(ð_private_key).unwrap();
let signer = Signer::new(eth_signer, address_from_pk, L2ChainId(CHAIN));
//-------------------------------------------///
// Force default URL
// Parse the URL string into a Url object
let url = Url::parse(RPC_URL).expect("Failed to parse URL");
// grab default port
let default_port = url.scheme() == "https" && url.port().is_none();
let port = url
.port()
.unwrap_or_else(|| if default_port { 443 } else { 0 });
// Format complete url
let complete_url = format!(
"{}://{}:{}{}",
url.scheme(),
url.host_str().unwrap(),
port,
url.path()
);
println!("Complete URL: {}", complete_url);
let url_str = complete_url.as_str();
//-------------------------------------------///
// getting port error retrieving this wallet, if no port provided
let wallet = Wallet::with_http_client(url_str, signer);
println!("{:#?} wallet", wallet);
} |
Hello! Development of SDK in this monorepo is discontinued, this SDK currently exists for some internal needs only and will be removed soon. |
Info
Currently when attempting to instantiate a wallet with the
with_http_client()
method, it is returning an error if a port is not included in the rpc url.example: when url is without a port number, such as:
https://testnet.era.zksync.dev
, an error is returned,but when url includes a port number, like
https://testnet.era.zksync.dev:443
, a wallet is successfully instantiated.Unfortunately many rpc urls do not contain a port number (i.e infura links), these rpc urls are unable to successfully instantiate a wallet.
Here is code that illustrates the issue: (can be pulled from this repo)
Cargo.toml:
main.rs:
When the above code is run:
Output:
To Reproduce Error:
Clone Repo
Clone rpc-url-issue
The text was updated successfully, but these errors were encountered: