From 174ddef7cd499d28528086c63efb1e5d248a3b61 Mon Sep 17 00:00:00 2001 From: thib Date: Tue, 3 Sep 2019 18:28:22 +0200 Subject: [PATCH 1/2] chore: refactor protocol --- src/screens/AccountList.js | 2 ++ src/screens/AccountNetworkChooser.js | 2 +- src/screens/SignedTx.js | 4 ++-- src/screens/TxDetails.js | 4 +++- src/stores/ScannerStore.js | 6 ++---- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/screens/AccountList.js b/src/screens/AccountList.js index f765863751..57b383973b 100644 --- a/src/screens/AccountList.js +++ b/src/screens/AccountList.js @@ -115,6 +115,8 @@ class AccountListView extends React.PureComponent { const hasNoAccount = accounts.length < 1; const { navigate } = navigation; + console.log('accounts',accounts); + return ( diff --git a/src/screens/AccountNetworkChooser.js b/src/screens/AccountNetworkChooser.js index 508ce69004..93fe44c7d9 100644 --- a/src/screens/AccountNetworkChooser.js +++ b/src/screens/AccountNetworkChooser.js @@ -60,7 +60,7 @@ class AccountNetworkChooserView extends React.PureComponent { } ]} onPress={() => { - accounts.updateNew({ networkKey, protocol: networkParams.protocol }); + accounts.updateNew({ networkKey }); navigation.goBack(); }} > diff --git a/src/screens/SignedTx.js b/src/screens/SignedTx.js index 3c5d67ed11..f9bae51277 100644 --- a/src/screens/SignedTx.js +++ b/src/screens/SignedTx.js @@ -26,7 +26,7 @@ import AccountCard from '../components/AccountCard'; import PayloadDetailsCard from '../components/PayloadDetailsCard'; import TxDetailsCard from '../components/TxDetailsCard'; import QrView from '../components/QrView'; -import { NetworkProtocols, TX_DETAILS_MSG } from '../constants'; +import { NETWORK_LIST, NetworkProtocols, TX_DETAILS_MSG } from '../constants'; import fonts from '../fonts'; import AccountsStore from '../stores/AccountsStore'; import ScannerStore from '../stores/ScannerStore'; @@ -71,7 +71,7 @@ export class SignedTxView extends React.PureComponent { TRANSACTION DETAILS { - sender.protocol === NetworkProtocols.ETHEREUM + NETWORK_LIST[sender.networkKey].protocol === NetworkProtocols.ETHEREUM ? ( TRANSACTION DETAILS { - this.props.sender.protocol === NetworkProtocols.ETHEREUM + NETWORK_LIST[this.props.sender.networkKey].protocol === NetworkProtocols.ETHEREUM ? ( { const networkKey = isEthereum ? tx.ethereumChainId : txRequest.data.data.genesisHash.toHex(); const sender = accountsStore.getById({ - protocol, networkKey, address: txRequest.data.account }); @@ -211,14 +210,13 @@ export default class ScannerStore extends Container { } const recipient = accountsStore.getById({ - protocol, networkKey: networkKey, address: isEthereum ? tx.action : txRequest.data.account }); // For Eth, always sign the keccak hash. // For Substrate, only sign the blake2 hash if payload bytes length > 256 bytes (handled in decoder.js). - const dataToSign = sender.protocol === NetworkProtocols.ETHEREUM ? await keccak(txRequest.data.rlp) : txRequest.data.data; + const dataToSign = NETWORK_LIST[sender.networkKey].protocol === NetworkProtocols.ETHEREUM ? await keccak(txRequest.data.rlp) : txRequest.data.data; this.setState({ type: 'transaction', @@ -236,7 +234,7 @@ export default class ScannerStore extends Container { const { isHash, sender, type } = this.state; const seed = await decryptData(sender.encryptedSeed, pin); - const isEthereum = sender.protocol === NetworkProtocols.ETHEREUM; + const isEthereum = NETWORK_LIST[sender.networkKey].protocol === NetworkProtocols.ETHEREUM; let signedData; From 83efc2eeb086ea46355bafe8b063556aef39c24a Mon Sep 17 00:00:00 2001 From: thib Date: Tue, 3 Sep 2019 18:32:32 +0200 Subject: [PATCH 2/2] fix: stray log --- src/screens/AccountList.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/screens/AccountList.js b/src/screens/AccountList.js index 57b383973b..f765863751 100644 --- a/src/screens/AccountList.js +++ b/src/screens/AccountList.js @@ -115,8 +115,6 @@ class AccountListView extends React.PureComponent { const hasNoAccount = accounts.length < 1; const { navigate } = navigation; - console.log('accounts',accounts); - return (