Soneso / stellar_flutter_sdk

Stellar SDK for flutter - dart, Stellar, Horizon, Soneso
MIT License
71 stars 33 forks source link

Required changes for passing parameters when communicating with Soroban RPC. #85

Closed Shaptic closed 4 months ago

Shaptic commented 4 months ago

TL;DR: Array-based passing will no longer be allowed in Soroban RPC.

Soroban RPC Changes

With the introduction of stellar/soroban-rpc#13, the Soroban RPC server changes the way it interprets the JSON-RPC spec.

Specifically, in Section 4.2, it states that parameters can be passed by position (i.e. through an array) and by name (i.e. through an object). However, endpoints that support optional parameters will not work with position-(array-)based calls. Thus, we must move exclusively to object-based calls to support optional parameters in the future.

We saw this issue introduced in Soroban RPC v20.1.0 as part of soroban-tools#1131: adding an optional parameter should be a non-breaking change, but because of array-based parameter parsing, this resulted in a breaking change in any environment using that method.

Expectations

You should remove all instances of array-based parameter passing in your low-level JSON-RPC code.

For example, RPC calls should change like this:

 {
   jsonrpc: "2.0",
   id: 1,
   method: "getTransaction",
-  params: [ "d1344aacdb36949b0164b9b97a8a4961bd9ccadcf2c3b562c93b09bc8651dad7" ]
+  params: { hash: "d1344aacdb36949b0164b9b97a8a4961bd9ccadcf2c3b562c93b09bc8651dad7" }
 }

References

christian-rogobete commented 4 months ago

Hello @Shaptic,

thank you for adding this issue. The flutter sdk is not using array-based parameter passing.