From a855395c60cd07bbbd789d44fb7d7b4823e668ad Mon Sep 17 00:00:00 2001 From: Keith Date: Fri, 15 Dec 2023 18:36:32 +0900 Subject: [PATCH] wip: ignore unidentified locks to debug polycrypt --- .../src/controllers/offline-sign.ts | 17 ++++++--- .../src/services/hardware/hardware.ts | 1 + .../src/services/transaction-sender.ts | 38 +++++++++++++------ 3 files changed, 40 insertions(+), 16 deletions(-) diff --git a/packages/neuron-wallet/src/controllers/offline-sign.ts b/packages/neuron-wallet/src/controllers/offline-sign.ts index c31bb8865b..e364dcff49 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 polyscrypt') + 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 e94dcde00c..13393ad378 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 polyscrypt') + 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 })