@near-js/client initial approach #1367
Closed
andy-haynes
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The upcoming client library seeks to provide a new set of functions for building client applications with Near. This new functionality is meant to be clear and easy-to-use, while addressing longstanding friction points in the current implementation. Our immediate goal is to encapsulate mid-to-high level functionality in individual, purpose-built functions which are tree-shakable.
Below are some common use cases with the current implementation and potential implementations presented. The potential implementations are by no means locked in, but instead should express the design philosophy of clarity and ease of use mentioned above. These implementations written to use IoC for complex dependencies like signers and RPC providers; the intention here is to strictly manage dependencies to make tree shaking maximally effective and cohesive without strong coupling.
View function
View functions require an RPC provider to make readonly requests.
near-api-js
exposes aviewFunction
method (used in the code snippet below) on theAccount
class, which is more or less the most straightforward way of making view calls currently.The proposed implementation reduces the amount of initialization overhead and would provide a dedicated function with clear parameters. A separate function initializes the RPC provider with minimal arguments, which the view function takes as an argument to make the request.
Current implementation
Potential implementations
Call function
Call functions add a signing component, which requires initialization of an underlying key store. It still relies on the
Account
class, with the represented account being the transaction signer. The method currently takes several parameters that are only applicable in very specific use cases, making it awkward for general use.The proposed implementation exposes a dedicated method with simple arguments. Initialization of the signer is much more clear by way of a simple initialization method which can trivially be extended to accommodate other signers.
Current implementation
Potential implementations
Create account
Current implementation
Potential implementations
Beta Was this translation helpful? Give feedback.
All reactions