Skip to content

Commit 0065f4d

Browse files
authored
feat: Identify and prompt for multisig transaction (#3370)
* feat: Identify and prompt for multisig transaction * fix: error message
1 parent 4571d2f commit 0065f4d

File tree

8 files changed

+65
-5
lines changed

8 files changed

+65
-5
lines changed

packages/neuron-wallet/src/exceptions/transaction.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ export class TransactionInputParameterMiss extends Error {
2424
}
2525
}
2626

27+
export class UnrecognizedLockScript extends Error {
28+
public code = 117
29+
constructor(message: string) {
30+
super(message)
31+
}
32+
}
33+
2734
export default {
2835
TransactionNotFound,
2936
CapacityTooSmall,

packages/neuron-wallet/src/locales/ar.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,12 @@ export default {
228228
ignore: 'تجاهل واستمرار',
229229
},
230230
},
231+
'unrecognized-multisig-transaction': {
232+
message: 'هذه معاملة متعددة التوقيعات. يرجى الموافقة عليها من عنوان التوقيع المتعدد باستخدام المحفظة المناسبة.',
233+
buttons: {
234+
cancel: 'إلغاء',
235+
},
236+
},
231237
},
232238
prompt: {
233239
password: {

packages/neuron-wallet/src/locales/en.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,13 @@ export default {
230230
ignore: 'Ignore and continue',
231231
},
232232
},
233+
'unrecognized-multisig-transaction': {
234+
message:
235+
'This is a multisig transaction. Please approve it from the multisig address using the appropriate wallet. ',
236+
buttons: {
237+
cancel: 'Cancel',
238+
},
239+
},
233240
},
234241
prompt: {
235242
password: {

packages/neuron-wallet/src/locales/es.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,13 @@ export default {
233233
ignore: 'Ignorar y continuar',
234234
},
235235
},
236+
'unrecognized-multisig-transaction': {
237+
message:
238+
'Esta es una transacción multisignatura. Por favor, apróbala desde la dirección multisignatura utilizando la billetera correspondiente.',
239+
buttons: {
240+
cancel: 'Cancelar',
241+
},
242+
},
236243
},
237244
prompt: {
238245
password: {

packages/neuron-wallet/src/locales/fr.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,13 @@ export default {
234234
ignore: 'Ignorer et continuer',
235235
},
236236
},
237+
'unrecognized-multisig-transaction': {
238+
message:
239+
"Il s'agit d'une transaction multisignature. Veuillez l'approuver depuis l'adresse multisignature en utilisant le portefeuille approprié.",
240+
buttons: {
241+
cancel: 'Annuler',
242+
},
243+
},
237244
},
238245
prompt: {
239246
password: {

packages/neuron-wallet/src/locales/zh-tw.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,12 @@ export default {
216216
ignore: '忽略並繼續',
217217
},
218218
},
219+
'unrecognized-multisig-transaction': {
220+
message: '這是一筆多簽交易。請使用對應的錢包在多簽地址中批准該交易。',
221+
buttons: {
222+
cancel: '取消',
223+
},
224+
},
219225
},
220226
prompt: {
221227
password: {

packages/neuron-wallet/src/locales/zh.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,12 @@ export default {
217217
ignore: '忽略并继续',
218218
},
219219
},
220+
'unrecognized-multisig-transaction': {
221+
message: '这是一笔多签交易。请使用对应的钱包在多签地址中批准该交易。',
222+
buttons: {
223+
cancel: '取消',
224+
},
225+
},
220226
},
221227
prompt: {
222228
password: {

packages/neuron-wallet/src/services/transaction-sender.ts

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import {
3232
NoMatchAddressForSign,
3333
SignTransactionFailed,
3434
TransactionIsNotCommittedYet,
35+
UnrecognizedLockScript,
3536
} from '../exceptions'
3637
import AssetAccountInfo from '../models/asset-account-info'
3738
import MultisigConfigModel from '../models/multisig-config'
@@ -206,19 +207,32 @@ export default class TransactionSender {
206207
} catch (error) {
207208
const BLOCK_UNRECOGNIZED = 0
208209
const IGNORE_UNRECOGNIZED_AND_CONTINUE = 1
210+
211+
let message = t('messageBox.unrecognized-lock-script.message')
212+
let buttons = [
213+
t('messageBox.unrecognized-lock-script.buttons.cancel'),
214+
t('messageBox.unrecognized-lock-script.buttons.ignore'),
215+
]
216+
217+
const input = tx.inputs.find(input => input.lockHash === lockHash)
218+
if (input && input.lock && SystemScriptInfo.isMultiSignCodeHash(input.lock.codeHash)) {
219+
message = t('messageBox.unrecognized-multisig-transaction.message')
220+
buttons = [t('messageBox.unrecognized-multisig-transaction.buttons.cancel')]
221+
}
222+
209223
const res = await dialog.showMessageBox({
210224
type: 'warning',
211-
message: t('messageBox.unrecognized-lock-script.message'),
212-
buttons: [
213-
t('messageBox.unrecognized-lock-script.buttons.cancel'),
214-
t('messageBox.unrecognized-lock-script.buttons.ignore'),
215-
],
225+
message,
226+
buttons,
216227
defaultId: BLOCK_UNRECOGNIZED,
217228
cancelId: IGNORE_UNRECOGNIZED_AND_CONTINUE,
218229
})
219230
if (res.response === IGNORE_UNRECOGNIZED_AND_CONTINUE) {
220231
continue
221232
}
233+
if (res.response === BLOCK_UNRECOGNIZED) {
234+
throw new UnrecognizedLockScript(message)
235+
}
222236
throw error
223237
}
224238

0 commit comments

Comments
 (0)