Skip to content

Commit 28ecac2

Browse files
authored
Add CLI to generate starkli arguments for send_transfer (#232)
* Add CLI to generate 'starkli' arguments for send_transfer * Use to_hex_string instead of to_string to format MsgTransfer arguments * Remove unnecessary trait impl for TransferArgs * Add documentation for arguments for the 'demo transfer' command * Set denom argument as required for 'demo transfer' command * Update hermes-sdk used in relayer crate * Create new 'tools' crate for helper tools * Remove 'demo' subcommand from starknet-cli crate * Use SocketAddr instead of String for StarknetChainConfig 'json_rpc_url' field * Allow ERC20 tokens denom in 'starknet transfer-args' command * Add 'rpc_addr' to StarknetNodeConfig * Fix json_rpc_url parsing when building chain driver * Fix MsgTransfer in 'starknet transfer-args' command * Remove sender argument to starknet transfer-args command * Add docstring to 'starknet transfer-args' command * Remove dependency from running starknet node and add '--timeout-timestamp' flag to 'transfer-args' command * Remove unnecessary components from ToolApp * Remove unnecessary components from ToolApp
1 parent 1bd76db commit 28ecac2

File tree

18 files changed

+7625
-5
lines changed

18 files changed

+7625
-5
lines changed

relayer/crates/starknet-chain-components/src/impls/types/config.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::net::SocketAddr;
2+
13
use hermes_cosmos_chain_components::impls::types::config::CosmosChainConfig;
24
use serde::{Deserialize, Serialize};
35

@@ -11,6 +13,6 @@ pub struct StarknetRelayerConfig {
1113

1214
#[derive(Debug, Serialize, Deserialize)]
1315
pub struct StarknetChainConfig {
14-
pub json_rpc_url: String,
16+
pub json_rpc_url: SocketAddr,
1517
pub relayer_wallet: StarknetWallet,
1618
}

relayer/crates/starknet-cli/src/contexts/app.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use std::net::SocketAddr;
12
use std::path::PathBuf;
23

34
use cgp::core::component::UseDelegate;
@@ -220,7 +221,10 @@ impl ConfigUpdater<StarknetChainDriver, StarknetRelayerConfig> for UpdateStarkne
220221
.clone();
221222

222223
let chain_config = StarknetChainConfig {
223-
json_rpc_url: format!("http://localhost:{}/", chain_driver.node_config.rpc_port),
224+
json_rpc_url: SocketAddr::new(
225+
chain_driver.node_config.rpc_addr,
226+
chain_driver.node_config.rpc_port,
227+
),
224228
relayer_wallet,
225229
};
226230

relayer/crates/starknet-integration-tests/src/contexts/bootstrap.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,10 @@ impl ChainDriverBuilder<StarknetBootstrap> for StarknetBootstrapComponents {
120120
.ok_or_else(|| StarknetBootstrap::raise_error("expect relayer wallet to be present"))?
121121
.clone();
122122

123-
let json_rpc_url = Url::parse(&format!("http://localhost:{}/", node_config.rpc_port))?;
123+
let json_rpc_url = Url::parse(&format!(
124+
"http://{}:{}/",
125+
node_config.rpc_addr, node_config.rpc_port
126+
))?;
124127

125128
let rpc_client = Arc::new(JsonRpcClient::new(HttpTransport::new(json_rpc_url)));
126129

relayer/crates/starknet-relayer/src/contexts/builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ impl StarknetBuilder {
123123
}
124124

125125
pub async fn build_chain_with_config(&self) -> Result<StarknetChain, HermesError> {
126-
let json_rpc_url = Url::parse(&self.starknet_chain_config.json_rpc_url)?;
126+
let json_rpc_url = Url::parse(&self.starknet_chain_config.json_rpc_url.to_string())?;
127127

128128
let rpc_client = Arc::new(JsonRpcClient::new(HttpTransport::new(json_rpc_url)));
129129

relayer/crates/starknet-test-components/src/impls/bootstrap/bootstrap_chain.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use std::collections::BTreeMap;
2+
use std::net::{IpAddr, Ipv4Addr};
23

34
use cgp::core::error::CanRaiseAsyncError;
45
use hermes_cosmos_test_components::bootstrap::traits::chain::build_chain_driver::CanBuildChainDriver;
@@ -58,6 +59,10 @@ where
5859
.await
5960
.map_err(Bootstrap::raise_error)?;
6061

62+
// FIXME: RPC address is set to localhost and port is set to a random free port
63+
// The values should be configurable to connect to a specific node
64+
let rpc_addr = IpAddr::V4(Ipv4Addr::LOCALHOST);
65+
6166
let rpc_port = runtime
6267
.reserve_tcp_port()
6368
.await
@@ -74,7 +79,7 @@ where
7479
),
7580
};
7681

77-
let node_config = StarknetNodeConfig { rpc_port };
82+
let node_config = StarknetNodeConfig { rpc_addr, rpc_port };
7883

7984
let chain_process = bootstrap
8085
.start_chain_full_node(&chain_home_dir, &node_config, &genesis_config)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
use std::net::IpAddr;
2+
13
pub struct StarknetNodeConfig {
4+
pub rpc_addr: IpAddr,
25
pub rpc_port: u16,
36
}

0 commit comments

Comments
 (0)