Skip to content

Commit

Permalink
chore: clean up unwrap call
Browse files Browse the repository at this point in the history
  • Loading branch information
chadoh committed Mar 22, 2024
1 parent 201d5d6 commit 43e38e5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 20 deletions.

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

33 changes: 17 additions & 16 deletions cmd/crates/soroban-spec-typescript/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,28 +105,29 @@ pub fn generate(spec: &[ScSpecEntry]) -> String {
}

fn doc_to_ts_doc(doc: &str, method: Option<&str>) -> String {
if method.is_none() {
if doc.is_empty() {
return String::new();
}
let doc = doc.split('\n').join("\n * ");
if let Some(method) = method {
let doc = if doc.is_empty() {
String::new()
} else {
format!(" *\n * {}", doc.split('\n').join("\n * "))
};
return format!(
r#"/**
* {doc}
*/
"#
* Construct and simulate a {method} transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.{doc}
*/"#
);
}
let method = method.unwrap();
let doc = if doc.is_empty() {
String::new()
} else {
format!(" *\n * {}", doc.split('\n').join("\n * "))
};

if doc.is_empty() {
return String::new();
}

let doc = doc.split('\n').join("\n * ");
format!(
r#"/**
* Construct and simulate a {method} transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object.{doc}
*/"#
* {doc}
*/
"#
)
}

Expand Down

0 comments on commit 43e38e5

Please sign in to comment.