Skip to content

Commit

Permalink
disable web3 wallets in offline mode
Browse files Browse the repository at this point in the history
  • Loading branch information
skubakdj committed Oct 18, 2017
1 parent 88db5b9 commit ac17c14
Showing 1 changed file with 129 additions and 116 deletions.
245 changes: 129 additions & 116 deletions common/containers/Tabs/SendTransaction/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -272,131 +272,144 @@ export class SendTransaction extends React.Component<Props, State> {
/>
<div className="row">
{/* Send Form */}
{unlocked && (
<main className="col-sm-8">
<div className="Tab-content-pane">
{hasQueryString && (
<div className="alert alert-info">
<p>{translate('WARN_Send_Link')}</p>
</div>
)}

<AddressField
placeholder={donationAddressMap.ETH}
value={this.state.to}
onChange={readOnly ? null : this.onAddressChange}
/>
<AmountField
value={value}
unit={unit}
balance={balance}
tokens={this.props.tokenBalances
.filter(token => !token.balance.eq(0))
.map(token => token.symbol)
.sort()}
onChange={readOnly ? void 0 : this.onAmountChange}
/>
<GasField
value={gasLimit}
onChange={readOnly ? void 0 : this.onGasChange}
/>
{(offline || forceOffline) && (
<div>
<NonceField
value={nonce}
onChange={this.onNonceChange}
placeholder={'0'}
/>
{unlocked &&
!(offline || (forceOffline && isWeb3Wallet)) && (
<main className="col-sm-8">
<div className="Tab-content-pane">
{hasQueryString && (
<div className="alert alert-info">
<p>{translate('WARN_Send_Link')}</p>
</div>
)}
{unit === 'ether' && (
<DataField
value={data}
onChange={readOnly ? void 0 : this.onDataChange}
/>
)}
<CustomMessage message={customMessage} />

<div className="row form-group">
<div className="col-xs-12 clearfix">
<button
disabled={this.state.generateDisabled}
className="btn btn-info btn-block"
onClick={
isWeb3Wallet
? this.generateWeb3TxFromState
: this.generateTxFromState
}
>
{isWeb3Wallet
? translate('Send to MetaMask / Mist')
: translate('SEND_generate')}
</button>
</div>
</div>

{generateTxProcessing && (
<div className="container">
<div className="row form-group text-center">
<Spinner size="5x" />
</div>
</div>
)}

{transaction && (
<div>
<div className="row form-group">
<div className="col-sm-6">
<label>{translate('SEND_raw')}</label>
<textarea
className="form-control"
value={transaction.rawTx}
rows={4}
readOnly={true}
<AddressField
placeholder={donationAddressMap.ETH}
value={this.state.to}
onChange={readOnly ? null : this.onAddressChange}
/>
<AmountField
value={value}
unit={unit}
balance={balance}
tokens={this.props.tokenBalances
.filter(token => !token.balance.eq(0))
.map(token => token.symbol)
.sort()}
onChange={readOnly ? void 0 : this.onAmountChange}
/>
<GasField
value={gasLimit}
onChange={readOnly ? void 0 : this.onGasChange}
/>
{(offline || forceOffline) && (
<div>
<NonceField
value={nonce}
onChange={this.onNonceChange}
placeholder={'0'}
/>
</div>
<div className="col-sm-6">
<label>{translate('SEND_signed')}</label>
<textarea
className="form-control"
value={transaction.signedTx}
rows={4}
readOnly={true}
/>
{offline && (
<p>
To broadcast this transaction, paste the above
into{' '}
<a href="https://myetherwallet.com/pushTx">
{' '}
myetherwallet.com/pushTx
</a>{' '}
or{' '}
<a href="https://etherscan.io/pushTx">
{' '}
etherscan.io/pushTx
</a>
</p>
)}
)}
{unit === 'ether' && (
<DataField
value={data}
onChange={readOnly ? void 0 : this.onDataChange}
/>
)}
<CustomMessage message={customMessage} />

<div className="row form-group">
<div className="col-xs-12 clearfix">
<button
disabled={this.state.generateDisabled}
className="btn btn-info btn-block"
onClick={
isWeb3Wallet
? this.generateWeb3TxFromState
: this.generateTxFromState
}
>
{isWeb3Wallet
? translate('Send to MetaMask / Mist')
: translate('SEND_generate')}
</button>
</div>
</div>

{generateTxProcessing && (
<div className="container">
<div className="row form-group text-center">
<Spinner size="5x" />
</div>
</div>
)}

{!offline && (
<div className="form-group">
<button
className="btn btn-primary btn-block col-sm-11"
disabled={!this.state.transaction}
onClick={this.openTxModal}
>
{translate('SEND_trans')}
</button>
{transaction && (
<div>
<div className="row form-group">
<div className="col-sm-6">
<label>{translate('SEND_raw')}</label>
<textarea
className="form-control"
value={transaction.rawTx}
rows={4}
readOnly={true}
/>
</div>
<div className="col-sm-6">
<label>{translate('SEND_signed')}</label>
<textarea
className="form-control"
value={transaction.signedTx}
rows={4}
readOnly={true}
/>
{offline && (
<p>
To broadcast this transaction, paste the above
into{' '}
<a href="https://myetherwallet.com/pushTx">
{' '}
myetherwallet.com/pushTx
</a>{' '}
or{' '}
<a href="https://etherscan.io/pushTx">
{' '}
etherscan.io/pushTx
</a>
</p>
)}
</div>
</div>
)}
</div>
)}
</div>
</main>
)}

{!offline && (
<div className="form-group">
<button
className="btn btn-primary btn-block col-sm-11"
disabled={!this.state.transaction}
onClick={this.openTxModal}
>
{translate('SEND_trans')}
</button>
</div>
)}
</div>
)}
</div>
</main>
)}

{unlocked &&
(offline || (forceOffline && isWeb3Wallet)) && (
<main className="col-sm-8">
<div className="Tab-content-pane">
<h4>Sorry...</h4>
<p>
MetaMask / Mist wallets are not available in offline mode.
</p>
</div>
</main>
)}

{/* Sidebar */}
{unlocked && (
Expand Down

0 comments on commit ac17c14

Please sign in to comment.