GithubHelp home page GithubHelp logo

sarvalabs / js-moi-sdk Goto Github PK

View Code? Open in Web Editor NEW
23.0 23.0 1.0 2.58 MB

JavaScript library to interact with MOI Protocol via RPC API

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

License: Apache License 2.0

JavaScript 0.57% TypeScript 99.43%
blockchain javascript moi sdk web3

js-moi-sdk's People

Contributors

sarvalabs-gk avatar sarvalabs-gokul avatar sarvalabs-sai avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

js-moi-sdk's Issues

Make signer optional in `getLogicDriver`

Make signer optional in getLogicDriver

Description

This issue concerns the signer is not required to execute the call and estimateFuel methods.

Environment

  • Operating System: Browser/Linux/macOS/Windows
  • Branch/Version: NA

Screenshots

NA

Proposed Solution

Implement new method in base provider.

Passing a tuple/object with argument keys when invoking a endpoint

Passing a tuple/object with argument keys when invoking a endpoint

Description

In the current implementation of cocolang, developers must explicitly mention argument variable names, even when passing a single argument to a function, as demonstrated by the following syntax:

someFunc(name: bhim)

Inspired by this approach, there is a proposal to enhance the js-moi-sdk by adopting a similar convention. The idea is to use tuples instead of arrays when passing arguments to endpoints, aligning the SDK syntax more closely with the cocolang convention.

The current syntax for passing arguments in the SDK looks like this:

logicDriver.routines.someFunc(["bhim"])

The proposed syntax, on the other hand, suggests using a more structured and readable format:

logicDriver.routines.someFunc({name: "Bhim"})

In this proposed change, each argument is explicitly labeled with its corresponding parameter name. To ensure code integrity, the SDK should implement thorough validation. If there is a mistake in the number of arguments provided, an invalid argument name, or a datatype mismatch, the SDK should check against the manifest and throw an appropriate error.

Proposal to Simplify Code Structure in SDK for call Routines

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.

Implement Moi.js v0.1.0

Description

Create a unified package for moi.js which should include all the sub-packages. The package should enable easy access to the various functionalities offered by moi.js. Additionally, each sub-package should remain independently available for separate installation and usage.

Add Support For Latest RPC Methods

Description.

  • Implement the latest RPC methods available in the protocol.
  • Upgrade the logic factory and driver components to seamlessly accommodate the latest "call" and "estimateFuel" methods.
  • Fix the deep struct calldata encoding bug in js-moi-manifest package.

TypeScript Declaration File Linking Causing Build Failure

TypeScript Declaration File Linking Causing Build Failure

When attempting to build the project, there is a critical error caused by the linkage between the TypeScript declaration file (*.d.ts) index.d.ts and import from the src directory inside the js-moi-signer. This linkage issue is impeding the successful compilation of the project.

Additional Information:

Package Version: 0.1.2

Support for optional nonce in logic calls

Support for optional nonce in logic calls

Description

The current state of the JavaScript library lacks support for an optional nonce parameter in logic calls. This feature is crucial for certain use cases where nonce values need to be included

Environment

  • Operating System: Browser/Linux/MacOs/Windows
  • Branch/Version: NA

Screenshots

NA

Proposed Solution

Add the nonce as an optional field in LogicIxArguments

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

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:

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);

Implement new RPC Methods for Handling pending interactions and tesseracts

Implement new RPC Methods for Handling pending interactions and tesseracts

Description

Introduce methods that enable operations such as retrieving pending tesseracts based on account filters, fetching pending interaction filters, removing filters, and obtaining changes made to specific filters since the last poll.

Environment

  • Operating System: Browser/Linux/macOS/Windows
  • Branch/Version: NA

Screenshots

NA

Proposed Solution

Implement new method in base provider.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.