Client Extension #200
hayes-mysten
started this conversation in
Technical Discussions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Client Extension
As we've been developing more and more SDKs for the sui ecosystem, we have identified a need for unified patterns, shared utilities, and composability between SDKs.
There are a number of pain points we've identified as common issues faced by most SDKs:
SuiClient
(a thin wrapper of JSON RPC) which makes migration to other APIs (GraphQL and GRPC) effectively impossibleWhat we're building to solve these problems
There are a couple tightly coupled pieces to our solution:
BaseClient
that SDKs can extend via client extensionsCoreClient
that defines a common set of functionality that will be supported by JSON RPC (SuiClient
), GraphQL, and GRPC apis.BaseClient
The new
BaseClient
will allow clients (likeSuiClient
) to be extended via "client extensions":This pattern will allow any SDK to extend existing clients with new functionality. This solves the problem of
needing custom context providers for each SDK.
To make this work properly, dapp-kit will be updated so that it can provide an extended client via it's existing hooks.
For end users, client extensions will likely be easier to use:
CoreClient
The new
CoreClient
is intended as a target for SDKs that want to be compatible across different APIs(currently JSON RPC, GraphQL, and GRPC).
SuiClient
already implements an experimental version of this API.The CoreClient will support most common functionality needed by SDKs including:
These APIs are not fully defined yet, and will be expanded as the GRPC API adds more functionality.
An early version of the interface is defined here.
Rather than accepting a
SuiClient
, they can accept aBaseClient
with the extensions they need to function.The
CoreClient
will be implemented implemented as a client extension that is enable by default by some clientlike the existing
SuiClient
.If your SDK depends on the CoreClient and the Walrus SDK, you can define something like:
This will allow only allow your SDK to be registered with a client that has the right extensions, and allow your
SDK to access the walrus SDK without requiring it to be explicitly provided.
This will also ensure your SDK works with future GraphQL and GRPC clients.
SDK conventions
We are still in the early stages of this work stream, and are exploring what conventions we want to standardize on for our SDKs.
Our current plan is to write up public documentation about the standards we are using for our own SDKs as a set of best
practices for 3rd parties to adopt in their own SDKs.
Some important concepts we know we want to standardize include:
We'll have more to share on this once we've updated more of our SDKs to use these patterns.
New SDKs
So far, we've landed experimental versions of some of these APIs and updated the Walrus SDK to be usable as a client extension.
This isn't documented yet, and we aren't expecting them to be used yet, but we will be updating more SDKs in the coming weeks.
Our goal is for most of the changes to be fully backwards compatible, but we will need to evaluate our exact approach to migrations on a case by case basis.
Beta Was this translation helpful? Give feedback.
All reactions