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

Implemented v0.3.0-rc3 changes #56

Merged
merged 20 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
cff5978
feat: implement support for listening pending interactions (#17)
sarvalabs-harshrastogi Jan 22, 2024
4c4867f
feat: implement support for optional nonce in logic calls (#19)
sarvalabs-harshrastogi Jan 22, 2024
903e22c
fix: typescript interface causing build failure (#23)
sarvalabs-harshrastogi Jan 22, 2024
3b938ba
feat: implement new JSON-RPC methods (#20)
sarvalabs-harshrastogi Jan 22, 2024
6c35691
fix: make signer optional in getlogicdriver (#25)
sarvalabs-harshrastogi Jan 22, 2024
51e20d7
refactor: simplify routine call and result handler (#32)
sarvalabs-harshrastogi Feb 5, 2024
c67269b
refactor: remove debug methods (#34)
sarvalabs-harshrastogi Feb 5, 2024
56a6985
chore: bump version to 0.2.0 (#35)
sarvalabs-harshrastogi Feb 5, 2024
f48b9ad
fix: receipt retrieval bug (#37)
sarvalabs-harshrastogi Feb 5, 2024
839a7f1
Merge branch 'main' into develop
sarvalabs-gokul Feb 5, 2024
748177a
fix: value transfer exception (#41)
sarvalabs-harshrastogi Feb 6, 2024
e84a9d3
Merge branch 'main' into develop
sarvalabs-gokul Feb 6, 2024
8276d50
Merge branch 'main' into develop
sarvalabs-gokul Feb 6, 2024
e11830d
refactor: added support for latest tesseract changes (#45)
sarvalabs-harshrastogi Feb 16, 2024
872c59f
Merge branch 'main' into develop
sarvalabs-gokul Feb 19, 2024
910cce5
bump the js-polo version to v0.1.3 (#49)
sarvalabs-harshrastogi Feb 19, 2024
22ed27f
refactor: make signer optional in logic driver (#54)
sarvalabs-harshrastogi Feb 27, 2024
0e3822b
refactor: extend wallet capabilities (#52)
sarvalabs-harshrastogi Feb 27, 2024
687595b
chore: bump version to v0.3.0-rc3 (#55)
sarvalabs-harshrastogi Feb 27, 2024
f73c71e
Merge branch 'main' into develop
sarvalabs-gokul Feb 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ node_modules
package-lock.json
.DS_Store
**/tsconfig.tsbuildinfo
**/*.js.map
**/*.js.map
4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
# built documents.
#
# The short X.Y version.
version = u'v0.3.0-rc2'
version = u'v0.3.0-rc3'
# The full version, including alpha/beta/rc tags.
release = u'v0.3.0-rc2'
release = u'v0.3.0-rc3'

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand Down
2 changes: 1 addition & 1 deletion docs/source/constants.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ js-moi-sdk package.

console.log(moi.VERSION)

>> 0.3.0-rc2
>> 0.3.0-rc3

MOI Derivation Path
-------------------
Expand Down
164 changes: 66 additions & 98 deletions docs/source/hierarchical-deterministic-wallet.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,169 +44,125 @@ The ``Keystore`` interface represents a keystore object. It has the following pr

Wallet
------

A class representing a Hierarchical Deterministic Wallet that can sign interactions and manage accounts.

.. code-block:: javascript

// Example
const provider = new JsonRpcProvider("http://localhost:1600");
const wallet = new Wallet(provider);
const mnemonic = "hollow appear story text start mask salt social child ...";

Methods
~~~~~~~
const wallet = await Wallet.fromMnemonic(mnemonic);

.. autofunction:: Wallet#load

.. code-block:: javascript
Creating Instances
======================

// Example
const privateKey = Buffer.from("...")
wallet.load(privateKey, "secp256k1")
- Create a wallet instance from private key

.. autofunction:: Wallet#isInitialized
.. code-block:: javascript

.. code-block:: javascript
const privateKey = "0x...";

// Example
const isInitialized = wallet.isInitialized();
console.log(isInitialized)

>> true

.. autofunction:: Wallet#createRandom
const wallet = new Wallet(privateKey, CURVE.SECP256K1);

- Create a wallet instance from a mnemonic

.. code-block:: javascript
.. code-block:: javascript

// Example
await wallet.createRandom();
const mnemonic = "hollow appear story text start mask salt social child ...";

.. autofunction:: Wallet#generateKeystore
const wallet = await Wallet.fromMnemonic(mnemonic);

.. code-block:: javascript
- Create a wallet instance from JSON keystore

// Example
const keystore = await wallet.generateKeystore("CZ%90$DI");
console.log(keystore);
.. code-block:: javascript

// Output
/*
{
const keystore = `{
"cipher": "aes-128-ctr",
"ciphertext": "...",
"cipherparams": {
"IV": "..."
},
"kdf": "scrypt",
"kdfparams": {
...
"n": 4096,
"r": 8,
"p": 1,
"dklen": 32,
"salt": "..."
},
"mac": "..."
}
*/
}`;
const password = "YOUR_PASSWORD_HERE";

.. autofunction:: Wallet#fromMnemonic
const wallet = await Wallet.fromKeystore(keystore, password);

.. code-block:: javascript

// Example
const mnemonic = "hollow appear story text start mask salt social child ...";
const path = "m/44'/7567'/0'/0/1";
await wallet.fromMnemonic(mnemonic, path);
- Create a wallet instance from a random mnemonic

.. autofunction:: Wallet#fromKeystore
.. code-block:: javascript

.. code-block:: javascript
const wallet = await Wallet.createRandom();

// Example
const keystore = {
"cipher": "aes-128-ctr",
"ciphertext": "...",
"cipherparams": {
"IV": "..."
},
"kdf": "scrypt",
"kdfparams": {
...
},
"mac": "..."
}
wallet.fromKeystore(keystore, "CZ%90$DI");
Properties
======================

.. autofunction:: Wallet#mnemonic
- ``address`` - ``readonly`` ``string`` : The address of the wallet.

.. code-block:: javascript

// Example
const mnemonic = wallet.mnemonic();
console.log(mnemonic);

>> hollow appear story text start mask salt social child ...
console.log(wallet.address);
>> "0x87925..."

.. autofunction:: Wallet#privateKey
- ``publicKey`` - ``readonly`` ``string``: The public key of the wallet.

.. code-block:: javascript

// Example
const privateKey = wallet.privateKey();
console.log(privateKey);
console.log(wallet.publicKey);
>> "038792..."

>> 084384...

.. autofunction:: Wallet#publicKey
- ``privateKey`` - ``readonly`` ``string``: The private key of the wallet.

.. code-block:: javascript

// Example
const publicKey = wallet.publicKey();
console.log(publicKey);

>> 038792...
console.log(wallet.privateKey);
>> "0x87925..."

.. autofunction:: Wallet#curve
- ``mnemonic`` - ``readonly`` ``string``: The mnemonic of the wallet.

.. code-block:: javascript

// Example
const curve = wallet.curve();
console.log(curve);

>> secp256k1
console.log(wallet.mnemonic);
>> "hollow appear story text start mask salt social child ..."

.. autofunction:: Wallet#getAddress
- ``curve`` - ``readonly`` ``string``: The curve of the wallet.

.. code-block:: javascript

// Example
const address = wallet.getAddress();
console.log(address);
console.log(wallet.curve);
>> "secp256k1"

>> 0x87925...

.. autofunction:: Wallet#connect
Methods
======================

.. code-block:: javascript
.. autofunction:: Wallet#sign

// Example
const provider = new VoyageProvider("babylon");
wallet.connect(provider);

.. autofunction:: Wallet#sign
**Example**

.. code-block:: javascript

// Example
const message = "Hello, MOI";
const sigAlgo = wallet.signingAlgorithms["ecdsa_secp256k1"];
const signature = wallet.sign(Buffer.from(message), sigAlgo);
console.log(signature);
const message = "Hello, MOI";
const algo = wallet.signingAlgorithms["ecdsa_secp256k1"];

>> 0146304402201546497d46ed2ad7b1b77d1cdf383a28d988197bcad268be7163ebdf2f70645002207768e4225951c02a488713caf32d76ed8ea0bf3d7706128c59ee01788aac726402
const signature = wallet.sign(Buffer.from(message), algo);
>> "0146304402201546497d46ed2ad7b1b77d1cdf383a28d988197bcad268be7163ebdf2f70645002207768e4225951c02a488713caf32d76ed8ea0bf3d7706128c59ee..."

.. autofunction:: Wallet#signInteraction

.. code-block:: javascript

// Example
const address = "0x870ad6c5150ea8c0355316974873313004c6b9425a855a06fff16f408b0e0a8b";
const interaction = {
type: IxType.ASSET_CREATE,
Expand All @@ -224,10 +180,22 @@ Methods
const signedIxn = wallet.signInteraction(interaction, sigAlgo);
console.log(signedIxn)

// Ouptut
// Output
/*
{
ix_args:'0e9f0203131696049608900c900c930ca30cb60c03870ad6c5150ea8c0355316974873313004c6b9425a855a06fff16f408b0e0a8b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c80e7f063363636161604d4f49130d41',
signature: '01463044022059e8e9839a02d2a0b2585e2267400826f91e575eb27cb89485d2deab697c5a34022020d71b2d3caa8c0b003849a2cb4effdbfd32028357db335549a75c82dd329f8902'
}
*/

.. autofunction:: Wallet#generateKeystore

.. autofunction:: Wallet.fromMnemonic

.. autofunction:: Wallet.fromMnemonicSync

.. autofunction:: Wallet.fromKeystore

.. autofunction:: Wallet.createRandom

.. autofunction:: Wallet.createRandomSync
20 changes: 16 additions & 4 deletions docs/source/logic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,10 @@ applications on the MOI network.
// Example
const initWallet = async () => {
const mnemonic = "mother clarify push liquid ordinary social track ...";
const wallet = await Wallet.fromMnemonic(mnemonic);
const provider = new JsonRpcProvider("http://localhost:1600/");
const wallet = new Wallet(provider);
await wallet.fromMnemonic(mnemonic);
wallet.connect(provider);

return wallet;
}

Expand Down Expand Up @@ -220,16 +221,27 @@ Functions
// Example
const initWallet = async () => {
const mnemonic = "mother clarify push liquid ordinary social track ...";
const wallet = await Wallet.fromMnemonic(mnemonic);
const provider = new JsonRpcProvider("http://localhost:1600/");
const wallet = new Wallet(provider);
await wallet.fromMnemonic(mnemonic);

wallet.connect(provider);

return wallet;
}

const logicId = "0x0800007d70c34ed6ec4384c75d469894052647a078b33ac0f08db0d3751c1fce29a49a";
const wallet = await initWallet();
const logicDriver = await getLogicDriver(logicId, wallet);

.. warning::
When the logic driver is initialized with a provider,
any attempt to execute a mutating routine will trigger the SDK to
raise an exception. The error message associated with this exception
will state: **"Mutating routine calls require a signer to be initialized"**.
Developers should ensure they should pass signer instance while
doing mutating routine calls to avoid encountering this exception.


Usage
~~~~~

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "moi",
"version": "0.3.0-rc2",
"version": "0.3.0-rc3",
"description": "JavaScript library to interact with MOI Protocol via RPC API",
"private": true,
"main": "packages/js-moi/dist/index.js",
Expand Down
10 changes: 5 additions & 5 deletions packages/js-moi-bip39/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "js-moi-bip39",
"version": "0.3.0-rc2",
"version": "0.3.0-rc3",
"description": "Bitcoin BIP39 package for deterministic key generation using mnemonic code",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand All @@ -24,10 +24,10 @@
"author": "Sarva Labs Inc. & MOI Protocol Developers",
"license": "Apache-2.0 OR MIT",
"dependencies": {
"js-moi-hdnode": "^0.3.0-rc2",
"js-moi-signer": "^0.3.0-rc2",
"js-moi-constants": "^0.3.0-rc2",
"js-moi-utils": "^0.3.0-rc2",
"js-moi-hdnode": "^0.3.0-rc3",
"js-moi-signer": "^0.3.0-rc3",
"js-moi-constants": "^0.3.0-rc3",
"js-moi-utils": "^0.3.0-rc3",
"buffer": "^6.0.3",
"@noble/hashes": "^1.1.5"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/js-moi-constants/dist/version.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export declare const VERSION = "0.3.0-rc2";
export declare const VERSION = "0.3.0-rc3";
2 changes: 1 addition & 1 deletion packages/js-moi-constants/dist/version.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.VERSION = void 0;
exports.VERSION = "0.3.0-rc2";
exports.VERSION = "0.3.0-rc3";
2 changes: 1 addition & 1 deletion packages/js-moi-constants/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "js-moi-constants",
"version": "0.3.0-rc2",
"version": "0.3.0-rc3",
"description": "Collection of constant variables used in js-moi-sdk",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/js-moi-constants/src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const VERSION = "0.3.0-rc2";
export const VERSION = "0.3.0-rc3";
4 changes: 2 additions & 2 deletions packages/js-moi-hdnode/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "js-moi-hdnode",
"version": "0.3.0-rc2",
"version": "0.3.0-rc3",
"description": "BIP32 HD Node for cryptocurrency key management.",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand All @@ -23,7 +23,7 @@
"author": "Sarva Labs Inc. & MOI Protocol Developers",
"license": "Apache-2.0 OR MIT",
"dependencies": {
"js-moi-utils": "^0.3.0-rc2",
"js-moi-utils": "^0.3.0-rc3",
"buffer": "^6.0.3",
"hdkey": "^2.1.0",
"assert": "^2.0.0",
Expand Down
Loading
Loading