Skip to content

Commit ef6f7d2

Browse files
committed
improve ux
Signed-off-by: Sam Batschelet <[email protected]>
1 parent bd42bdf commit ef6f7d2

File tree

4 files changed

+15
-20
lines changed

4 files changed

+15
-20
lines changed

spaces-cli/src/bin/spaces-cli/main.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ fn main() -> Result<(), Box<dyn error::Error>> {
8484
/// Takes a TX command and returns transaction data.
8585
fn command_to_tx(command: Command) -> std::io::Result<TransactionData> {
8686
match command {
87-
Command::Claim { space } => Ok(claim_tx(space)),
88-
Command::Set { space, key, value } => Ok(set_tx(space, key, value.as_bytes().to_vec())),
89-
Command::Delete { space, key } => Ok(delete_tx(space, key)),
87+
Command::Claim { space } => Ok(claim_tx(&space)),
88+
Command::Set { space, key, value } => Ok(set_tx(&space, &key, &value)),
89+
Command::Delete { space, key } => Ok(delete_tx(&space, &key)),
9090
_ => Err(std::io::Error::new(
9191
std::io::ErrorKind::Other,
9292
"not a supported tx",

spacesvm/src/api/client.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -177,29 +177,29 @@ impl Client<HttpConnector> {
177177
}
178178
}
179179

180-
pub fn claim_tx(space: String) -> TransactionData {
180+
pub fn claim_tx(space: &str) -> TransactionData {
181181
TransactionData {
182182
typ: TransactionType::Claim,
183-
space,
183+
space: space.to_owned(),
184184
key: String::new(),
185185
value: vec![],
186186
}
187187
}
188188

189-
pub fn set_tx(space: String, key: String, value: Vec<u8>) -> TransactionData {
189+
pub fn set_tx(space: &str, key: &str, value: &str) -> TransactionData {
190190
TransactionData {
191191
typ: TransactionType::Set,
192-
space,
193-
key,
194-
value,
192+
space: space.to_owned(),
193+
key: key.to_owned(),
194+
value: value.as_bytes().to_vec(),
195195
}
196196
}
197197

198-
pub fn delete_tx(space: String, key: String) -> TransactionData {
198+
pub fn delete_tx(space: &str, key: &str) -> TransactionData {
199199
TransactionData {
200200
typ: TransactionType::Delete,
201-
space,
202-
key,
201+
space: space.to_owned(),
202+
key: key.to_owned(),
203203
value: vec![],
204204
}
205205
}

spacesvm/tests/vm/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ async fn test_api() {
138138
let body = std::str::from_utf8(&resp.body()).unwrap();
139139
log::info!("ping response {}", body);
140140

141-
let tx_data = claim_tx("test_claim".to_owned());
141+
let tx_data = claim_tx("test_claim");
142142
let arg_value = serde_json::to_value(&DecodeTxArgs { tx_data }).unwrap();
143143

144144
let (_id, json_str) = client.raw_request("decodeTx", &Params::Array(vec![arg_value]));

tests/e2e/src/tests/mod.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@ use avalanche_network_runner_sdk::{BlockchainSpec, Client, GlobalConfig, StartRe
99
use avalanche_types::subnet;
1010
use spacesvm::{
1111
self,
12-
api::{
13-
client::{claim_tx, get_or_create_pk, Uri},
14-
DecodeTxArgs,
15-
},
12+
api::client::{claim_tx, get_or_create_pk, Uri},
1613
};
1714

1815
#[tokio::test]
@@ -199,9 +196,7 @@ async fn e2e() {
199196

200197
log::info!("decode claim tx request...");
201198
let resp = scli
202-
.decode_tx(DecodeTxArgs {
203-
tx_data: claim_tx("test".to_owned()),
204-
})
199+
.decode_tx(claim_tx("test"))
205200
.await
206201
.expect("decodeTx success");
207202
log::info!("decode claim response from {}: {:?}", ep, resp);

0 commit comments

Comments
 (0)