Skip to content

Commit

Permalink
feat: remove support for custom settlement chain
Browse files Browse the repository at this point in the history
  • Loading branch information
kariy committed Jan 18, 2025
1 parent 57cfe1e commit 4361264
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 7 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions bin/katana/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ serde.workspace = true
shellexpand = "3.1.0"
spinoff.workspace = true
starknet.workspace = true
strum_macros.workspace = true
thiserror.workspace = true
tokio.workspace = true
toml.workspace = true
Expand All @@ -41,5 +42,6 @@ starknet.workspace = true
[features]
default = [ "jemalloc", "katana-cli/slot" ]

init-custom-settlement-chain = [ ]
jemalloc = [ ]
starknet-messaging = [ "katana-cli/starknet-messaging" ]
41 changes: 34 additions & 7 deletions bin/katana/src/cli/init/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::sync::Arc;

use anyhow::{Context, Result};
use clap::Args;
use inquire::{Confirm, CustomType, Text};
use inquire::{Confirm, CustomType, Select, Text};
use katana_primitives::{ContractAddress, Felt};
use serde::{Deserialize, Serialize};
use starknet::accounts::{ExecutionEncoding, SingleOwnerAccount};
Expand All @@ -19,6 +19,8 @@ use starknet::providers::{JsonRpcClient, Provider, Url};
use starknet::signers::{LocalWallet, SigningKey};
use tokio::runtime::Runtime;

const CARTRIDGE_SN_SEPOLIA_PROVIDER: &str = "https://api.cartridge.gg/x/starknet/sepolia";

#[derive(Debug)]
struct InitInput {
/// the account address that is used to send the transactions for contract
Expand Down Expand Up @@ -117,12 +119,37 @@ impl InitArgs {
fn prompt(&self, rt: &Runtime) -> Result<InitInput> {
let chain_id = Text::new("Id").prompt()?;

let url = CustomType::<Url>::new("Settlement RPC URL")
.with_default(Url::parse("http://localhost:5050")?)
.with_error_message("Please enter a valid URL")
.prompt()?;
#[derive(Debug, strum_macros::Display)]

Check warning on line 122 in bin/katana/src/cli/init/mod.rs

View check run for this annotation

Codecov / codecov/patch

bin/katana/src/cli/init/mod.rs#L122

Added line #L122 was not covered by tests
enum SettlementChainOpt {
Sepolia,
#[cfg(feature = "init-custom-settlement-chain")]
Custom,
}

// Right now we only support settling on Starknet Sepolia because we're limited to what
// network the Atlantic service could settle the proofs to. Supporting a custom
// network here (eg local devnet) would require that the proving service we're using
// be able to settle the proofs there.
let network_opts = vec![
SettlementChainOpt::Sepolia,
#[cfg(feature = "init-custom-settlement-chain")]
SettlementChainOpt::Custom,
];

Check warning on line 137 in bin/katana/src/cli/init/mod.rs

View check run for this annotation

Codecov / codecov/patch

bin/katana/src/cli/init/mod.rs#L133-L137

Added lines #L133 - L137 were not covered by tests

let network_type = Select::new("Select settlement chain", network_opts).prompt()?;

Check warning on line 139 in bin/katana/src/cli/init/mod.rs

View check run for this annotation

Codecov / codecov/patch

bin/katana/src/cli/init/mod.rs#L139

Added line #L139 was not covered by tests

let settlement_url = match network_type {
SettlementChainOpt::Sepolia => Url::parse(CARTRIDGE_SN_SEPOLIA_PROVIDER)?,

Check warning on line 142 in bin/katana/src/cli/init/mod.rs

View check run for this annotation

Codecov / codecov/patch

bin/katana/src/cli/init/mod.rs#L141-L142

Added lines #L141 - L142 were not covered by tests

// Useful for testing the program flow without having to run it against actual network.
#[cfg(feature = "init-custom-settlement-chain")]
SettlementChainOpt::Custom => CustomType::<Url>::new("Settlement RPC URL")
.with_default(Url::parse("http://localhost:5050")?)
.with_error_message("Please enter a valid URL")
.prompt()?,

Check warning on line 149 in bin/katana/src/cli/init/mod.rs

View check run for this annotation

Codecov / codecov/patch

bin/katana/src/cli/init/mod.rs#L146-L149

Added lines #L146 - L149 were not covered by tests
};

let l1_provider = Arc::new(JsonRpcClient::new(HttpTransport::new(url.clone())));
let l1_provider = Arc::new(JsonRpcClient::new(HttpTransport::new(settlement_url.clone())));

Check warning on line 152 in bin/katana/src/cli/init/mod.rs

View check run for this annotation

Codecov / codecov/patch

bin/katana/src/cli/init/mod.rs#L152

Added line #L152 was not covered by tests

let contract_exist_parser = &|input: &str| {
let block_id = BlockId::Tag(BlockTag::Pending);
Expand Down Expand Up @@ -192,7 +219,7 @@ impl InitArgs {
settlement_id: parse_cairo_short_string(&l1_chain_id)?,
id: chain_id,
fee_token,
rpc_url: url,
rpc_url: settlement_url,

Check warning on line 222 in bin/katana/src/cli/init/mod.rs

View check run for this annotation

Codecov / codecov/patch

bin/katana/src/cli/init/mod.rs#L222

Added line #L222 was not covered by tests
output_path,
})
}
Expand Down

0 comments on commit 4361264

Please sign in to comment.