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

More examples. #982

Closed
twhiteheadzm opened this issue May 28, 2023 · 4 comments
Closed

More examples. #982

twhiteheadzm opened this issue May 28, 2023 · 4 comments

Comments

@twhiteheadzm
Copy link

I am really struggling to figure out how to create dynamic calls with parameters more complicated than simple types. For example I need to create a call whose second parameter is a vec of structs (I initially had it as a vec of tuples but couldn't get that working either).
The same call works fine if I use the auto generated call based on the metadata, but I cannot use that method as I then need to pass the call as a parameter (proposal)

@lexnv
Copy link
Contributor

lexnv commented May 29, 2023

Hi, it seems that encoding did not work properly for me either.

This seems to be an edge-case of scale-value where we recurse too deeply into the value types, basically flattening the values from nested sequences.

I've created an initial fix to validate the following behavior, in paritytech/scale-value#31:

    #[test]
    fn can_encode_vec_tuples() {
        // Presume we have a type: Vec<(u8, u16)>.
        let vec_tuple = Value::unnamed_composite(vec![Value::unnamed_composite(vec![
            Value::u128(20u8.into()),
            Value::u128(30u16.into()),
        ])]);

        assert_can_encode_to_type(vec_tuple, vec![(20u8, 30u16)]);
    }

@jsdw
Copy link
Collaborator

jsdw commented May 30, 2023

@twhiteheadzm sorry for your frustration here; we did identify a bug in scale-value which you ran into here, and the proposed fix should ensure that in the future, Values that mirror the structure you're encoding to should always work as expected :)

The next subxt release will also come with a new and much more comprehensive guide which I hope will be of some help; dynamic values are covered much more in general than they were previously.

@jsdw
Copy link
Collaborator

jsdw commented May 30, 2023

scale-value 0.8.1 is now published, so updating dependencies to brign in this new patch release will hopefully fix things for you. I'll close this for now based on that (and the upcoming docs) but pelase re-open or open a new issue if you have any more issues here!

@jsdw jsdw closed this as completed May 30, 2023
@twhiteheadzm
Copy link
Author

@jsdw Thank you, greatly appreciated.

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

3 participants