diff --git a/cmd/crates/soroban-rpc/src/lib.rs b/cmd/crates/soroban-rpc/src/lib.rs index cf309c6927..623e180865 100644 --- a/cmd/crates/soroban-rpc/src/lib.rs +++ b/cmd/crates/soroban-rpc/src/lib.rs @@ -404,7 +404,7 @@ pub struct Event { #[serde(rename = "type")] pub event_type: String, - pub ledger: String, + pub ledger: u32, #[serde(rename = "ledgerClosedAt")] pub ledger_closed_at: String, @@ -892,7 +892,7 @@ soroban config identity fund {address} --helper-url "# let mut oparams = ObjectParams::new(); match start { - EventStart::Ledger(l) => oparams.insert("startLedger", l.to_string())?, + EventStart::Ledger(l) => oparams.insert("startLedger", l)?, EventStart::Cursor(c) => { pagination.insert("cursor".to_string(), c.into()); } diff --git a/cmd/crates/soroban-spec-tools/src/contract.rs b/cmd/crates/soroban-spec-tools/src/contract.rs index 9292583040..7543b5462c 100644 --- a/cmd/crates/soroban-spec-tools/src/contract.rs +++ b/cmd/crates/soroban-spec-tools/src/contract.rs @@ -157,12 +157,12 @@ impl Display for Contract { } fn write_func(f: &mut std::fmt::Formatter<'_>, func: &ScSpecFunctionV0) -> std::fmt::Result { - writeln!(f, " • Function: {}", func.name.to_string_lossy())?; + writeln!(f, " • Function: {}", func.name.to_utf8_string_lossy())?; if func.doc.len() > 0 { writeln!( f, " Docs: {}", - &indent(&func.doc.to_string_lossy(), 11).trim() + &indent(&func.doc.to_utf8_string_lossy(), 11).trim() )?; } writeln!( @@ -185,7 +185,7 @@ fn write_union(f: &mut std::fmt::Formatter<'_>, udt: &ScSpecUdtUnionV0) -> std:: writeln!( f, " Docs: {}", - indent(&udt.doc.to_string_lossy(), 10).trim() + indent(&udt.doc.to_utf8_string_lossy(), 10).trim() )?; } writeln!(f, " Cases:")?; @@ -202,7 +202,7 @@ fn write_struct(f: &mut std::fmt::Formatter<'_>, udt: &ScSpecUdtStructV0) -> std writeln!( f, " Docs: {}", - indent(&udt.doc.to_string_lossy(), 10).trim() + indent(&udt.doc.to_utf8_string_lossy(), 10).trim() )?; } writeln!(f, " Fields:")?; @@ -210,7 +210,7 @@ fn write_struct(f: &mut std::fmt::Formatter<'_>, udt: &ScSpecUdtStructV0) -> std writeln!( f, " • {}: {}", - field.name.to_string_lossy(), + field.name.to_utf8_string_lossy(), indent(&format!("{:#?}", field.type_), 8).trim() )?; if field.doc.len() > 0 { @@ -227,7 +227,7 @@ fn write_enum(f: &mut std::fmt::Formatter<'_>, udt: &ScSpecUdtEnumV0) -> std::fm writeln!( f, " Docs: {}", - indent(&udt.doc.to_string_lossy(), 10).trim() + indent(&udt.doc.to_utf8_string_lossy(), 10).trim() )?; } writeln!(f, " Cases:")?; @@ -244,7 +244,7 @@ fn write_error(f: &mut std::fmt::Formatter<'_>, udt: &ScSpecUdtErrorEnumV0) -> s writeln!( f, " Docs: {}", - indent(&udt.doc.to_string_lossy(), 10).trim() + indent(&udt.doc.to_utf8_string_lossy(), 10).trim() )?; } writeln!(f, " Cases:")?; @@ -265,8 +265,8 @@ fn indent(s: &str, n: usize) -> String { fn format_name(lib: &StringM<80>, name: &StringM<60>) -> String { if lib.len() > 0 { - format!("{}::{}", lib.to_string_lossy(), name.to_string_lossy()) + format!("{}::{}", lib.to_utf8_string_lossy(), name.to_utf8_string_lossy()) } else { - name.to_string_lossy() + name.to_utf8_string_lossy() } } diff --git a/cmd/soroban-cli/src/lib.rs b/cmd/soroban-cli/src/lib.rs index 311ac43a19..5e7c42f00a 100644 --- a/cmd/soroban-cli/src/lib.rs +++ b/cmd/soroban-cli/src/lib.rs @@ -7,7 +7,6 @@ pub mod commands; pub mod fee; pub mod key; pub mod log; -// pub mod rpc; pub mod toid; pub mod utils; pub mod wasm; diff --git a/cmd/soroban-cli/src/rpc/fixtures/event_response.json b/cmd/soroban-cli/src/rpc/fixtures/event_response.json deleted file mode 100644 index 6f520fdfd5..0000000000 --- a/cmd/soroban-cli/src/rpc/fixtures/event_response.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "events": [{ - "eventType": "system", - "ledger": "43601283", - "ledgerClosedAt": "2022-11-16T16:10:41Z", - "contractId": "CDR6QKTWZQYW6YUJ7UP7XXZRLWQPFRV6SWBLQS4ZQOSAF4BOUD77OO5Z", - "id": "0164090849041387521-0000000003", - "pagingToken": "164090849041387521-3", - "topic": [ - "AAAABQAAAAh0cmFuc2Zlcg==", - "AAAAAQB6Mcc=" - ], - "value": "AAAABQAAAApHaWJNb255UGxzAAA=" - }, { - "eventType": "contract", - "ledger": "43601284", - "ledgerClosedAt": "2022-11-16T16:10:41Z", - "contractId": "CDR6QKTWZQYW6YUJ7UP7XXZRLWQPFRV6SWBLQS4ZQOSAF4BOUD77OO5Z", - "id": "0164090849041387521-0000000003", - "pagingToken": "164090849041387521-3", - "topic": [ - "AAAABQAAAAh0cmFuc2Zlcg==", - "AAAAAQB6Mcc=" - ], - "value": "AAAABQAAAApHaWJNb255UGxzAAA=" - }, { - "eventType": "system", - "ledger": "43601285", - "ledgerClosedAt": "2022-11-16T16:10:41Z", - "contractId": "CCR6QKTWZQYW6YUJ7UP7XXZRLWQPFRV6SWBLQS4ZQOSAF4BOUD77OTE2", - "id": "0164090849041387521-0000000003", - "pagingToken": "164090849041387521-3", - "topic": [ - "AAAABQAAAAh0cmFuc2Zlcg==", - "AAAAAQB6Mcc=" - ], - "value": "AAAABQAAAApHaWJNb255UGxzAAA=" - }] -} \ No newline at end of file diff --git a/cmd/soroban-cli/src/rpc/txn/finished.rs b/cmd/soroban-cli/src/rpc/txn/finished.rs deleted file mode 100644 index 0e29be14cb..0000000000 --- a/cmd/soroban-cli/src/rpc/txn/finished.rs +++ /dev/null @@ -1,74 +0,0 @@ -use soroban_env_host::xdr::{self, ContractEventType, DiagnosticEvent, ScVal}; - -use super::Error; -use crate::rpc::{extract_events, GetTransactionResponse, SimulateTransactionResponse}; - -pub enum Kind { - Simulated(SimulateTransactionResponse), - Signed(GetTransactionResponse), -} - -pub struct Finished { - txn_res: Kind, -} - -impl Finished { - pub fn simulated(txn_res: SimulateTransactionResponse) -> Self { - Self { - txn_res: Kind::Simulated(txn_res), - } - } - - pub fn signed(txn_res: GetTransactionResponse) -> Self { - Self { - txn_res: Kind::Signed(txn_res), - } - } - - pub fn return_value(&self) -> Result { - match &self.txn_res { - Kind::Simulated(sim_res) => Ok(sim_res - .results()? - .get(0) - .ok_or(Error::MissingOp)? - .xdr - .clone()), - Kind::Signed(GetTransactionResponse { - result_meta: - Some(xdr::TransactionMeta::V3(xdr::TransactionMetaV3 { - soroban_meta: Some(xdr::SorobanTransactionMeta { return_value, .. }), - .. - })), - .. - }) => Ok(return_value.clone()), - Kind::Signed(_) => Err(Error::MissingOp), - } - } - - pub fn events(&self) -> Result, Error> { - match &self.txn_res { - Kind::Simulated(sim_res) => sim_res.events(), - Kind::Signed(GetTransactionResponse { - result_meta: Some(meta), - .. - }) => Ok(extract_events(meta)), - Kind::Signed(_) => Err(Error::MissingOp), - } - } - - pub fn contract_events(&self) -> Result, Error> { - Ok(self - .events()? - .into_iter() - .filter(|e| matches!(e.event.type_, ContractEventType::Contract)) - .collect::>()) - } - - pub fn as_signed(&self) -> Result<&GetTransactionResponse, Error> { - if let Kind::Signed(res) = &self.txn_res { - Ok(res) - } else { - Err(Error::NotSignedTransaction) - } - } -}