Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(template): add full typename to invalid argument error #1226

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion dan_layer/engine/tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,8 @@ mod errors {
match result.finalize.result.full_reject().unwrap() {
RejectReason::ExecutionFailure(message) => {
assert!(message.starts_with(
"Panic! failed to decode argument at position 0 for function 'please_pass_invalid_args':"
"Panic! failed to decode argument at position 0 (tari_template_lib::models::amount::Amount) for \
function 'please_pass_invalid_args':"
),);
},
reason => panic!("Unexpected failure reason: {}", reason),
Expand Down
22 changes: 20 additions & 2 deletions dan_layer/template_abi/src/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ mod no_std {
extern crate alloc;

pub use alloc::{boxed, format, str, string, vec};
pub use core::{cmp, fmt, iter, mem, num, ops, ptr, slice, write, writeln};
pub use core::{any, cmp, fmt, iter, mem, num, ops, ptr, slice, write, writeln};

pub mod collections {
extern crate alloc;
Expand All @@ -41,7 +41,25 @@ pub use no_std::*;

#[cfg(feature = "std")]
mod rust_std {
pub use ::std::{boxed, cmp, fmt, format, io, iter, mem, num, ops, ptr, slice, str, string, vec, write, writeln};
pub use ::std::{
any,
boxed,
cmp,
fmt,
format,
io,
iter,
mem,
num,
ops,
ptr,
slice,
str,
string,
vec,
write,
writeln,
};

pub mod collections {
pub use ::std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
Expand Down
2 changes: 1 addition & 1 deletion dan_layer/template_lib/src/template_dependencies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
//! Public types that are available to internal template code.

pub use tari_bor::{decode, decode_exact, encode_with_len, from_value, serde};
pub use tari_template_abi::{wrap_ptr, CallInfo};
pub use tari_template_abi::{rust, wrap_ptr, CallInfo};

pub use crate::{args::LogLevel, debug, engine, get_context as context, init_context, panic_hook::register_panic_hook};
2 changes: 1 addition & 1 deletion dan_layer/template_macros/src/template/dispatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ fn get_function_block(template_ident: &Ident, ast: FunctionAst) -> Expr {
args.push(parse_quote! { #arg_ident });
stmts.push(parse_quote! {
let #arg_ident = from_value::<#type_path>(&call_info.args[#i])
.unwrap_or_else(|e| panic!("failed to decode argument at position {} for function '{}': {}", #i, #func_name, e));
.unwrap_or_else(|e| panic!("failed to decode argument at position {} ({}) for function '{}': {}", #i, rust::any::type_name::<#type_path>(), #func_name, e));
})
},
TypeAst::Tuple { type_tuple, .. } => {
Expand Down
Loading