From 9a5c704d825a44872decfd3167e48c65dd3a7bec Mon Sep 17 00:00:00 2001 From: Sanka Darshana Date: Wed, 26 Jul 2023 08:50:32 +0530 Subject: [PATCH] wasm bug fixing --- index.node.ts | 10 +++++++--- index.web.ts | 10 +++++++--- package-lock.json | 18 +++++++++--------- package.json | 4 ++-- saito.ts | 13 +++++++++++-- 5 files changed, 36 insertions(+), 19 deletions(-) diff --git a/index.node.ts b/index.node.ts index 9aa2886..ad6c2d4 100644 --- a/index.node.ts +++ b/index.node.ts @@ -1,4 +1,4 @@ -import Saito from "./saito"; +import Saito, {LogLevel} from "./saito"; import SharedMethods from "./shared_methods"; import Transaction from "./lib/transaction"; import Slip from "./lib/slip"; @@ -21,12 +21,16 @@ if (NODE_MAJOR_VERSION < 19) { * * @param configs * @param sharedMethods + * @param factory + * @param privateKey + * @param logLevel */ export async function initialize( configs: any, sharedMethods: SharedMethods, factory: Factory, - privateKey: string + privateKey: string, + logLevel: LogLevel = LogLevel.Info ) { if (Saito.getLibInstance()) { console.error("saito already initialized"); @@ -52,7 +56,7 @@ export async function initialize( PeerServiceList.Type = s.WasmPeerServiceList; // Config.Type = s.WasmConfiguration; - return Saito.initialize(configs, sharedMethods, factory, privateKey); + return Saito.initialize(configs, sharedMethods, factory, privateKey, logLevel); } export default Saito; diff --git a/index.web.ts b/index.web.ts index ffac247..f6cd415 100644 --- a/index.web.ts +++ b/index.web.ts @@ -1,4 +1,4 @@ -import Saito from "./saito"; +import Saito, {LogLevel} from "./saito"; import SharedMethods from "./shared_methods"; import Transaction from "./lib/transaction"; import Slip from "./lib/slip"; @@ -16,12 +16,16 @@ import PeerServiceList from "./lib/peer_service_list"; * * @param configs * @param sharedMethods + * @param factory + * @param privateKey + * @param logLevel */ export async function initialize( configs: any, sharedMethods: SharedMethods, factory: Factory, - privateKey: string + privateKey: string, + logLevel: LogLevel = LogLevel.Info ) { if (Saito.getLibInstance()) { console.error("saito already initialized"); @@ -51,7 +55,7 @@ export async function initialize( console.log("init output = ", s); Saito.setWasmMemory(s.memory); - return Saito.initialize(configs, sharedMethods, factory, privateKey); + return Saito.initialize(configs, sharedMethods, factory, privateKey, logLevel); }); } diff --git a/package-lock.json b/package-lock.json index e3574d1..14e03e0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "saito-js", - "version": "0.0.26", + "version": "0.0.27", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "saito-js", - "version": "0.0.26", + "version": "0.0.27", "license": "ISC", "dependencies": { "buffer": "^6.0.3", @@ -17,7 +17,7 @@ "morgan": "~1.10.0", "node-fetch": "^2.6.1", "process": "^0.11.10", - "saito-wasm": "^0.0.15", + "saito-wasm": "^0.0.16", "url": "^0.11.0", "util": "^0.12.5", "ws": "^8.13.0" @@ -4151,9 +4151,9 @@ "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, "node_modules/saito-wasm": { - "version": "0.0.15", - "resolved": "https://registry.npmjs.org/saito-wasm/-/saito-wasm-0.0.15.tgz", - "integrity": "sha512-+zLWMSKDM+5aTGlu/773PeC7UyEeoqtIQ9Uh6mI0xbv6q/59AZeY+tOKY39oE5M293WPA5Zk3+FACCjnsYKHTw==", + "version": "0.0.16", + "resolved": "https://registry.npmjs.org/saito-wasm/-/saito-wasm-0.0.16.tgz", + "integrity": "sha512-VvZ7+ZzR9mYc3/z9tq8Njln4QR8QwkiWzhmTkG8uQthMTxhBSLwACTFrXq5xFX5+l3l+tiqvSGao0LRPkqmtaA==", "dependencies": { "cross-env": "^7.0.3", "node-fetch": "^3.3.0" @@ -8195,9 +8195,9 @@ "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, "saito-wasm": { - "version": "0.0.15", - "resolved": "https://registry.npmjs.org/saito-wasm/-/saito-wasm-0.0.15.tgz", - "integrity": "sha512-+zLWMSKDM+5aTGlu/773PeC7UyEeoqtIQ9Uh6mI0xbv6q/59AZeY+tOKY39oE5M293WPA5Zk3+FACCjnsYKHTw==", + "version": "0.0.16", + "resolved": "https://registry.npmjs.org/saito-wasm/-/saito-wasm-0.0.16.tgz", + "integrity": "sha512-VvZ7+ZzR9mYc3/z9tq8Njln4QR8QwkiWzhmTkG8uQthMTxhBSLwACTFrXq5xFX5+l3l+tiqvSGao0LRPkqmtaA==", "requires": { "cross-env": "^7.0.3", "node-fetch": "^3.3.0" diff --git a/package.json b/package.json index 947f74e..3445849 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "saito-js", - "version": "0.0.26", + "version": "0.0.27", "description": "js wrappings around saito-core using wasm", "scripts": { "test": "env TS_NODE_PROJECT=\"tsconfig.testing.json\" mocha --require ts-node/register 'tests/**/*.ts'", @@ -29,7 +29,7 @@ "dependencies": { "buffer": "^6.0.3", "cookie-parser": "~1.4.6", - "saito-wasm": "^0.0.15", + "saito-wasm": "^0.0.16", "cors": "^2.8.5", "debug": "^4.3.4", "express": "~4.18.2", diff --git a/saito.ts b/saito.ts index 2f84ff8..3245a6d 100644 --- a/saito.ts +++ b/saito.ts @@ -25,6 +25,14 @@ import Blockchain from "./lib/blockchain"; // ApplicationTransaction, // } +export enum LogLevel { + Error = 0, + Warn, + Info, + Debug, + Trace, +} + export default class Saito { private static instance: Saito; private static libInstance: any; @@ -41,7 +49,8 @@ export default class Saito { configs: any, sharedMethods: SharedMethods, factory = new Factory(), - privateKey: string + privateKey: string, + logLevel: LogLevel ) { console.log("initializing saito lib"); Saito.instance = new Saito(factory); @@ -117,7 +126,7 @@ export default class Saito { } let configStr = JSON.stringify(configs); - await Saito.getLibInstance().initialize(configStr, privateKey); + await Saito.getLibInstance().initialize(configStr, privateKey, logLevel); console.log("saito initialized"); }