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

Panic when constructing a dynamic transaction with invalid arguments #1880

Open
AlexD10S opened this issue Dec 9, 2024 · 1 comment
Open

Comments

@AlexD10S
Copy link

AlexD10S commented Dec 9, 2024

I encountered a panic! in the subxt library when attempting to construct a dynamic transaction call_data with invalid arguments.
The issue occurs in this specific line of codehttps://github.com/paritytech/subxt/blob/master/core/src/tx/payload.rs#L186

Error output:

The fields are valid types from the metadata, qed;: Error { context: Context { path: [Location { inner: Index(0) }] }, kind: WrongShape { actual: Number, expected_id: "13" } }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Steps to Reproduce

let arg = scale_value::stringify::from_str_custom()
				.add_custom_parser(custom_parsers::parse_hex)
				.add_custom_parser(custom_parsers::parse_ss58)
				.parse("123")
				.0?;
subxt::dynamic::tx("System", "remark", parsed_args);
let call_data = tx.encode_call_data(&client.metadata());

I should ensure proper validation of the requested arguments before constructing the transaction. However, if the provided arguments are invalid, it would be ideal for the encode_call_data function to throw a meaningful error instead of causing a panic.

@niklasad1
Copy link
Member

I should ensure proper validation of the requested arguments before constructing the transaction. However, if the provided arguments are invalid, it would be ideal for the encode_call_data function to throw a meaningful error instead of causing a panic.

Yes agree, it should be an easy fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants