diff --git a/src/front/shared/pages/Multisign/Btc/Btc.tsx b/src/front/shared/pages/Multisign/Btc/Btc.tsx index 5cc3e9dcc1..8f43a9a505 100644 --- a/src/front/shared/pages/Multisign/Btc/Btc.tsx +++ b/src/front/shared/pages/Multisign/Btc/Btc.tsx @@ -19,12 +19,7 @@ import styles from './Btc.scss' import SwapApp from 'swap.app' import config from 'app-config' - -@connect(({ - user: { - btcData, - }, -}) => { +@connect(({ user: { btcData } }) => { return { data: btcData, } @@ -32,16 +27,13 @@ import config from 'app-config' @injectIntl @CSSModules(styles, { allowMultiple: true }) export default class Btc extends PureComponent { - timerWaitOnlineJoin: any static propTypes = { history: PropTypes.object, location: PropTypes.object, intl: PropTypes.object.isRequired, - }; - - + } constructor() { //@ts-ignore @@ -49,7 +41,7 @@ export default class Btc extends PureComponent { console.log('Btc mulsign connected') const mnemonic = localStorage.getItem(constants.privateKeyNames.twentywords) - const mnemonicSaved = (mnemonic === `-`) + const mnemonicSaved = mnemonic === `-` this.timerWaitOnlineJoin = false this.state = { @@ -65,25 +57,18 @@ export default class Btc extends PureComponent { async componentWillMount() { let { match: { - params: { - action, - data, - peer, - }, - }, - intl: { - locale, + params: { action, data, peer }, }, + intl: { locale }, history, - location: { - pathname, - }, - data: { - privateKey, - }, + location: { pathname }, + data: { privateKey }, } = this.props - if (!action || ['join', 'connect', 'confirm', 'confirminvoice'].indexOf(action.toLowerCase()) === -1) { + if ( + !action || + ['join', 'connect', 'confirm', 'confirminvoice'].indexOf(action.toLowerCase()) === -1 + ) { history.push(localisedUrl(locale, links.notFound)) return } @@ -142,27 +127,30 @@ export default class Btc extends PureComponent { showCloseButton: true, onClose: () => { history.push(localisedUrl(locale, links.home)) - } + }, }) }, 100) } else { try { - this.setState({ - action, - txData: await actions.btcmultisig.parseRawTX(txRaw), - invoice, - txRaw: txRaw, - }, () => { - setTimeout(() => { - actions.modals.open(constants.modals.BtcMultisignConfirmTx, { - txData: txRaw, - showCloseButton: false, - onClose: () => { - history.push(localisedUrl(locale, links.home)) - } - }) - }, 100) - }) + this.setState( + { + action, + txData: await actions.btcmultisig.parseRawTX(txRaw), + invoice, + txRaw: txRaw, + }, + () => { + setTimeout(() => { + actions.modals.open(constants.modals.BtcMultisignConfirmTx, { + txData: txRaw, + showCloseButton: false, + onClose: () => { + history.push(localisedUrl(locale, links.home)) + }, + }) + }, 100) + } + ) } catch (e) { console.log('Bad tx raw data') } @@ -172,7 +160,10 @@ export default class Btc extends PureComponent { } async componentWillUnmount() { - SwapApp.shared().services.room.unsubscribe('btc multisig join ready', this.handleOnlineWalletConnect) + SwapApp.shared().services.room.unsubscribe( + 'btc multisig join ready', + this.handleOnlineWalletConnect + ) clearTimeout(this.timerWaitOnlineJoin) } @@ -183,7 +174,7 @@ export default class Btc extends PureComponent { actions.core.markCoinAsVisible('BTC (Multisig)', true) this.setState({ - action: (action === 'join') ? 'linkready' : 'ready' + action: action === 'join' ? 'linkready' : 'ready', }) if (action === 'join') { actions.modals.open(constants.modals.MultisignJoinLink, { @@ -201,7 +192,10 @@ export default class Btc extends PureComponent { const { fromPeer, data } = _data const { peer } = this.state if (fromPeer === peer) { - SwapApp.shared().services.room.unsubscribe('btc multisig join ready', this.handleOnlineWalletConnect) + SwapApp.shared().services.room.unsubscribe( + 'btc multisig join ready', + this.handleOnlineWalletConnect + ) clearTimeout(this.timerWaitOnlineJoin) this.connectWallet('ready') } @@ -213,7 +207,7 @@ export default class Btc extends PureComponent { //If peer is online - try connect via pubsubRoom this.setState({ - waitCreateWallet: true + waitCreateWallet: true, }) actions.pubsubRoom.waitPeer( @@ -222,16 +216,22 @@ export default class Btc extends PureComponent { this.setState({ action: 'onlinejoin', }) - SwapApp.shared().services.room.subscribe('btc multisig join ready', this.handleOnlineWalletConnect) + SwapApp.shared().services.room.subscribe( + 'btc multisig join ready', + this.handleOnlineWalletConnect + ) SwapApp.shared().services.room.sendMessagePeer(peer, { event: 'btc multisig join', data: { publicKey: myPublicKey, checkKey: publicKey, - } + }, }) this.timerWaitOnlineJoin = setTimeout(() => { - SwapApp.shared().services.room.unsubscribe('btc multisig join ready', this.handleOnlineWalletConnect) + SwapApp.shared().services.room.unsubscribe( + 'btc multisig join ready', + this.handleOnlineWalletConnect + ) this.connectWallet(action) }, 10000) }, @@ -246,21 +246,19 @@ export default class Btc extends PureComponent { actions.modals.open(constants.modals.SaveMnemonicModal, { onClose: () => { const mnemonic = localStorage.getItem(constants.privateKeyNames.twentywords) - const mnemonicSaved = (mnemonic === `-`) + const mnemonicSaved = mnemonic === `-` this.setState({ mnemonicSaved, }) - } + }, }) } handleGoToWallet = async () => { const { history, - intl: { - locale, - }, + intl: { locale }, } = this.props const { address } = actions.user.getAuthData('btcMultisigUser') @@ -303,20 +301,29 @@ export default class Btc extends PureComponent { return (
- {(action === 'onlinejoin') && + {action === 'onlinejoin' && (

- +

- +

- } - {(action === 'join' || action === 'connect') && + )} + {(action === 'join' || action === 'connect') && (

- +

@@ -329,24 +336,34 @@ export default class Btc extends PureComponent { - {' '}{walletBalance} BTC + {walletBalance} BTC
{mnemonicSaved ? ( <> - {addWalletEnabled ? - waitCreateWallet ? + {addWalletEnabled ? ( + waitCreateWallet ? ( - : + ) : ( - : + ) + ) : ( - } + )} ) : ( <> @@ -367,102 +384,129 @@ export default class Btc extends PureComponent { )}
- } + )} {!mnemonicSaved && (
- +
)} - {(/*action=='confirm' ||*/ action === 'confirminvoice') && - -

- -

-

- -

- {debugShowInput && -
-                
-                  {
-                    //@ts-ignore
-                    JSON.stringify(this.state.txData.input, false, 4)
-                  }
-                
-              
- } -

- -

- {debugShowOutput && -
-                
-                  {
-                    //@ts-ignore
-                    JSON.stringify(this.state.txData.output, false, 4)
-                  }
-                
-                
-                  {
-                    //@ts-ignore
-                    JSON.stringify(this.state.txData, false, 4)
-                  }
-                
-              
- } -
- -
-
+ { + /*action=='confirm' ||*/ action === 'confirminvoice' && ( + +

+ +

+

+ +

+ {debugShowInput && ( +
+                  {JSON.stringify(this.state.txData.input, null, 4)}
+                
+ )} +

+ +

+ {debugShowOutput && ( +
+                  {JSON.stringify(this.state.txData.output, null, 4)}
+                  {JSON.stringify(this.state.txData, null, 4)}
+                
+ )} +
+ +
+
+ ) } - {(action === 'confirmready') && + {action === 'confirmready' && (

- +

-              
-                {
-                  //@ts-ignore
-                  JSON.stringify(this.state.txID, false, 4)
-                }
-              
+              {JSON.stringify(this.state.txID, null, 4)}
             
-
- } - {(action === 'linkready' || action === 'ready') && + )} + {(action === 'linkready' || action === 'ready') && (

- +

- {action === 'linkready' &&

} - {action === 'ready' &&

} + {action === 'linkready' && ( +

+ +

+ )} + {action === 'ready' && ( +

+ +

+ )} {action === 'linkready' && {joinLink}}
- } + )}
) } diff --git a/src/front/shared/pages/Swap/Debug/Debug.tsx b/src/front/shared/pages/Swap/Debug/Debug.tsx index d6cb87dfc8..13391c26c3 100644 --- a/src/front/shared/pages/Swap/Debug/Debug.tsx +++ b/src/front/shared/pages/Swap/Debug/Debug.tsx @@ -9,12 +9,10 @@ import ShowBtcScript from './ShowBtcScript' @CSSModules(styles) export default class Debug extends Component { - static propTypes = { flow: PropTypes.object, } - render() { const { flow: { @@ -38,14 +36,9 @@ export default class Debug extends Component {
-          
-            {/*
-            //@ts-ignore */}
-            { JSON.stringify(flowState, false, 4) }
-          
+          {JSON.stringify(flowState, null, 4)}
         
) } - }