Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const useGetCountDownAndFeeRateStats = ({ seconds = 30, interval = 1000 }: Count
suggestFeeRate: number
}>({ suggestFeeRate: MEDIUM_FEE_RATE })

const handleGetFeeRateStatis = useCallback(() => {
const handleGetFeeRateStatistics = useCallback(() => {
getFeeRateStatistics()
.then(res => {
const { median } = res ?? {}
Expand Down Expand Up @@ -50,7 +50,7 @@ const useGetCountDownAndFeeRateStats = ({ seconds = 30, interval = 1000 }: Count

useEffect(() => {
if (countDown === seconds) {
handleGetFeeRateStatis()
handleGetFeeRateStatistics()
}
}, [countDown, seconds])

Expand Down
1 change: 1 addition & 0 deletions packages/neuron-wallet/src/exceptions/multisig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export class MultisigConfigAddressError extends Error {
}

export class MultisigConfigNeedError extends Error {
public code = 502
constructor() {
super(t('messages.multisig-config-need-error'))
}
Expand Down
7 changes: 7 additions & 0 deletions packages/neuron-wallet/src/locales/ar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,13 @@ export default {
cancel: 'إلغاء',
},
},
'unrecognized-lock-script': {
message: 'تم العثور على نص قفل غير معرّف في هذه المعاملة، يرجى التحقق.',
buttons: {
cancel: 'إلغاء',
ignore: 'تجاهل واستمرار',
},
},
},
prompt: {
password: {
Expand Down
7 changes: 7 additions & 0 deletions packages/neuron-wallet/src/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,13 @@ export default {
cancel: 'Cancel',
},
},
'unrecognized-lock-script': {
message: 'An unrecognized lock script was found in this transaction, please check it.',
buttons: {
cancel: 'Cancel',
ignore: 'Ignpre and continue',
},
},
},
prompt: {
password: {
Expand Down
7 changes: 7 additions & 0 deletions packages/neuron-wallet/src/locales/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,13 @@ export default {
cancel: 'Cancelar',
},
},
'unrecognized-lock-script': {
message: 'Se encontró un script de bloqueo no reconocido en esta transacción, por favor verifíquelo.',
buttons: {
cancel: 'Cancelar',
ignore: 'Ignorar y continuar',
},
},
},
prompt: {
password: {
Expand Down
7 changes: 7 additions & 0 deletions packages/neuron-wallet/src/locales/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,13 @@ export default {
cancel: 'Annuler',
},
},
'unrecognized-lock-script': {
message: 'Un script de verrouillage non reconnu a été trouvé dans cette transaction, veuillez vérifier.',
buttons: {
cancel: 'Annuler',
ignore: 'Ignorer et continuer',
},
},
},
prompt: {
password: {
Expand Down
7 changes: 7 additions & 0 deletions packages/neuron-wallet/src/locales/zh-tw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,13 @@ export default {
cancel: '取消',
},
},
'unrecognized-lock-script': {
message: '在此交易中發現了一個未識別的lock script,請檢查。',
buttons: {
cancel: '取消',
ignore: '忽略並繼續',
},
},
},
prompt: {
password: {
Expand Down
7 changes: 7 additions & 0 deletions packages/neuron-wallet/src/locales/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,13 @@ export default {
cancel: '取消',
},
},
'unrecognized-lock-script': {
message: '在此交易中发现了一个未识别的lock script,请检查。',
buttons: {
cancel: '取消',
ignore: '忽略并继续',
},
},
},
prompt: {
password: {
Expand Down
15 changes: 15 additions & 0 deletions packages/neuron-wallet/src/services/transaction-sender.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { t } from 'i18next'
import { dialog } from 'electron'
import { serializeWitnessArgs } from '../utils/serialization'
import { scriptToAddress } from '../utils/scriptAndAddress'
import { TargetOutput, TransactionGenerator, TransactionPersistor } from './tx'
Expand Down Expand Up @@ -330,6 +332,19 @@ export default class TransactionSender {
for (const lockHash of lockHashes) {
const multisigConfig = multisigConfigMap[lockHash]
if (!multisigConfig) {
const res = await dialog.showMessageBox({
type: 'warning',
message: t('messageBox.unrecognized-lock-script.message'),
buttons: [
t('messageBox.unrecognized-lock-script.buttons.cancel'),
t('messageBox.unrecognized-lock-script.buttons.ignore'),
],
defaultId: 0,
cancelId: 1,
})
if (res.response === 1) {
continue
}
throw new MultisigConfigNeedError()
}
const [privateKey, blake160] = findPrivateKeyAndBlake160(multisigConfig.blake160s, tx.signatures?.[lockHash])
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { dialog } from 'electron'
import { CKBComponents } from '@ckb-lumos/lumos/rpc'
import { bytes } from '@ckb-lumos/lumos/codec'
import 'dotenv/config'
Expand Down Expand Up @@ -181,6 +182,12 @@ jest.doMock('services/cells', () => ({
getLiveCell: stubbedGetLiveCell,
}))

jest.mock('electron', () => ({
dialog: {
showMessageBox: jest.fn(),
},
}))

import Transaction from '../../../src/models/chain/transaction'
import TxStatus from '../../../src/models/chain/tx-status'
import CellDep, { DepType } from '../../../src/models/chain/cell-dep'
Expand Down Expand Up @@ -1001,13 +1008,28 @@ describe('TransactionSender Test', () => {
})
})

it('throw exception no matched multisig config', async () => {
it('no matched multisig config, ignore and continue', async () => {
const showMessageBoxMock = jest
.spyOn(dialog, 'showMessageBox')
.mockImplementation(() => Promise.resolve({ response: 1, checkboxChecked: true }))
mockGAI.mockReturnValueOnce([{ path: '' }])
transactionSender.getAddressInfos = mockGAI.bind(transactionSender)
const tx = Transaction.fromObject(transactionObject)
await expect(transactionSender.signMultisig(fakeWallet.id, tx, '1234', [])).resolves.not.toThrow()
expect(showMessageBoxMock).toHaveBeenCalled()
})

it('no matched multisig config, throw exception', async () => {
const showMessageBoxMock = jest
.spyOn(dialog, 'showMessageBox')
.mockImplementation(() => Promise.resolve({ response: 0, checkboxChecked: false }))
mockGAI.mockReturnValueOnce([{ path: '' }])
transactionSender.getAddressInfos = mockGAI.bind(transactionSender)
const tx = Transaction.fromObject(transactionObject)
await expect(transactionSender.signMultisig(fakeWallet.id, tx, '1234', [])).rejects.toThrowError(
new MultisigConfigNeedError()
)
expect(showMessageBoxMock).toHaveBeenCalled()
})

it('throw exception no matched multisig config addresses', async () => {
Expand Down
Loading