Skip to content

Commit

Permalink
Minor cleanup in deposit modal, fix a typo
Browse files Browse the repository at this point in the history
  • Loading branch information
svk31 committed Jan 5, 2018
1 parent 8e13af8 commit 6d720c7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 26 deletions.
2 changes: 1 addition & 1 deletion app/assets/locales/locale-en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1280,7 +1280,7 @@
"gateway": "Gateway",
"disabled": "Gateway service disabled",
"wallet_error": "Gateway wallet disabled",
"select_gateway": "Please select a gateway opperator",
"select_gateway": "Please select a gateway operator",
"address_generation_error": "Unable to generate address",
"bts_transfer_description": "It's easy to receive BTS from anywhere. As long as BTS is sent to your account name it will show up in your wallet. This QR code also contains your account name.",
"close": "Close",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import React from "react";
import { connect } from "alt-react";
import Translate from "react-translate-component";
import BindToChainState from "../Utility/BindToChainState";
import { Apis } from "bitsharesjs-ws";
import { settingsAPIs, rudexAPIs } from "api/apiConfig";
import { rudexAPIs } from "api/apiConfig";
import GatewayStore from "stores/GatewayStore";
import GatewayActions from "actions/GatewayActions";
import TypeAhead from "../Utility/TypeAhead";
Expand Down
43 changes: 20 additions & 23 deletions app/components/Modal/DepositModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,29 @@ import ZfApi from "react-foundation-apps/src/utils/foundation-api";
import BaseModal from "../Modal/BaseModal";
import Translate from "react-translate-component";
import utils from "common/utils";
import BindToChainState from "../Utility/BindToChainState";
import {requestDepositAddress, validateAddress} from "common/blockTradesMethods";
import {requestDepositAddress} from "common/blockTradesMethods";
import BlockTradesDepositAddressCache from "common/BlockTradesDepositAddressCache";
import CopyButton from "../Utility/CopyButton";
import Icon from "../Icon/Icon";
import LoadingIndicator from "../LoadingIndicator";
import {DecimalChecker} from "../Exchange/ExchangeInput";
import QRCode from "qrcode.react";
import DepositWithdrawAssetSelector from "../DepositWithdraw/DepositWithdrawAssetSelector.js";
import ChainTypes from "../Utility/ChainTypes";

