Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions packages/neuron-wallet/src/controllers/networks.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -16,7 +14,6 @@ export default class NetworksController {
}
}

@CatchControllerError
public static async get(id: NetworkID) {
if (typeof id === 'undefined') {
throw new IsRequired('ID')
Expand All @@ -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')
Expand All @@ -49,7 +45,6 @@ export default class NetworksController {
}
}

@CatchControllerError
public static async update(id: NetworkID, options: Partial<Network>) {
if (options.name && options.name === 'error') {
throw new InvalidName('Network')
Expand All @@ -62,7 +57,6 @@ export default class NetworksController {
}
}

@CatchControllerError
public static async delete(id: NetworkID) {
await networksService.delete(id)

Expand All @@ -72,7 +66,6 @@ export default class NetworksController {
}
}

@CatchControllerError
public static async currentID() {
const currentID = await networksService.getCurrentID()
if (currentID) {
Expand All @@ -84,7 +77,6 @@ export default class NetworksController {
throw new CurrentNetworkNotSet()
}

@CatchControllerError
public static async activate(id: NetworkID) {
await networksService.activate(id)
return {
Expand All @@ -93,7 +85,6 @@ export default class NetworksController {
}
}

@CatchControllerError
public static async clear() {
await networksService.clear()
return {
Expand Down
3 changes: 0 additions & 3 deletions packages/neuron-wallet/src/controllers/skip-data-and-type.ts
Original file line number Diff line number Diff line change
@@ -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<Controller.Response<boolean>> {
SkipDataAndType.getInstance().update(skip)

Expand All @@ -13,7 +11,6 @@ export default class SkipDataAndTypeController {
}
}

@CatchControllerError
public static async get(): Promise<Controller.Response<boolean>> {
const skip = SkipDataAndType.getInstance().get()

Expand Down
2 changes: 0 additions & 2 deletions packages/neuron-wallet/src/controllers/sync-info.ts
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
6 changes: 0 additions & 6 deletions packages/neuron-wallet/src/controllers/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ 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'

const CELL_COUNT_THRESHOLD = 10

export default class TransactionsController {
@CatchControllerError
public static async getAll(
params: TransactionsByLockHashesParam,
): Promise<Controller.Response<PaginationResult<Transaction>>> {
Expand All @@ -28,7 +26,6 @@ export default class TransactionsController {
}
}

@CatchControllerError
public static async getAllByKeywords(
params: Controller.Params.TransactionsByKeywords,
): Promise<Controller.Response<PaginationResult<Transaction> & Controller.Params.TransactionsByKeywords>> {
Expand All @@ -52,7 +49,6 @@ export default class TransactionsController {
}
}

@CatchControllerError
public static async getAllByAddresses(
params: Controller.Params.TransactionsByAddresses,
): Promise<Controller.Response<PaginationResult<Transaction> & Controller.Params.TransactionsByAddresses>> {
Expand Down Expand Up @@ -82,7 +78,6 @@ export default class TransactionsController {
}
}

@CatchControllerError
public static async get(
walletID: string,
hash: string,
Expand Down Expand Up @@ -132,7 +127,6 @@ export default class TransactionsController {
}
}

@CatchControllerError
public static async updateDescription({ hash, description }: { hash: string; description: string }) {
await TransactionsService.updateDescription(hash, description)

Expand Down
25 changes: 4 additions & 21 deletions packages/neuron-wallet/src/controllers/wallets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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<Controller.Response<Pick<Wallet, 'id' | 'name'>[]>> {
const walletsService = WalletsService.getInstance()
const wallets = walletsService.getAll()
Expand Down Expand Up @@ -52,7 +50,6 @@ export default class WalletsController {
}
}

@CatchControllerError
public static async get(id: string): Promise<Controller.Response<Wallet>> {
const walletsService = WalletsService.getInstance()
if (typeof id === 'undefined') {
Expand All @@ -69,7 +66,6 @@ export default class WalletsController {
}
}

@CatchControllerError
public static async importMnemonic({
name,
password,
Expand All @@ -91,7 +87,6 @@ export default class WalletsController {
return result
}

@CatchControllerError
public static async create({
name,
password,
Expand Down Expand Up @@ -164,7 +159,6 @@ export default class WalletsController {
}
}

@CatchControllerError
public static async importKeystore({
name,
password,
Expand Down Expand Up @@ -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()
Expand All @@ -213,7 +207,7 @@ export default class WalletsController {
}

// TODO: update addresses?
@CatchControllerError

public static async update({
id,
name,
Expand Down Expand Up @@ -248,7 +242,6 @@ export default class WalletsController {
}
}

@CatchControllerError
public static async delete({
id = '',
password = '',
Expand All @@ -267,7 +260,6 @@ export default class WalletsController {
}
}

@CatchControllerError
public static async backup({
id = '',
password = '',
Expand All @@ -290,12 +282,10 @@ export default class WalletsController {
result: true,
})
}
}
)
})
})
}

@CatchControllerError
public static async getCurrent() {
const currentWallet = WalletsService.getInstance().getCurrent() || null
return {
Expand All @@ -304,7 +294,6 @@ export default class WalletsController {
}
}

@CatchControllerError
public static async activate(id: string) {
const walletsService = WalletsService.getInstance()
walletsService.setCurrent(id)
Expand All @@ -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(
Expand Down Expand Up @@ -347,7 +335,6 @@ export default class WalletsController {
}
}

@CatchControllerError
public static async sendCapacity(params: {
id: string
walletID: string
Expand Down Expand Up @@ -382,7 +369,6 @@ export default class WalletsController {
}
}

@CatchControllerError
public static async sendTx(params: {
walletID: string
tx: TransactionWithoutHash
Expand All @@ -405,7 +391,6 @@ export default class WalletsController {
}
}

@CatchControllerError
public static async generateTx(params: {
walletID: string
items: {
Expand All @@ -431,7 +416,6 @@ export default class WalletsController {
}
}

@CatchControllerError
public static async computeCycles(params: { walletID: string; capacities: string }) {
if (!params) {
throw new IsRequired('Parameters')
Expand All @@ -444,7 +428,6 @@ export default class WalletsController {
}
}

@CatchControllerError
public static async updateAddressDescription({
walletID,
address,
Expand Down