Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

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

Open
Shaptic opened this issue Feb 13, 2024 · 0 comments

Comments

@Shaptic
Copy link

Shaptic commented Feb 13, 2024

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant