diff --git a/gen/Generator.ts b/gen/Generator.ts index 95571e4..1049c2f 100644 --- a/gen/Generator.ts +++ b/gen/Generator.ts @@ -264,7 +264,7 @@ export class Generator { } this.save(); - this.apis.every((api) => { + this.apis.forEach((api) => { const path = this.project.getDirectory(`${this.outApi}${api.packageSuffix}`); if (path) { rimraf(path.getPath(), (error) => { diff --git a/package.json b/package.json index e00ca72..4eab503 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dcorejs-sdk", - "version": "3.0.2", + "version": "3.0.3", "homepage": "https://decent.ch/", "description": "DcoreJS SDK.", "main": "./dist/index.js", diff --git a/src/utils/Utils.ts b/src/utils/Utils.ts index 2530bec..0ae93de 100644 --- a/src/utils/Utils.ts +++ b/src/utils/Utils.ts @@ -1,5 +1,5 @@ import * as BaseX from "base-x"; -import { serialize } from "class-transformer"; +import { classToPlain, serialize } from "class-transformer"; import * as Crypto from "crypto"; import { createHash } from "crypto"; import * as Long from "long"; @@ -22,7 +22,7 @@ export function info(tag: string, logger: Logger): MonoTypeOperatorFunction logger.info(`${tag}: #complete`), error: (err) => logger.error(`${tag}: #error ${err.toString()}`), - next: (value) => logger.info(`${tag}: #next ${str(value)}`), + next: (value) => logger.info(`${tag}: #next ${Utils.stringify(value)}`), }); } @@ -30,18 +30,22 @@ export function debug(tag: string, logger: Logger): MonoTypeOperatorFunction< return tap({ complete: () => logger.debug(`${tag}: #complete`), error: (err) => logger.error(`${tag}: #error ${err.toString()}`), - next: (value) => logger.debug(`${tag}: #next ${str(value)}`), + next: (value) => logger.debug(`${tag}: #next ${Utils.stringify(value)}`), }); } -function str(value: any): string { - return typeof value === "string" ? value : serialize(value); -} - export class Utils { public static Base58 = BaseX("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"); + public static stringify(value: any): string { + return typeof value === "string" ? value : serialize(value); + } + + public static toPlain(value: any): object { + return classToPlain(value); + } + public static generateNonce(power: number = 250): Long { return Long.fromString(Utils.generateEntropy(power).toString("hex"), true, 16); }