From: Chris Duncan Date: Sat, 9 Aug 2025 08:34:58 +0000 (-0700) Subject: Update crypto module imports. X-Git-Tag: v0.10.5~41^2~145 X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=ba7f6a385e8fce1976c659adb0b808ff93c1c770;p=libnemo.git Update crypto module imports. --- diff --git a/package.json b/package.json index 649cfec..f2196c2 100644 --- a/package.json +++ b/package.json @@ -54,6 +54,7 @@ "test:prod": "npm run build:prod && npm run test:node" }, "imports": { + "#crypto": "./src/lib/crypto/index.js", "#types": "./src/types.d.ts" }, "dependencies": { diff --git a/src/lib/account.ts b/src/lib/account.ts index 109d618..f0b6e67 100644 --- a/src/lib/account.ts +++ b/src/lib/account.ts @@ -1,12 +1,11 @@ //! SPDX-FileCopyrightText: 2025 Chris Duncan //! SPDX-License-Identifier: GPL-3.0-or-later -import { Blake2b } from './crypto/blake2b' +import { Blake2b, NanoNaCl } from '#crypto' +import { Key, KeyPair } from '#types' import { ACCOUNT_KEY_BYTE_LENGTH, ACCOUNT_KEY_HEX_LENGTH, ALPHABET, PREFIX, PREFIX_LEGACY } from './constants' import { base32, bytes, hex } from './convert' -import { NanoNaCl } from './crypto/nano-nacl' import { Rpc } from './rpc' -import { Key, KeyPair } from '#types' /** * Represents a single Nano address and the associated public key. To include the diff --git a/src/lib/block.ts b/src/lib/block.ts index 6969891..3261c50 100644 --- a/src/lib/block.ts +++ b/src/lib/block.ts @@ -2,11 +2,10 @@ //! SPDX-License-Identifier: GPL-3.0-or-later import { NanoPow } from 'nano-pow' +import { Blake2b, NanoNaCl } from '#crypto' import { Account } from './account' -import { Blake2b } from './crypto/blake2b' import { BURN_PUBLIC_KEY, PREAMBLE, DIFFICULTY_RECEIVE, DIFFICULTY_SEND, UNITS } from './constants' import { bytes, dec, hex } from './convert' -import { NanoNaCl } from './crypto/nano-nacl' import { Rpc } from './rpc' import { convert } from './tools' import { Wallet } from './wallet/wallet' diff --git a/src/lib/crypto/index.ts b/src/lib/crypto/index.ts new file mode 100644 index 0000000..bc47074 --- /dev/null +++ b/src/lib/crypto/index.ts @@ -0,0 +1,6 @@ +import { Bip39 } from "./bip39" +import { Bip44 } from "./bip44" +import { Blake2b } from "./blake2b" +import { NanoNaCl } from "./nano-nacl" + +export { Bip39, Bip44, Blake2b, NanoNaCl } diff --git a/src/lib/crypto/nano-nacl.ts b/src/lib/crypto/nano-nacl.ts index 21f8c95..c235280 100644 --- a/src/lib/crypto/nano-nacl.ts +++ b/src/lib/crypto/nano-nacl.ts @@ -3,7 +3,7 @@ 'use strict' -import { Blake2b } from './blake2b' +import { Blake2b } from '#crypto' /** * Ported in 2014 by Dmitry Chestnykh and Devi Mandiri. diff --git a/src/lib/rolodex.ts b/src/lib/rolodex.ts index 8bd0e3b..28809de 100644 --- a/src/lib/rolodex.ts +++ b/src/lib/rolodex.ts @@ -1,10 +1,10 @@ //! SPDX-FileCopyrightText: 2025 Chris Duncan //! SPDX-License-Identifier: GPL-3.0-or-later +import { NamedData } from '#types' import { Account } from './account' import { Database } from './database' import { verify } from './tools' -import { NamedData } from '#types' /** * Represents a basic address book of Nano accounts. Multiple addresses can be diff --git a/src/lib/tools.ts b/src/lib/tools.ts index b8fc267..7deb136 100644 --- a/src/lib/tools.ts +++ b/src/lib/tools.ts @@ -1,16 +1,15 @@ //! SPDX-FileCopyrightText: 2025 Chris Duncan //! SPDX-License-Identifier: GPL-3.0-or-later +import { Blake2b, NanoNaCl } from '#crypto' +import { Key } from '#types' import { Account } from './account' -import { Blake2b } from './crypto/blake2b' import { Block } from './block' import { MAX_SUPPLY, UNITS } from './constants' import { bytes, hex } from './convert' import { Ledger } from './wallet/ledger' -import { NanoNaCl } from './crypto/nano-nacl' import { Rpc } from './rpc' import { Wallet } from './wallet/wallet' -import { Key } from '#types' type SweepResult = { status: "success" | "error" diff --git a/src/lib/wallet/safe.ts b/src/lib/wallet/safe.ts index 4fc6b94..21c2909 100644 --- a/src/lib/wallet/safe.ts +++ b/src/lib/wallet/safe.ts @@ -4,13 +4,10 @@ 'use strict' import { parentPort } from 'node:worker_threads' -import { Bip39 } from '../crypto/bip39' -import { Bip44 } from '../crypto/bip44' -import { Blake2b } from '../crypto/blake2b' +import { Bip39, Bip44, Blake2b, NanoNaCl } from '#crypto' +import { NamedData } from '#types' import { default as Constants, BIP44_COIN_NANO } from '../constants' import { default as Convert, bytes, hex, utf8 } from '../convert' -import { NanoNaCl } from '../crypto/nano-nacl' -import { NamedData } from '#types' /** * Cross-platform worker for managing wallet secrets. diff --git a/src/lib/wallet/wallet.ts b/src/lib/wallet/wallet.ts index 8d81079..61aa240 100644 --- a/src/lib/wallet/wallet.ts +++ b/src/lib/wallet/wallet.ts @@ -1,8 +1,9 @@ //! SPDX-FileCopyrightText: 2025 Chris Duncan //! SPDX-License-Identifier: GPL-3.0-or-later +import { Bip39 } from '#crypto' +import { KeyPair, NamedData, WalletType } from '#types' import { Account, AccountList } from '../account' -import { Bip39 } from '../crypto/bip39' import { Block } from '../block' import { ADDRESS_GAP } from '../constants' import { bytes, hex, utf8 } from '../convert' @@ -10,7 +11,6 @@ import { Database } from '../database' import { Rpc } from '../rpc' import { default as SafeWorker } from './safe' import { WorkerQueue } from './worker-queue' -import { KeyPair, NamedData, WalletType } from '#types' /** * Represents a wallet containing numerous Nano accounts derived from a single diff --git a/src/main.ts b/src/main.ts index 777b871..090c562 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,8 +1,8 @@ //! SPDX-FileCopyrightText: 2025 Chris Duncan //! SPDX-License-Identifier: GPL-3.0-or-later +import { Blake2b } from '#crypto' import { Account } from './lib/account' -import { Blake2b } from './lib/crypto/blake2b' import { Block } from './lib/block' import { Ledger } from './lib/wallet/ledger' import { Rolodex } from './lib/rolodex' @@ -11,8 +11,8 @@ import { Tools } from './lib/tools' import { Wallet } from './lib/wallet/wallet' export { - Account, Blake2b, + Account, Block, Ledger, Rolodex,