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

Simplified Wallet Setup with the New API

sarvalabs-harshrastogi opened this issue · comments

New wallet initialization API

The current implementation of the Wallet class lacks readability and user-friendliness, especially during instance creation. Developers are currently forced to use the constructor directly for initialization, with options like Wallet.fromMnemonic, Wallet.fromKeystore, or Wallet.createRandom instances method available separately to initialize Wallet. This approach leads to confusion and makes the code less maintainable. A more streamlined and intuitive design is needed to enhance the readability and developer experience when setting up a Wallet instance.

Solution:

The SDK should expose unified static methods responsible for both creating and initializing a Wallet instance. These methods should handle various initialization options, such as mnemonic, keystore, or random generation. Meanwhile, the constructor should be reserved for creating a Wallet instance using the private key and curve. This approach aims to streamline the initialization process, making it more intuitive and developer-friendly.