diff --git a/packages/neuron-wallet/src/controllers/offline-sign.ts b/packages/neuron-wallet/src/controllers/offline-sign.ts index c31bb8865b..84e4697b42 100644 --- a/packages/neuron-wallet/src/controllers/offline-sign.ts +++ b/packages/neuron-wallet/src/controllers/offline-sign.ts @@ -15,6 +15,7 @@ import { getMultisigStatus } from '../utils/multisig' import { generateRPC } from '../utils/ckb-rpc' import ShowGlobalDialogSubject from '../models/subjects/show-global-dialog' import NetworksService from '../services/networks' +import logger from '../utils/logger' export default class OfflineSignController { public async exportTransactionAsJSON({ @@ -99,11 +100,17 @@ export default class OfflineSignController { .then(({ tx: t, metadata }) => { // TODO: maybe unidentified inputs can be skipped in offline sign if (metadata.locks.skipped.size) { - throw new Error( - `Fail to sign transaction, following lock scripts cannot be identified: ${[ - ...metadata.locks.skipped.values(), - ]}` - ) + try { + throw new Error( + `Fail to sign transaction, following lock scripts cannot be identified: ${[ + ...metadata.locks.skipped.values(), + ]}` + ) + } catch (err) { + // FIXME: remove this before being merged into develop branch + logger.debug('Ignore the following error for debugging polycrypt') + logger.error(err) + } } return t }) diff --git a/packages/neuron-wallet/src/services/hardware/hardware.ts b/packages/neuron-wallet/src/services/hardware/hardware.ts index 2c5801a4cc..a0db5a5435 100644 --- a/packages/neuron-wallet/src/services/hardware/hardware.ts +++ b/packages/neuron-wallet/src/services/hardware/hardware.ts @@ -60,6 +60,7 @@ export abstract class Hardware { } else if (args.length === 42) { return addressInfos.find(i => i.blake160 === args)!.path } else { + // FIXME: should not be a fallback const addressInfo = AssetAccountInfo.findSignPathForCheque(addressInfos, args) return addressInfo!.path } diff --git a/packages/neuron-wallet/src/services/transaction-sender.ts b/packages/neuron-wallet/src/services/transaction-sender.ts index d26904aac4..7edb39c489 100644 --- a/packages/neuron-wallet/src/services/transaction-sender.ts +++ b/packages/neuron-wallet/src/services/transaction-sender.ts @@ -73,12 +73,18 @@ export default class TransactionSender { const tx = skipSign ? Transaction.fromObject(transaction) : await this.sign(walletID, transaction, password, skipLastInput).then(({ tx, metadata }) => { - if (metadata.locks.skipped.size) { - throw new Error( - `Fail to send transaction, following lock scripts cannot be identified: ${[ - ...metadata.locks.skipped.values(), - ]} ` - ) + try { + if (metadata.locks.skipped.size) { + throw new Error( + `Fail to send transaction, following lock scripts cannot be identified: ${[ + ...metadata.locks.skipped.values(), + ]} ` + ) + } + } catch (err) { + // FIXME: remove this before being merged into develop branch + logger.debug('Ignore the following error for debugging polycrypt') + logger.error(err) } return tx }) @@ -165,8 +171,13 @@ export default class TransactionSender { } else if (args.length === 42) { path = addressInfos.find(i => i.blake160 === args)?.path } else { - const addressInfo = AssetAccountInfo.findSignPathForCheque(addressInfos, args) - path = addressInfo?.path + // FIXME: should not be a fallback + try { + const addressInfo = AssetAccountInfo.findSignPathForCheque(addressInfos, args) + path = addressInfo?.path + } catch { + logger.error(`Failed to find args: ${args}`) + } } return pathAndPrivateKeys.find(p => p.path === path)?.privateKey @@ -303,9 +314,14 @@ export default class TransactionSender { path = matchAddress?.path matchArgs = matchAddress?.blake160 } else { - const addressInfo = AssetAccountInfo.findSignPathForCheque(addressInfos, args) - path = addressInfo?.path - matchArgs = addressInfo?.blake160 + // FIXME: should not be a fallback + try { + const addressInfo = AssetAccountInfo.findSignPathForCheque(addressInfos, args) + path = addressInfo?.path + matchArgs = addressInfo?.blake160 + } catch { + logger.error(`Failed to find args: ${args}`) + } } return !!path })