sarvalabs / js-moi-sdk

JavaScript library to interact with MOI Protocol via RPC API

Home Page:https://js-moi-sdk.docs.moi.technology/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Proposal to Simplify Code Structure in SDK for call Routines

Bhimgouda opened this issue · comments

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.

resolved in #36