Skip to content

Commit

Permalink
Implemented v0.4.0 changes (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
sarvalabs-harshrastogi authored Apr 29, 2024
1 parent fd7615f commit d796bef
Show file tree
Hide file tree
Showing 160 changed files with 3,723 additions and 3,447 deletions.
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-rc4'
version = u'v0.4.0'
# The full version, including alpha/beta/rc tags.
release = u'v0.3.0-rc4'
release = u'v0.4.0'

# -- 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-rc4
>> 0.4.0
MOI Derivation Path
-------------------
Expand Down
70 changes: 67 additions & 3 deletions docs/source/logic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,76 @@ Variables
logic manifest. Developers can easily invoke and execute these routines, which
encapsulate specific functionalities and operations provided by the logic.

``ephemeralState`` - The ephemeral state, accessible via this variable,
represents the short-term or temporary state of the logic.

``persistentState`` - The persistent state is accessible via this variable. It
allows developers to retrieve state of the logic, which persists across
different invocations and interactions.

``ephemeralState`` - The ephemeral state, accessible via this variable,
represents the short-term or temporary state of the logic.
It contains the following method:

* ``get``
This method retrieves the value from persistent state using the storage key.
As the storage key hash generation is complex, a builder
object is passed to callback to generate storage key. The builder object has the following methods:

* ``entity`` - This method used to select the member of the state persistent.
* ``length`` - This method used to access length/size of `Array`, `Varray` and, `Map`.
* ``property`` - This method used to access the property of map using the passed key.
* ``at`` - This method used to access the element of `Array` and `Varray` using the passed index.
* ``field`` - This method used to access the field of `Class` using the passed field name.

.. code-block:: javascript
// Example
const logic = await getLogicDriver(logicId, wallet);
const symbol = await logic.persistentState.get(access => access.entity("symbol"));
console.log(symbol);
>> MOI
.. code-block:: javascript
// Example: if you want to access size of the array/map
const logic = await getLogicDriver(logicId, wallet);
const length = await logic.persistentState.get(access => access.entity("persons").length());
console.log(length);
>> 10
.. code-block:: javascript
// Example: if you want to access the balance of the address from the map
const logic = await getLogicDriver(logicId, wallet);
const address = "0x035dcdaa46f9b8984803b1105d8f327aef97de58481a5d3fea447735cee28fdc";
const balance = await logic.persistentState.get(access => access.entity("Balances").property(hexToBytes(address)));
console.log(balance);
>> 10000
.. code-block:: javascript
// Example: if you want to field of the class
const logic = await getLogicDriver(logicId, wallet);
const name = await logic.persistentState.get(access => access.entity("persons").field("name"));
console.log(name);
>> Alice
.. code-block:: javascript
// Example: if you want to access the element of the array
const logic = await getLogicDriver(logicId, wallet);
const product = await logic.persistentState.get(access => access.entity("Products").at(0));
console.log(name);
>> Chocolate
Functions
~~~~~~~~~
Expand Down Expand Up @@ -277,7 +341,7 @@ Usage
const logic = await getLogicDriver(logicId, wallet);
// Get the persistent state
const symbol = await logic.persistentState.get("symbol");
const symbol = await logic.persistentState.get(access => access.entity("symbol"));
console.log(symbol); // MOI
Expand Down
12 changes: 10 additions & 2 deletions docs/source/manifest-call-encoder.rst
Original file line number Diff line number Diff line change
Expand Up @@ -229,13 +229,21 @@ Methods
.. code-block:: javascript
// Example
const error = "0x0e4f0666ae03737472696e67536f6d657468696e672077656e742077726f6e673f06b60166756e6374696f6e31282966756e6374696f6e322829";
const error = "0x0e6f0666d104de04737472696e67696e73756666696369656e742062616c616e636520666f722073656e6465723f06e60172756e74696d652e726f6f742829726f7574696e652e5472616e736665722829205b3078635d202e2e2e205b307831623a205448524f57203078355d";
const exception = ManifestCoder.decodeException(error);
console.log(exception)
>> { class: 'string', data: 'Something went wrong', trace: [ 'function1()', 'function2()' ] }
>> {
class: "string",
error: "insufficient balance for sender",
revert: false,
trace: [
"runtime.root()",
"routine.Transfer() [0xc] ... [0x1b: THROW 0x5]"
],
}
.. autofunction:: decodeState

Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "moi",
"version": "0.3.0-rc4",
"version": "0.4.0",
"description": "JavaScript library to interact with MOI Protocol via RPC API",
"private": true,
"main": "packages/js-moi/lib.cjs/index.js",
Expand Down Expand Up @@ -36,8 +36,9 @@
"@types/aes-js": "^3.1.4",
"@types/jest": "^29.4.0",
"jest": "^29.4.3",
"ts-node": "10.9.2",
"ts-jest": "^29.0.5"
"jsdoc": "^4.0.2",
"ts-jest": "^29.0.5",
"ts-node": "10.9.2"
},
"dependencies": {
"@noble/hashes": "^1.1.5",
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-rc4",
"version": "0.4.0",
"description": "Bitcoin BIP39 package for deterministic key generation using mnemonic code",
"main": "./lib.cjs/index.js",
"module": "./lib.esm/index.js",
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-rc4",
"js-moi-signer": "^0.3.0-rc4",
"js-moi-constants": "^0.3.0-rc4",
"js-moi-utils": "^0.3.0-rc4",
"js-moi-hdnode": "^0.4.0",
"js-moi-signer": "^0.4.0",
"js-moi-constants": "^0.4.0",
"js-moi-utils": "^0.4.0",
"buffer": "^6.0.3",
"@noble/hashes": "^1.1.5"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/js-moi-constants/lib.cjs/version.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export declare const VERSION = "0.3.0-rc4";
export declare const VERSION = "0.4.0";
//# sourceMappingURL=version.d.ts.map
2 changes: 1 addition & 1 deletion packages/js-moi-constants/lib.cjs/version.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/js-moi-constants/lib.cjs/version.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/js-moi-constants/lib.cjs/version.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/js-moi-constants/lib.esm/version.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export declare const VERSION = "0.3.0-rc4";
export declare const VERSION = "0.4.0";
//# sourceMappingURL=version.d.ts.map
2 changes: 1 addition & 1 deletion packages/js-moi-constants/lib.esm/version.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/js-moi-constants/lib.esm/version.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/js-moi-constants/lib.esm/version.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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-rc4",
"version": "0.4.0",
"description": "Collection of constant variables used in js-moi-sdk",
"main": "./lib.cjs/index.js",
"module": "./lib.esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/js-moi-constants/src.ts/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const VERSION = "0.3.0-rc4";
export const VERSION = "0.4.0";
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-rc4",
"version": "0.4.0",
"description": "BIP32 HD Node for cryptocurrency key management.",
"main": "./lib.cjs/index.js",
"module": "./lib.esm/index.js",
Expand Down Expand Up @@ -28,7 +28,7 @@
"buffer": "^6.0.3",
"crypto": "npm:crypto-browserify",
"hdkey": "^2.1.0",
"js-moi-utils": "^0.3.0-rc4",
"js-moi-utils": "^0.4.0",
"process": "^0.11.10",
"secp256k1": "^5.0.0",
"stream": "npm:stream-browserify"
Expand Down
Loading

0 comments on commit d796bef

Please sign in to comment.