diff --git a/src/translations/en_US.js b/src/translations/en_US.js index 7a365948aa..94cea50e1a 100755 --- a/src/translations/en_US.js +++ b/src/translations/en_US.js @@ -21,6 +21,7 @@ import secalotError from './errors-secalot/en_US'; import keepkeyError from './errors-keepkey/en_US'; import bitboxError from './errors-bitbox/en_US'; import bitbox02Error from './errors-bitbox02/en_US'; +import satochipError from './errors-satochip/en_US'; import buyHardwareWallet from './other/buy-hardware-wallet/en_US'; import convertUnits from './other/convert-units/en_US'; import verifyMessage from './other/verify-message/en_US'; @@ -66,6 +67,7 @@ const en_US = { keepkeyError: keepkeyError, bitboxError: bitboxError, bitbox02Error: bitbox02Error, + satochipError: satochipError, buyHardwareWallet: buyHardwareWallet, dappsMaker: dappsMaker, convertUnits: convertUnits, diff --git a/src/translations/errors-satochip/en_US.json b/src/translations/errors-satochip/en_US.json new file mode 100644 index 0000000000..5b1572a0b7 --- /dev/null +++ b/src/translations/errors-satochip/en_US.json @@ -0,0 +1,15 @@ +{ + "popup-closed": "Popup Closed", + "device-disconnect": "Device disconnected", + "device-disconnect-action": "device disconnected during action", + "user-cancelled-action": "Action cancelled by user", + "no-permission": "Permissions not granted", + "call-in-progress": "Device call in progress", + "cancelled": "Event cancelled by user", + "iframe-timeout": "Make sure you enable pop-ups in the browser, and that your ad blocker is not blocking the pop-up", + "popup-failed-to-open": "Popup failed to open. Make sure you enable pop-ups in the browser, and that your ad blocker is not blocking the pop-up", + "connect-error": "Satochip: error while connecting to Satochip-Bridge. Make sure that Satochip-Bridge is up and running", + "noresponse-2FA": "Satochip: no response received from 2FA device", + "rejected-2FA": "Satochip: signing request rejected by user", + "no-card-found": "Satochip error: no card found! Please insert a Satochip" +} diff --git a/src/translations/errors-satochip/es_ES.json b/src/translations/errors-satochip/es_ES.json new file mode 100644 index 0000000000..5b1572a0b7 --- /dev/null +++ b/src/translations/errors-satochip/es_ES.json @@ -0,0 +1,15 @@ +{ + "popup-closed": "Popup Closed", + "device-disconnect": "Device disconnected", + "device-disconnect-action": "device disconnected during action", + "user-cancelled-action": "Action cancelled by user", + "no-permission": "Permissions not granted", + "call-in-progress": "Device call in progress", + "cancelled": "Event cancelled by user", + "iframe-timeout": "Make sure you enable pop-ups in the browser, and that your ad blocker is not blocking the pop-up", + "popup-failed-to-open": "Popup failed to open. Make sure you enable pop-ups in the browser, and that your ad blocker is not blocking the pop-up", + "connect-error": "Satochip: error while connecting to Satochip-Bridge. Make sure that Satochip-Bridge is up and running", + "noresponse-2FA": "Satochip: no response received from 2FA device", + "rejected-2FA": "Satochip: signing request rejected by user", + "no-card-found": "Satochip error: no card found! Please insert a Satochip" +} diff --git a/src/translations/errors-satochip/ja_JP.json b/src/translations/errors-satochip/ja_JP.json new file mode 100644 index 0000000000..5b1572a0b7 --- /dev/null +++ b/src/translations/errors-satochip/ja_JP.json @@ -0,0 +1,15 @@ +{ + "popup-closed": "Popup Closed", + "device-disconnect": "Device disconnected", + "device-disconnect-action": "device disconnected during action", + "user-cancelled-action": "Action cancelled by user", + "no-permission": "Permissions not granted", + "call-in-progress": "Device call in progress", + "cancelled": "Event cancelled by user", + "iframe-timeout": "Make sure you enable pop-ups in the browser, and that your ad blocker is not blocking the pop-up", + "popup-failed-to-open": "Popup failed to open. Make sure you enable pop-ups in the browser, and that your ad blocker is not blocking the pop-up", + "connect-error": "Satochip: error while connecting to Satochip-Bridge. Make sure that Satochip-Bridge is up and running", + "noresponse-2FA": "Satochip: no response received from 2FA device", + "rejected-2FA": "Satochip: signing request rejected by user", + "no-card-found": "Satochip error: no card found! Please insert a Satochip" +} diff --git a/src/translations/errors-satochip/ko_KR.json b/src/translations/errors-satochip/ko_KR.json new file mode 100644 index 0000000000..5b1572a0b7 --- /dev/null +++ b/src/translations/errors-satochip/ko_KR.json @@ -0,0 +1,15 @@ +{ + "popup-closed": "Popup Closed", + "device-disconnect": "Device disconnected", + "device-disconnect-action": "device disconnected during action", + "user-cancelled-action": "Action cancelled by user", + "no-permission": "Permissions not granted", + "call-in-progress": "Device call in progress", + "cancelled": "Event cancelled by user", + "iframe-timeout": "Make sure you enable pop-ups in the browser, and that your ad blocker is not blocking the pop-up", + "popup-failed-to-open": "Popup failed to open. Make sure you enable pop-ups in the browser, and that your ad blocker is not blocking the pop-up", + "connect-error": "Satochip: error while connecting to Satochip-Bridge. Make sure that Satochip-Bridge is up and running", + "noresponse-2FA": "Satochip: no response received from 2FA device", + "rejected-2FA": "Satochip: signing request rejected by user", + "no-card-found": "Satochip error: no card found! Please insert a Satochip" +} diff --git a/src/translations/errors-satochip/ru_RU.json b/src/translations/errors-satochip/ru_RU.json new file mode 100644 index 0000000000..5b1572a0b7 --- /dev/null +++ b/src/translations/errors-satochip/ru_RU.json @@ -0,0 +1,15 @@ +{ + "popup-closed": "Popup Closed", + "device-disconnect": "Device disconnected", + "device-disconnect-action": "device disconnected during action", + "user-cancelled-action": "Action cancelled by user", + "no-permission": "Permissions not granted", + "call-in-progress": "Device call in progress", + "cancelled": "Event cancelled by user", + "iframe-timeout": "Make sure you enable pop-ups in the browser, and that your ad blocker is not blocking the pop-up", + "popup-failed-to-open": "Popup failed to open. Make sure you enable pop-ups in the browser, and that your ad blocker is not blocking the pop-up", + "connect-error": "Satochip: error while connecting to Satochip-Bridge. Make sure that Satochip-Bridge is up and running", + "noresponse-2FA": "Satochip: no response received from 2FA device", + "rejected-2FA": "Satochip: signing request rejected by user", + "no-card-found": "Satochip error: no card found! Please insert a Satochip" +} diff --git a/src/translations/errors-satochip/zh_CN.json b/src/translations/errors-satochip/zh_CN.json new file mode 100644 index 0000000000..5b1572a0b7 --- /dev/null +++ b/src/translations/errors-satochip/zh_CN.json @@ -0,0 +1,15 @@ +{ + "popup-closed": "Popup Closed", + "device-disconnect": "Device disconnected", + "device-disconnect-action": "device disconnected during action", + "user-cancelled-action": "Action cancelled by user", + "no-permission": "Permissions not granted", + "call-in-progress": "Device call in progress", + "cancelled": "Event cancelled by user", + "iframe-timeout": "Make sure you enable pop-ups in the browser, and that your ad blocker is not blocking the pop-up", + "popup-failed-to-open": "Popup failed to open. Make sure you enable pop-ups in the browser, and that your ad blocker is not blocking the pop-up", + "connect-error": "Satochip: error while connecting to Satochip-Bridge. Make sure that Satochip-Bridge is up and running", + "noresponse-2FA": "Satochip: no response received from 2FA device", + "rejected-2FA": "Satochip: signing request rejected by user", + "no-card-found": "Satochip error: no card found! Please insert a Satochip" +} diff --git a/src/wallets/hardware/satochip/errorHandler.js b/src/wallets/hardware/satochip/errorHandler.js index f7b77bca0d..e47d3a600b 100644 --- a/src/wallets/hardware/satochip/errorHandler.js +++ b/src/wallets/hardware/satochip/errorHandler.js @@ -2,23 +2,19 @@ import { Toast } from '@/helpers'; import Vue from 'vue'; const ERRORS = { - 'Popup closed': 'trezorError.popup-closed', - 'Device disconnected': 'trezorError.device-disconnect', - 'device disconnected during action': 'trezorError.device-disconnect-action', - 'Action cancelled by user': 'trezorError.user-cancelled-action', - 'Permissions not granted': 'trezorError.no-permission', - 'Device call in progress': 'trezorError.call-in-progress', - 'Transport is missing': 'trezorError.transport-missing', - 'EthAppPleaseEnableContractData: Please enable Contract data on the Ethereum app Settings': - 'trezorError.turn-on-contract-data', - 'Initialize failed: Response of unexpected type: Address. Should be Features': - 'trezor.initializing-failed', - Cancelled: 'trezorError.cancelled', - 'Iframe timeout': 'trezor.iframe-timeout', - 'Browser not supported': 'trezor.unsupported-browser', - 'popup failed to open': 'trezor.popup-failed-to-open', - 'Safety check failed': 'trezor.safety-check-failed', - 'TrezorConnect not yet initialized': 'trezor.trezor-connect-not-initialized' + 'Popup closed': 'satochipError.popup-closed', + 'Device disconnected': 'satochipError.device-disconnect', + 'device disconnected during action': 'satochipError.device-disconnect-action', + 'Action cancelled by user': 'satochipError.user-cancelled-action', + 'Permissions not granted': 'satochipError.no-permission', + 'Device call in progress': 'satochipError.call-in-progress', + Cancelled: 'satochipError.cancelled', + 'Iframe timeout': 'satochipError.iframe-timeout', + 'popup failed to open': 'satochipError.popup-failed-to-open', + 'Satochip: error while connecting to Satochip-Bridge': 'satochipError.connect-error', + 'No response received from 2FA': 'satochipError.noresponse-2FA', + 'Signing request rejected by user': 'satochipError.rejected-2FA', + 'No card found': 'satochipError.no-card-found' }; const WARNING = {}; @@ -27,7 +23,12 @@ export default err => { const errorValues = Object.keys(ERRORS); const warningValues = Object.keys(WARNING); const foundError = errorValues.find(item => { - return err.message.includes(item) || item.includes(err); + return ( + item.includes(err.message) || + item.includes(err) || + (err.message && err.message.includes(item)) || + (typeof err === 'string' && err.includes(item)) + ); }); const foundWarning = warningValues.find(item => { diff --git a/src/wallets/hardware/satochip/index.js b/src/wallets/hardware/satochip/index.js index 9c37b7537d..8bf71b5103 100644 --- a/src/wallets/hardware/satochip/index.js +++ b/src/wallets/hardware/satochip/index.js @@ -27,7 +27,7 @@ class SatochipWallet { this.resolveMap= new Map(); this.requestID=0; this.ws= 0; - this.reconnectInterval = (1 * 1000 * 60) / 4; + this.reconnectInterval = (1 * 1000 * 60) / 4; //time in ms } // end constructor() @@ -55,7 +55,7 @@ class SatochipWallet { }; const request = JSON.stringify(msg); - return new Promise((resolve) => { + return new Promise((resolve, reject) => { // send request to device and keep a ref of the resolve function in a map new Promise((resolve2) => { console.log('Satochip: resolveMap.size - before:' + this.resolveMap.size); @@ -66,10 +66,14 @@ class SatochipWallet { //console.log('Satochip: resolveMap.size - after:' + this.resolveMap.size); }).then((res) => { console.log('In satochip-connect-tab: getChainCode: res: ', res); - resolve({ - publicKey: res.pubkey, - chainCode: res.chaincode - }); + if (res.exitstatus == 0){//no issue + resolve({ + publicKey: res.pubkey, + chainCode: res.chaincode + }); + }else{// there was an issue + reject(res.reason) + } }); }) }); @@ -124,6 +128,8 @@ class SatochipWallet { mywallet.ws.onerror = function error() { console.log('disconnected with error!'); mywallet.isConnected = false; + //throw new Error('Satochip: error while connecting to Satochip-Bridge') + errorHandler('Satochip: error while connecting to Satochip-Bridge') }; } else { resolve(mywallet.ws); @@ -151,7 +157,7 @@ class SatochipWallet { const request = JSON.stringify(msg); const chainId= tx_info.chainId; - return new Promise((resolve) => { + return new Promise((resolve, reject) => { // send request to device and keep a ref of the resolve function in a map new Promise((resolve2) => { this.resolveMap.set(msg.requestID, resolve2); @@ -160,9 +166,12 @@ class SatochipWallet { }).then((res) => { // extracts usefull data from device response and resolve original promise console.log('In satochip-connect-tab: signRawTransaction: res: ', res); - const payload={ v: (res.v+chainId*2+35), r:res.r, s:res.s} - resolve(payload); - + if (res.exitstatus == 0){//no issue + const payload={ v: (res.v+chainId*2+35), r:res.r, s:res.s} + resolve(payload); + }else{// there was an issue + reject(res.reason) + } }); }); }); @@ -172,7 +181,8 @@ class SatochipWallet { console.log('Satochip: signMessage() START'); // message is a hex-string prefixed with 0x if (!msg) { - throw Error('No message to sign'); + //throw new Error('No message to sign'); + errorHandler('No message to sign'); } return this.connect().then((ws) => { @@ -194,11 +204,16 @@ class SatochipWallet { }).then((res) => { // extracts usefull data from device response and resolve original promise console.log('Satochip: signMessage: result: ' + res); - const r = res.r; - const s = res.s; - const v = ('0' + res.v.toString(16)).slice(-2); //padd with '0' - const combined = '0x'+r + s + v; - resolve(combined); + if (res.exitstatus == 0){//no issue + const r = res.r; + const s = res.s; + const v = ('0' + res.v.toString(16)).slice(-2); //padd with '0' + const combined = '0x'+r + s + v; + resolve(combined); + }else{// there was an issue + //throw new Error(res.reason); //reject(res.reason) + errorHandler(res.reason) + } }); }); }); @@ -294,4 +309,4 @@ const createWallet = async basePath => { }; createWallet.errorHandler = errorHandler; -export default createWallet; +export default createWallet; \ No newline at end of file