-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tck): add AccountCreateTransaction
Signed-off-by: Ricky Saechao <[email protected]>
- Loading branch information
Showing
5 changed files
with
216 additions
and
3 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
use std::collections::HashMap; | ||
|
||
use serde::{Deserialize, Serialize}; | ||
use std::str::FromStr; | ||
|
||
#[derive(Debug, Clone)] | ||
#[derive(Serialize, Deserialize)] | ||
pub enum TransactionParamValue { | ||
String(String), | ||
I64(i64), | ||
Bool(bool), | ||
Array(Vec<String>), | ||
Map(HashMap<String, String>) | ||
} | ||
|
||
impl FromStr for TransactionParamValue { | ||
type Err = String; | ||
|
||
fn from_str(s: &str) -> Result<Self, Self::Err> { | ||
// Try parsing as i64 | ||
if let Ok(i) = s.parse::<i64>() { | ||
return Ok(TransactionParamValue::I64(i)); | ||
} | ||
|
||
// Try parsing as bool | ||
if let Ok(b) = s.parse::<bool>() { | ||
return Ok(TransactionParamValue::Bool(b)); | ||
} | ||
|
||
// Try parsing as JSON array | ||
if s.starts_with('[') && s.ends_with(']') { | ||
if let Ok(array) = serde_json::from_str::<Vec<String>>(s) { | ||
return Ok(TransactionParamValue::Array(array)); | ||
} | ||
} | ||
|
||
// Try parsing as JSON map | ||
if s.starts_with('{') && s.ends_with('}') { | ||
if let Ok(map) = serde_json::from_str::<HashMap<String, String>>(s) { | ||
return Ok(TransactionParamValue::Map(map)); | ||
} | ||
} | ||
|
||
// Default to String | ||
Ok(TransactionParamValue::String(s.to_string())) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters