tomusdrw / rust-web3

Ethereum JSON-RPC multi-transport client. Rust implementation of web3 library. ENS address: rust-web3.eth
MIT License
1.45k stars 465 forks source link

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

Open charb3l opened 1 year ago

charb3l commented 1 year ago

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 commented 11 months ago

@charb3l were you able to solve this?