GenesysGo / shadow-drive-rust

Apache License 2.0
21 stars 13 forks source link

ShdwDriveResponse causes parsing errors #19

Open dboures opened 2 years ago

dboures commented 2 years ago

While testing the add_immutable_storage method, I noticed that the parsing of ShdwDriveResponse was causing Rust to panic. For example: ReqwestError(reqwest::Error { kind: Decode, source: Error("missing field txid", line: 1, column: 231) })' https://github.com/VegetarianOrc/shadow-drive-rust/blob/a4cb2acb24fa8185906db8540fb0e38445ff71ef/src/models.rs#L24-L26

In V1.5 different SHDW endpoints tend to have different fields in their responses (txid is largely missing). See /add-storage in https://shdw.genesysgo.com/using-shadow-drive/the-shadow-drive-platform/shadow-drive-api for example.

I'm not sure what the best solution is, perhaps to have a different response struct for each endpoint? Then we could refactor send_shdw_txn to have a response type associated with it? send_shdw_txn<AddStorageResponse> for example.