Not allowing user to pick between .call() and .send() when doing routines.endPoint() #26
Labels
enhancement
New feature or request
logic
Module to interact with MOI Logic Objects
providers
Issues related to providers
Milestone
Not allowing user to pick between .call() and .send() when doing routines.endPoint()
Description
Presently, developers have the option to choose between two methods:
This choice may cause confusion, especially for new developers. Additionally, it introduces the risk of developers unintentionally calling a read-only endpoint using .send(), which is not only inefficient (consumes gas and creates a tesseract) but also considered bad practice.
The desired behavior is to have the js-moi-sdk automatically determine the appropriate method based on the nature of the endpoint being called.
Additionally, if a developer intends to simulate interaction with a mutating function, they should continue to use routines.someEndpoint.call() (as per the existing convention).
However, the option of using routines.someEndpoint.send() for this purpose should be deprecated and ultimately removed - The SDK should only decide if the endpoint being called is a mutating function and internally use .send() for such interactions.
Possible resolution
To achieve this behavior, the js-moi-sdk should emulate the pattern used by ethers.js when handling different types of functions:
In case of an error when doing a mutating call: SDK should throw an error.
How ethers handle a mutate function call -
How ethers handle a view function call -
The text was updated successfully, but these errors were encountered: