Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

Commit

Permalink
Merge pull request #29 from SaitoTech/develop
Browse files Browse the repository at this point in the history
wasm bug fixing
  • Loading branch information
SankaD authored Jul 26, 2023
2 parents 3e1fc16 + 9a5c704 commit aaf6778
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 19 deletions.
10 changes: 7 additions & 3 deletions index.node.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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");
Expand All @@ -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;
10 changes: 7 additions & 3 deletions index.web.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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");
Expand Down Expand Up @@ -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);
});
}

Expand Down
18 changes: 9 additions & 9 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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'",
Expand Down Expand Up @@ -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",
Expand Down
13 changes: 11 additions & 2 deletions saito.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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");
}
Expand Down

0 comments on commit aaf6778

Please sign in to comment.