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

Cannot use query for complex return data (nested tuples) #680

Open
charb3l opened this issue Jan 20, 2023 · 1 comment
Open

Cannot use query for complex return data (nested tuples) #680

charb3l opened this issue Jan 20, 2023 · 1 comment

Comments

@charb3l
Copy link

charb3l commented Jan 20, 2023

example query:

let query_result : (U256)= my_contract.query("function", (), None, Options::default(), None).await.unwrap();

error:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: InvalidOutputType("Expected `U256`, got Tuple([Uint(1000000140856), Tuple([Uint(1673923700), Uint(1674010100), Uint(2000000018306), Uint(1000000092215), Uint(0), Uint(6)]), Tuple([Uint(236384871824846926185638121917731175518273516860303563044477647242592644), Uint(167534655691853844631300442264200498166105435679304635417750901130100802), Uint(0), Bool(false), Uint(4), Uint(1914), Uint(878), Uint(3), Uint(0), Uint(2)]), Tuple([Uint(0), Uint(0), Uint(0), Uint(1), Uint(0), Address(0x0000000000000000000000000000000000000000), Uint(0), Uint(0)]), Tuple([Uint(13), Uint(5), Uint(5), Uint(7), Uint(7), Uint(9), Uint(8), Uint(8), Uint(150), Uint(25), Uint(25)]), Tuple([Uint(7500), Uint(2000), Uint(2200), Uint(3500), Uint(5000), Uint(6500), Uint(6500), Uint(7000), Uint(1500), Uint(4000), Uint(4500), Uint(5000), Uint(3500), Uint(1500)]), Tuple([Uint(1375), Uint(625), Uint(1275), Uint(1625), Uint(1750), Uint(1250), Uint(1125), Uint(1375), Uint(625), Uint(1250), Uint(625), Uint(750), Uint(1000), Uint(750)]), Tuple([Uint(0), Uint(0), Uint(0), Uint(0)])])")', src\main.rs:97:109

Painstakingly reconstructing this typing and setting it instead of the initial (U256) give this error:

error[E0277]: the trait bound `(U256, (U256, U256, U256, U256, U256, U256), (U256, U256, U256, U256, U256, U256, U256, U256, U256, U256), (U256, U256, U256, U256, U256, H160, U256, U256), (U256, U256, U256, U256, U256, U256, U256, U256, U256, U256, U256), (U256, U256, U256, U256, U256, U256, U256, U256, U256, U256, U256, U256, U256, U256), (U256, U256, U256, U256, U256, U256, U256, U256, U256, U256, U256, U256, U256, U256), (U256, U256, U256, U256)): Detokenize` is not satisfied
   --> src\main.rs:97:462
    |
97  | ...6, U256), (U256, U256, U256, U256))= my_contract.query("function", (), None, Options::default(), None).await.unwrap();
    |                                                       ^^^^^ the trait `Detokenize` is not implemented for `(U256, (U256, U256, U256, U256, U256, U256), (U256, U256, U256, U256, U256, U256, U256, U256, U256, U256), (U256, U256, U256, U256, U256, H160, U256, U256), (U256, U256, U256, U256, U256, U256, U256, U256, U256, U256, U256), (U256, U256, U256, U256, U256, U256, U256, U256, U256, U256, U256, U256, U256, U256), (U256, U256, U256, U256, U256, U256, U256, U256, U256, U256, U256, U256, U256, U256), (U256, U256, U256, U256))`
    |
    = help: the following other types implement trait `Detokenize`:
              (A, B)
              (A, B, C)
              (A, B, C, D)
              (A, B, C, D, E)
              (A, B, C, D, E, F)
              (A, B, C, D, E, F, G)
              (A, B, C, D, E, F, G, H)
              (A, B, C, D, E, F, G, H, I)
            and 8 others
note: required by a bound in `web3::contract::Contract::<T>::query`
@SharksT
Copy link

SharksT commented Sep 29, 2023

@charb3l were you able to solve this?

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