Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not allowing user to pick between .call() and .send() when doing routines.endPoint() #26

Closed
Bhimgouda opened this issue Dec 19, 2023 · 1 comment · Fixed by #32
Closed
Assignees
Labels
enhancement New feature or request logic Module to interact with MOI Logic Objects providers Issues related to providers
Milestone

Comments

@Bhimgouda
Copy link

Bhimgouda commented Dec 19, 2023

Not allowing user to pick between .call() and .send() when doing routines.endPoint()

Description

Presently, developers have the option to choose between two methods:

routines.SomeEndpoint.call()
// or
routines.SomeEndpoint.send()

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 -

const tx = await erc20Contract.transfer(toAddress, amount);
const receipt = await tx.wait();

How ethers handle a view function call -

const balance = await erc20Contract.balanceOf(targetAddress);
@sarvalabs-harshrastogi
Copy link
Member

resolved in #36

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request logic Module to interact with MOI Logic Objects providers Issues related to providers
Projects
None yet
2 participants