From d663ce1f145dc07cdbd15bee9669890aaee768ad Mon Sep 17 00:00:00 2001 From: =?utf8?q?Miro=20Mets=C3=A4nheimo?= Date: Wed, 9 Oct 2019 21:31:40 +0300 Subject: [PATCH] working tsc build --- .gitignore | 2 ++ lib/block-signer.ts | 3 ++- lib/ed25519.ts | 3 ++- lib/nano-address.ts | 3 ++- lib/nano-converter.ts | 8 ++++---- lib/util/curve25519.ts | 4 ++-- package-lock.json | 15 +++++++++++++++ package.json | 8 +++++--- tsconfig.json | 4 ++-- 9 files changed, 36 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index ad46b30..e4f46fd 100644 --- a/.gitignore +++ b/.gitignore @@ -59,3 +59,5 @@ typings/ # next.js build output .next + +dist diff --git a/lib/block-signer.ts b/lib/block-signer.ts index 0ee3734..d3fdb8d 100644 --- a/lib/block-signer.ts +++ b/lib/block-signer.ts @@ -1,10 +1,11 @@ import BigNumber from 'bignumber.js' -import * as blake from 'blakejs' import { Ed25519 } from './ed25519' import { NanoAddress } from './nano-address' import NanoConverter from './nano-converter' import { Convert } from './util/convert' +const blake = require('blakejs') + export default class BlockSigner { nanoAddress = new NanoAddress() diff --git a/lib/ed25519.ts b/lib/ed25519.ts index 9a11a22..b03b484 100644 --- a/lib/ed25519.ts +++ b/lib/ed25519.ts @@ -1,7 +1,8 @@ -import * as blake from 'blakejs' import { Convert } from './util/convert' import { Curve25519 } from './util/curve25519' +const blake = require('blakejs') + export class Ed25519 { curve: Curve25519 diff --git a/lib/nano-address.ts b/lib/nano-address.ts index 6db5c9c..7a4e9e4 100644 --- a/lib/nano-address.ts +++ b/lib/nano-address.ts @@ -1,6 +1,7 @@ -import * as blake from 'blakejs' import { Convert } from './util/convert' +const blake = require('blakejs') + export class NanoAddress { readonly alphabet = '13456789abcdefghijkmnopqrstuwxyz' diff --git a/lib/nano-converter.ts b/lib/nano-converter.ts index 6f8ece3..0ce45b4 100644 --- a/lib/nano-converter.ts +++ b/lib/nano-converter.ts @@ -5,11 +5,11 @@ export default class NanoConverter { /** * Converts the input value to the wanted unit * - * @param input {BigNumber} value - * @param inputUnit {Unit} the unit to convert from - * @param outputUnit {Unit} the unit to convert to + * @param input {string | BigNumber} value + * @param inputUnit {string} the unit to convert from + * @param outputUnit {string} the unit to convert to */ - static convert(input: BigNumber, inputUnit: string, outputUnit: string): string { + static convert(input: string | BigNumber, inputUnit: string, outputUnit: string): string { let value = new BigNumber(input.toString()) switch (inputUnit) { diff --git a/lib/util/curve25519.ts b/lib/util/curve25519.ts index 21ed61f..56a9a69 100644 --- a/lib/util/curve25519.ts +++ b/lib/util/curve25519.ts @@ -555,7 +555,7 @@ export class Curve25519 { } } - unpack25519(o: Int32Array, n: Int32Array): void { + unpack25519(o: Int32Array, n: Uint8Array): void { for (let i = 0; i < 16; i++) { o[i] = n[2 * i] + (n[2 * i + 1] << 8) } @@ -563,7 +563,7 @@ export class Curve25519 { o[15] &= 0x7fff } - unpackNeg(r: Int32Array[], p: Int32Array): number { + unpackNeg(r: Int32Array[], p: Uint8Array): number { const t = this.gf(), chk = this.gf(), num = this.gf(), diff --git a/package-lock.json b/package-lock.json index 7783b0d..a71d636 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,6 +4,15 @@ "lockfileVersion": 1, "requires": true, "dependencies": { + "@types/bignumber.js": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@types/bignumber.js/-/bignumber.js-5.0.0.tgz", + "integrity": "sha512-0DH7aPGCClywOFaxxjE6UwpN2kQYe9LwuDQMv+zYA97j5GkOMo8e66LYT+a8JYU7jfmUFRZLa9KycxHDsKXJCA==", + "dev": true, + "requires": { + "bignumber.js": "9.0.0" + } + }, "@types/node": { "version": "12.7.12", "resolved": "https://registry.npmjs.org/@types/node/-/node-12.7.12.tgz", @@ -15,6 +24,12 @@ "resolved": "https://registry.npmjs.org/bignumber/-/bignumber-1.1.0.tgz", "integrity": "sha1-5qsKdD2l8+oBjlwXWX0SH3howVk=" }, + "bignumber.js": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.0.0.tgz", + "integrity": "sha512-t/OYhhJ2SD+YGBQcjY8GzzDHEk9f3nerxjtfa6tlMXfe7frs/WozhvCNoGvpM0P3bNf3Gq5ZRMlGr5f3r4/N8A==", + "dev": true + }, "blakejs": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/blakejs/-/blakejs-1.1.0.tgz", diff --git a/package.json b/package.json index 4bf0015..c76f349 100644 --- a/package.json +++ b/package.json @@ -14,14 +14,16 @@ }, "main": "index.js", "scripts": { + "build": "tsc", "test": "echo \"Error: no test specified\" && exit 1" }, "dependencies": { - "bignumber": "^1.1.0", - "blakejs": "^1.1.0" + "bignumber": "1.1.0", + "blakejs": "1.1.0" }, "devDependencies": { - "@types/node": "^12.7.12", + "@types/bignumber.js": "5.0.0", + "@types/node": "12.7.12", "typescript": "3.6.3" } } diff --git a/tsconfig.json b/tsconfig.json index e3007c0..8c3ddd8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,9 +7,9 @@ "strict": true, "esModuleInterop": true, "downlevelIteration": true, + "strictNullChecks": false, "types": [ - "node", - "index.d.ts" + "node" ], "lib": [ "es2017" -- 2.34.1