sarvalabs / js-moi-sdk

JavaScript library to interact with MOI Protocol via RPC API
https://js-moi-sdk.docs.moi.technology/
Apache License 2.0
24 stars 2 forks source link

Proposal to Simplify Code Structure in SDK for call Routines #27

Closed Bhimgouda closed 10 months ago

Bhimgouda commented 11 months ago

Proposal to Simplify Code Structure in SDK for .call() Routine

Description

The existing code structure appears as follows:

let ixResponse = await logicDriver.routines.GetPosts()
let { allPosts } = (await ixResponse.result()).output;

This proposal suggests simplifying it to the following form:

let { allPosts } = await logicDriver.routines.GetPosts().unwrap();

With this proposed change, devs can use .unwrap() to directly retrieve the returned object if they are not concerned about the ixResponse data.

Comparison

This proposal draws inspiration from the approach taken by ethers.js in simplifying their call methods:

await erc20.decimals();
// you get 18

The intention is to streamline the code structure and enhance the developer experience with a more readable syntax.

sarvalabs-harshrastogi commented 10 months ago

resolved in https://github.com/sarvalabs/js-moi-sdk/pull/36