diff --git a/package.json b/package.json index 0b81528a5f..6ace9f1558 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "lerna": "5.6.2", "ncp": "2.0.0", "ts-jest": "27.1.5", - "typescript": "4.8.3", + "typescript": "5.0.4", "wait-on": "6.0.1" }, "dependencies": {}, diff --git a/packages/neuron-ui/src/components/PasswordRequest/index.tsx b/packages/neuron-ui/src/components/PasswordRequest/index.tsx index 9163b5aad6..9ed21a258d 100644 --- a/packages/neuron-ui/src/components/PasswordRequest/index.tsx +++ b/packages/neuron-ui/src/components/PasswordRequest/index.tsx @@ -153,7 +153,7 @@ const PasswordRequest = () => { break } await sendTransaction({ walletID, tx: generatedTx, description, password, multisigConfig })(dispatch).then( - (res: { result: string; status: number; message: string | { content: string } }) => { + (res: { result?: string; status: number; message: string | { content: string } }) => { if (isSuccessResponse(res)) { requestOpenInExplorer({ type: 'transaction', key: res.result }) } else if (res.status === ErrorCode.PasswordIncorrect) { diff --git a/packages/neuron-wallet/package.json b/packages/neuron-wallet/package.json index 937be7321e..ef2159cb86 100644 --- a/packages/neuron-wallet/package.json +++ b/packages/neuron-wallet/package.json @@ -18,8 +18,8 @@ "license": "MIT", "scripts": { "start": "electron .", - "build": "ttsc", - "watch": "ttsc -w", + "build": "tsc", + "watch": "tsc -w", "start:dev": "yarn run build && electron .", "start:debug": "yarn run build && electron --inspect=5858 .", "clean": "npx rimraf dist/*", @@ -53,7 +53,7 @@ "electron-window-state": "5.0.3", "elliptic": "6.5.4", "hw-app-ckb": "0.1.2", - "i18next": "17.3.1", + "i18next": "21.10.0", "leveldown": "6.1.1", "levelup": "4.4.0", "reflect-metadata": "0.1.13", @@ -80,7 +80,6 @@ "@types/levelup": "4.3.3", "@types/sqlite3": "3.1.8", "@types/uuid": "8.3.4", - "@zerollup/ts-transform-paths": "1.7.18", "devtron": "1.4.0", "electron": "24.1.1", "electron-build-env": "0.2.0", @@ -93,7 +92,6 @@ "lint-staged": "13.2.1", "neuron-ui": "0.106.0", "prettier": "2.8.7", - "ttypescript": "1.5.15", - "typescript": "4.2.3" + "typescript": "5.0.4" } } diff --git a/packages/neuron-wallet/src/block-sync-renderer/index.ts b/packages/neuron-wallet/src/block-sync-renderer/index.ts index 76abec472a..149dcb8e2c 100644 --- a/packages/neuron-wallet/src/block-sync-renderer/index.ts +++ b/packages/neuron-wallet/src/block-sync-renderer/index.ts @@ -1,20 +1,20 @@ import path from 'path' import { fork, ChildProcess } from 'child_process' -import SyncApiController from 'controllers/sync-api' -import NetworksService from 'services/networks' -import AddressService from 'services/addresses' -import WalletService from 'services/wallets' -import { Network, EMPTY_GENESIS_HASH } from 'models/network' -import DataUpdateSubject from 'models/subjects/data-update' -import AddressCreatedSubject from 'models/subjects/address-created-subject' -import WalletDeletedSubject from 'models/subjects/wallet-deleted-subject' -import TxDbChangedSubject from 'models/subjects/tx-db-changed-subject' +import SyncApiController from '../controllers/sync-api' +import NetworksService from '../services/networks' +import AddressService from '../services/addresses' +import WalletService from '../services/wallets' +import { Network, EMPTY_GENESIS_HASH } from '../models/network' +import DataUpdateSubject from '../models/subjects/data-update' +import AddressCreatedSubject from '../models/subjects/address-created-subject' +import WalletDeletedSubject from '../models/subjects/wallet-deleted-subject' +import TxDbChangedSubject from '../models/subjects/tx-db-changed-subject' import { LumosCellQuery, LumosCell } from './sync/indexer-connector' import { WorkerMessage, StartParams, QueryIndexerParams } from './task' -import logger from 'utils/logger' -import CommonUtils from 'utils/common' -import queueWrapper from 'utils/queue' -import env from 'env' +import logger from '../utils/logger' +import CommonUtils from '../utils/common' +import queueWrapper from '../utils/queue' +import env from '../env' let network: Network | null let child: ChildProcess | null = null diff --git a/packages/neuron-wallet/src/block-sync-renderer/sync/indexer-cache-service.ts b/packages/neuron-wallet/src/block-sync-renderer/sync/indexer-cache-service.ts index 3ac3ab9c6d..e36745206e 100644 --- a/packages/neuron-wallet/src/block-sync-renderer/sync/indexer-cache-service.ts +++ b/packages/neuron-wallet/src/block-sync-renderer/sync/indexer-cache-service.ts @@ -1,9 +1,9 @@ import { getConnection } from 'typeorm' import { queue } from 'async' -import AddressMeta from 'database/address/meta' -import IndexerTxHashCache from 'database/chain/entities/indexer-tx-hash-cache' -import RpcService from 'services/rpc-service' -import TransactionWithStatus from 'models/chain/transaction-with-status' +import AddressMeta from '../../database/address/meta' +import IndexerTxHashCache from '../../database/chain/entities/indexer-tx-hash-cache' +import RpcService from '../../services/rpc-service' +import TransactionWithStatus from '../../models/chain/transaction-with-status' import { TransactionCollector, CellCollector, CkbIndexer } from '@nervina-labs/ckb-indexer' export default class IndexerCacheService { diff --git a/packages/neuron-wallet/src/block-sync-renderer/sync/indexer-connector.ts b/packages/neuron-wallet/src/block-sync-renderer/sync/indexer-connector.ts index 15c2e1b955..0da3dbcbdd 100644 --- a/packages/neuron-wallet/src/block-sync-renderer/sync/indexer-connector.ts +++ b/packages/neuron-wallet/src/block-sync-renderer/sync/indexer-connector.ts @@ -1,16 +1,16 @@ // eslint-disable-next-line prettier/prettier -import type { ScriptHashType } from 'models/chain/script' +import type { ScriptHashType } from '../../models/chain/script' import { Subject } from 'rxjs' import { queue, AsyncQueue } from 'async' import { Tip, QueryOptions } from '@ckb-lumos/base' import { CkbIndexer, CellCollector } from '@nervina-labs/ckb-indexer' -import logger from 'utils/logger' -import CommonUtils from 'utils/common' -import RpcService from 'services/rpc-service' -import TransactionWithStatus from 'models/chain/transaction-with-status' -import { Address } from "models/address" -import AddressMeta from 'database/address/meta' -import IndexerTxHashCache from 'database/chain/entities/indexer-tx-hash-cache' +import logger from '../../utils/logger' +import CommonUtils from '../../utils/common' +import RpcService from '../../services/rpc-service' +import TransactionWithStatus from '../../models/chain/transaction-with-status' +import { Address } from '../../models/address' +import AddressMeta from '../../database/address/meta' +import IndexerTxHashCache from '../../database/chain/entities/indexer-tx-hash-cache' import IndexerCacheService from './indexer-cache-service' export interface LumosCellQuery { diff --git a/packages/neuron-wallet/src/block-sync-renderer/sync/queue.ts b/packages/neuron-wallet/src/block-sync-renderer/sync/queue.ts index 462de283e1..c1ad3ef332 100644 --- a/packages/neuron-wallet/src/block-sync-renderer/sync/queue.ts +++ b/packages/neuron-wallet/src/block-sync-renderer/sync/queue.ts @@ -1,21 +1,21 @@ import { queue, AsyncQueue } from 'async' -import { TransactionPersistor } from 'services/tx' -import RpcService from 'services/rpc-service' -import AssetAccountService from 'services/asset-account-service' -import OutPoint from 'models/chain/out-point' -import Transaction from 'models/chain/transaction' -import TransactionWithStatus from 'models/chain/transaction-with-status' -import SystemScriptInfo from 'models/system-script-info' -import AssetAccountInfo from 'models/asset-account-info' -import { Address as AddressInterface } from "models/address" -import AddressParser from 'models/address-parser' -import Multisig from 'models/multisig' +import { TransactionPersistor } from '../../services/tx' +import RpcService from '../../services/rpc-service' +import AssetAccountService from '../../services/asset-account-service' +import OutPoint from '../../models/chain/out-point' +import Transaction from '../../models/chain/transaction' +import TransactionWithStatus from '../../models/chain/transaction-with-status' +import SystemScriptInfo from '../../models/system-script-info' +import AssetAccountInfo from '../../models/asset-account-info' +import { Address as AddressInterface } from '../../models/address' +import AddressParser from '../../models/address-parser' +import Multisig from '../../models/multisig' import TxAddressFinder from './tx-address-finder' import IndexerConnector, { BlockTips } from './indexer-connector' import IndexerCacheService from './indexer-cache-service' -import logger from 'utils/logger' -import CommonUtils from 'utils/common' -import { ShouldInChildProcess } from 'exceptions' +import logger from '../../utils/logger' +import CommonUtils from '../../utils/common' +import { ShouldInChildProcess } from '../../exceptions' export default class Queue { // eslint-disable-next-line prettier/prettier diff --git a/packages/neuron-wallet/src/block-sync-renderer/sync/tx-address-finder.ts b/packages/neuron-wallet/src/block-sync-renderer/sync/tx-address-finder.ts index 2c8ce83ffa..37e32d262c 100644 --- a/packages/neuron-wallet/src/block-sync-renderer/sync/tx-address-finder.ts +++ b/packages/neuron-wallet/src/block-sync-renderer/sync/tx-address-finder.ts @@ -1,11 +1,11 @@ import { getConnection } from 'typeorm' import { scriptToAddress } from '@nervosnetwork/ckb-sdk-utils' -import OutputEntity from 'database/chain/entities/output' -import NetworksService from 'services/networks' -import Output from 'models/chain/output' -import OutPoint from 'models/chain/out-point' -import Transaction from 'models/chain/transaction' -import SystemScriptInfo from 'models/system-script-info' +import OutputEntity from '../../database/chain/entities/output' +import NetworksService from '../../services/networks' +import Output from '../../models/chain/output' +import OutPoint from '../../models/chain/out-point' +import Transaction from '../../models/chain/transaction' +import SystemScriptInfo from '../../models/system-script-info' export interface AnyoneCanPayInfo { tokenID: string diff --git a/packages/neuron-wallet/src/block-sync-renderer/task.ts b/packages/neuron-wallet/src/block-sync-renderer/task.ts index 8a52a7764a..475aea45c5 100644 --- a/packages/neuron-wallet/src/block-sync-renderer/task.ts +++ b/packages/neuron-wallet/src/block-sync-renderer/task.ts @@ -1,11 +1,11 @@ // eslint-disable-next-line prettier/prettier import type { LumosCellQuery } from './sync/indexer-connector' -import initConnection from 'database/chain/ormconfig' +import initConnection from '../database/chain/ormconfig' import { register as registerTxStatusListener, } from './tx-status-listener' import SyncQueue from './sync/queue' -import logger from 'utils/logger' -import { ShouldInChildProcess } from 'exceptions' -import env from 'env' +import logger from '../utils/logger' +import { ShouldInChildProcess } from '../exceptions' +import env from '../env' let syncQueue: SyncQueue | null diff --git a/packages/neuron-wallet/src/block-sync-renderer/tx-status-listener.ts b/packages/neuron-wallet/src/block-sync-renderer/tx-status-listener.ts index 1d8378a86e..cb412f3591 100644 --- a/packages/neuron-wallet/src/block-sync-renderer/tx-status-listener.ts +++ b/packages/neuron-wallet/src/block-sync-renderer/tx-status-listener.ts @@ -1,12 +1,12 @@ import { getConnection } from 'typeorm' import CKB from '@nervosnetwork/ckb-sdk-core' -import { CONNECTION_NOT_FOUND_NAME } from 'database/chain/ormconfig' -import { FailedTransaction, TransactionPersistor } from 'services/tx' -import RpcService from 'services/rpc-service' -import NetworksService from 'services/networks' -import { TransactionStatus } from 'models/chain/transaction' -import TransactionWithStatus from 'models/chain/transaction-with-status' -import logger from 'utils/logger' +import { CONNECTION_NOT_FOUND_NAME } from '../database/chain/ormconfig' +import { FailedTransaction, TransactionPersistor } from '../services/tx' +import RpcService from '../services/rpc-service' +import NetworksService from '../services/networks' +import { TransactionStatus } from '../models/chain/transaction' +import TransactionWithStatus from '../models/chain/transaction-with-status' +import logger from '../utils/logger' import { interval } from 'rxjs' const getTransactionStatus = async (hash: string) => { diff --git a/packages/neuron-wallet/src/controllers/anyone-can-pay.ts b/packages/neuron-wallet/src/controllers/anyone-can-pay.ts index a32298b0a0..1016d8bdb4 100644 --- a/packages/neuron-wallet/src/controllers/anyone-can-pay.ts +++ b/packages/neuron-wallet/src/controllers/anyone-can-pay.ts @@ -1,11 +1,11 @@ -import AssetAccountInfo from 'models/asset-account-info' -import Transaction from 'models/chain/transaction' -import { ServiceHasNoResponse } from 'exceptions' -import { ResponseCode } from 'utils/const' -import AnyoneCanPayService from 'services/anyone-can-pay' -import TransactionSender from 'services/transaction-sender' -import { set as setDescription } from 'services/tx/transaction-description' -import AddressParser from 'models/address-parser' +import AssetAccountInfo from '../models/asset-account-info' +import Transaction from '../models/chain/transaction' +import { ServiceHasNoResponse } from '../exceptions' +import { ResponseCode } from '../utils/const' +import AnyoneCanPayService from '../services/anyone-can-pay' +import TransactionSender from '../services/transaction-sender' +import { set as setDescription } from '../services/tx/transaction-description' +import AddressParser from '../models/address-parser' export interface GenerateAnyoneCanPayTxParams { walletID: string diff --git a/packages/neuron-wallet/src/controllers/api.ts b/packages/neuron-wallet/src/controllers/api.ts index 226fbad635..e731218eee 100644 --- a/packages/neuron-wallet/src/controllers/api.ts +++ b/packages/neuron-wallet/src/controllers/api.ts @@ -15,28 +15,28 @@ import { import { t } from 'i18next' import path from 'path' import fs from 'fs' -import env from 'env' +import env from '../env' import { showWindow } from './app/show-window' -import CommonUtils from 'utils/common' -import { NetworkType, Network } from 'models/network' -import { ConnectionStatusSubject } from 'models/subjects/node' -import NetworksService from 'services/networks' -import WalletsService from 'services/wallets' -import SettingsService, { Locale } from 'services/settings' -import { ResponseCode, SETTINGS_WINDOW_TITLE, SETTINGS_WINDOW_WIDTH } from 'utils/const' -import { clean as cleanChain } from 'database/chain' -import WalletsController from 'controllers/wallets' -import TransactionsController from 'controllers/transactions' -import DaoController from 'controllers/dao' -import NetworksController from 'controllers/networks' -import UpdateController from 'controllers/update' -import MultisigController from 'controllers/multisig' -import Transaction from 'models/chain/transaction' -import OutPoint from 'models/chain/out-point' -import SignMessageController from 'controllers/sign-message' +import CommonUtils from '../utils/common' +import { NetworkType, Network } from '../models/network' +import { ConnectionStatusSubject } from '../models/subjects/node' +import NetworksService from '../services/networks' +import WalletsService from '../services/wallets' +import SettingsService, { Locale } from '../services/settings' +import { ResponseCode, SETTINGS_WINDOW_TITLE, SETTINGS_WINDOW_WIDTH } from '../utils/const' +import { clean as cleanChain } from '../database/chain' +import WalletsController from '../controllers/wallets' +import TransactionsController from '../controllers/transactions' +import DaoController from '../controllers/dao' +import NetworksController from '../controllers/networks' +import UpdateController from '../controllers/update' +import MultisigController from '../controllers/multisig' +import Transaction from '../models/chain/transaction' +import OutPoint from '../models/chain/out-point' +import SignMessageController from '../controllers/sign-message' import CustomizedAssetsController from './customized-assets' -import SystemScriptInfo from 'models/system-script-info' -import logger from 'utils/logger' +import SystemScriptInfo from '../models/system-script-info' +import logger from '../utils/logger' import AssetAccountController, { GenerateWithdrawChequeTxParams } from './asset-account' import { GenerateCreateAssetAccountTxParams, @@ -48,16 +48,16 @@ import { } from './asset-account' import AnyoneCanPayController from './anyone-can-pay' import { GenerateAnyoneCanPayTxParams, SendAnyoneCanPayTxParams } from './anyone-can-pay' -import { DeviceInfo, ExtendedPublicKey } from 'services/hardware/common' +import { DeviceInfo, ExtendedPublicKey } from '../services/hardware/common' import HardwareController from './hardware' import OfflineSignController from './offline-sign' -import SUDTController from "controllers/sudt" -import SyncedBlockNumber from 'models/synced-block-number' -import IndexerService from 'services/indexer' -import MultisigConfigModel from 'models/multisig-config' -import startMonitor, { stopMonitor } from 'services/monitor' -import { migrateCkbData } from 'services/ckb-runner' -import NodeService from 'services/node' +import SUDTController from "./sudt" +import SyncedBlockNumber from '../models/synced-block-number' +import IndexerService from '../services/indexer' +import MultisigConfigModel from '../models/multisig-config' +import startMonitor, { stopMonitor } from '../services/monitor' +import { migrateCkbData } from '../services/ckb-runner' +import NodeService from '../services/node' export type Command = 'export-xpubkey' | 'import-xpubkey' | 'delete-wallet' | 'backup-wallet' | 'migrate-acp' // Handle channel messages from renderer process and user actions. diff --git a/packages/neuron-wallet/src/controllers/app/index.ts b/packages/neuron-wallet/src/controllers/app/index.ts index f00c8e0b7b..377247c796 100644 --- a/packages/neuron-wallet/src/controllers/app/index.ts +++ b/packages/neuron-wallet/src/controllers/app/index.ts @@ -3,17 +3,17 @@ import { t } from 'i18next' import { app as electronApp, BrowserWindow, nativeImage } from 'electron' import windowStateKeeper from 'electron-window-state' -import env from 'env' +import env from '../../env' import { updateApplicationMenu } from './menu' -import logger from 'utils/logger' +import logger from '../../utils/logger' import { subscribe } from './subscribe' -import { register as registerListeners } from 'listeners/main' -import WalletsService from 'services/wallets' -import ApiController, { Command } from 'controllers/api' -import { migrate as mecuryMigrate } from 'controllers/mercury' -import SyncApiController from 'controllers/sync-api' -import { SETTINGS_WINDOW_TITLE } from 'utils/const' -import { stopCkbNode } from 'services/ckb-runner' +import { register as registerListeners } from '../../listeners/main' +import WalletsService from '../../services/wallets' +import ApiController, { Command } from '../api' +import { migrate as mecuryMigrate } from '../mercury' +import SyncApiController from '../sync-api' +import { SETTINGS_WINDOW_TITLE } from '../../utils/const' +import { stopCkbNode } from '../../services/ckb-runner' const app = electronApp diff --git a/packages/neuron-wallet/src/controllers/app/menu.ts b/packages/neuron-wallet/src/controllers/app/menu.ts index 23fcad9d1d..588e8c7001 100644 --- a/packages/neuron-wallet/src/controllers/app/menu.ts +++ b/packages/neuron-wallet/src/controllers/app/menu.ts @@ -4,18 +4,18 @@ import { app, shell, clipboard, BrowserWindow, dialog, MenuItemConstructorOption import { t } from 'i18next' import { Subject } from 'rxjs' import { throttleTime } from 'rxjs/operators' -import env from 'env' -import UpdateController from 'controllers/update' -import ExportDebugController from 'controllers/export-debug' -import { showWindow } from 'controllers/app/show-window' -import WalletsService from 'services/wallets' -import OfflineSignService from 'services/offline-sign' -import CommandSubject from 'models/subjects/command' -import logger from 'utils/logger' -import { SETTINGS_WINDOW_TITLE, SETTINGS_WINDOW_WIDTH } from 'utils/const' -import { OfflineSignJSON } from 'models/offline-sign' -import NetworksService from 'services/networks' -import { clearCkbNodeCache } from 'services/ckb-runner' +import env from '../../env' +import UpdateController from '../update' +import ExportDebugController from '../export-debug' +import { showWindow } from '../app/show-window' +import WalletsService from '../../services/wallets' +import OfflineSignService from '../../services/offline-sign' +import CommandSubject from '../../models/subjects/command' +import logger from '../../utils/logger' +import { SETTINGS_WINDOW_TITLE, SETTINGS_WINDOW_WIDTH } from '../../utils/const' +import { OfflineSignJSON } from '../../models/offline-sign' +import NetworksService from '../../services/networks' +import { clearCkbNodeCache } from '../../services/ckb-runner' enum URL { Settings = '/settings/general', diff --git a/packages/neuron-wallet/src/controllers/app/show-window.ts b/packages/neuron-wallet/src/controllers/app/show-window.ts index abf8fb5c20..fe5c917a94 100644 --- a/packages/neuron-wallet/src/controllers/app/show-window.ts +++ b/packages/neuron-wallet/src/controllers/app/show-window.ts @@ -1,6 +1,6 @@ import { BrowserWindow } from 'electron' import path from 'path' -import env from 'env' +import env from '../../env' import AppController from '.' const showWindow = ( diff --git a/packages/neuron-wallet/src/controllers/app/subscribe.ts b/packages/neuron-wallet/src/controllers/app/subscribe.ts index c924ed667a..048395a1c6 100644 --- a/packages/neuron-wallet/src/controllers/app/subscribe.ts +++ b/packages/neuron-wallet/src/controllers/app/subscribe.ts @@ -2,20 +2,20 @@ import { BrowserWindow, dialog, MessageBoxReturnValue } from 'electron' import { t } from 'i18next' import { debounceTime } from 'rxjs/operators' -import CommandSubject from 'models/subjects/command' -import DataUpdateSubject from 'models/subjects/data-update' -import { CurrentNetworkIDSubject, NetworkListSubject } from 'models/subjects/networks' -import { ConnectionStatusSubject } from 'models/subjects/node' -import { WalletListSubject, CurrentWalletSubject } from 'models/subjects/wallets' -import AppUpdaterSubject from 'models/subjects/app-updater' -import { SETTINGS_WINDOW_TITLE } from 'utils/const' -import SyncStateSubject from 'models/subjects/sync-state-subject' -import DeviceSignIndexSubject from 'models/subjects/device-sign-index-subject' -import SyncApiController from 'controllers/sync-api' -import MultisigOutputChangedSubject from 'models/subjects/multisig-output-db-changed-subject' -import MigrateSubject from 'models/subjects/migrate-subject' -import startMonitor, { stopMonitor } from 'services/monitor' -import { clearCkbNodeCache } from 'services/ckb-runner' +import CommandSubject from '../../models/subjects/command' +import DataUpdateSubject from '../../models/subjects/data-update' +import { CurrentNetworkIDSubject, NetworkListSubject } from '../../models/subjects/networks' +import { ConnectionStatusSubject } from '../../models/subjects/node' +import { WalletListSubject, CurrentWalletSubject } from '../../models/subjects/wallets' +import AppUpdaterSubject from '../../models/subjects/app-updater' +import { SETTINGS_WINDOW_TITLE } from '../../utils/const' +import SyncStateSubject from '../../models/subjects/sync-state-subject' +import DeviceSignIndexSubject from '../../models/subjects/device-sign-index-subject' +import SyncApiController from '../sync-api' +import MultisigOutputChangedSubject from '../../models/subjects/multisig-output-db-changed-subject' +import MigrateSubject from '../../models/subjects/migrate-subject' +import startMonitor, { stopMonitor } from '../../services/monitor' +import { clearCkbNodeCache } from '../../services/ckb-runner' interface AppResponder { sendMessage: (channel: string, arg: any) => void diff --git a/packages/neuron-wallet/src/controllers/asset-account.ts b/packages/neuron-wallet/src/controllers/asset-account.ts index 8852bcdea5..4854e41052 100644 --- a/packages/neuron-wallet/src/controllers/asset-account.ts +++ b/packages/neuron-wallet/src/controllers/asset-account.ts @@ -1,19 +1,19 @@ import { scriptToAddress } from '@nervosnetwork/ckb-sdk-utils' -import AssetAccount from 'models/asset-account' -import Transaction from 'models/chain/transaction' -import AssetAccountService from 'services/asset-account-service' -import { ServiceHasNoResponse } from 'exceptions' -import { ResponseCode } from 'utils/const' -import NetworksService from 'services/networks' -import AssetAccountInfo from 'models/asset-account-info' -import TransactionSender from 'services/transaction-sender' +import AssetAccount from '../models/asset-account' +import Transaction from '../models/chain/transaction' +import AssetAccountService from '../services/asset-account-service' +import { ServiceHasNoResponse } from '../exceptions' +import { ResponseCode } from '../utils/const' +import NetworksService from '../services/networks' +import AssetAccountInfo from '../models/asset-account-info' +import TransactionSender from '../services/transaction-sender' import { BrowserWindow, dialog } from 'electron' import { t } from 'i18next' -import WalletsService from 'services/wallets' -import CommandSubject from 'models/subjects/command' +import WalletsService from '../services/wallets' +import CommandSubject from '../models/subjects/command' import SyncApiController, { SyncStatus } from './sync-api' -import { TransactionGenerator } from 'services/tx' -import OutPoint from 'models/chain/out-point' +import { TransactionGenerator } from '../services/tx' +import OutPoint from '../models/chain/out-point' export interface GenerateCreateAssetAccountTxParams { walletID: string diff --git a/packages/neuron-wallet/src/controllers/customized-assets.ts b/packages/neuron-wallet/src/controllers/customized-assets.ts index d32efcc7ee..291e922fff 100644 --- a/packages/neuron-wallet/src/controllers/customized-assets.ts +++ b/packages/neuron-wallet/src/controllers/customized-assets.ts @@ -1,11 +1,11 @@ -import AddressService from 'services/addresses' -import CellsService, { PaginationResult, CustomizedLock } from 'services/cells' -import Cell from 'models/chain/output' -import { ServiceHasNoResponse } from 'exceptions' -import { ResponseCode } from 'utils/const' -import Transaction from 'models/chain/transaction' -import TransactionSender from 'services/transaction-sender' -import OutPoint from 'models/chain/out-point' +import AddressService from '../services/addresses' +import CellsService, { PaginationResult, CustomizedLock } from '../services/cells' +import Cell from '../models/chain/output' +import { ServiceHasNoResponse } from '../exceptions' +import { ResponseCode } from '../utils/const' +import Transaction from '../models/chain/transaction' +import TransactionSender from '../services/transaction-sender' +import OutPoint from '../models/chain/out-point' export default class CustomizedAssetsController { public async getCustomizedAssetCells( diff --git a/packages/neuron-wallet/src/controllers/dao.ts b/packages/neuron-wallet/src/controllers/dao.ts index 83e66f1bfa..991ede2eea 100644 --- a/packages/neuron-wallet/src/controllers/dao.ts +++ b/packages/neuron-wallet/src/controllers/dao.ts @@ -1,10 +1,10 @@ -import { ServiceHasNoResponse, IsRequired } from 'exceptions' -import { ResponseCode } from 'utils/const' -import CellsService from 'services/cells' -import TransactionSender from 'services/transaction-sender' -import OutPoint from 'models/chain/out-point' -import Cell from 'models/chain/output' -import Transaction from 'models/chain/transaction' +import { ServiceHasNoResponse, IsRequired } from '../exceptions' +import { ResponseCode } from '../utils/const' +import CellsService from '../services/cells' +import TransactionSender from '../services/transaction-sender' +import OutPoint from '../models/chain/out-point' +import Cell from '../models/chain/output' +import Transaction from '../models/chain/transaction' export default class DaoController { public async getDaoCells(params: Controller.Params.GetDaoCellsParams): Promise> { diff --git a/packages/neuron-wallet/src/controllers/export-debug.ts b/packages/neuron-wallet/src/controllers/export-debug.ts index 39ce8aa3d3..a32cd4d738 100644 --- a/packages/neuron-wallet/src/controllers/export-debug.ts +++ b/packages/neuron-wallet/src/controllers/export-debug.ts @@ -4,13 +4,13 @@ import path from 'path' import archiver from 'archiver' import CKB from '@nervosnetwork/ckb-sdk-core' import { app, dialog } from 'electron' -import logger from 'utils/logger' +import logger from '../utils/logger' import { t } from 'i18next' -import NetworksService from 'services/networks' -import SyncedBlockNumber from 'models/synced-block-number' -import AddressService from 'services/addresses' -import redistCheck from 'utils/redist-check' -import SettingsService from 'services/settings' +import NetworksService from '../services/networks' +import SyncedBlockNumber from '../models/synced-block-number' +import AddressService from '../services/addresses' +import redistCheck from '../utils/redist-check' +import SettingsService from '../services/settings' export default class ExportDebugController { // eslint-disable-next-line prettier/prettier diff --git a/packages/neuron-wallet/src/controllers/hardware.ts b/packages/neuron-wallet/src/controllers/hardware.ts index ee75cbcd83..b831c57818 100644 --- a/packages/neuron-wallet/src/controllers/hardware.ts +++ b/packages/neuron-wallet/src/controllers/hardware.ts @@ -1,8 +1,8 @@ -import { DeviceInfo, ExtendedPublicKey, PublicKey } from 'services/hardware/common' -import { ResponseCode } from 'utils/const' -import HardwareWalletService from 'services/hardware' -import { connectDeviceFailed } from 'exceptions' -import { AccountExtendedPublicKey } from 'models/keys/key' +import { DeviceInfo, ExtendedPublicKey, PublicKey } from '../services/hardware/common' +import { ResponseCode } from '../utils/const' +import HardwareWalletService from '../services/hardware' +import { connectDeviceFailed } from '../exceptions' +import { AccountExtendedPublicKey } from '../models/keys/key' export default class HardwareController { public async connectDevice(deviceInfo: DeviceInfo): Promise> { diff --git a/packages/neuron-wallet/src/controllers/mercury.ts b/packages/neuron-wallet/src/controllers/mercury.ts index 930d6395ac..513d7fa863 100644 --- a/packages/neuron-wallet/src/controllers/mercury.ts +++ b/packages/neuron-wallet/src/controllers/mercury.ts @@ -1,9 +1,9 @@ import path from 'path' import fs from 'fs' -import env from 'env' +import env from '../env' import { dialog } from 'electron' import { t } from 'i18next' -import SettingsService from 'services/settings' +import SettingsService from '../services/settings' const { app } = env diff --git a/packages/neuron-wallet/src/controllers/multisig.ts b/packages/neuron-wallet/src/controllers/multisig.ts index ffd6b818f0..34b02cee09 100644 --- a/packages/neuron-wallet/src/controllers/multisig.ts +++ b/packages/neuron-wallet/src/controllers/multisig.ts @@ -3,15 +3,15 @@ import path from 'path' import { dialog, BrowserWindow } from 'electron' import { t } from 'i18next' import { addressToScript, scriptToAddress, scriptToHash } from '@nervosnetwork/ckb-sdk-utils' -import { ResponseCode } from 'utils/const' -import MultisigConfig from 'database/chain/entities/multisig-config' -import MultisigConfigModel from 'models/multisig-config' -import MultisigService from 'services/multisig' -import CellsService from 'services/cells' -import OfflineSignService from 'services/offline-sign' -import Multisig from 'models/multisig' -import SystemScriptInfo from 'models/system-script-info' -import NetworksService from 'services/networks' +import { ResponseCode } from '../utils/const' +import MultisigConfig from '../database/chain/entities/multisig-config' +import MultisigConfigModel from '../models/multisig-config' +import MultisigService from '../services/multisig' +import CellsService from '../services/cells' +import OfflineSignService from '../services/offline-sign' +import Multisig from '../models/multisig' +import SystemScriptInfo from '../models/system-script-info' +import NetworksService from '../services/networks' interface MultisigConfigOutput { multisig_configs: Record> { diff --git a/packages/neuron-wallet/src/controllers/sudt.ts b/packages/neuron-wallet/src/controllers/sudt.ts index 77719118a6..d7e067360a 100644 --- a/packages/neuron-wallet/src/controllers/sudt.ts +++ b/packages/neuron-wallet/src/controllers/sudt.ts @@ -1,11 +1,11 @@ import { scriptToHash } from '@nervosnetwork/ckb-sdk-utils' -import LiveCellService from 'services/live-cell-service' +import LiveCellService from '../services/live-cell-service' import AssetAccountInfo from '../models/asset-account-info' -import Script, { ScriptHashType } from 'models/chain/script' -import parseSUDTTokenInfo from 'utils/parse_sudt_token_info' -import { ResponseCode } from 'utils/const' -import { SudtTokenInfo } from 'models/chain/transaction' -import AssetAccountService from 'services/asset-account-service' +import Script, { ScriptHashType } from '../models/chain/script' +import parseSUDTTokenInfo from '../utils/parse_sudt_token_info' +import { ResponseCode } from '../utils/const' +import { SudtTokenInfo } from '../models/chain/transaction' +import AssetAccountService from '../services/asset-account-service' export default class SUDTController { public async getSUDTTokenInfo(params: { tokenID: string }): Promise> { diff --git a/packages/neuron-wallet/src/controllers/sync-api.ts b/packages/neuron-wallet/src/controllers/sync-api.ts index 8badd373e0..e35bf2051b 100644 --- a/packages/neuron-wallet/src/controllers/sync-api.ts +++ b/packages/neuron-wallet/src/controllers/sync-api.ts @@ -1,12 +1,12 @@ import EventEmiter from 'events' import { debounceTime } from 'rxjs/operators' -import NodeService from 'services/node' -import RpcService from 'services/rpc-service' -import SyncedBlockNumber from 'models/synced-block-number' -import SyncStateSubject from 'models/subjects/sync-state-subject' -import { CurrentNetworkIDSubject } from 'models/subjects/networks' -import MultisigService from 'services/multisig' -import { getLookingValidTargetStatus } from 'services/ckb-runner' +import NodeService from '../services/node' +import RpcService from '../services/rpc-service' +import SyncedBlockNumber from '../models/synced-block-number' +import SyncStateSubject from '../models/subjects/sync-state-subject' +import { CurrentNetworkIDSubject } from '../models/subjects/networks' +import MultisigService from '../services/multisig' +import { getLookingValidTargetStatus } from '../services/ckb-runner' const TEN_MINS = 600000 const MAX_TIP_BLOCK_DELAY = 180000 diff --git a/packages/neuron-wallet/src/controllers/transactions.ts b/packages/neuron-wallet/src/controllers/transactions.ts index 5d2f420e5d..3a1b42295f 100644 --- a/packages/neuron-wallet/src/controllers/transactions.ts +++ b/packages/neuron-wallet/src/controllers/transactions.ts @@ -1,15 +1,15 @@ import { dialog } from 'electron' import { t } from 'i18next' -import { TransactionsService, PaginationResult } from 'services/tx' -import AddressesService from 'services/addresses' -import WalletsService from 'services/wallets' +import { TransactionsService, PaginationResult } from '../services/tx' +import AddressesService from '../services/addresses' +import WalletsService from '../services/wallets' -import { ResponseCode } from 'utils/const' -import { TransactionNotFound, CurrentWalletNotSet } from 'exceptions' -import Transaction from 'models/chain/transaction' +import { ResponseCode } from '../utils/const' +import { TransactionNotFound, CurrentWalletNotSet } from '../exceptions' +import Transaction from '../models/chain/transaction' -import { set as setDescription, get as getDescription } from 'services/tx/transaction-description' -import AddressParser from 'models/address-parser' +import { set as setDescription, get as getDescription } from '../services/tx/transaction-description' +import AddressParser from '../models/address-parser' export default class TransactionsController { public async getAll( diff --git a/packages/neuron-wallet/src/controllers/update.ts b/packages/neuron-wallet/src/controllers/update.ts index 15e63c43c2..0153090421 100644 --- a/packages/neuron-wallet/src/controllers/update.ts +++ b/packages/neuron-wallet/src/controllers/update.ts @@ -1,7 +1,7 @@ import { BrowserWindow, dialog } from 'electron' import { t } from 'i18next' import { autoUpdater, UpdateInfo } from 'electron-updater' -import AppUpdaterSubject from 'models/subjects/app-updater' +import AppUpdaterSubject from '../models/subjects/app-updater' export default class UpdateController { static isChecking = false // One instance is already running and checking diff --git a/packages/neuron-wallet/src/controllers/wallets.ts b/packages/neuron-wallet/src/controllers/wallets.ts index aa31beafc2..44ed72b8f6 100644 --- a/packages/neuron-wallet/src/controllers/wallets.ts +++ b/packages/neuron-wallet/src/controllers/wallets.ts @@ -1,14 +1,14 @@ import fs from 'fs' import { t } from 'i18next' import { dialog, SaveDialogReturnValue, BrowserWindow, OpenDialogReturnValue } from 'electron' -import WalletsService, { Wallet, WalletProperties, FileKeystoreWallet } from 'services/wallets' -import NetworksService from 'services/networks' -import Keystore from 'models/keys/keystore' -import Keychain from 'models/keys/keychain' -import { validateMnemonic, mnemonicToSeedSync } from 'models/keys/mnemonic' -import { AccountExtendedPublicKey, ExtendedPrivateKey, generateMnemonic } from 'models/keys/key' -import CommandSubject from 'models/subjects/command' -import { ResponseCode } from 'utils/const' +import WalletsService, { Wallet, WalletProperties, FileKeystoreWallet } from '../services/wallets' +import NetworksService from '../services/networks' +import Keystore from '../models/keys/keystore' +import Keychain from '../models/keys/keychain' +import { validateMnemonic, mnemonicToSeedSync } from '../models/keys/mnemonic' +import { AccountExtendedPublicKey, ExtendedPrivateKey, generateMnemonic } from '../models/keys/key' +import CommandSubject from '../models/subjects/command' +import { ResponseCode } from '../utils/const' import { CurrentWalletNotSet, IsRequired, @@ -20,17 +20,17 @@ import { InvalidJSON, InvalidAddress, UsedName -} from 'exceptions' -import AddressService from 'services/addresses' -import { MainnetAddressRequired, TestnetAddressRequired } from 'exceptions/address' -import TransactionSender from 'services/transaction-sender' -import Transaction from 'models/chain/transaction' -import logger from 'utils/logger' -import { set as setDescription } from 'services/tx/transaction-description' -import HardwareWalletService from 'services/hardware' -import { DeviceInfo, ExtendedPublicKey } from 'services/hardware/common' -import AddressParser from 'models/address-parser' -import MultisigConfigModel from 'models/multisig-config' +} from '../exceptions' +import AddressService from '../services/addresses' +import { MainnetAddressRequired, TestnetAddressRequired } from '../exceptions/address' +import TransactionSender from '../services/transaction-sender' +import Transaction from '../models/chain/transaction' +import logger from '../utils/logger' +import { set as setDescription } from '../services/tx/transaction-description' +import HardwareWalletService from '../services/hardware' +import { DeviceInfo, ExtendedPublicKey } from '../services/hardware/common' +import AddressParser from '../models/address-parser' +import MultisigConfigModel from '../models/multisig-config' export default class WalletsController { public async getAll(): Promise[]>> { diff --git a/packages/neuron-wallet/src/database/address/meta.ts b/packages/neuron-wallet/src/database/address/meta.ts index ecb950a103..56f2c05a1b 100644 --- a/packages/neuron-wallet/src/database/address/meta.ts +++ b/packages/neuron-wallet/src/database/address/meta.ts @@ -1,10 +1,10 @@ import { Address, AddressVersion } from '../../models/address' -import { AddressType } from 'models/keys/address' -import Script from 'models/chain/script' -import SystemScriptInfo from 'models/system-script-info' -import AssetAccountInfo from 'models/asset-account-info' -import HdPublicKeyInfoModel from 'models/keys/hd-public-key-info' -import Multisig from 'models/multisig' +import { AddressType } from '../../models/keys/address' +import Script from '../../models/chain/script' +import SystemScriptInfo from '../../models/system-script-info' +import AssetAccountInfo from '../../models/asset-account-info' +import HdPublicKeyInfoModel from '../../models/keys/hd-public-key-info' +import Multisig from '../../models/multisig' export default class AddressMeta implements Address { walletId: string diff --git a/packages/neuron-wallet/src/database/chain/entities/asset-account.ts b/packages/neuron-wallet/src/database/chain/entities/asset-account.ts index aafb9853bc..8280ded5e4 100644 --- a/packages/neuron-wallet/src/database/chain/entities/asset-account.ts +++ b/packages/neuron-wallet/src/database/chain/entities/asset-account.ts @@ -1,5 +1,5 @@ import { Entity, Column, PrimaryGeneratedColumn, Index, ManyToOne, JoinColumn } from 'typeorm' -import AssetAccountModel from 'models/asset-account' +import AssetAccountModel from '../../../models/asset-account' import SudtTokenInfo from './sudt-token-info' @Entity() diff --git a/packages/neuron-wallet/src/database/chain/entities/hd-public-key-info.ts b/packages/neuron-wallet/src/database/chain/entities/hd-public-key-info.ts index 228c860e90..4162a80ad5 100644 --- a/packages/neuron-wallet/src/database/chain/entities/hd-public-key-info.ts +++ b/packages/neuron-wallet/src/database/chain/entities/hd-public-key-info.ts @@ -1,6 +1,6 @@ import { Entity, Column, PrimaryGeneratedColumn, Index, CreateDateColumn } from 'typeorm' -import HdPublicKeyInfoModel from 'models/keys/hd-public-key-info' -import { AddressType } from 'models/keys/address' +import HdPublicKeyInfoModel from '../../../models/keys/hd-public-key-info' +import { AddressType } from '../../../models/keys/address' @Entity() export default class HdPublicKeyInfo { diff --git a/packages/neuron-wallet/src/database/chain/entities/input.ts b/packages/neuron-wallet/src/database/chain/entities/input.ts index 53e0a959f4..9586013367 100644 --- a/packages/neuron-wallet/src/database/chain/entities/input.ts +++ b/packages/neuron-wallet/src/database/chain/entities/input.ts @@ -1,8 +1,8 @@ import { Entity, BaseEntity, Column, ManyToOne, PrimaryGeneratedColumn } from 'typeorm' import Transaction from './transaction' -import OutPoint from 'models/chain/out-point' -import InputModel from 'models/chain/input' -import Script, { ScriptHashType } from 'models/chain/script' +import OutPoint from '../../../models/chain/out-point' +import InputModel from '../../../models/chain/input' +import Script, { ScriptHashType } from '../../../models/chain/script' // cellbase input may have same OutPoint @Entity() diff --git a/packages/neuron-wallet/src/database/chain/entities/multisig-config.ts b/packages/neuron-wallet/src/database/chain/entities/multisig-config.ts index aa90c8ab30..d32b193a25 100644 --- a/packages/neuron-wallet/src/database/chain/entities/multisig-config.ts +++ b/packages/neuron-wallet/src/database/chain/entities/multisig-config.ts @@ -1,5 +1,5 @@ -import MultisigConfigModel from 'models/multisig-config' -import MultisigConfigDbChangedSubject from 'models/subjects/multisig-config-db-changed-subject' +import MultisigConfigModel from '../../../models/multisig-config' +import MultisigConfigDbChangedSubject from '../../../models/subjects/multisig-config-db-changed-subject' import { Entity, Column, PrimaryGeneratedColumn, Index, AfterInsert, AfterRemove } from 'typeorm' @Entity() diff --git a/packages/neuron-wallet/src/database/chain/entities/multisig-output.ts b/packages/neuron-wallet/src/database/chain/entities/multisig-output.ts index 3077c64395..9b4683246d 100644 --- a/packages/neuron-wallet/src/database/chain/entities/multisig-output.ts +++ b/packages/neuron-wallet/src/database/chain/entities/multisig-output.ts @@ -1,8 +1,8 @@ import { Entity, BaseEntity, Column, PrimaryColumn } from 'typeorm' -import Script, { ScriptHashType } from 'models/chain/script' -import OutPoint from 'models/chain/out-point' +import Script, { ScriptHashType } from '../../../models/chain/script' +import OutPoint from '../../../models/chain/out-point' import { scriptToHash } from '@nervosnetwork/ckb-sdk-utils' -import { OutputStatus } from 'models/chain/output' +import { OutputStatus } from '../../../models/chain/output' @Entity() export default class MultisigOutput extends BaseEntity { diff --git a/packages/neuron-wallet/src/database/chain/entities/output.ts b/packages/neuron-wallet/src/database/chain/entities/output.ts index 2ce5e80758..0db351f331 100644 --- a/packages/neuron-wallet/src/database/chain/entities/output.ts +++ b/packages/neuron-wallet/src/database/chain/entities/output.ts @@ -1,8 +1,8 @@ import { Entity, BaseEntity, Column, PrimaryColumn, ManyToOne } from 'typeorm' import TransactionEntity from './transaction' -import Script, { ScriptHashType } from 'models/chain/script' -import OutPoint from 'models/chain/out-point' -import OutputModel, { OutputStatus } from 'models/chain/output' +import Script, { ScriptHashType } from '../../../models/chain/script' +import OutPoint from '../../../models/chain/out-point' +import OutputModel, { OutputStatus } from '../../../models/chain/output' @Entity() export default class Output extends BaseEntity { diff --git a/packages/neuron-wallet/src/database/chain/entities/transaction.ts b/packages/neuron-wallet/src/database/chain/entities/transaction.ts index fe3de1e1e5..13586ca451 100644 --- a/packages/neuron-wallet/src/database/chain/entities/transaction.ts +++ b/packages/neuron-wallet/src/database/chain/entities/transaction.ts @@ -10,14 +10,14 @@ import { AfterUpdate, AfterRemove } from 'typeorm' -import TxDbChangedSubject from 'models/subjects/tx-db-changed-subject' +import TxDbChangedSubject from '../../../models/subjects/tx-db-changed-subject' import InputEntity from './input' import OutputEntity from './output' -import TransactionModel, { TransactionStatus } from 'models/chain/transaction' -import CellDep, { DepType } from 'models/chain/cell-dep' -import OutPoint from 'models/chain/out-point' -import Input from 'models/chain/input' -import Output from 'models/chain/output' +import TransactionModel, { TransactionStatus } from '../../../models/chain/transaction' +import CellDep, { DepType } from '../../../models/chain/cell-dep' +import OutPoint from '../../../models/chain/out-point' +import Input from '../../../models/chain/input' +import Output from '../../../models/chain/output' @Entity() export default class Transaction extends BaseEntity { diff --git a/packages/neuron-wallet/src/database/chain/index.ts b/packages/neuron-wallet/src/database/chain/index.ts index 491c026457..be614f57cf 100644 --- a/packages/neuron-wallet/src/database/chain/index.ts +++ b/packages/neuron-wallet/src/database/chain/index.ts @@ -1,5 +1,5 @@ import { getConnection } from 'typeorm' -import MultisigOutputChangedSubject from 'models/subjects/multisig-output-db-changed-subject' +import MultisigOutputChangedSubject from '../../models/subjects/multisig-output-db-changed-subject' import InputEntity from './entities/input' import OutputEntity from './entities/output' import TransactionEntity from './entities/transaction' diff --git a/packages/neuron-wallet/src/database/chain/meta-info.ts b/packages/neuron-wallet/src/database/chain/meta-info.ts index 31b9c4b3a7..6a39f00225 100644 --- a/packages/neuron-wallet/src/database/chain/meta-info.ts +++ b/packages/neuron-wallet/src/database/chain/meta-info.ts @@ -1,6 +1,6 @@ -import FileService from 'services/file' -import OutPoint from 'models/chain/out-point' -import { ScriptHashType } from 'models/chain/script' +import FileService from '../../services/file' +import OutPoint from '../../models/chain/out-point' +import { ScriptHashType } from '../../models/chain/script' const moduleName = 'cells' const fileName = 'meta-info.json' diff --git a/packages/neuron-wallet/src/database/chain/migrations/1599441769473-TxDescription.ts b/packages/neuron-wallet/src/database/chain/migrations/1599441769473-TxDescription.ts index 7105b3aa00..a59e88c19e 100644 --- a/packages/neuron-wallet/src/database/chain/migrations/1599441769473-TxDescription.ts +++ b/packages/neuron-wallet/src/database/chain/migrations/1599441769473-TxDescription.ts @@ -1,5 +1,5 @@ import {MigrationInterface, QueryRunner } from "typeorm"; -import env from "env"; +import env from "../../../env"; export class TxDescription1599441769473 implements MigrationInterface { name = 'TxDescription1599441769473' diff --git a/packages/neuron-wallet/src/database/chain/migrations/1602543179168-AddAddressDescription.ts b/packages/neuron-wallet/src/database/chain/migrations/1602543179168-AddAddressDescription.ts index 3fb050059a..849a145242 100644 --- a/packages/neuron-wallet/src/database/chain/migrations/1602543179168-AddAddressDescription.ts +++ b/packages/neuron-wallet/src/database/chain/migrations/1602543179168-AddAddressDescription.ts @@ -1,9 +1,9 @@ import {MigrationInterface, QueryRunner} from "typeorm"; import fs from "fs"; -import env from "env"; import path from "path"; -import NetworksService from "services/networks"; -import AddressMeta from "database/address/meta"; +import NetworksService from "../../../services/networks"; +import AddressMeta from "../../../database/address/meta"; +import env from "../../../env"; export class AddAddressDescription1602543179168 implements MigrationInterface { name = 'AddAddressDescription1602543179168' diff --git a/packages/neuron-wallet/src/database/chain/migrations/1652945662504-UpdateOutputChequeLockHash.ts b/packages/neuron-wallet/src/database/chain/migrations/1652945662504-UpdateOutputChequeLockHash.ts index 88d34e167e..9d4d306ad8 100644 --- a/packages/neuron-wallet/src/database/chain/migrations/1652945662504-UpdateOutputChequeLockHash.ts +++ b/packages/neuron-wallet/src/database/chain/migrations/1652945662504-UpdateOutputChequeLockHash.ts @@ -1,6 +1,6 @@ import { In, MigrationInterface, QueryRunner } from "typeorm"; import { scriptToHash } from '@nervosnetwork/ckb-sdk-utils' -import { ScriptHashType } from "models/chain/script"; +import { ScriptHashType } from "../../../models/chain/script"; import Output from "../entities/output"; export class UpdateOutputChequeLockHash1652945662504 implements MigrationInterface { diff --git a/packages/neuron-wallet/src/database/chain/ormconfig.ts b/packages/neuron-wallet/src/database/chain/ormconfig.ts index db85e17000..145599e566 100644 --- a/packages/neuron-wallet/src/database/chain/ormconfig.ts +++ b/packages/neuron-wallet/src/database/chain/ormconfig.ts @@ -2,8 +2,8 @@ import { createConnection, getConnectionOptions, getConnection } from 'typeorm' import { SqliteConnectionOptions } from 'typeorm/driver/sqlite/SqliteConnectionOptions' import path from 'path' -import logger from 'utils/logger' -import env from 'env' +import logger from '../../utils/logger' +import env from '../../env' import HdPublicKeyInfo from './entities/hd-public-key-info' import Transaction from './entities/transaction' diff --git a/packages/neuron-wallet/src/database/leveldb/index.ts b/packages/neuron-wallet/src/database/leveldb/index.ts index e9ae0a0f47..2278135375 100644 --- a/packages/neuron-wallet/src/database/leveldb/index.ts +++ b/packages/neuron-wallet/src/database/leveldb/index.ts @@ -2,8 +2,8 @@ import fs from 'fs' import path from 'path' import levelup, { LevelUp } from 'levelup' import leveldown from 'leveldown' -import env from 'env' -import logger from 'utils/logger' +import env from '../../env' +import logger from '../../utils/logger' const leveldb = (dbname: string): LevelUp => { const dir = env.fileBasePath diff --git a/packages/neuron-wallet/src/listeners/main/index.ts b/packages/neuron-wallet/src/listeners/main/index.ts index cc8443f60a..f7e31f20ab 100644 --- a/packages/neuron-wallet/src/listeners/main/index.ts +++ b/packages/neuron-wallet/src/listeners/main/index.ts @@ -1,9 +1,9 @@ import { debounceTime } from 'rxjs/operators' -import TxDbChangedSubject from 'models/subjects/tx-db-changed-subject' -import AddressDbChangedSubject from 'models/subjects/address-db-changed-subject' -import DataUpdateSubject from 'models/subjects/data-update' -import MultisigConfigDbChangedSubject from 'models/subjects/multisig-config-db-changed-subject' -import MultisigService from 'services/multisig' +import TxDbChangedSubject from '../../models/subjects/tx-db-changed-subject' +import AddressDbChangedSubject from '../../models/subjects/address-db-changed-subject' +import DataUpdateSubject from '../../models/subjects/data-update' +import MultisigConfigDbChangedSubject from '../../models/subjects/multisig-config-db-changed-subject' +import MultisigService from '../../services/multisig' /** * Update addresses and transactions actively diff --git a/packages/neuron-wallet/src/main.ts b/packages/neuron-wallet/src/main.ts index e358754995..a65b386bea 100644 --- a/packages/neuron-wallet/src/main.ts +++ b/packages/neuron-wallet/src/main.ts @@ -1,9 +1,9 @@ import { app } from 'electron' -import AppController from 'controllers/app' -import SettingsService from 'services/settings' -import { changeLanguage } from 'locales/i18n' -import logger from 'utils/logger' +import AppController from './controllers/app' +import SettingsService from './services/settings' +import { changeLanguage } from './locales/i18n' +import logger from './utils/logger' const appController = AppController.getInstance() diff --git a/packages/neuron-wallet/src/models/address.ts b/packages/neuron-wallet/src/models/address.ts index 480a145974..00aaa87662 100644 --- a/packages/neuron-wallet/src/models/address.ts +++ b/packages/neuron-wallet/src/models/address.ts @@ -1,4 +1,4 @@ -import { AddressType } from 'models/keys/address' +import { AddressType } from '../models/keys/address' export enum AddressVersion { Testnet = 'testnet', diff --git a/packages/neuron-wallet/src/models/asset-account-info.ts b/packages/neuron-wallet/src/models/asset-account-info.ts index 140bbbcecb..a6646d2886 100644 --- a/packages/neuron-wallet/src/models/asset-account-info.ts +++ b/packages/neuron-wallet/src/models/asset-account-info.ts @@ -1,9 +1,9 @@ import CellDep, { DepType } from './chain/cell-dep' import Script, { ScriptHashType } from './chain/script' import OutPoint from './chain/out-point' -import NetworksService from 'services/networks' +import NetworksService from '../services/networks' import Transaction from './chain/transaction' -import HexUtils from 'utils/hex' +import HexUtils from '../utils/hex' import SystemScriptInfo from './system-script-info' import { Address } from './address' diff --git a/packages/neuron-wallet/src/models/chain/block-header.ts b/packages/neuron-wallet/src/models/chain/block-header.ts index 0b9ca468f8..3bbd5cff6b 100644 --- a/packages/neuron-wallet/src/models/chain/block-header.ts +++ b/packages/neuron-wallet/src/models/chain/block-header.ts @@ -1,4 +1,4 @@ -import TypeChecker from 'utils/type-checker' +import TypeChecker from '../../utils/type-checker' export default class BlockHeader { public version: string diff --git a/packages/neuron-wallet/src/models/chain/cell-data.ts b/packages/neuron-wallet/src/models/chain/cell-data.ts index ea38794526..61df520c94 100644 --- a/packages/neuron-wallet/src/models/chain/cell-data.ts +++ b/packages/neuron-wallet/src/models/chain/cell-data.ts @@ -1,4 +1,4 @@ -import TypeChecker from 'utils/type-checker' +import TypeChecker from '../../utils/type-checker' export default class CellData { public content: string diff --git a/packages/neuron-wallet/src/models/chain/input.ts b/packages/neuron-wallet/src/models/chain/input.ts index 3a38a0534f..6b6afe0e1c 100644 --- a/packages/neuron-wallet/src/models/chain/input.ts +++ b/packages/neuron-wallet/src/models/chain/input.ts @@ -1,7 +1,7 @@ import OutPoint from './out-point' import Script from './script' -import HexUtils from 'utils/hex' -import TypeChecker from 'utils/type-checker' +import HexUtils from '../../utils/hex' +import TypeChecker from '../../utils/type-checker' export default class Input { public previousOutput: OutPoint | null diff --git a/packages/neuron-wallet/src/models/chain/live-cell.ts b/packages/neuron-wallet/src/models/chain/live-cell.ts index a4f1c7a6c2..6cd68eb9c4 100644 --- a/packages/neuron-wallet/src/models/chain/live-cell.ts +++ b/packages/neuron-wallet/src/models/chain/live-cell.ts @@ -1,6 +1,6 @@ import Script, { ScriptHashType } from './script' import OutPoint from './out-point' -import { LumosCell } from 'block-sync-renderer/sync/indexer-connector' +import { LumosCell } from '../../block-sync-renderer/sync/indexer-connector' const LUMOS_HASH_TYPE_MAP: Record = { type: ScriptHashType.Type, diff --git a/packages/neuron-wallet/src/models/chain/out-point.ts b/packages/neuron-wallet/src/models/chain/out-point.ts index 7f85f3e3dd..a5c54ef31d 100644 --- a/packages/neuron-wallet/src/models/chain/out-point.ts +++ b/packages/neuron-wallet/src/models/chain/out-point.ts @@ -1,5 +1,5 @@ -import HexUtils from 'utils/hex' -import TypeChecker from 'utils/type-checker' +import HexUtils from '../../utils/hex' +import TypeChecker from '../../utils/type-checker' export default class OutPoint { public txHash: string diff --git a/packages/neuron-wallet/src/models/chain/output.ts b/packages/neuron-wallet/src/models/chain/output.ts index 76ca7f53c9..a1700c776d 100644 --- a/packages/neuron-wallet/src/models/chain/output.ts +++ b/packages/neuron-wallet/src/models/chain/output.ts @@ -1,7 +1,7 @@ import Script from './script' import OutPoint from './out-point' -import HexUtils from 'utils/hex' -import TypeChecker from 'utils/type-checker' +import HexUtils from '../../utils/hex' +import TypeChecker from '../../utils/type-checker' // sent: pending transaction's output // pending: pending transaction's input diff --git a/packages/neuron-wallet/src/models/chain/script.ts b/packages/neuron-wallet/src/models/chain/script.ts index bb47826b3b..66901f573e 100644 --- a/packages/neuron-wallet/src/models/chain/script.ts +++ b/packages/neuron-wallet/src/models/chain/script.ts @@ -1,6 +1,6 @@ import { scriptToHash } from '@nervosnetwork/ckb-sdk-utils' -import HexUtils from 'utils/hex' -import TypeChecker from 'utils/type-checker' +import HexUtils from '../../utils/hex' +import TypeChecker from '../../utils/type-checker' export enum ScriptHashType { Data = 'data', diff --git a/packages/neuron-wallet/src/models/chain/transaction-point.ts b/packages/neuron-wallet/src/models/chain/transaction-point.ts index 46652d6a3f..7e8fa31922 100644 --- a/packages/neuron-wallet/src/models/chain/transaction-point.ts +++ b/packages/neuron-wallet/src/models/chain/transaction-point.ts @@ -1,4 +1,4 @@ -import TypeChecker from 'utils/type-checker' +import TypeChecker from '../../utils/type-checker' export default class TransactionPoint { public blockNumber: string diff --git a/packages/neuron-wallet/src/models/chain/transaction.ts b/packages/neuron-wallet/src/models/chain/transaction.ts index 3699a5383d..26bd196cbd 100644 --- a/packages/neuron-wallet/src/models/chain/transaction.ts +++ b/packages/neuron-wallet/src/models/chain/transaction.ts @@ -2,12 +2,12 @@ import CellDep from './cell-dep' import Input from './input' import Output from './output' import WitnessArgs from './witness-args' -import HexUtils from 'utils/hex' +import HexUtils from '../../utils/hex' import { serializeWitnessArgs, rawTransactionToHash } from '@nervosnetwork/ckb-sdk-utils' import BlockHeader from './block-header' -import TypeCheckerUtils from 'utils/type-checker' +import TypeCheckerUtils from '../../utils/type-checker' import OutPoint from './out-point' -import { Signatures } from 'models/offline-sign' +import { Signatures } from '../../models/offline-sign' export enum TransactionStatus { Pending = 'pending', diff --git a/packages/neuron-wallet/src/models/chain/tx-status.ts b/packages/neuron-wallet/src/models/chain/tx-status.ts index d36a2b894b..0dc10193ce 100644 --- a/packages/neuron-wallet/src/models/chain/tx-status.ts +++ b/packages/neuron-wallet/src/models/chain/tx-status.ts @@ -1,4 +1,4 @@ -import TypeCheckerUtils from 'utils/type-checker' +import TypeCheckerUtils from '../../utils/type-checker' export enum TxStatusType { Pending = 'pending', diff --git a/packages/neuron-wallet/src/models/keys/hd-public-key-info.ts b/packages/neuron-wallet/src/models/keys/hd-public-key-info.ts index 1ed7a50110..73db4fba9c 100644 --- a/packages/neuron-wallet/src/models/keys/hd-public-key-info.ts +++ b/packages/neuron-wallet/src/models/keys/hd-public-key-info.ts @@ -1,6 +1,6 @@ import { scriptToAddress } from '@nervosnetwork/ckb-sdk-utils' -import SystemScriptInfo from 'models/system-script-info' -import NetworksService from 'services/networks' +import SystemScriptInfo from '../../models/system-script-info' +import NetworksService from '../../services/networks' import Address, { AddressType } from './address' export default class HdPublicKeyInfoModel { diff --git a/packages/neuron-wallet/src/models/keys/keystore.ts b/packages/neuron-wallet/src/models/keys/keystore.ts index 93ad5032a9..7bbf65050d 100644 --- a/packages/neuron-wallet/src/models/keys/keystore.ts +++ b/packages/neuron-wallet/src/models/keys/keystore.ts @@ -2,7 +2,7 @@ import crypto from 'crypto' import { Keccak } from 'sha3' import { v4 as uuid } from 'uuid' -import { UnsupportedCipher, IncorrectPassword, InvalidKeystore } from 'exceptions' +import { UnsupportedCipher, IncorrectPassword, InvalidKeystore } from '../../exceptions' import { ExtendedPrivateKey } from './key' const CIPHER = 'aes-128-ctr' diff --git a/packages/neuron-wallet/src/models/multisig.ts b/packages/neuron-wallet/src/models/multisig.ts index 1e9d21c9d9..95e4ef73b2 100644 --- a/packages/neuron-wallet/src/models/multisig.ts +++ b/packages/neuron-wallet/src/models/multisig.ts @@ -1,4 +1,4 @@ -import { MultisigPrefixError } from 'exceptions' +import { MultisigPrefixError } from '../exceptions' import Blake2b from './blake2b' import SystemScriptInfo from './system-script-info' diff --git a/packages/neuron-wallet/src/models/store.ts b/packages/neuron-wallet/src/models/store.ts index bd22bf3440..9bf89fb86c 100644 --- a/packages/neuron-wallet/src/models/store.ts +++ b/packages/neuron-wallet/src/models/store.ts @@ -1,5 +1,5 @@ import EventEmitter from 'events' -import FileService from 'services/file' +import FileService from '../services/file' class Store extends EventEmitter { public moduleName: string diff --git a/packages/neuron-wallet/src/models/subjects/address-created-subject.ts b/packages/neuron-wallet/src/models/subjects/address-created-subject.ts index 270948f682..ed7396edbb 100644 --- a/packages/neuron-wallet/src/models/subjects/address-created-subject.ts +++ b/packages/neuron-wallet/src/models/subjects/address-created-subject.ts @@ -1,5 +1,5 @@ import { ReplaySubject } from 'rxjs' -import { Address } from 'models/address' +import { Address } from '../../models/address' export default class AddressCreatedSubject { private static subject = new ReplaySubject(100) diff --git a/packages/neuron-wallet/src/models/synced-block-number.ts b/packages/neuron-wallet/src/models/synced-block-number.ts index 0171a9a8a7..50562d6dc0 100644 --- a/packages/neuron-wallet/src/models/synced-block-number.ts +++ b/packages/neuron-wallet/src/models/synced-block-number.ts @@ -1,6 +1,6 @@ import { getConnection } from 'typeorm' -import SyncInfoEntity from 'database/chain/entities/sync-info' -import logger from 'utils/logger' +import SyncInfoEntity from '../database/chain/entities/sync-info' +import logger from '../utils/logger' // Keep track of synced block number. export default class SyncedBlockNumber { diff --git a/packages/neuron-wallet/src/models/system-script-info.ts b/packages/neuron-wallet/src/models/system-script-info.ts index 1015b2c610..d7241abb8f 100644 --- a/packages/neuron-wallet/src/models/system-script-info.ts +++ b/packages/neuron-wallet/src/models/system-script-info.ts @@ -1,7 +1,7 @@ import OutPoint from './chain/out-point' import CellDep, { DepType } from './chain/cell-dep' -import NetworksService from 'services/networks' -import RpcService from 'services/rpc-service' +import NetworksService from '../services/networks' +import RpcService from '../services/rpc-service' import Script, { ScriptHashType } from './chain/script' export default class SystemScriptInfo { diff --git a/packages/neuron-wallet/src/models/transaction-size.ts b/packages/neuron-wallet/src/models/transaction-size.ts index ac357772dd..887b8315c1 100644 --- a/packages/neuron-wallet/src/models/transaction-size.ts +++ b/packages/neuron-wallet/src/models/transaction-size.ts @@ -1,12 +1,12 @@ import { serializeOutput, serializeWitnessArgs } from '@nervosnetwork/ckb-sdk-utils/lib/serialization/transaction' -import HexUtils from 'utils/hex' +import HexUtils from '../utils/hex' import { serializeFixVec } from '@nervosnetwork/ckb-sdk-utils/lib/serialization' import Output from './chain/output' import WitnessArgs from './chain/witness-args' import Transaction from './chain/transaction' import Multisig from './multisig' import Script, { ScriptHashType } from './chain/script' -import BufferUtils from 'utils/buffer' +import BufferUtils from '../utils/buffer' export default class TransactionSize { public static SERIALIZED_OFFSET_BYTESIZE = 4 diff --git a/packages/neuron-wallet/src/services/addresses.ts b/packages/neuron-wallet/src/services/addresses.ts index 99569f7451..a3ae9e870c 100644 --- a/packages/neuron-wallet/src/services/addresses.ts +++ b/packages/neuron-wallet/src/services/addresses.ts @@ -1,19 +1,19 @@ -import { AccountExtendedPublicKey, DefaultAddressNumber } from 'models/keys/key' -import Address, { AddressType, publicKeyToAddress } from 'models/keys/address' -import { Address as AddressInterface } from 'models/address' -import AddressCreatedSubject from 'models/subjects/address-created-subject' -import NetworksService from 'services/networks' -import AddressParser from 'models/address-parser' +import { AccountExtendedPublicKey, DefaultAddressNumber } from '../models/keys/key' +import Address, { AddressType, publicKeyToAddress } from '../models/keys/address' +import { Address as AddressInterface } from '../models/address' +import AddressCreatedSubject from '../models/subjects/address-created-subject' +import NetworksService from '../services/networks' +import AddressParser from '../models/address-parser' import { getConnection } from 'typeorm' -import { TransactionsService } from 'services/tx' +import { TransactionsService } from '../services/tx' import CellsService from './cells' -import SystemScriptInfo from 'models/system-script-info' -import Script from 'models/chain/script' -import HdPublicKeyInfo from 'database/chain/entities/hd-public-key-info' -import AddressDescription from 'database/chain/entities/address-description' -import AddressDbChangedSubject from 'models/subjects/address-db-changed-subject' -import AddressMeta from 'database/address/meta' -import queueWrapper from 'utils/queue' +import SystemScriptInfo from '../models/system-script-info' +import Script from '../models/chain/script' +import HdPublicKeyInfo from '../database/chain/entities/hd-public-key-info' +import AddressDescription from '../database/chain/entities/address-description' +import AddressDbChangedSubject from '../models/subjects/address-db-changed-subject' +import AddressMeta from '../database/address/meta' +import queueWrapper from '../utils/queue' const MAX_ADDRESS_COUNT = 100 diff --git a/packages/neuron-wallet/src/services/anyone-can-pay.ts b/packages/neuron-wallet/src/services/anyone-can-pay.ts index a0ab6cf10d..f41ae2db85 100644 --- a/packages/neuron-wallet/src/services/anyone-can-pay.ts +++ b/packages/neuron-wallet/src/services/anyone-can-pay.ts @@ -1,20 +1,20 @@ -import AssetAccountInfo from 'models/asset-account-info' -import AddressParser from 'models/address-parser' +import AssetAccountInfo from '../models/asset-account-info' +import AddressParser from '../models/address-parser' import { TransactionGenerator } from './tx' import { getConnection } from 'typeorm' -import Output from 'models/chain/output' -import LiveCell from 'models/chain/live-cell' -import Transaction from 'models/chain/transaction' -import AssetAccountEntity from 'database/chain/entities/asset-account' -import { TargetLockError, TargetOutputNotFoundError } from 'exceptions' -import { AcpSendSameAccountError } from 'exceptions' -import Script from 'models/chain/script' -import OutPoint from 'models/chain/out-point' +import Output from '../models/chain/output' +import LiveCell from '../models/chain/live-cell' +import Transaction from '../models/chain/transaction' +import AssetAccountEntity from '../database/chain/entities/asset-account' +import { TargetLockError, TargetOutputNotFoundError } from '../exceptions' +import { AcpSendSameAccountError } from '../exceptions' +import Script from '../models/chain/script' +import OutPoint from '../models/chain/out-point' import LiveCellService from './live-cell-service' import WalletService from './wallets' -import SystemScriptInfo from 'models/system-script-info' +import SystemScriptInfo from '../models/system-script-info' import CellsService from './cells' -import { MIN_SUDT_CAPACITY } from 'utils/const' +import { MIN_SUDT_CAPACITY } from '../utils/const' export default class AnyoneCanPayService { public static async generateAnyoneCanPayTx( diff --git a/packages/neuron-wallet/src/services/asset-account-service.ts b/packages/neuron-wallet/src/services/asset-account-service.ts index 68b0fea274..3dbcb05226 100644 --- a/packages/neuron-wallet/src/services/asset-account-service.ts +++ b/packages/neuron-wallet/src/services/asset-account-service.ts @@ -1,21 +1,21 @@ import { getConnection, In, Not } from 'typeorm' -import BufferUtils from 'utils/buffer' -import OutputEntity from 'database/chain/entities/output' -import Transaction, { TransactionStatus } from 'models/chain/transaction' -import AssetAccountInfo from 'models/asset-account-info' -import { OutputStatus } from 'models/chain/output' -import AssetAccount from 'models/asset-account' -import SudtTokenInfoEntity from 'database/chain/entities/sudt-token-info' -import AssetAccountEntity from 'database/chain/entities/asset-account' -import { CapacityNotEnoughForChange } from 'exceptions' -import CellsService from 'services/cells' +import BufferUtils from '../utils/buffer' +import OutputEntity from '../database/chain/entities/output' +import Transaction, { TransactionStatus } from '../models/chain/transaction' +import AssetAccountInfo from '../models/asset-account-info' +import { OutputStatus } from '../models/chain/output' +import AssetAccount from '../models/asset-account' +import SudtTokenInfoEntity from '../database/chain/entities/sudt-token-info' +import AssetAccountEntity from '../database/chain/entities/asset-account' +import { CapacityNotEnoughForChange } from '../exceptions' +import CellsService from '../services/cells' import TransactionSender from './transaction-sender' import { TransactionGenerator } from './tx' import WalletService from './wallets' -import OutPoint from 'models/chain/out-point' -import SystemScriptInfo from 'models/system-script-info' -import Input from 'models/chain/input' -import { MIN_CELL_CAPACITY } from 'utils/const' +import OutPoint from '../models/chain/out-point' +import SystemScriptInfo from '../models/system-script-info' +import Input from '../models/chain/input' +import { MIN_CELL_CAPACITY } from '../utils/const' export default class AssetAccountService { private static async getACPCells(publicKeyHash: string, tokenId: string = 'CKBytes') { diff --git a/packages/neuron-wallet/src/services/cells.ts b/packages/neuron-wallet/src/services/cells.ts index 7b44e9ce5b..16a8f3fbd7 100644 --- a/packages/neuron-wallet/src/services/cells.ts +++ b/packages/neuron-wallet/src/services/cells.ts @@ -6,30 +6,30 @@ import { LiveCapacityNotEnough, MultisigConfigNeedError, TransactionInputParamterMiss -} from 'exceptions' -import FeeMode from 'models/fee-mode' -import OutputEntity from 'database/chain/entities/output' -import InputEntity from 'database/chain/entities/input' -import TransactionEntity from 'database/chain/entities/transaction' -import TransactionSize from 'models/transaction-size' -import TransactionFee from 'models/transaction-fee' -import Cell, { OutputStatus } from 'models/chain/output' -import { TransactionStatus } from 'models/chain/transaction' -import OutPoint from 'models/chain/out-point' -import Input from 'models/chain/input' -import WitnessArgs from 'models/chain/witness-args' -import Multisig from 'models/multisig' -import BufferUtils from 'utils/buffer' -import LiveCell from 'models/chain/live-cell' -import Output from 'models/chain/output' -import SystemScriptInfo from 'models/system-script-info' -import Script, { ScriptHashType } from 'models/chain/script' +} from '../exceptions' +import FeeMode from '../models/fee-mode' +import OutputEntity from '../database/chain/entities/output' +import InputEntity from '../database/chain/entities/input' +import TransactionEntity from '../database/chain/entities/transaction' +import TransactionSize from '../models/transaction-size' +import TransactionFee from '../models/transaction-fee' +import Cell, { OutputStatus } from '../models/chain/output' +import { TransactionStatus } from '../models/chain/transaction' +import OutPoint from '../models/chain/out-point' +import Input from '../models/chain/input' +import WitnessArgs from '../models/chain/witness-args' +import Multisig from '../models/multisig' +import BufferUtils from '../utils/buffer' +import LiveCell from '../models/chain/live-cell' +import Output from '../models/chain/output' +import SystemScriptInfo from '../models/system-script-info' +import Script, { ScriptHashType } from '../models/chain/script' import LiveCellService from './live-cell-service' -import AssetAccountInfo from 'models/asset-account-info' -import NFT from 'models/nft' -import MultisigConfigModel from 'models/multisig-config' -import MultisigOutput from 'database/chain/entities/multisig-output' -import { MIN_CELL_CAPACITY } from 'utils/const' +import AssetAccountInfo from '../models/asset-account-info' +import NFT from '../models/nft' +import MultisigConfigModel from '../models/multisig-config' +import MultisigOutput from '../database/chain/entities/multisig-output' +import { MIN_CELL_CAPACITY } from '../utils/const' export interface PaginationResult { totalCount: number diff --git a/packages/neuron-wallet/src/services/ckb-runner.ts b/packages/neuron-wallet/src/services/ckb-runner.ts index 20c24d05df..6bd6496a4a 100644 --- a/packages/neuron-wallet/src/services/ckb-runner.ts +++ b/packages/neuron-wallet/src/services/ckb-runner.ts @@ -1,11 +1,11 @@ -import env from 'env' +import env from '../env' import path from 'path' import fs from 'fs' import { ChildProcess, spawn } from 'child_process' import process from 'process' -import logger from 'utils/logger' +import logger from '../utils/logger' import SettingsService from './settings' -import MigrateSubject from 'models/subjects/migrate-subject' +import MigrateSubject from '../models/subjects/migrate-subject' import IndexerService from './indexer' const platform = (): string => { diff --git a/packages/neuron-wallet/src/services/file.ts b/packages/neuron-wallet/src/services/file.ts index 5d0e877532..4361c1c918 100644 --- a/packages/neuron-wallet/src/services/file.ts +++ b/packages/neuron-wallet/src/services/file.ts @@ -1,7 +1,7 @@ import fs from 'fs' import path from 'path' -import env from 'env' -import { FileNotFound, ModuleNotFound } from 'exceptions' +import env from '../env' +import { FileNotFound, ModuleNotFound } from '../exceptions' export default class FileService { private static instance: FileService diff --git a/packages/neuron-wallet/src/services/hardware/common.ts b/packages/neuron-wallet/src/services/hardware/common.ts index 57cf637f8f..a343a6871a 100644 --- a/packages/neuron-wallet/src/services/hardware/common.ts +++ b/packages/neuron-wallet/src/services/hardware/common.ts @@ -1,4 +1,4 @@ -import { AddressType } from 'models/keys/address' +import { AddressType } from '../../models/keys/address' export enum Manufacturer { Ledger = 'Ledger' diff --git a/packages/neuron-wallet/src/services/hardware/hardware.ts b/packages/neuron-wallet/src/services/hardware/hardware.ts index 0aa3de6821..2a9270d7cc 100644 --- a/packages/neuron-wallet/src/services/hardware/hardware.ts +++ b/packages/neuron-wallet/src/services/hardware/hardware.ts @@ -1,15 +1,15 @@ // eslint-disable-next-line prettier/prettier -import type Transaction from 'models/chain/transaction' -import WitnessArgs from 'models/chain/witness-args' +import type Transaction from '../../models/chain/transaction' +import WitnessArgs from '../../models/chain/witness-args' import { serializeWitnessArgs } from '@nervosnetwork/ckb-sdk-utils' -import AddressService from 'services/addresses' -import TransactionSender from 'services/transaction-sender' -import Multisig from 'models/multisig' -import WalletService from 'services/wallets' -import DeviceSignIndexSubject from 'models/subjects/device-sign-index-subject' +import AddressService from '../../services/addresses' +import TransactionSender from '../../services/transaction-sender' +import Multisig from '../../models/multisig' +import WalletService from '../../services/wallets' +import DeviceSignIndexSubject from '../../models/subjects/device-sign-index-subject' import type { DeviceInfo, ExtendedPublicKey, PublicKey } from './common' -import { AccountExtendedPublicKey } from 'models/keys/key' -import AssetAccountInfo from 'models/asset-account-info' +import { AccountExtendedPublicKey } from '../../models/keys/key' +import AssetAccountInfo from '../../models/asset-account-info' export abstract class Hardware { public deviceInfo: DeviceInfo diff --git a/packages/neuron-wallet/src/services/hardware/index.ts b/packages/neuron-wallet/src/services/hardware/index.ts index b0126b6a8b..25ebd9af29 100644 --- a/packages/neuron-wallet/src/services/hardware/index.ts +++ b/packages/neuron-wallet/src/services/hardware/index.ts @@ -1,8 +1,8 @@ -import { UnsupportedManufacturer } from 'exceptions' +import { UnsupportedManufacturer } from '../../exceptions' import { DeviceInfo, Manufacturer } from './common' import Ledger from './ledger' import { Hardware, HardwareClass } from './hardware' -import logger from 'utils/logger' +import logger from '../../utils/logger' export default class HardwareWalletService { private static instance: HardwareWalletService diff --git a/packages/neuron-wallet/src/services/hardware/ledger.ts b/packages/neuron-wallet/src/services/hardware/ledger.ts index 389ad40986..8933649308 100644 --- a/packages/neuron-wallet/src/services/hardware/ledger.ts +++ b/packages/neuron-wallet/src/services/hardware/ledger.ts @@ -7,12 +7,12 @@ import type { DescriptorEvent, Subscription, Observer } from '@ledgerhq/hw-trans import type Transport from '@ledgerhq/hw-transport' import { Observable, timer } from 'rxjs' import { takeUntil, filter, scan } from 'rxjs/operators' -import Transaction from 'models/chain/transaction' -import NodeService from 'services/node' -import Address, { AddressType } from 'models/keys/address' -import HexUtils from 'utils/hex' -import logger from 'utils/logger' -import NetworksService from 'services/networks' +import Transaction from '../../models/chain/transaction' +import NodeService from '../../services/node' +import Address, { AddressType } from '../../models/keys/address' +import HexUtils from '../../utils/hex' +import logger from '../../utils/logger' +import NetworksService from '../../services/networks' export default class Ledger extends Hardware { private ledgerCKB: LedgerCKB | null = null diff --git a/packages/neuron-wallet/src/services/indexer.ts b/packages/neuron-wallet/src/services/indexer.ts index 7d70189f63..0c50710634 100644 --- a/packages/neuron-wallet/src/services/indexer.ts +++ b/packages/neuron-wallet/src/services/indexer.ts @@ -1,8 +1,8 @@ import path from 'path' import fs from 'fs' -import logger from 'utils/logger' -import SyncedBlockNumber from 'models/synced-block-number' -import { clean as cleanChain } from 'database/chain' +import logger from '../utils/logger' +import SyncedBlockNumber from '../models/synced-block-number' +import { clean as cleanChain } from '../database/chain' import SettingsService from './settings' import startMonitor, { stopMonitor } from './monitor' import NodeService from './node' diff --git a/packages/neuron-wallet/src/services/live-cell-service.ts b/packages/neuron-wallet/src/services/live-cell-service.ts index 04ce4ec117..146eb256c0 100644 --- a/packages/neuron-wallet/src/services/live-cell-service.ts +++ b/packages/neuron-wallet/src/services/live-cell-service.ts @@ -1,7 +1,7 @@ -import Script from 'models/chain/script' -import LiveCell from 'models/chain/live-cell' -import { queryIndexer } from 'block-sync-renderer/index' -import { LumosCellQuery, LumosCell } from 'block-sync-renderer/sync/indexer-connector' +import Script from '../models/chain/script' +import LiveCell from '../models/chain/live-cell' +import { queryIndexer } from '../block-sync-renderer/index' +import { LumosCellQuery, LumosCell } from '../block-sync-renderer/sync/indexer-connector' export default class LiveCellService { private static instance: LiveCellService diff --git a/packages/neuron-wallet/src/services/monitor/base.ts b/packages/neuron-wallet/src/services/monitor/base.ts index 6480788edc..13bfc6e5b6 100644 --- a/packages/neuron-wallet/src/services/monitor/base.ts +++ b/packages/neuron-wallet/src/services/monitor/base.ts @@ -1,4 +1,4 @@ -import logger from 'utils/logger' +import logger from '../../utils/logger' import { interval, timer, Subscription, race, from, Observable } from 'rxjs' import { map } from 'rxjs/operators' diff --git a/packages/neuron-wallet/src/services/monitor/ckb-monitor.ts b/packages/neuron-wallet/src/services/monitor/ckb-monitor.ts index eb3fccee85..395f0e246d 100644 --- a/packages/neuron-wallet/src/services/monitor/ckb-monitor.ts +++ b/packages/neuron-wallet/src/services/monitor/ckb-monitor.ts @@ -1,4 +1,4 @@ -import { stopCkbNode } from 'services/ckb-runner' +import { stopCkbNode } from '../../services/ckb-runner' import NodeService from '../node' import BaseMonitor from './base' diff --git a/packages/neuron-wallet/src/services/multisig.ts b/packages/neuron-wallet/src/services/multisig.ts index b2a2d73de8..96c432821c 100644 --- a/packages/neuron-wallet/src/services/multisig.ts +++ b/packages/neuron-wallet/src/services/multisig.ts @@ -1,14 +1,14 @@ import { getConnection, In, Not } from 'typeorm' -import MultisigConfig from 'database/chain/entities/multisig-config' -import MultisigOutput from 'database/chain/entities/multisig-output' -import { MultisigConfigNotExistError, MultisigConfigExistError } from 'exceptions/multisig' -import { rpcBatchRequest } from 'utils/rpc-request' +import MultisigConfig from '../database/chain/entities/multisig-config' +import MultisigOutput from '../database/chain/entities/multisig-output' +import { MultisigConfigNotExistError, MultisigConfigExistError } from '../exceptions/multisig' +import { rpcBatchRequest } from '../utils/rpc-request' import { scriptToHash } from '@nervosnetwork/ckb-sdk-utils' -import MultisigOutputChangedSubject from 'models/subjects/multisig-output-db-changed-subject' -import Transaction from 'models/chain/transaction' -import { OutputStatus } from 'models/chain/output' +import MultisigOutputChangedSubject from '../models/subjects/multisig-output-db-changed-subject' +import Transaction from '../models/chain/transaction' +import { OutputStatus } from '../models/chain/output' import NetworksService from './networks' -import Multisig from 'models/multisig' +import Multisig from '../models/multisig' const max64Int = '0x' + 'f'.repeat(16) export default class MultisigService { diff --git a/packages/neuron-wallet/src/services/networks.ts b/packages/neuron-wallet/src/services/networks.ts index 0400f70402..14ed8a9542 100644 --- a/packages/neuron-wallet/src/services/networks.ts +++ b/packages/neuron-wallet/src/services/networks.ts @@ -1,14 +1,14 @@ import CKB from '@nervosnetwork/ckb-sdk-core' import { v4 as uuid } from 'uuid' -import { DefaultNetworkUnremovable } from 'exceptions/network' +import { DefaultNetworkUnremovable } from '../exceptions/network' -import Store from 'models/store' +import Store from '../models/store' -import { Validate, Required } from 'utils/validators' -import { UsedName, NetworkNotFound, InvalidFormat } from 'exceptions' -import { MAINNET_GENESIS_HASH, EMPTY_GENESIS_HASH, NetworkType, Network } from 'models/network' -import CommonUtils from 'utils/common' -import { BUNDLED_CKB_URL } from 'utils/const' +import { Validate, Required } from '../utils/validators' +import { UsedName, NetworkNotFound, InvalidFormat } from '../exceptions' +import { MAINNET_GENESIS_HASH, EMPTY_GENESIS_HASH, NetworkType, Network } from '../models/network' +import CommonUtils from '../utils/common' +import { BUNDLED_CKB_URL } from '../utils/const' const presetNetworks: { selected: string; networks: Network[] } = { selected: 'mainnet', diff --git a/packages/neuron-wallet/src/services/node.ts b/packages/neuron-wallet/src/services/node.ts index d7206af267..3e5ca37030 100644 --- a/packages/neuron-wallet/src/services/node.ts +++ b/packages/neuron-wallet/src/services/node.ts @@ -7,18 +7,18 @@ import { t } from 'i18next' import CKB from '@nervosnetwork/ckb-sdk-core' import { interval, BehaviorSubject, merge } from 'rxjs' import { distinctUntilChanged, sampleTime, flatMap, delay, retry, debounceTime } from 'rxjs/operators' -import env from 'env' -import { ShouldBeTypeOf } from 'exceptions' -import { ConnectionStatusSubject } from 'models/subjects/node' -import { CurrentNetworkIDSubject } from 'models/subjects/networks' -import NetworksService from 'services/networks' -import RpcService from 'services/rpc-service' -import { startCkbNode } from 'services/ckb-runner' -import HexUtils from 'utils/hex' -import { BUNDLED_CKB_URL, START_WITHOUT_INDEXER } from 'utils/const' -import logger from 'utils/logger' -import redistCheck from 'utils/redist-check' -import { rpcRequest } from 'utils/rpc-request' +import env from '../env' +import { ShouldBeTypeOf } from '../exceptions' +import { ConnectionStatusSubject } from '../models/subjects/node' +import { CurrentNetworkIDSubject } from '../models/subjects/networks' +import NetworksService from '../services/networks' +import RpcService from '../services/rpc-service' +import { startCkbNode } from '../services/ckb-runner' +import HexUtils from '../utils/hex' +import { BUNDLED_CKB_URL, START_WITHOUT_INDEXER } from '../utils/const' +import logger from '../utils/logger' +import redistCheck from '../utils/redist-check' +import { rpcRequest } from '../utils/rpc-request' import startMonitor from './monitor' class NodeService { diff --git a/packages/neuron-wallet/src/services/offline-sign.ts b/packages/neuron-wallet/src/services/offline-sign.ts index fae96d9a08..c4fdf8a7e3 100644 --- a/packages/neuron-wallet/src/services/offline-sign.ts +++ b/packages/neuron-wallet/src/services/offline-sign.ts @@ -3,7 +3,7 @@ import path from 'path' import { dialog } from 'electron' import { t } from 'i18next' // eslint-disable-next-line prettier/prettier -import type { OfflineSignJSON } from 'models/offline-sign' +import type { OfflineSignJSON } from '../models/offline-sign' export default class OfflineSignService { public static async loadTransactionJSON () { diff --git a/packages/neuron-wallet/src/services/rpc-service.ts b/packages/neuron-wallet/src/services/rpc-service.ts index b6d073e4e9..09d2e2b39d 100644 --- a/packages/neuron-wallet/src/services/rpc-service.ts +++ b/packages/neuron-wallet/src/services/rpc-service.ts @@ -1,14 +1,14 @@ import CKB from '@nervosnetwork/ckb-sdk-core' -import { generateCKB } from 'services/sdk-core' - -import HexUtils from 'utils/hex' -import CommonUtils from 'utils/common' -import Block from 'models/chain/block' -import BlockHeader from 'models/chain/block-header' -import TransactionWithStatus from 'models/chain/transaction-with-status' -import OutPoint from 'models/chain/out-point' -import CellWithStatus from 'models/chain/cell-with-status' -import logger from 'utils/logger' +import { generateCKB } from '../services/sdk-core' + +import HexUtils from '../utils/hex' +import CommonUtils from '../utils/common' +import Block from '../models/chain/block' +import BlockHeader from '../models/chain/block-header' +import TransactionWithStatus from '../models/chain/transaction-with-status' +import OutPoint from '../models/chain/out-point' +import CellWithStatus from '../models/chain/cell-with-status' +import logger from '../utils/logger' export default class RpcService { private retryTime: number diff --git a/packages/neuron-wallet/src/services/settings.ts b/packages/neuron-wallet/src/services/settings.ts index dff8009fcb..8369637e57 100644 --- a/packages/neuron-wallet/src/services/settings.ts +++ b/packages/neuron-wallet/src/services/settings.ts @@ -1,8 +1,8 @@ import { BrowserWindow } from 'electron' -import env from 'env' -import Store from 'models/store' -import { changeLanguage } from 'locales/i18n' -import { updateApplicationMenu } from 'controllers/app/menu' +import env from '../env' +import Store from '../models/store' +import { changeLanguage } from '../locales/i18n' +import { updateApplicationMenu } from '../controllers/app/menu' import path from 'path' const { app } = env diff --git a/packages/neuron-wallet/src/services/sign-message.ts b/packages/neuron-wallet/src/services/sign-message.ts index 94cf05bfb7..b6851cadcc 100644 --- a/packages/neuron-wallet/src/services/sign-message.ts +++ b/packages/neuron-wallet/src/services/sign-message.ts @@ -1,12 +1,12 @@ import AddressService from './addresses' import WalletService, { Wallet } from './wallets' -import Keychain from 'models/keys/keychain' -import Blake2b from 'models/blake2b' +import Keychain from '../models/keys/keychain' +import Blake2b from '../models/blake2b' import ECPair from '@nervosnetwork/ckb-sdk-utils/lib/ecpair' import { ec as EC } from 'elliptic' -import { AddressNotFound } from 'exceptions' +import { AddressNotFound } from '../exceptions' import HardwareWalletService from './hardware' -import AddressParser from 'models/address-parser' +import AddressParser from '../models/address-parser' export default class SignMessage { static GENERATE_COUNT = 100 diff --git a/packages/neuron-wallet/src/services/transaction-sender.ts b/packages/neuron-wallet/src/services/transaction-sender.ts index 2c95facbda..707f164764 100644 --- a/packages/neuron-wallet/src/services/transaction-sender.ts +++ b/packages/neuron-wallet/src/services/transaction-sender.ts @@ -1,30 +1,30 @@ -import WalletService, { Wallet } from 'services/wallets' +import WalletService, { Wallet } from '../services/wallets' import NodeService from './node' import { scriptToAddress, serializeWitnessArgs, toUint64Le } from '@nervosnetwork/ckb-sdk-utils' import { TransactionPersistor, TransactionGenerator, TargetOutput } from './tx' import AddressService from './addresses' -import { Address } from 'models/address' -import { PathAndPrivateKey } from 'models/keys/key' -import { CellIsNotYetLive, TransactionIsNotCommittedYet } from 'exceptions/dao' -import FeeMode from 'models/fee-mode' -import TransactionSize from 'models/transaction-size' -import TransactionFee from 'models/transaction-fee' -import logger from 'utils/logger' -import Keychain from 'models/keys/keychain' -import Input from 'models/chain/input' -import OutPoint from 'models/chain/out-point' -import Output from 'models/chain/output' -import RpcService from 'services/rpc-service' -import WitnessArgs from 'models/chain/witness-args' -import Transaction from 'models/chain/transaction' -import BlockHeader from 'models/chain/block-header' -import Script from 'models/chain/script' -import Multisig from 'models/multisig' -import Blake2b from 'models/blake2b' -import HexUtils from 'utils/hex' +import { Address } from '../models/address' +import { PathAndPrivateKey } from '../models/keys/key' +import { CellIsNotYetLive, TransactionIsNotCommittedYet } from '../exceptions/dao' +import FeeMode from '../models/fee-mode' +import TransactionSize from '../models/transaction-size' +import TransactionFee from '../models/transaction-fee' +import logger from '../utils/logger' +import Keychain from '../models/keys/keychain' +import Input from '../models/chain/input' +import OutPoint from '../models/chain/out-point' +import Output from '../models/chain/output' +import RpcService from '../services/rpc-service' +import WitnessArgs from '../models/chain/witness-args' +import Transaction from '../models/chain/transaction' +import BlockHeader from '../models/chain/block-header' +import Script from '../models/chain/script' +import Multisig from '../models/multisig' +import Blake2b from '../models/blake2b' +import HexUtils from '../utils/hex' import ECPair from '@nervosnetwork/ckb-sdk-utils/lib/ecpair' -import SystemScriptInfo from 'models/system-script-info' -import AddressParser from 'models/address-parser' +import SystemScriptInfo from '../models/system-script-info' +import AddressParser from '../models/address-parser' import HardwareWalletService from './hardware' import { CapacityNotEnoughForChange, @@ -32,13 +32,13 @@ import { MultisigConfigNeedError, NoMatchAddressForSign, SignTransactionFailed -} from 'exceptions' -import AssetAccountInfo from 'models/asset-account-info' -import MultisigConfigModel from 'models/multisig-config' +} from '../exceptions' +import AssetAccountInfo from '../models/asset-account-info' +import MultisigConfigModel from '../models/multisig-config' import { Hardware } from './hardware/hardware' import MultisigService from './multisig' -import { getMultisigStatus } from 'utils/multisig' -import { SignStatus } from 'models/offline-sign' +import { getMultisigStatus } from '../utils/multisig' +import { SignStatus } from '../models/offline-sign' import NetworksService from './networks' interface SignInfo { diff --git a/packages/neuron-wallet/src/services/tx/failed-transaction.ts b/packages/neuron-wallet/src/services/tx/failed-transaction.ts index 17c07b1f3a..0cefaef89f 100644 --- a/packages/neuron-wallet/src/services/tx/failed-transaction.ts +++ b/packages/neuron-wallet/src/services/tx/failed-transaction.ts @@ -1,9 +1,9 @@ import { getConnection, In } from 'typeorm' -import OutputEntity from 'database/chain/entities/output' -import TransactionEntity from 'database/chain/entities/transaction' -import { OutputStatus } from 'models/chain/output' +import OutputEntity from '../../database/chain/entities/output' +import TransactionEntity from '../../database/chain/entities/transaction' +import { OutputStatus } from '../../models/chain/output' import TransactionsService from './transaction-service' -import { TransactionStatus } from 'models/chain/transaction' +import { TransactionStatus } from '../../models/chain/transaction' export class FailedTransaction { public static pendings = async (): Promise => { diff --git a/packages/neuron-wallet/src/services/tx/transaction-description.ts b/packages/neuron-wallet/src/services/tx/transaction-description.ts index 749ad82d3c..d0902d2e14 100644 --- a/packages/neuron-wallet/src/services/tx/transaction-description.ts +++ b/packages/neuron-wallet/src/services/tx/transaction-description.ts @@ -1,5 +1,5 @@ import { getConnection } from 'typeorm' -import TxDescription from 'database/chain/entities/tx-description' +import TxDescription from '../../database/chain/entities/tx-description' const getEntity = async (walletId: string, txHash: string) => { return await getConnection() diff --git a/packages/neuron-wallet/src/services/tx/transaction-generator.ts b/packages/neuron-wallet/src/services/tx/transaction-generator.ts index 91f055a3ec..b00a48a7dd 100644 --- a/packages/neuron-wallet/src/services/tx/transaction-generator.ts +++ b/packages/neuron-wallet/src/services/tx/transaction-generator.ts @@ -1,39 +1,39 @@ -import CellsService from 'services/cells' +import CellsService from '../../services/cells' import { CapacityTooSmall, MigrateSudtCellNoTypeError, SudtAcpHaveDataError, TargetOutputNotFoundError -} from 'exceptions' -import FeeMode from 'models/fee-mode' -import TransactionSize from 'models/transaction-size' -import TransactionFee from 'models/transaction-fee' -import { CapacityNotEnough, CurrentWalletNotSet, LiveCapacityNotEnough } from 'exceptions/wallet' -import Output from 'models/chain/output' -import Input from 'models/chain/input' -import OutPoint from 'models/chain/out-point' -import Script, { ScriptHashType } from 'models/chain/script' -import Transaction from 'models/chain/transaction' -import WitnessArgs from 'models/chain/witness-args' -import AddressParser from 'models/address-parser' -import Multisig from 'models/multisig' -import RpcService from 'services/rpc-service' -import NodeService from 'services/node' -import BlockHeader from 'models/chain/block-header' -import CellDep from 'models/chain/cell-dep' -import SystemScriptInfo from 'models/system-script-info' -import ArrayUtils from 'utils/array' -import AssetAccountInfo from 'models/asset-account-info' -import BufferUtils from 'utils/buffer' +} from '../../exceptions' +import FeeMode from '../../models/fee-mode' +import TransactionSize from '../../models/transaction-size' +import TransactionFee from '../../models/transaction-fee' +import { CapacityNotEnough, CurrentWalletNotSet, LiveCapacityNotEnough } from '../../exceptions/wallet' +import Output from '../../models/chain/output' +import Input from '../../models/chain/input' +import OutPoint from '../../models/chain/out-point' +import Script, { ScriptHashType } from '../../models/chain/script' +import Transaction from '../../models/chain/transaction' +import WitnessArgs from '../../models/chain/witness-args' +import AddressParser from '../../models/address-parser' +import Multisig from '../../models/multisig' +import RpcService from '../../services/rpc-service' +import NodeService from '../../services/node' +import BlockHeader from '../../models/chain/block-header' +import CellDep from '../../models/chain/cell-dep' +import SystemScriptInfo from '../../models/system-script-info' +import ArrayUtils from '../../utils/array' +import AssetAccountInfo from '../../models/asset-account-info' +import BufferUtils from '../../utils/buffer' import assert from 'assert' -import AssetAccount from 'models/asset-account' -import AddressService from 'services/addresses' +import AssetAccount from '../../models/asset-account' +import AddressService from '../../services/addresses' import { addressToScript } from '@nervosnetwork/ckb-sdk-utils' -import MultisigConfigModel from 'models/multisig-config' -import WalletService from 'services/wallets' -import { MIN_CELL_CAPACITY, MIN_SUDT_CAPACITY } from 'utils/const' -import AssetAccountService from 'services/asset-account-service' -import LiveCellService from 'services/live-cell-service' +import MultisigConfigModel from '../../models/multisig-config' +import WalletService from '../../services/wallets' +import { MIN_CELL_CAPACITY, MIN_SUDT_CAPACITY } from '../../utils/const' +import AssetAccountService from '../../services/asset-account-service' +import LiveCellService from '../../services/live-cell-service' export interface TargetOutput { address: string diff --git a/packages/neuron-wallet/src/services/tx/transaction-persistor.ts b/packages/neuron-wallet/src/services/tx/transaction-persistor.ts index 8ac55036ec..12bc64c49a 100644 --- a/packages/neuron-wallet/src/services/tx/transaction-persistor.ts +++ b/packages/neuron-wallet/src/services/tx/transaction-persistor.ts @@ -1,14 +1,14 @@ import { getConnection, QueryRunner } from 'typeorm' -import InputEntity from 'database/chain/entities/input' -import OutputEntity from 'database/chain/entities/output' -import TransactionEntity from 'database/chain/entities/transaction' -import ArrayUtils from 'utils/array' -import CommonUtils from 'utils/common' -import logger from 'utils/logger' -import OutPoint from 'models/chain/out-point' -import Output, { OutputStatus } from 'models/chain/output' -import Transaction, { TransactionStatus } from 'models/chain/transaction' -import Input from 'models/chain/input' +import InputEntity from '../../database/chain/entities/input' +import OutputEntity from '../../database/chain/entities/output' +import TransactionEntity from '../../database/chain/entities/transaction' +import ArrayUtils from '../../utils/array' +import CommonUtils from '../../utils/common' +import logger from '../../utils/logger' +import OutPoint from '../../models/chain/out-point' +import Output, { OutputStatus } from '../../models/chain/output' +import Transaction, { TransactionStatus } from '../../models/chain/transaction' +import Input from '../../models/chain/input' export enum TxSaveType { Sent = 'sent', diff --git a/packages/neuron-wallet/src/services/tx/transaction-service.ts b/packages/neuron-wallet/src/services/tx/transaction-service.ts index 45cf6298b0..331548a679 100644 --- a/packages/neuron-wallet/src/services/tx/transaction-service.ts +++ b/packages/neuron-wallet/src/services/tx/transaction-service.ts @@ -1,14 +1,14 @@ import { getConnection } from 'typeorm' -import TransactionEntity from 'database/chain/entities/transaction' -import OutputEntity from 'database/chain/entities/output' -import Transaction, { TransactionStatus, SudtInfo, NFTType, NFTInfo, AssetAccountType } from 'models/chain/transaction' -import InputEntity from 'database/chain/entities/input' -import AddressParser from 'models/address-parser' -import AssetAccountInfo from 'models/asset-account-info' -import BufferUtils from 'utils/buffer' -import AssetAccountEntity from 'database/chain/entities/asset-account' -import SudtTokenInfoEntity from 'database/chain/entities/sudt-token-info' -import exportTransactions from 'utils/export-history' +import TransactionEntity from '../../database/chain/entities/transaction' +import OutputEntity from '../../database/chain/entities/output' +import Transaction, { TransactionStatus, SudtInfo, NFTType, NFTInfo, AssetAccountType } from '../../models/chain/transaction' +import InputEntity from '../../database/chain/entities/input' +import AddressParser from '../../models/address-parser' +import AssetAccountInfo from '../../models/asset-account-info' +import BufferUtils from '../../utils/buffer' +import AssetAccountEntity from '../../database/chain/entities/asset-account' +import SudtTokenInfoEntity from '../../database/chain/entities/sudt-token-info' +import exportTransactions from '../../utils/export-history' export interface TransactionsByAddressesParam { pageNo: number diff --git a/packages/neuron-wallet/src/services/wallets.ts b/packages/neuron-wallet/src/services/wallets.ts index 1fa67d0362..f61a646943 100644 --- a/packages/neuron-wallet/src/services/wallets.ts +++ b/packages/neuron-wallet/src/services/wallets.ts @@ -1,16 +1,16 @@ import { v4 as uuid } from 'uuid' -import { WalletNotFound, IsRequired, UsedName, WalletFunctionNotSupported } from 'exceptions' -import Store from 'models/store' -import Keystore from 'models/keys/keystore' -import WalletDeletedSubject from 'models/subjects/wallet-deleted-subject' -import { WalletListSubject, CurrentWalletSubject } from 'models/subjects/wallets' -import { AccountExtendedPublicKey, DefaultAddressNumber } from 'models/keys/key' -import { Address as AddressInterface } from 'models/address' +import { WalletNotFound, IsRequired, UsedName, WalletFunctionNotSupported } from '../exceptions' +import Store from '../models/store' +import Keystore from '../models/keys/keystore' +import WalletDeletedSubject from '../models/subjects/wallet-deleted-subject' +import { WalletListSubject, CurrentWalletSubject } from '../models/subjects/wallets' +import { AccountExtendedPublicKey, DefaultAddressNumber } from '../models/keys/key' +import { Address as AddressInterface } from '../models/address' import FileService from './file' import AddressService from './addresses' import { DeviceInfo } from './hardware/common' -import HdPublicKeyInfo from 'database/chain/entities/hd-public-key-info' +import HdPublicKeyInfo from '../database/chain/entities/hd-public-key-info' import { getConnection, In, Not } from 'typeorm' const fileService = FileService.getInstance() diff --git a/packages/neuron-wallet/src/utils/common.ts b/packages/neuron-wallet/src/utils/common.ts index b0a7cd13ed..c260ae2287 100644 --- a/packages/neuron-wallet/src/utils/common.ts +++ b/packages/neuron-wallet/src/utils/common.ts @@ -1,4 +1,4 @@ -import logger from 'utils/logger' +import logger from '../utils/logger' export default class CommonUtils { public static sleep = (ms: number): Promise => { diff --git a/packages/neuron-wallet/src/utils/export-history.ts b/packages/neuron-wallet/src/utils/export-history.ts index a3fdb53fc4..0fe86bc56b 100644 --- a/packages/neuron-wallet/src/utils/export-history.ts +++ b/packages/neuron-wallet/src/utils/export-history.ts @@ -1,11 +1,11 @@ import fs from 'fs' import { promisify } from 'util' import { t } from 'i18next' -import TransactionsService from 'services/tx/transaction-service' -import AddressService from 'services/addresses' -import Transaction from 'models/chain/transaction' -import toCSVRow from 'utils/to-csv-row' -import { get as getDescription } from 'services/tx/transaction-description' +import TransactionsService from '../services/tx/transaction-service' +import AddressService from '../services/addresses' +import Transaction from '../models/chain/transaction' +import toCSVRow from '../utils/to-csv-row' +import { get as getDescription } from '../services/tx/transaction-description' const exportHistory = async ({ walletID, filePath }: { walletID: string; filePath: string }) => { if (!walletID) { @@ -25,10 +25,11 @@ const exportHistory = async ({ walletID, filePath }: { walletID: string; filePat const ws = fs.createWriteStream(filePath) const wsPromises: any = new Proxy(ws, { get(target, key: keyof typeof ws, receiver) { - if (typeof target[key] === 'function') { - return promisify(Reflect.get(target, key, receiver)).bind(target) + const meta = Reflect.get(target, key, receiver) + if (typeof meta === 'function') { + return promisify(meta).bind(target) } - return Reflect.get(target, key, receiver) + return meta } }) await wsPromises.write(`${headers.map(label => t(`export-transactions.column.${label}`))}\n`) diff --git a/packages/neuron-wallet/src/utils/logger.ts b/packages/neuron-wallet/src/utils/logger.ts index 5bc73fb4c7..10a52498e9 100644 --- a/packages/neuron-wallet/src/utils/logger.ts +++ b/packages/neuron-wallet/src/utils/logger.ts @@ -1,5 +1,5 @@ import logger from 'electron-log' -import env from 'env' +import env from '../env' if (!env.isDevMode) { logger.transports.file.level = 'info' diff --git a/packages/neuron-wallet/src/utils/multisig.ts b/packages/neuron-wallet/src/utils/multisig.ts index 3d3e1ee2f5..8a457a2b31 100644 --- a/packages/neuron-wallet/src/utils/multisig.ts +++ b/packages/neuron-wallet/src/utils/multisig.ts @@ -1,7 +1,7 @@ import { scriptToHash } from '@nervosnetwork/ckb-sdk-utils' -import Multisig from 'models/multisig' -import MultisigConfigModel from 'models/multisig-config' -import { Signatures, SignStatus } from 'models/offline-sign' +import Multisig from '../models/multisig' +import MultisigConfigModel from '../models/multisig-config' +import { Signatures, SignStatus } from '../models/offline-sign' export const getMultisigStatus = (multisigConfig: MultisigConfigModel, signatures: Signatures) => { const multisigLockHash = scriptToHash( diff --git a/packages/neuron-wallet/src/utils/redist-check.ts b/packages/neuron-wallet/src/utils/redist-check.ts index b4159ee25c..408af371d4 100644 --- a/packages/neuron-wallet/src/utils/redist-check.ts +++ b/packages/neuron-wallet/src/utils/redist-check.ts @@ -1,7 +1,7 @@ import { exec } from 'child_process' import { promisify } from 'util' import path from 'path' -import logger from 'utils/logger' +import logger from '../utils/logger' const redistCheck = async () => { if (process.platform !== 'win32') { diff --git a/packages/neuron-wallet/src/utils/to-csv-row.ts b/packages/neuron-wallet/src/utils/to-csv-row.ts index aff1687732..31eff7f950 100644 --- a/packages/neuron-wallet/src/utils/to-csv-row.ts +++ b/packages/neuron-wallet/src/utils/to-csv-row.ts @@ -1,8 +1,8 @@ import { t } from 'i18next' -import shannonToCKB from 'utils/shannonToCKB' -import sudtValueToAmount from 'utils/sudt-value-to-amount' -import Transaction from 'models/chain/transaction' -import { DEFAULT_UDT_SYMBOL } from 'utils/const' +import shannonToCKB from '../utils/shannonToCKB' +import sudtValueToAmount from '../utils/sudt-value-to-amount' +import Transaction from '../models/chain/transaction' +import { DEFAULT_UDT_SYMBOL } from '../utils/const' export const formatDatetime = (datetime: Date) => { const isoFmt = datetime.toISOString() diff --git a/packages/neuron-wallet/src/utils/validators.ts b/packages/neuron-wallet/src/utils/validators.ts index 887508da31..1f3ea21d6a 100644 --- a/packages/neuron-wallet/src/utils/validators.ts +++ b/packages/neuron-wallet/src/utils/validators.ts @@ -1,8 +1,8 @@ import 'reflect-metadata' import { t } from 'i18next' -import { MIN_PASSWORD_LENGTH, MAX_PASSWORD_LENGTH } from 'utils/const' -import { MissingRequiredArgument } from 'exceptions' +import { MIN_PASSWORD_LENGTH, MAX_PASSWORD_LENGTH } from '../utils/const' +import { MissingRequiredArgument } from '../exceptions' const requiredMetadataKey = Symbol('required') const passwordMetadataKey = Symbol('password') diff --git a/packages/neuron-wallet/tests/services/tx/transaction-generator.test.ts b/packages/neuron-wallet/tests/services/tx/transaction-generator.test.ts index 8b8c144d99..7e5c712260 100644 --- a/packages/neuron-wallet/tests/services/tx/transaction-generator.test.ts +++ b/packages/neuron-wallet/tests/services/tx/transaction-generator.test.ts @@ -249,7 +249,7 @@ describe('TransactionGenerator', () => { ) const inputCapacities = tx - .inputs!.map(input => BigInt(input.capacity)) + .inputs!.map(input => BigInt(input.capacity ?? 0)) .reduce((result, c) => result + c, BigInt(0)) const outputCapacities = tx .outputs!.map(output => BigInt(output.capacity)) @@ -279,7 +279,7 @@ describe('TransactionGenerator', () => { ) const inputCapacities = tx - .inputs!.map(input => BigInt(input.capacity)) + .inputs!.map(input => BigInt(input.capacity ?? 0)) .reduce((result, c) => result + c, BigInt(0)) const outputCapacities = tx .outputs!.map(output => BigInt(output.capacity)) @@ -308,7 +308,7 @@ describe('TransactionGenerator', () => { ) const inputCapacities = tx - .inputs!.map(input => BigInt(input.capacity)) + .inputs!.map(input => BigInt(input.capacity ?? 0)) .reduce((result, c) => result + c, BigInt(0)) const outputCapacities = tx .outputs!.map(output => BigInt(output.capacity)) @@ -337,7 +337,7 @@ describe('TransactionGenerator', () => { ) const inputCapacities = tx - .inputs!.map(input => BigInt(input.capacity)) + .inputs!.map(input => BigInt(input.capacity ?? 0)) .reduce((result, c) => result + c, BigInt(0)) const outputCapacities = tx .outputs!.map(output => BigInt(output.capacity)) @@ -494,7 +494,7 @@ describe('TransactionGenerator', () => { ) const inputCapacities = tx - .inputs!.map(input => BigInt(input.capacity)) + .inputs!.map(input => BigInt(input.capacity ?? 0)) .reduce((result, c) => result + c, BigInt(0)) const outputCapacities = tx .outputs!.map(output => BigInt(output.capacity)) @@ -517,7 +517,7 @@ describe('TransactionGenerator', () => { ) const inputCapacities = tx - .inputs!.map(input => BigInt(input.capacity)) + .inputs!.map(input => BigInt(input.capacity ?? 0)) .reduce((result, c) => result + c, BigInt(0)) const outputCapacities = tx .outputs!.map(output => BigInt(output.capacity)) @@ -540,7 +540,7 @@ describe('TransactionGenerator', () => { ) const inputCapacities = tx - .inputs!.map(input => BigInt(input.capacity)) + .inputs!.map(input => BigInt(input.capacity ?? 0)) .reduce((result, c) => result + c, BigInt(0)) const outputCapacities = tx .outputs!.map(output => BigInt(output.capacity)) @@ -563,7 +563,7 @@ describe('TransactionGenerator', () => { ) const inputCapacities = tx - .inputs!.map(input => BigInt(input.capacity)) + .inputs!.map(input => BigInt(input.capacity ?? 0)) .reduce((result, c) => result + c, BigInt(0)) const outputCapacities = tx .outputs!.map(output => BigInt(output.capacity)) @@ -607,7 +607,7 @@ describe('TransactionGenerator', () => { const tx: Transaction = await TransactionGenerator.generateSendingAllTx(walletId1, targetOutputs, fee) const inputCapacities = tx - .inputs!.map(input => BigInt(input.capacity)) + .inputs!.map(input => BigInt(input.capacity ?? 0)) .reduce((result, c) => result + c, BigInt(0)) const outputCapacities = tx .outputs!.map(output => BigInt(output.capacity)) @@ -620,7 +620,7 @@ describe('TransactionGenerator', () => { expect(o.capacity).toEqual(tx.outputs![index].capacity) } }) - expect(outputCapacities + BigInt(tx.fee)).toEqual(totalCapacities) + expect(outputCapacities + BigInt(tx.fee ?? 0)).toEqual(totalCapacities) }) it('with feeRate 1000', async () => { @@ -628,7 +628,7 @@ describe('TransactionGenerator', () => { const tx: Transaction = await TransactionGenerator.generateSendingAllTx(walletId1, targetOutputs, '0', feeRate) const inputCapacities = tx - .inputs!.map(input => BigInt(input.capacity)) + .inputs!.map(input => BigInt(input.capacity ?? 0)) .reduce((result, c) => result + c, BigInt(0)) const outputCapacities = tx .outputs!.map(output => BigInt(output.capacity)) @@ -647,7 +647,7 @@ describe('TransactionGenerator', () => { expect(o.capacity).toEqual(tx.outputs![index].capacity) } }) - expect(outputCapacities + BigInt(tx.fee)).toEqual(totalCapacities) + expect(outputCapacities + BigInt(tx.fee ?? 0)).toEqual(totalCapacities) }) it('full address with feeRate 1000, 43 capacity', async () => { @@ -678,7 +678,7 @@ describe('TransactionGenerator', () => { const expectedFee: bigint = TransactionFee.fee(expectedSize, BigInt(feeRate)) expect(tx.fee).toEqual(expectedFee.toString()) expect(tx.outputs[0].capacity).toEqual(toShannon('43')) - expect(outputCapacities + BigInt(tx.fee)).toEqual(totalCapacities) + expect(outputCapacities + BigInt(tx.fee ?? 0)).toEqual(totalCapacities) }) it('full address with feeRate 1000, 42 capacity', async () => { @@ -757,7 +757,7 @@ describe('TransactionGenerator', () => { ) const inputCapacities = tx - .inputs!.map(input => BigInt(input.capacity)) + .inputs!.map(input => BigInt(input.capacity ?? 0)) .reduce((result, c) => result + c, BigInt(0)) const outputCapacities = tx .outputs!.map(output => BigInt(output.capacity)) @@ -774,7 +774,7 @@ describe('TransactionGenerator', () => { } }) const totalCapacities: bigint = BigInt(toShannon('3000')) - expect(outputCapacities + BigInt(tx.fee)).toEqual(totalCapacities) + expect(outputCapacities + BigInt(tx.fee ?? 0)).toEqual(totalCapacities) }) }) @@ -1054,7 +1054,7 @@ describe('TransactionGenerator', () => { expect(tx.outputs[0].lock.codeHash).toEqual(SystemScriptInfo.SECP_CODE_HASH) const inputCapacities = tx.inputs - .map(input => BigInt(input.capacity)) + .map(input => BigInt(input.capacity ?? 0)) .reduce((result, c) => result + c, BigInt(0)) const outputCapacities = tx.outputs .map(output => BigInt(output.capacity)) @@ -1171,7 +1171,7 @@ describe('TransactionGenerator', () => { expect(tx.outputs.length).toEqual(2) const inputCapacities = tx.inputs - .map(input => BigInt(input.capacity)) + .map(input => BigInt(input.capacity ?? 0)) .reduce((result, c) => result + c, BigInt(0)) const outputCapacities = tx.outputs .map(output => BigInt(output.capacity)) @@ -1221,7 +1221,7 @@ describe('TransactionGenerator', () => { expect(tx.outputs.length).toEqual(2) const inputCapacities = tx.inputs - .map(input => BigInt(input.capacity)) + .map(input => BigInt(input.capacity ?? 0)) .reduce((result, c) => result + c, BigInt(0)) const outputCapacities = tx.outputs .map(output => BigInt(output.capacity)) @@ -1278,7 +1278,7 @@ describe('TransactionGenerator', () => { expect(tx.outputs.length).toEqual(2) const inputCapacities = tx.inputs - .map(input => BigInt(input.capacity)) + .map(input => BigInt(input.capacity ?? 0)) .reduce((result, c) => result + c, BigInt(0)) const outputCapacities = tx.outputs .map(output => BigInt(output.capacity)) @@ -1358,7 +1358,7 @@ describe('TransactionGenerator', () => { expect(tx.fee).toEqual(expectedTxFee) const inputCapacities = tx.inputs - .map(input => BigInt(input.capacity)) + .map(input => BigInt(input.capacity ?? 0)) .reduce((result, c) => result + c, BigInt(0)) const outputCapacities = tx.outputs .map(output => BigInt(output.capacity)) @@ -1408,7 +1408,7 @@ describe('TransactionGenerator', () => { expect(tx.fee).toEqual(expectedTxFee) const inputCapacities = tx.inputs - .map(input => BigInt(input.capacity)) + .map(input => BigInt(input.capacity ?? 0)) .reduce((result, c) => result + c, BigInt(0)) const outputCapacities = tx.outputs .map(output => BigInt(output.capacity)) @@ -1537,7 +1537,7 @@ describe('TransactionGenerator', () => { BigInt(targetOutput.capacity) + BigInt(toShannon('70')) + (BigInt(toShannon('70')) - BigInt(changeOutput!.capacity)) - - BigInt(tx.fee) + BigInt(tx.fee ?? 0) ).toString() ) }) @@ -1633,13 +1633,13 @@ describe('TransactionGenerator', () => { expect(tx.fee).toEqual(expectedTxFee) const expectedOutputCapacities: bigint[] = [ - BigInt(toShannon('150')) - BigInt(tx.fee), + BigInt(toShannon('150')) - BigInt(tx.fee ?? 0), BigInt(toShannon('142')) ] expect(tx.outputs.map(o => BigInt(o.capacity))).toEqual(expectedOutputCapacities) const inputCapacities = tx.inputs - .map(input => BigInt(input.capacity)) + .map(input => BigInt(input.capacity ?? 0)) .reduce((result, c) => result + c, BigInt(0)) const outputCapacities = tx.outputs .map(output => BigInt(output.capacity)) @@ -1791,12 +1791,12 @@ describe('TransactionGenerator', () => { const expectedOutputCapacities: bigint[] = [ BigInt(toShannon('142')), BigInt(toShannon('142')), - BigInt(toShannon('1000')) - BigInt(tx.fee) + BigInt(toShannon('1000')) - BigInt(tx.fee ?? 0) ] expect(tx.outputs.map(o => BigInt(o.capacity))).toEqual(expectedOutputCapacities) const inputCapacities = tx.inputs - .map(input => BigInt(input.capacity)) + .map(input => BigInt(input.capacity ?? 0)) .reduce((result, c) => result + c, BigInt(0)) const outputCapacities = tx.outputs .map(output => BigInt(output.capacity)) @@ -1867,7 +1867,7 @@ describe('TransactionGenerator', () => { expect(tx.fee).toEqual(expectedTxFee) const inputCapacities = tx.inputs - .map(input => BigInt(input.capacity)) + .map(input => BigInt(input.capacity ?? 0)) .reduce((result, c) => result + c, BigInt(0)) const outputCapacities = tx.outputs .map(output => BigInt(output.capacity)) @@ -1876,7 +1876,7 @@ describe('TransactionGenerator', () => { expect(inputCapacities - outputCapacities).toEqual(BigInt(expectedTxFee)) const expectedOutputCapacities: bigint[] = [ - BigInt(toShannon('143')) + BigInt(toShannon('142')) - BigInt(tx.fee), + BigInt(toShannon('143')) + BigInt(toShannon('142')) - BigInt(tx.fee ?? 0), BigInt(toShannon('142')) ] expect(tx.outputs.map(o => BigInt(o.capacity))).toEqual(expectedOutputCapacities) @@ -1972,13 +1972,13 @@ describe('TransactionGenerator', () => { expect(tx.fee).toEqual(expectedTxFee) const expectedOutputCapacities: bigint[] = [ - BigInt(toShannon('1000')) - BigInt(tx.fee), + BigInt(toShannon('1000')) - BigInt(tx.fee ?? 0), BigInt(toShannon('142')) ] expect(tx.outputs.map(o => BigInt(o.capacity))).toEqual(expectedOutputCapacities) const inputCapacities = tx.inputs - .map(input => BigInt(input.capacity)) + .map(input => BigInt(input.capacity ?? 0)) .reduce((result, c) => result + c, BigInt(0)) const outputCapacities = tx.outputs .map(output => BigInt(output.capacity)) @@ -2059,12 +2059,12 @@ describe('TransactionGenerator', () => { const expectedOutputCapacities: bigint[] = [ BigInt(toShannon('142')), BigInt(toShannon('142')), - BigInt(toShannon('1008')) - BigInt(toShannon('142')) - BigInt(tx.fee), + BigInt(toShannon('1008')) - BigInt(toShannon('142')) - BigInt(tx.fee ?? 0), ] expect(tx.outputs.map(o => BigInt(o.capacity))).toEqual(expectedOutputCapacities) const inputCapacities = tx.inputs - .map(input => BigInt(input.capacity)) + .map(input => BigInt(input.capacity ?? 0)) .reduce((result, c) => result + c, BigInt(0)) const outputCapacities = tx.outputs .map(output => BigInt(output.capacity)) @@ -2095,7 +2095,7 @@ describe('TransactionGenerator', () => { ) // check fee - const inputCapacities = tx.inputs.map(i => BigInt(i.capacity)).reduce((result, c) => result + c, BigInt(0)) + const inputCapacities = tx.inputs.map(i => BigInt(i.capacity ?? 0)).reduce((result, c) => result + c, BigInt(0)) const outputCapacities = tx.outputs.map(o => BigInt(o.capacity)).reduce((result, c) => result + c, BigInt(0)) expect(tx.fee).toEqual((inputCapacities - outputCapacities).toString()) @@ -2130,7 +2130,7 @@ describe('TransactionGenerator', () => { ) // check fee - const inputCapacities = tx.inputs.map(i => BigInt(i.capacity)).reduce((result, c) => result + c, BigInt(0)) + const inputCapacities = tx.inputs.map(i => BigInt(i.capacity ?? 0)).reduce((result, c) => result + c, BigInt(0)) const outputCapacities = tx.outputs.map(o => BigInt(o.capacity)).reduce((result, c) => result + c, BigInt(0)) expect(tx.fee).toEqual((inputCapacities - outputCapacities).toString()) @@ -2406,7 +2406,7 @@ describe('TransactionGenerator', () => { const senderDefaultLockOutput = tx.outputs.find( output => output.lockHash === senderDefaultLockInputEntity.lockHash )! - const capacityAfterFees = BigInt(chequeOutputEntity.capacity) - BigInt(tx.fee) + const capacityAfterFees = BigInt(chequeOutputEntity.capacity) - BigInt(tx.fee ?? 0) expect(senderDefaultLockOutput.capacity).toEqual(capacityAfterFees.toString()) }) it('use 6 relative epoch in cheque input since', () => { @@ -2536,7 +2536,7 @@ describe('TransactionGenerator', () => { const res = (await TransactionGenerator.generateSudtMigrateAcpTx(sudtCell, bobLockHash)) as Transaction expect(res.outputs).toHaveLength(3) expect(res.outputs[1].data).toEqual(BufferUtils.writeBigUInt128LE(BigInt(200))) - expect(res.outputs[2].capacity).toEqual((BigInt(secpCell.capacity) - BigInt(res.fee)).toString()) + expect(res.outputs[2].capacity).toEqual((BigInt(secpCell.capacity) - BigInt(res.fee ?? 0)).toString()) expect(res.inputs).toHaveLength(3) expect(res.inputs[2].lockHash).toBe(bobAnyoneCanPayLockScript.computeHash()) }) @@ -2571,7 +2571,7 @@ describe('TransactionGenerator', () => { const res = (await TransactionGenerator.generateSudtMigrateAcpTx(sudtCell)) as Transaction expect(res.outputs).toHaveLength(1) expect(res.outputs[0].data).toEqual(sudtCell.data) - expect(res.outputs[0].capacity).toEqual((BigInt(sudtCell.capacity) - BigInt(res.fee)).toString()) + expect(res.outputs[0].capacity).toEqual((BigInt(sudtCell.capacity) - BigInt(res.fee ?? 0)).toString()) }) it('account capacity is not enough', async () => { @@ -2615,7 +2615,7 @@ describe('TransactionGenerator', () => { ) // check fee - const inputCapacities = tx.inputs.map(i => BigInt(i.capacity)).reduce((result, c) => result + c, BigInt(0)) + const inputCapacities = tx.inputs.map(i => BigInt(i.capacity ?? 0)).reduce((result, c) => result + c, BigInt(0)) const outputCapacities = tx.outputs.map(o => BigInt(o.capacity)).reduce((result, c) => result + c, BigInt(0)) expect(tx.fee).toEqual((inputCapacities - outputCapacities).toString()) @@ -2629,7 +2629,7 @@ describe('TransactionGenerator', () => { expect(tx.outputs.length).toEqual(1) const output = tx.outputs[0] - expect(output.capacity).toEqual((BigInt(100 * 10 ** 8) - BigInt(tx.fee)).toString()) + expect(output.capacity).toEqual((BigInt(100 * 10 ** 8) - BigInt(tx.fee ?? 0)).toString()) expect(!!output.type).toBe(false) expect(assetAccountInfo.isAnyoneCanPayScript(output.lock)).toBe(true) expect(output.data).toEqual('0x') @@ -2649,7 +2649,7 @@ describe('TransactionGenerator', () => { ) // check fee - const inputCapacities = tx.inputs.map(i => BigInt(i.capacity)).reduce((result, c) => result + c, BigInt(0)) + const inputCapacities = tx.inputs.map(i => BigInt(i.capacity ?? 0)).reduce((result, c) => result + c, BigInt(0)) const outputCapacities = tx.outputs.map(o => BigInt(o.capacity)).reduce((result, c) => result + c, BigInt(0)) expect(tx.fee).toEqual((inputCapacities - outputCapacities).toString()) @@ -2657,7 +2657,7 @@ describe('TransactionGenerator', () => { expect(tx.outputs.length).toEqual(1) const output = tx.outputs[0] - expect(output.capacity).toEqual((BigInt(143 * 10 ** 8) - BigInt(tx.fee)).toString()) + expect(output.capacity).toEqual((BigInt(143 * 10 ** 8) - BigInt(tx.fee ?? 0)).toString()) expect(assetAccountInfo.isSudtScript(output.type!)).toBe(true) expect(assetAccountInfo.isAnyoneCanPayScript(output.lock)).toBe(true) expect(output.data).toEqual('0x' + '0'.repeat(32)) @@ -2720,7 +2720,7 @@ describe('TransactionGenerator', () => { const normalInputCellCapacity = tx.inputs .filter(input => input.lockHash === defaultLock.computeHash()) .reduce((sum, input) => { - return (sum += BigInt(input.capacity)) + return (sum += BigInt(input.capacity ?? 0)) }, BigInt(0)) const normalOutputCellCapacity = tx.outputs .filter(output => output.lockHash === defaultLock.computeHash()) @@ -2739,7 +2739,7 @@ describe('TransactionGenerator', () => { expect(totalLegacyACPCellsCount).toEqual(4) expect(totalMigratedACPCellsCount).toEqual(4) expect(normalInputCellCapacity.toString()).toEqual(toShannon('161')) - expect(normalOutputCellCapacity.toString()).toEqual((normalInputCellCapacity - BigInt(tx.fee)).toString()) + expect(normalOutputCellCapacity.toString()).toEqual((normalInputCellCapacity - BigInt(tx.fee ?? 0)).toString()) expect(acpCellCapacity.toString()).toEqual(toShannon('2400')) expect(totalMigratedSUDTCellCount).toEqual(2) expect(acpCellSudtAmount).toEqual(BigInt(200)) diff --git a/packages/neuron-wallet/tsconfig.json b/packages/neuron-wallet/tsconfig.json index 467877e86a..4df538ca62 100644 --- a/packages/neuron-wallet/tsconfig.json +++ b/packages/neuron-wallet/tsconfig.json @@ -8,12 +8,6 @@ "incremental": true, "outDir": "dist", "baseUrl": ".", - "paths": { - "*": ["./src/*", "node_modules/*"] - }, - "plugins": [ - { "transform": "@zerollup/ts-transform-paths" } - ], "lib": [ "es2019", "dom" diff --git a/yarn.lock b/yarn.lock index 72745e06c0..49f6214e05 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1170,13 +1170,20 @@ resolved "https://registry.yarnpkg.com/@babel/regjsgen/-/regjsgen-0.8.0.tgz#f0ba69b075e1f05fb2825b7fad991e7adbb18310" integrity sha512-x/rqGMdzj+fWZvCOYForTghzbtqPDZ5gPwaoNGHdgDfF2QA/XZbCBp4Moo5scrkAMPhB7z26XM/AaHuIJdgauA== -"@babel/runtime@^7.0.0", "@babel/runtime@^7.1.2", "@babel/runtime@^7.11.2", "@babel/runtime@^7.12.1", "@babel/runtime@^7.12.13", "@babel/runtime@^7.12.5", "@babel/runtime@^7.16.3", "@babel/runtime@^7.17.2", "@babel/runtime@^7.20.6", "@babel/runtime@^7.20.7", "@babel/runtime@^7.3.1", "@babel/runtime@^7.4.4", "@babel/runtime@^7.5.0", "@babel/runtime@^7.5.5", "@babel/runtime@^7.6.3", "@babel/runtime@^7.7.2", "@babel/runtime@^7.7.6", "@babel/runtime@^7.8.4", "@babel/runtime@^7.8.7", "@babel/runtime@^7.9.2": +"@babel/runtime@^7.0.0", "@babel/runtime@^7.1.2", "@babel/runtime@^7.11.2", "@babel/runtime@^7.12.1", "@babel/runtime@^7.12.13", "@babel/runtime@^7.12.5", "@babel/runtime@^7.16.3", "@babel/runtime@^7.20.6", "@babel/runtime@^7.20.7", "@babel/runtime@^7.3.1", "@babel/runtime@^7.4.4", "@babel/runtime@^7.5.0", "@babel/runtime@^7.5.5", "@babel/runtime@^7.6.3", "@babel/runtime@^7.7.2", "@babel/runtime@^7.7.6", "@babel/runtime@^7.8.4", "@babel/runtime@^7.8.7", "@babel/runtime@^7.9.2": version "7.21.0" resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.21.0.tgz#5b55c9d394e5fcf304909a8b00c07dc217b56673" integrity sha512-xwII0//EObnq89Ji5AKYQaRYiW/nZ3llSv29d49IuxPhKbtJoLP+9QUUZ4nVragQVtaVGeZrpB+ZtG/Pdy/POw== dependencies: regenerator-runtime "^0.13.11" +"@babel/runtime@^7.17.2": + version "7.21.5" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.21.5.tgz#8492dddda9644ae3bda3b45eabe87382caee7200" + integrity sha512-8jI69toZqqcsnqGGqwGS4Qb1VwLOEp4hz+CXPywcvjs60u3B4Pom/U/7rm4W8tMOYEB+E9wgD0mW1l3r8qlI9Q== + dependencies: + regenerator-runtime "^0.13.11" + "@babel/template@^7.12.7", "@babel/template@^7.18.10", "@babel/template@^7.20.7", "@babel/template@^7.3.3", "@babel/template@^7.4.0": version "7.20.7" resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.20.7.tgz#a15090c2839a83b02aa996c0b4994005841fd5a8" @@ -6088,20 +6095,6 @@ js-yaml "^3.10.0" tslib "^2.4.0" -"@zerollup/ts-helpers@^1.7.18": - version "1.7.18" - resolved "https://registry.yarnpkg.com/@zerollup/ts-helpers/-/ts-helpers-1.7.18.tgz#747177f6d5abc06c3a0f5dffe7362d365cf0391d" - integrity sha512-S9zN+y+i5yN/evfWquzSO3lubqPXIsPQf6p9OiPMpRxDx/0totPLF39XoRw48Dav5dSvbIE8D2eAPpXXJxvKwg== - dependencies: - resolve "^1.12.0" - -"@zerollup/ts-transform-paths@1.7.18": - version "1.7.18" - resolved "https://registry.yarnpkg.com/@zerollup/ts-transform-paths/-/ts-transform-paths-1.7.18.tgz#72f705c66690879e51d53c73dc76c4e2518a8c50" - integrity sha512-YPVUxvWQVzRx1OBN0Pmkd58+R9FcfUJuwTaPUSoi5rKxuXMtxevTXdfi0w5mEaIH8b0DfL+wg0wFDHiJE+S2zA== - dependencies: - "@zerollup/ts-helpers" "^1.7.18" - "@zkochan/js-yaml@0.0.6": version "0.0.6" resolved "https://registry.yarnpkg.com/@zkochan/js-yaml/-/js-yaml-0.0.6.tgz#975f0b306e705e28b8068a07737fa46d3fc04826" @@ -12977,13 +12970,6 @@ hw-app-ckb@0.1.2: bip32-path "0.4.2" blake2b-wasm "2.1.0" -i18next@17.3.1: - version "17.3.1" - resolved "https://registry.yarnpkg.com/i18next/-/i18next-17.3.1.tgz#5fe75e054aae39a6f38f1a79f7ab49184c6dc7a1" - integrity sha512-4nY+yaENaoZKmpbiDXPzucVHCN3hN9Z9Zk7LyQXVOKVIpnYOJ3L/yxHJlBPtJDq3PGgjFwA0QBFm/26Z0iDT5A== - dependencies: - "@babel/runtime" "^7.3.1" - i18next@21.10.0: version "21.10.0" resolved "https://registry.yarnpkg.com/i18next/-/i18next-21.10.0.tgz#85429af55fdca4858345d0e16b584ec29520197d" @@ -19990,7 +19976,7 @@ resolve@1.1.7: resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b" integrity sha512-9znBF0vBcaSN3W2j7wKvdERPwqTxSpCq+if5C0WoTCyV9n24rua28jeuQ2pL/HOf+yUe/Mef+H/5p60K0Id3bg== -resolve@>=1.9.0, resolve@^1.1.6, resolve@^1.1.7, resolve@^1.10.0, resolve@^1.11.0, resolve@^1.12.0, resolve@^1.14.2, resolve@^1.19.0, resolve@^1.20.0, resolve@^1.22.1, resolve@^1.3.2: +resolve@^1.1.6, resolve@^1.1.7, resolve@^1.10.0, resolve@^1.11.0, resolve@^1.12.0, resolve@^1.14.2, resolve@^1.19.0, resolve@^1.20.0, resolve@^1.22.1, resolve@^1.3.2: version "1.22.1" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.1.tgz#27cb2ebb53f91abb49470a928bba7558066ac177" integrity sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw== @@ -22107,13 +22093,6 @@ tty-browserify@0.0.0: resolved "https://registry.yarnpkg.com/tty-browserify/-/tty-browserify-0.0.0.tgz#a157ba402da24e9bf957f9aa69d524eed42901a6" integrity sha512-JVa5ijo+j/sOoHGjw0sxw734b1LhBkQ3bvUGNdxnVXDCX81Yx7TFgnZygxrIIWn23hbfTaMYLwRmAxFyDuFmIw== -ttypescript@1.5.15: - version "1.5.15" - resolved "https://registry.yarnpkg.com/ttypescript/-/ttypescript-1.5.15.tgz#e45550ad69289d06d3bc3fd4a3c87e7c1ef3eba7" - integrity sha512-48ykDNHzFnPMnv4hYX1P8Q84TvCZyL1QlFxeuxsuZ48X2+ameBgPenvmCkHJtoOSxpoWTWi8NcgNrRnVDOmfSg== - dependencies: - resolve ">=1.9.0" - tunnel-agent@^0.6.0: version "0.6.0" resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd" @@ -22245,15 +22224,10 @@ typeorm@0.2.25: yargonaut "^1.1.2" yargs "^13.2.1" -typescript@4.2.3: - version "4.2.3" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.2.3.tgz#39062d8019912d43726298f09493d598048c1ce3" - integrity sha512-qOcYwxaByStAWrBf4x0fibwZvMRG+r4cQoTjbPtUlrWjBHbmCAww1i448U0GJ+3cNNEtebDteo/cHOR3xJ4wEw== - -typescript@4.8.3: - version "4.8.3" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.8.3.tgz#d59344522c4bc464a65a730ac695007fdb66dd88" - integrity sha512-goMHfm00nWPa8UvR/CPSvykqf6dVV8x/dp0c5mFTMTIu0u0FlGWRioyy7Nn0PGAdHxpJZnuO/ut+PpQ8UiHAig== +typescript@5.0.4: + version "5.0.4" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.0.4.tgz#b217fd20119bd61a94d4011274e0ab369058da3b" + integrity sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw== "typescript@^3 || ^4": version "4.9.5"