From: Chris Duncan Date: Sat, 9 Aug 2025 06:27:47 +0000 (-0700) Subject: Create new directories to improve file organization. X-Git-Tag: v0.10.5~41^2~159 X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=21516dfc8723a07d3106b2ff365b2a026d7a38c9;p=libnemo.git Create new directories to improve file organization. --- diff --git a/src/lib/account.ts b/src/lib/account.ts index b01d265..109d618 100644 --- a/src/lib/account.ts +++ b/src/lib/account.ts @@ -1,10 +1,10 @@ //! SPDX-FileCopyrightText: 2025 Chris Duncan //! SPDX-License-Identifier: GPL-3.0-or-later -import { Blake2b } from './blake2b' +import { Blake2b } from './crypto/blake2b' import { ACCOUNT_KEY_BYTE_LENGTH, ACCOUNT_KEY_HEX_LENGTH, ALPHABET, PREFIX, PREFIX_LEGACY } from './constants' import { base32, bytes, hex } from './convert' -import { NanoNaCl } from './nano-nacl' +import { NanoNaCl } from './crypto/nano-nacl' import { Rpc } from './rpc' import { Key, KeyPair } from '#types' diff --git a/src/lib/block.ts b/src/lib/block.ts index c02ca66..8bdbaeb 100644 --- a/src/lib/block.ts +++ b/src/lib/block.ts @@ -3,13 +3,13 @@ import { NanoPow } from 'nano-pow' import { Account } from './account' -import { Blake2b } from './blake2b' +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 './nano-nacl' +import { NanoNaCl } from './crypto/nano-nacl' import { Rpc } from './rpc' import { convert } from './tools' -import { Wallet } from './wallet' +import { Wallet } from './wallet/wallet' /** * Represents a block as defined by the Nano cryptocurrency protocol. @@ -424,7 +424,7 @@ export class Block { } } else if (typeof input === 'number') { const index = input - const { Ledger } = await import('./ledger') + const { Ledger } = await import('./wallet/ledger') const ledger = await Ledger.create() await ledger.connect() if (param && param instanceof Block) { diff --git a/src/lib/bip39.ts b/src/lib/crypto/bip39.ts similarity index 98% rename from src/lib/bip39.ts rename to src/lib/crypto/bip39.ts index e2a5485..3ae1261 100644 --- a/src/lib/bip39.ts +++ b/src/lib/crypto/bip39.ts @@ -1,8 +1,8 @@ //! SPDX-FileCopyrightText: 2025 Chris Duncan //! SPDX-License-Identifier: GPL-3.0-or-later -import { BIP39_ITERATIONS } from './constants' -import { bytes, utf8 } from './convert' +import { BIP39_ITERATIONS } from '../constants' +import { bytes, utf8 } from '../convert' /** * Represents a mnemonic phrase that identifies a wallet as defined by BIP-39. diff --git a/src/lib/bip44.ts b/src/lib/crypto/bip44.ts similarity index 99% rename from src/lib/bip44.ts rename to src/lib/crypto/bip44.ts index 00fd399..81c4823 100644 --- a/src/lib/bip44.ts +++ b/src/lib/crypto/bip44.ts @@ -1,7 +1,7 @@ //! SPDX-FileCopyrightText: 2025 Chris Duncan //! SPDX-License-Identifier: GPL-3.0-or-later -import { BIP44_PURPOSE, HARDENED_OFFSET, SLIP10_ED25519 } from './constants' +import { BIP44_PURPOSE, HARDENED_OFFSET, SLIP10_ED25519 } from '../constants' type ExtendedKey = { privateKey: ArrayBuffer diff --git a/src/lib/blake2b.ts b/src/lib/crypto/blake2b.ts similarity index 100% rename from src/lib/blake2b.ts rename to src/lib/crypto/blake2b.ts diff --git a/src/lib/nano-nacl.ts b/src/lib/crypto/nano-nacl.ts similarity index 100% rename from src/lib/nano-nacl.ts rename to src/lib/crypto/nano-nacl.ts diff --git a/src/lib/tools.ts b/src/lib/tools.ts index ea597ea..b8fc267 100644 --- a/src/lib/tools.ts +++ b/src/lib/tools.ts @@ -2,14 +2,14 @@ //! SPDX-License-Identifier: GPL-3.0-or-later import { Account } from './account' -import { Blake2b } from './blake2b' +import { Blake2b } from './crypto/blake2b' import { Block } from './block' import { MAX_SUPPLY, UNITS } from './constants' import { bytes, hex } from './convert' -import { Ledger } from './ledger' -import { NanoNaCl } from './nano-nacl' +import { Ledger } from './wallet/ledger' +import { NanoNaCl } from './crypto/nano-nacl' import { Rpc } from './rpc' -import { Wallet } from './wallet' +import { Wallet } from './wallet/wallet' import { Key } from '#types' type SweepResult = { diff --git a/src/lib/ledger.ts b/src/lib/wallet/ledger.ts similarity index 96% rename from src/lib/ledger.ts rename to src/lib/wallet/ledger.ts index b7044a3..89d2dab 100644 --- a/src/lib/ledger.ts +++ b/src/lib/wallet/ledger.ts @@ -5,12 +5,12 @@ import { ledgerUSBVendorId } from '@ledgerhq/devices' import { default as TransportBLE } from '@ledgerhq/hw-transport-web-ble' import { default as TransportUSB } from '@ledgerhq/hw-transport-webusb' import { default as TransportHID } from '@ledgerhq/hw-transport-webhid' -import { Account, AccountList } from './account' -import { Block } from './block' -import { BIP44_COIN_NANO, BIP44_PURPOSE, HARDENED_OFFSET, LEDGER_ADPU_CODES, LEDGER_STATUS_CODES } from './constants' -import { bytes, dec, hex } from './convert' -import { Database } from './database' -import { Rpc } from './rpc' +import { Account, AccountList } from '../account' +import { Block } from '../block' +import { BIP44_COIN_NANO, BIP44_PURPOSE, HARDENED_OFFSET, LEDGER_ADPU_CODES, LEDGER_STATUS_CODES } from '../constants' +import { bytes, dec, hex } from '../convert' +import { Database } from '../database' +import { Rpc } from '../rpc' import { Wallet } from './wallet' import { DeviceStatus, LedgerAccountResponse, LedgerResponse, LedgerSignResponse, LedgerVersionResponse } from '#types' diff --git a/src/lib/safe.ts b/src/lib/wallet/safe.ts similarity index 98% rename from src/lib/safe.ts rename to src/lib/wallet/safe.ts index c971827..c39b9b6 100644 --- a/src/lib/safe.ts +++ b/src/lib/wallet/safe.ts @@ -4,12 +4,12 @@ 'use strict' import { parentPort } from 'node:worker_threads' -import { Bip39 } from './bip39' -import { Bip44 } from './bip44' -import { Blake2b } from './blake2b' -import { default as Constants, BIP44_COIN_NANO } from './constants' -import { default as Convert, bytes, hex, utf8 } from './convert' -import { NanoNaCl } from './nano-nacl' +import { Bip39 } from '../crypto/bip39' +import { Bip44 } from '../crypto/bip44' +import { Blake2b } from '../crypto/blake2b' +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' /** diff --git a/src/lib/wallet.ts b/src/lib/wallet/wallet.ts similarity index 95% rename from src/lib/wallet.ts rename to src/lib/wallet/wallet.ts index bb5c12a..8d81079 100644 --- a/src/lib/wallet.ts +++ b/src/lib/wallet/wallet.ts @@ -1,13 +1,13 @@ //! SPDX-FileCopyrightText: 2025 Chris Duncan //! SPDX-License-Identifier: GPL-3.0-or-later -import { Account, AccountList } from './account' -import { Bip39 } from './bip39' -import { Block } from './block' -import { ADDRESS_GAP } from './constants' -import { bytes, hex, utf8 } from './convert' -import { Database } from './database' -import { Rpc } from './rpc' +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' +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' diff --git a/src/lib/worker-queue.ts b/src/lib/wallet/worker-queue.ts similarity index 100% rename from src/lib/worker-queue.ts rename to src/lib/wallet/worker-queue.ts diff --git a/src/main.ts b/src/main.ts index 06dfc6c..777b871 100644 --- a/src/main.ts +++ b/src/main.ts @@ -2,13 +2,13 @@ //! SPDX-License-Identifier: GPL-3.0-or-later import { Account } from './lib/account' -import { Blake2b } from './lib/blake2b' +import { Blake2b } from './lib/crypto/blake2b' import { Block } from './lib/block' -import { Ledger } from './lib/ledger' +import { Ledger } from './lib/wallet/ledger' import { Rolodex } from './lib/rolodex' import { Rpc } from './lib/rpc' import { Tools } from './lib/tools' -import { Wallet } from './lib/wallet' +import { Wallet } from './lib/wallet/wallet' export { Account,