class DepositModalContent extends DecimalChecker {

constructor() {
super();


this.state = {
depositAddress: "",
selectedAsset: "BTS",
selectedGateway: null,
fetchingAddress: false,
backingAsset: null,
gatewayStatus: {
OPEN: { id: "OPEN", name: "OPENLEDGER", enabled: false, selected: false, support_url: "https://wallet.bitshares.org/#/help/gateways/openledger" },
OPEN: { id: "OPEN", name: "OPENLEDGER", enabled: false, selected: false, support_url: "https://wallet.bitshares.org/#/help/gateways/openledger" },
RUDEX: { id: "RUDEX", name: "RUDEX", enabled: false, selected: false, support_url: "https://wallet.bitshares.org/#/help/gateways/rudex" }
}
};
Expand Down Expand Up @@ -55,7 +53,7 @@ class DepositModalContent extends DecimalChecker {
shouldComponentUpdate(np, ns) {
return(!utils.are_equal_shallow(ns, this.state));
}

onGatewayChanged(e) {
if(!e.target.value) return;
this._getDepositAddress(this.state.selectedAsset, e.target.value);
Expand All @@ -69,7 +67,7 @@ class DepositModalContent extends DecimalChecker {

for(let g in gatewayStatus) { if(gatewayStatus[g].enabled) { nAvailable++; } }
if(nAvailable == 1) { for(let g in gatewayStatus) { if(gatewayStatus[g].enabled) { selectedGateway = g; } } }

// Fetch address if we have a selected gateway
if(selectedGateway) { this._getDepositAddress(selectedAsset, selectedGateway); }
else {
Expand Down Expand Up @@ -99,7 +97,7 @@ class DepositModalContent extends DecimalChecker {
_getDepositAddress(selectedAsset, selectedGateway) {
let {account} = this.props;

this.setState({
this.setState({
fetchingAddress: true,
depositAddress: null,
gatewayStatus: this._getAvailableGateways(selectedAsset)
Expand All @@ -126,11 +124,11 @@ class DepositModalContent extends DecimalChecker {
selectedGateway.toUpperCase(),
account,
selectedAsset.toLowerCase(),
selectedGateway.toLowerCase() + "." + selectedAsset.toLowerCase(),
selectedGateway.toLowerCase() + "." + selectedAsset.toLowerCase(),
);
if(!depositAddress) {
requestDepositAddress({
inputCoinType: selectedAsset.toLowerCase(),
inputCoinType: selectedAsset.toLowerCase(),
outputCoinType: "open." + selectedAsset.toLowerCase(),
outputAddress: account,
stateCallback: this.addDepositAddress
Expand All @@ -143,7 +141,7 @@ class DepositModalContent extends DecimalChecker {
}
} else if(selectedGateway == "RUDEX") {
this.setState({
depositAddress: {
depositAddress: {
address: backingAsset.gatewayWallet,
memo: "dex:" + account,
},
Expand All @@ -153,7 +151,7 @@ class DepositModalContent extends DecimalChecker {
console.log("Withdraw Modal Error: Unknown Gateway " + selectedGateway + "(asset: " + selectedAsset + ")");
}

this.setState({
this.setState({
selectedAsset,
selectedGateway,
backingAsset
Expand Down Expand Up @@ -187,7 +185,7 @@ class DepositModalContent extends DecimalChecker {
render() {
let {selectedAsset, selectedGateway, depositAddress, fetchingAddress, gatewayStatus, backingAsset} = this.state;
let {account} = this.props;

let usingGateway = true;

if(selectedGateway == null && selectedAsset == "BTS") {
Expand Down Expand Up @@ -251,15 +249,15 @@ class DepositModalContent extends DecimalChecker {
</section>
</div>
</div> : null}
{!fetchingAddress ?
{!fetchingAddress ?
(!usingGateway || (usingGateway && selectedGateway && gatewayStatus[selectedGateway].enabled)) && depositAddress && !depositAddress.memo ?
<div className="container-row" style={{textAlign: "center"}}>{QR}</div> :
null :
<div className="container-row" style={{textAlign: "center"}}>{QR}</div> :
null :
<div className="container-row" style={{textAlign: "center"}}><LoadingIndicator type="three-bounce" /></div>
}
{selectedGateway && gatewayStatus[selectedGateway].enabled && depositAddress && !depositAddress.error ?
<div className="container-row deposit-info" style={{textAlign: "center"}}>

{backingAsset.minAmount ?
<div className="grid-block container-row maxDeposit">
<Translate
Expand Down Expand Up @@ -296,12 +294,12 @@ class DepositModalContent extends DecimalChecker {
<p>
<Translate content="modal.deposit.bts_transfer_description" />
</p>
</div>
</div>
: null}
</div>
<div className="Modal__footer">
<div className="container-row" style={{paddingBottom: 35}}>
<button className="ActionButton_Close" style={{width: "100%"}}onClick={this.onClose.bind(this)}>
<button className="ActionButton_Close" style={{width: "100%"}} onClick={this.onClose.bind(this)}>
<Translate content="modal.deposit.close" />
</button>
</div>
Expand All @@ -311,15 +309,14 @@ class DepositModalContent extends DecimalChecker {
);
}
}
DepositModal = BindToChainState(DepositModal);

export default class DepositModal extends React.Component {
constructor() {
super();

this.state = {open: false};
}

show() {
this.setState({open: true}, () => {
ZfApi.publish(this.props.modalId, "open");
Expand All @@ -338,4 +335,4 @@ export default class DepositModal extends React.Component {
</BaseModal> : null
);
}
}
}

0 comments on commit 6d720c7

Please sign in to comment.