Skip to content

Commit 5d07aec

Browse files
committed
feat: Enable TLS on tonic
1 parent fc2075e commit 5d07aec

File tree

14 files changed

+188
-31
lines changed

14 files changed

+188
-31
lines changed

Cargo.lock

Lines changed: 147 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bin/miden-cli/src/commands/init.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ impl Network {
3838
pub fn to_rpc_endpoint(&self) -> String {
3939
match self {
4040
Network::Custom(custom) => custom.clone(),
41-
Network::Devnet => "https://rpc.devnet.miden.io".to_string(),
41+
Network::Devnet => Endpoint::devnet().to_string(),
4242
Network::Localhost => Endpoint::default().to_string(),
43-
Network::Testnet => "https://rpc.testnet.miden.io".to_string(),
43+
Network::Testnet => Endpoint::testnet().to_string(),
4444
}
4545
}
4646
}

crates/rust-client/Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,27 @@ idxdb = ["dep:base64", "dep:serde-wasm-bindgen", "dep:wasm-bindgen", "dep:wasm-b
2222
sqlite = ["dep:rusqlite", "dep:deadpool-sqlite", "std"]
2323
std = ["miden-objects/std"]
2424
testing = ["miden-objects/testing", "miden-lib/testing", "miden-tx/testing"]
25-
tonic = ["dep:hex", "dep:prost", "dep:tonic", "std", "tonic/transport"]
26-
web-tonic = ["dep:hex", "dep:prost", "dep:tonic", "dep:tonic-web-wasm-client"]
25+
tonic = ["std", "tonic/transport", "tonic/tls", "tonic/tls-native-roots"]
26+
web-tonic = ["dep:tonic-web-wasm-client"]
2727

2828
[dependencies]
2929
async-trait = { workspace = true }
3030
base64 = { version = "0.22", optional = true }
3131
chrono = { version = "0.4", optional = false }
3232
deadpool-sqlite = { version = "0.9", features = ["rt_tokio_1"], optional = true }
33-
hex = { version = "0.4", optional = true }
33+
hex = { version = "0.4" }
3434
miden-lib = { workspace = true }
3535
miden-objects = { workspace = true }
3636
miden-tx = { workspace = true, features = ["async"] }
3737
pollster = { version = "0.4" }
38-
prost = { version = "0.13", optional = true, default-features = false, features = ["derive"] }
38+
prost = { version = "0.13", default-features = false, features = ["derive"] }
3939
rand = { workspace = true }
4040
rusqlite = { version = "0.32", features = ["vtab", "array", "bundled"], optional = true }
4141
serde = { workspace = true, optional = true }
4242
serde-wasm-bindgen = { version = "0.6", optional = true }
4343
thiserror = { workspace = true }
4444
tokio = { workspace = true, optional = true }
45-
tonic = { version = "0.12", default-features = false, optional = true, features = ["prost", "codegen"] }
45+
tonic = { version = "0.12", default-features = false, features = ["prost", "codegen"] }
4646
tonic-web-wasm-client = { version = "0.6", optional = true, default-features = false }
4747
tracing = { workspace = true }
4848
wasm-bindgen = { version = "0.2", features = ["serde-serialize"], optional = true }

crates/rust-client/src/rpc/endpoint.rs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,21 @@ impl Endpoint {
3232
Self { protocol, host, port }
3333
}
3434

35+
/// Returns the [Endpoint] associated with the testnet network.
36+
pub fn testnet() -> Self {
37+
Self::new("https".into(), "rpc.testnet.miden.io".into(), None)
38+
}
39+
40+
/// Returns the [Endpoint] associated with the devnet network.
41+
pub fn devnet() -> Self {
42+
Self::new("https".into(), "rpc.devnet.miden.io".into(), None)
43+
}
44+
45+
/// Returns the [Endpoint] associated with the devnet network.
46+
pub fn localhost() -> Self {
47+
Self::new("https".into(), "localhost".into(), Some(Self::MIDEN_NODE_PORT))
48+
}
49+
3550
pub fn protocol(&self) -> &str {
3651
&self.protocol
3752
}
@@ -56,11 +71,7 @@ impl fmt::Display for Endpoint {
5671

5772
impl Default for Endpoint {
5873
fn default() -> Self {
59-
Self {
60-
protocol: "http".to_string(),
61-
host: "localhost".to_string(),
62-
port: Some(Self::MIDEN_NODE_PORT),
63-
}
74+
Self::localhost()
6475
}
6576
}
6677

crates/rust-client/src/rpc/generated/nostd/account.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#[prost(skip_debug)]
88
pub struct AccountId {
99
/// 15 bytes (120 bits) encoded using \[winter_utils::Serializable\] implementation for
10-
/// \[miden_objects::accounts::account_id::AccountId\].
10+
/// \[miden_objects::account::account_id::AccountId\].
1111
#[prost(bytes = "vec", tag = "1")]
1212
pub id: ::prost::alloc::vec::Vec<u8>,
1313
}
@@ -31,7 +31,7 @@ pub struct AccountInfo {
3131
#[prost(message, optional, tag = "1")]
3232
pub summary: ::core::option::Option<AccountSummary>,
3333
/// Account details encoded using \[winter_utils::Serializable\] implementation for
34-
/// \[miden_objects::accounts::Account\].
34+
/// \[miden_objects::account::Account\].
3535
#[prost(bytes = "vec", optional, tag = "2")]
3636
pub details: ::core::option::Option<::prost::alloc::vec::Vec<u8>>,
3737
}

crates/rust-client/src/rpc/generated/nostd/note.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ pub struct NoteMetadata {
1010
pub note_type: u32,
1111
/// A value which can be used by the recipient(s) to identify notes intended for them.
1212
///
13-
/// See `miden_objects::notes::note_tag` for more info.
13+
/// See `miden_objects::note::note_tag` for more info.
1414
#[prost(fixed32, tag = "3")]
1515
pub tag: u32,
1616
/// Specifies when a note is ready to be consumed.
1717
///
18-
/// See `miden_objects::notes::execution_hint` for more info.
18+
/// See `miden_objects::note::execution_hint` for more info.
1919
#[prost(fixed64, tag = "4")]
2020
pub execution_hint: u64,
2121
/// An arbitrary user-defined value.

crates/rust-client/src/rpc/generated/nostd/responses.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ pub struct GetBlockByNumberResponse {
204204
#[derive(Clone, PartialEq, ::prost::Message)]
205205
pub struct GetAccountStateDeltaResponse {
206206
/// The calculated account delta encoded using \[winter_utils::Serializable\] implementation
207-
/// for \[miden_objects::accounts::delta::AccountDelta\].
207+
/// for \[miden_objects::account::delta::AccountDelta\].
208208
#[prost(bytes = "vec", optional, tag = "1")]
209209
pub delta: ::core::option::Option<::prost::alloc::vec::Vec<u8>>,
210210
}

crates/rust-client/src/rpc/generated/std/account.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#[prost(skip_debug)]
88
pub struct AccountId {
99
/// 15 bytes (120 bits) encoded using \[winter_utils::Serializable\] implementation for
10-
/// \[miden_objects::accounts::account_id::AccountId\].
10+
/// \[miden_objects::account::account_id::AccountId\].
1111
#[prost(bytes = "vec", tag = "1")]
1212
pub id: ::prost::alloc::vec::Vec<u8>,
1313
}
@@ -31,7 +31,7 @@ pub struct AccountInfo {
3131
#[prost(message, optional, tag = "1")]
3232
pub summary: ::core::option::Option<AccountSummary>,
3333
/// Account details encoded using \[winter_utils::Serializable\] implementation for
34-
/// \[miden_objects::accounts::Account\].
34+
/// \[miden_objects::account::Account\].
3535
#[prost(bytes = "vec", optional, tag = "2")]
3636
pub details: ::core::option::Option<::prost::alloc::vec::Vec<u8>>,
3737
}

crates/rust-client/src/rpc/generated/std/note.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ pub struct NoteMetadata {
1010
pub note_type: u32,
1111
/// A value which can be used by the recipient(s) to identify notes intended for them.
1212
///
13-
/// See `miden_objects::notes::note_tag` for more info.
13+
/// See `miden_objects::note::note_tag` for more info.
1414
#[prost(fixed32, tag = "3")]
1515
pub tag: u32,
1616
/// Specifies when a note is ready to be consumed.
1717
///
18-
/// See `miden_objects::notes::execution_hint` for more info.
18+
/// See `miden_objects::note::execution_hint` for more info.
1919
#[prost(fixed64, tag = "4")]
2020
pub execution_hint: u64,
2121
/// An arbitrary user-defined value.

crates/rust-client/src/rpc/generated/std/responses.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ pub struct GetBlockByNumberResponse {
204204
#[derive(Clone, PartialEq, ::prost::Message)]
205205
pub struct GetAccountStateDeltaResponse {
206206
/// The calculated account delta encoded using \[winter_utils::Serializable\] implementation
207-
/// for \[miden_objects::accounts::delta::AccountDelta\].
207+
/// for \[miden_objects::account::delta::AccountDelta\].
208208
#[prost(bytes = "vec", optional, tag = "1")]
209209
pub delta: ::core::option::Option<::prost::alloc::vec::Vec<u8>>,
210210
}

0 commit comments

Comments
 (0)