Skip to content

Commit

Permalink
chore(CLI): not use the formatted string for return values (#29)
Browse files Browse the repository at this point in the history
* chore(CLI): not use the formatted string for return values

* fmt
  • Loading branch information
Poytr1 authored Nov 27, 2022
1 parent c331c29 commit 95bb2a2
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "view-function"
license = "Apache-2.0"
version = "0.1.0"
version = "0.4.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
2 changes: 1 addition & 1 deletion app/client/src/views/HomeView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ export default defineComponent({
this.result = JSON.stringify(result.details, null, 2);
} else {
this.error = '';
this.result = JSON.stringify(result.details, null, 2);
this.result = result.details.return_values.join('\n');
}
this.isShow = true;
});
Expand Down
10 changes: 5 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ fn exec_func_internal(
function: &IdentStr,
type_args: Vec<TypeTag>,
args: Vec<Vec<u8>>,
) -> Option<Vec<String>> {
) -> Option<Vec<MoveValue>> {
let natives = natives::aptos_natives(
NativeGasParameters::zeros(),
AbstractValueSizeGasParameters::zeros(),
Expand Down Expand Up @@ -227,16 +227,16 @@ fn exec_func_internal(
);
match res {
Ok(success_result) => {
let pretty_print_values: Vec<String> = success_result
let move_values: Vec<MoveValue> = success_result
.return_values
.clone()
.into_iter()
.map(|v| {
let deserialized_value = MoveValue::simple_deserialize(&*v.0, &v.1).unwrap();
format!("{}", deserialized_value)
deserialized_value
})
.collect();
return Some(pretty_print_values);
return Some(move_values);
}
Err(err) => {
panic!("Error while executing the function! {}", err.to_string())
Expand Down Expand Up @@ -279,7 +279,7 @@ mod tests {
#[cfg(test)]
#[ctor::ctor]
fn init() {
SimpleLogger::init(LevelFilter::Info, Config::default()).unwrap();
SimpleLogger::init(LevelFilter::Debug, Config::default()).unwrap();
}

#[test]
Expand Down
5 changes: 3 additions & 2 deletions src/types.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use clap::{command, Parser, ValueEnum};
use move_core_types::value::MoveValue;
use serde::{Deserialize, Serialize};
use std::fmt::{Display, Formatter};

#[derive(Serialize, Deserialize, Debug)]
#[derive(Serialize, Debug)]
pub struct ExecutionResult {
pub(crate) log_path: String,
pub(crate) return_values: Vec<String>,
pub(crate) return_values: Vec<MoveValue>,
}

#[derive(ValueEnum, Deserialize, Eq, PartialEq, Hash, Clone, Copy, Debug)]
Expand Down

0 comments on commit 95bb2a2

Please sign in to comment.