Skip to content

Commit

Permalink
Merge pull request #2660 from yanguoyu/chore-typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
Keith-CY authored May 12, 2023
2 parents b314dfc + 0f3c4c8 commit f4f1073
Show file tree
Hide file tree
Showing 107 changed files with 634 additions and 667 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
10 changes: 4 additions & 6 deletions packages/neuron-wallet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/*",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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"
}
}
26 changes: 13 additions & 13 deletions packages/neuron-wallet/src/block-sync-renderer/index.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
28 changes: 14 additions & 14 deletions packages/neuron-wallet/src/block-sync-renderer/sync/queue.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 4 additions & 4 deletions packages/neuron-wallet/src/block-sync-renderer/task.ts
Original file line number Diff line number Diff line change
@@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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) => {
Expand Down
16 changes: 8 additions & 8 deletions packages/neuron-wallet/src/controllers/anyone-can-pay.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
56 changes: 28 additions & 28 deletions packages/neuron-wallet/src/controllers/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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.
Expand Down
18 changes: 9 additions & 9 deletions packages/neuron-wallet/src/controllers/app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
24 changes: 12 additions & 12 deletions packages/neuron-wallet/src/controllers/app/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion packages/neuron-wallet/src/controllers/app/show-window.ts
Original file line number Diff line number Diff line change
@@ -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 = (
Expand Down
Loading

1 comment on commit f4f1073

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Packaging for test is done in 4954459713

Please sign in to comment.