diff --git a/packages/neuron-wallet/src/controllers/networks.ts b/packages/neuron-wallet/src/controllers/networks.ts index 4e0c718de0..a7bc506784 100644 --- a/packages/neuron-wallet/src/controllers/networks.ts +++ b/packages/neuron-wallet/src/controllers/networks.ts @@ -1,13 +1,11 @@ import { NetworkType, NetworkID, Network } from 'types/network' import NetworksService from 'services/networks' -import { CatchControllerError } from 'decorators' import { ResponseCode } from 'utils/const' import { IsRequired, InvalidName, NetworkNotFound, CurrentNetworkNotSet } from 'exceptions' const networksService = NetworksService.getInstance() export default class NetworksController { - @CatchControllerError public static async getAll() { const networks = await networksService.getAll() return { @@ -16,7 +14,6 @@ export default class NetworksController { } } - @CatchControllerError public static async get(id: NetworkID) { if (typeof id === 'undefined') { throw new IsRequired('ID') @@ -33,7 +30,6 @@ export default class NetworksController { } } - @CatchControllerError public static async create({ name, remote, type = NetworkType.Normal }: Network) { if (!name || !remote) { throw new IsRequired('Name and address') @@ -49,7 +45,6 @@ export default class NetworksController { } } - @CatchControllerError public static async update(id: NetworkID, options: Partial) { if (options.name && options.name === 'error') { throw new InvalidName('Network') @@ -62,7 +57,6 @@ export default class NetworksController { } } - @CatchControllerError public static async delete(id: NetworkID) { await networksService.delete(id) @@ -72,7 +66,6 @@ export default class NetworksController { } } - @CatchControllerError public static async currentID() { const currentID = await networksService.getCurrentID() if (currentID) { @@ -84,7 +77,6 @@ export default class NetworksController { throw new CurrentNetworkNotSet() } - @CatchControllerError public static async activate(id: NetworkID) { await networksService.activate(id) return { @@ -93,7 +85,6 @@ export default class NetworksController { } } - @CatchControllerError public static async clear() { await networksService.clear() return { diff --git a/packages/neuron-wallet/src/controllers/skip-data-and-type.ts b/packages/neuron-wallet/src/controllers/skip-data-and-type.ts index 5357dc450d..9b88d1d19f 100644 --- a/packages/neuron-wallet/src/controllers/skip-data-and-type.ts +++ b/packages/neuron-wallet/src/controllers/skip-data-and-type.ts @@ -1,9 +1,7 @@ -import { CatchControllerError } from 'decorators/errors' import { ResponseCode } from 'utils/const' import SkipDataAndType from 'services/settings/skip-data-and-type' export default class SkipDataAndTypeController { - @CatchControllerError public static async update(skip: boolean): Promise> { SkipDataAndType.getInstance().update(skip) @@ -13,7 +11,6 @@ export default class SkipDataAndTypeController { } } - @CatchControllerError public static async get(): Promise> { const skip = SkipDataAndType.getInstance().get() diff --git a/packages/neuron-wallet/src/controllers/sync-info.ts b/packages/neuron-wallet/src/controllers/sync-info.ts index fc94e804b2..786380441e 100644 --- a/packages/neuron-wallet/src/controllers/sync-info.ts +++ b/packages/neuron-wallet/src/controllers/sync-info.ts @@ -1,9 +1,7 @@ -import { CatchControllerError } from 'decorators' import BlockNumber from 'services/sync/block-number' import { ResponseCode } from 'utils/const' export default class SyncInfoController { - @CatchControllerError public static async currentBlockNumber() { const blockNumber = new BlockNumber() const current: bigint = await blockNumber.getCurrent() diff --git a/packages/neuron-wallet/src/controllers/transactions.ts b/packages/neuron-wallet/src/controllers/transactions.ts index 3781bc94fb..b2e1a0a18c 100644 --- a/packages/neuron-wallet/src/controllers/transactions.ts +++ b/packages/neuron-wallet/src/controllers/transactions.ts @@ -4,7 +4,6 @@ import { TransactionsService, PaginationResult, TransactionsByLockHashesParam } import AddressesService from 'services/addresses' import WalletsService from 'services/wallets' -import { CatchControllerError } from 'decorators' import { ResponseCode } from 'utils/const' import { TransactionNotFound, CurrentWalletNotSet, ServiceHasNoResponse } from 'exceptions' import LockUtils from 'models/lock-utils' @@ -12,7 +11,6 @@ import LockUtils from 'models/lock-utils' const CELL_COUNT_THRESHOLD = 10 export default class TransactionsController { - @CatchControllerError public static async getAll( params: TransactionsByLockHashesParam, ): Promise>> { @@ -28,7 +26,6 @@ export default class TransactionsController { } } - @CatchControllerError public static async getAllByKeywords( params: Controller.Params.TransactionsByKeywords, ): Promise & Controller.Params.TransactionsByKeywords>> { @@ -52,7 +49,6 @@ export default class TransactionsController { } } - @CatchControllerError public static async getAllByAddresses( params: Controller.Params.TransactionsByAddresses, ): Promise & Controller.Params.TransactionsByAddresses>> { @@ -82,7 +78,6 @@ export default class TransactionsController { } } - @CatchControllerError public static async get( walletID: string, hash: string, @@ -132,7 +127,6 @@ export default class TransactionsController { } } - @CatchControllerError public static async updateDescription({ hash, description }: { hash: string; description: string }) { await TransactionsService.updateDescription(hash, description) diff --git a/packages/neuron-wallet/src/controllers/wallets.ts b/packages/neuron-wallet/src/controllers/wallets.ts index 8f64d15fbd..f194b7ec31 100644 --- a/packages/neuron-wallet/src/controllers/wallets.ts +++ b/packages/neuron-wallet/src/controllers/wallets.ts @@ -5,7 +5,6 @@ import Keystore from 'models/keys/keystore' import Keychain from 'models/keys/keychain' import { validateMnemonic, mnemonicToSeedSync } from 'models/keys/mnemonic' import { AccountExtendedPublicKey, ExtendedPrivateKey } from 'models/keys/key' -import { CatchControllerError } from 'decorators' import { ResponseCode } from 'utils/const' import { CurrentWalletNotSet, @@ -20,10 +19,9 @@ import { import i18n from 'utils/i18n' import AddressService from 'services/addresses' import WalletCreatedSubject from 'models/subjects/wallet-created-subject' -import { TransactionWithoutHash } from 'types/cell-types'; +import { TransactionWithoutHash } from 'types/cell-types' export default class WalletsController { - @CatchControllerError public static async getAll(): Promise[]>> { const walletsService = WalletsService.getInstance() const wallets = walletsService.getAll() @@ -52,7 +50,6 @@ export default class WalletsController { } } - @CatchControllerError public static async get(id: string): Promise> { const walletsService = WalletsService.getInstance() if (typeof id === 'undefined') { @@ -69,7 +66,6 @@ export default class WalletsController { } } - @CatchControllerError public static async importMnemonic({ name, password, @@ -91,7 +87,6 @@ export default class WalletsController { return result } - @CatchControllerError public static async create({ name, password, @@ -164,7 +159,6 @@ export default class WalletsController { } } - @CatchControllerError public static async importKeystore({ name, password, @@ -192,7 +186,7 @@ export default class WalletsController { const accountKeychain = masterKeychain.derivePath(AccountExtendedPublicKey.ckbAccountPath) const accountExtendedPublicKey = new AccountExtendedPublicKey( accountKeychain.publicKey.toString('hex'), - accountKeychain.chainCode.toString('hex') + accountKeychain.chainCode.toString('hex'), ) const walletsService = WalletsService.getInstance() @@ -213,7 +207,7 @@ export default class WalletsController { } // TODO: update addresses? - @CatchControllerError + public static async update({ id, name, @@ -248,7 +242,6 @@ export default class WalletsController { } } - @CatchControllerError public static async delete({ id = '', password = '', @@ -267,7 +260,6 @@ export default class WalletsController { } } - @CatchControllerError public static async backup({ id = '', password = '', @@ -290,12 +282,10 @@ export default class WalletsController { result: true, }) } - } - ) + }) }) } - @CatchControllerError public static async getCurrent() { const currentWallet = WalletsService.getInstance().getCurrent() || null return { @@ -304,7 +294,6 @@ export default class WalletsController { } } - @CatchControllerError public static async activate(id: string) { const walletsService = WalletsService.getInstance() walletsService.setCurrent(id) @@ -318,7 +307,6 @@ export default class WalletsController { } } - @CatchControllerError public static async getAllAddresses(id: string) { const addresses = await AddressService.allAddressesByWalletId(id).then(addrs => addrs.map( @@ -347,7 +335,6 @@ export default class WalletsController { } } - @CatchControllerError public static async sendCapacity(params: { id: string walletID: string @@ -382,7 +369,6 @@ export default class WalletsController { } } - @CatchControllerError public static async sendTx(params: { walletID: string tx: TransactionWithoutHash @@ -405,7 +391,6 @@ export default class WalletsController { } } - @CatchControllerError public static async generateTx(params: { walletID: string items: { @@ -431,7 +416,6 @@ export default class WalletsController { } } - @CatchControllerError public static async computeCycles(params: { walletID: string; capacities: string }) { if (!params) { throw new IsRequired('Parameters') @@ -444,7 +428,6 @@ export default class WalletsController { } } - @CatchControllerError public static async updateAddressDescription({ walletID, address,