Skip to content

Commit

Permalink
Merge branch 'staging'
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Schiessl committed Dec 12, 2019
2 parents ae5c66b + 4f6a114 commit d240ed9
Show file tree
Hide file tree
Showing 324 changed files with 34,775 additions and 20,315 deletions.
92 changes: 83 additions & 9 deletions app/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ import {Route, Switch, Redirect} from "react-router-dom";
// Nested route components
import Page404 from "./components/Page404/Page404";

const Invoice = Loadable({
loader: () =>
import(/* webpackChunkName: "exchange" */ "./components/Transfer/Invoice"),
loading: LoadingIndicator
});

const Exchange = Loadable({
loader: () =>
import(/* webpackChunkName: "exchange" */ "./components/Exchange/ExchangeContainer"),
Expand All @@ -40,15 +46,15 @@ const Explorer = Loadable({
loading: LoadingIndicator
});

const AccountPage = Loadable({
const PredictionMarketsPage = Loadable({
loader: () =>
import(/* webpackChunkName: "account" */ "./components/Account/AccountPage"),
import(/* webpackChunkName: "pm" */ "./components/PredictionMarkets/PMAssetsContainer"),
loading: LoadingIndicator
});

const Transfer = Loadable({
const AccountPage = Loadable({
loader: () =>
import(/* webpackChunkName: "transfer" */ "./components/Transfer/Transfer"),
import(/* webpackChunkName: "account" */ "./components/Account/AccountPage"),
loading: LoadingIndicator
});

Expand Down Expand Up @@ -140,6 +146,12 @@ const DirectDebit = Loadable({
loading: LoadingIndicator
});

const QuickTrade = Loadable({
loader: () =>
import(/* webpackChunkName: "QuickTrade" */ "./components/QuickTrade/QuickTradeRouter"),
loading: LoadingIndicator
});

import LoginSelector from "./components/LoginSelector";
import Login from "./components/Login/Login";
import RegistrationSelector from "./components/Registration/RegistrationSelector";
Expand All @@ -148,6 +160,10 @@ import AccountRegistration from "./components/Registration/AccountRegistration";
import {CreateWalletFromBrainkey} from "./components/Wallet/WalletCreate";
import ShowcaseGrid from "./components/Showcases/ShowcaseGrid";
import PriceAlertNotifications from "./components/PriceAlertNotifications";
import GatewaySelectorModal from "./components/Gateways/GatewaySelectorModal";
import SettingsStore from "./stores/SettingsStore";
import GatewayActions from "./actions/GatewayActions";
import {allowedGateway} from "./branding";

class App extends React.Component {
constructor() {
Expand All @@ -161,6 +177,7 @@ class App extends React.Component {
: false;
this.state = {
isBrowserSupportModalVisible: false,
isGatewaySelectorModalVisible: false,
loading: false,
synced: this._syncStatus(),
syncFail,
Expand All @@ -176,6 +193,9 @@ class App extends React.Component {

this.showBrowserSupportModal = this.showBrowserSupportModal.bind(this);
this.hideBrowserSupportModal = this.hideBrowserSupportModal.bind(this);
this.hideGatewaySelectorModal = this.hideGatewaySelectorModal.bind(
this
);

Notification.config({
duration: DEFAULT_NOTIFICATION_DURATION,
Expand Down Expand Up @@ -231,6 +251,12 @@ class App extends React.Component {
});
}

hideGatewaySelectorModal() {
this.setState({
isGatewaySelectorModalVisible: false
});
}

showBrowserSupportModal() {
this.setState({
isBrowserSupportModalVisible: true
Expand Down Expand Up @@ -286,7 +312,39 @@ class App extends React.Component {
this.setState({incognito});
}.bind(this)
);
updateGatewayBackers();
GatewayActions.loadOnChainGatewayConfig();

if (allowedGateway()) {
this._ensureExternalServices();
}
}

_ensureExternalServices() {
setTimeout(() => {
let hasLoggedIn =
AccountStore.getState().myActiveAccounts.length > 0 ||
!!AccountStore.getState().passwordAccount;
if (!hasLoggedIn) {
this._ensureExternalServices();
} else {
this._checkExternalServices();
}
}, 5000);
}

_checkExternalServices() {
if (
SettingsStore.getState().viewSettings.get(
"hasSeenExternalServices",
false
)
) {
updateGatewayBackers();
} else {
this.setState({
isGatewaySelectorModalVisible: true
});
}
}

componentDidUpdate(prevProps) {
Expand Down Expand Up @@ -412,11 +470,9 @@ class App extends React.Component {
component={Settings}
/>
<Route path="/settings" component={Settings} />

<Route
path="/transfer"
exact
component={Transfer}
path="/invoice/:data"
component={Invoice}
/>
<Route
path="/deposit-withdraw"
Expand Down Expand Up @@ -520,6 +576,20 @@ class App extends React.Component {
component={Help}
/>
<Route path="/htlc" component={Htlc} />
<Route
path="/prediction"
component={PredictionMarketsPage}
/>
<Route
exact
path="/instant-trade"
component={QuickTrade}
/>
<Route
exact
path="/instant-trade/:marketID"
component={QuickTrade}
/>
<Route path="*" component={Page404} />
</Switch>
</div>
Expand Down Expand Up @@ -573,6 +643,10 @@ class App extends React.Component {
hideModal={this.hideBrowserSupportModal}
showModal={this.showBrowserSupportModal}
/>
<GatewaySelectorModal
visible={this.state.isGatewaySelectorModalVisible}
hideModal={this.hideGatewaySelectorModal}
/>
</div>
</BodyClassName>
</div>
Expand Down
83 changes: 58 additions & 25 deletions app/AppInit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ import InitError from "./components/InitError";
import SyncError from "./components/SyncError";
import counterpart from "counterpart";
import LogsActions from "actions/LogsActions";

import NodeSelector from "./components/Utility/NodeSelector";
/*
* Electron does not support browserHistory, so we need to use hashHistory.
* The same is true for servers without configuration options, such as Github Pages
*/
import {HashRouter, BrowserRouter} from "react-router-dom";

const Router = __HASH_HISTORY__ ? HashRouter : BrowserRouter;

class RootIntl extends React.Component {
Expand Down Expand Up @@ -53,7 +54,9 @@ class AppInit extends React.Component {
apiError: false,
syncError: null,
status: "",
extendeLogText: [] // used to cache logs when not mounted
extendeLogText: [], // used to cache logs when not mounted
nodeFilterHasChanged: false,
showNodeFilter: false
};
this.mounted = true;
this.persistentLogEnabled = false;
Expand Down Expand Up @@ -156,7 +159,11 @@ class AppInit extends React.Component {
if (!__DEV__) {
this._enablePersistingLog();
}

setTimeout(() => {
this.setState({
showNodeFilter: true
});
}, 5000);
willTransitionTo(true, this._statusCallback.bind(this))
.then(() => {
this.setState({
Expand Down Expand Up @@ -202,39 +209,65 @@ class AppInit extends React.Component {
this.setState({status});
}

_onNodeFilterChange() {
this.setState({
nodeFilterHasChanged: true
});
}

_renderLoadingScreen() {
let server = this.props.apiServer;
if (!!!server) {
server = "";
}
return (
<React.Fragment>
<LoadingIndicator
loadingText={
this.state.status ||
counterpart.translate("app_init.connecting", {
server: server
})
}
>
{this.state.showNodeFilter && (
<div className="padding">
<NodeSelector
onChange={this._onNodeFilterChange.bind(this)}
/>
{this.state.nodeFilterHasChanged && (
<div style={{marginTop: "1rem"}}>
Please reload for the changes to take effect
</div>
)}
</div>
)}
</LoadingIndicator>
</React.Fragment>
);
}

render() {
const {theme, apiServer} = this.props;
const {apiConnected, apiError, syncError, status} = this.state;
const {theme} = this.props;
const {apiConnected, apiError, syncError} = this.state;

if (!apiConnected) {
let server = apiServer;
if (!!!server) {
server = "";
}
return (
<div
style={{backgroundColor: !theme ? "#2a2a2a" : null}}
className={theme}
>
<div id="content-wrapper">
<div className="grid-frame vertical">
{!apiError ? (
<LoadingIndicator
loadingText={
status ||
counterpart.translate(
"app_init.connecting",
{server: server}
)
}
/>
) : syncError ? (
<SyncError />
) : (
<BodyClassName className={theme}>
<BodyClassName className={theme}>
{!apiError ? (
this._renderLoadingScreen()
) : syncError ? (
<SyncError />
) : (
<InitError />
</BodyClassName>
)}
)}
</BodyClassName>
</div>
</div>
</div>
Expand Down
48 changes: 48 additions & 0 deletions app/actions/AssetActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import WalletDb from "stores/WalletDb";
import {ChainStore} from "bitsharesjs";
import big from "bignumber.js";
import {gatewayPrefixes} from "common/gateways";
import {price} from "bitsharesjs/es/serializer/src/operations";
let inProgress = {};

class AssetActions {
Expand Down Expand Up @@ -202,6 +203,33 @@ class AssetActions {
};
}

assetGlobalSettle(asset, account_id, price) {
let tr = WalletApi.new_transaction();

tr.add_type_operation("asset_global_settle", {
fee: {
amount: 0,
asset_id: 0
},
issuer: account_id,
asset_to_settle: asset.id,
settle_price: price
});
return dispatch => {
return WalletDb.process_transaction(tr, null, true)
.then(() => {
dispatch(true);
})
.catch(error => {
console.log(
"[AssetActions.js:223] ----- assetGlobalSettle error ----->",
error
);
dispatch(false);
});
};
}

createAsset(
account_id,
createObject,
Expand Down Expand Up @@ -466,6 +494,26 @@ class AssetActions {
});
}

async loadAssets() {
let start = "A";
const count = 10;

let assets = [];
let newAssets = null;
while (
assets.length == 0 ||
newAssets == null ||
newAssets.length > 0
) {
newAssets = await Apis.instance()
.db_api()
.exec("list_assets", [start, count]);
assets = assets.concat(newAssets);
start = assets[assets.length - 1].symbol + ".";
}
console.log("Assets loaded: ", assets.length);
}

getAssetList(start, count, includeGateways = false) {
let id = start + "_" + count;
return dispatch => {
Expand Down
14 changes: 14 additions & 0 deletions app/actions/GatewayActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
getActiveWallets
} from "common/gatewayMethods";
import {blockTradesAPIs} from "api/apiConfig";
import {getOnChainConfig} from "../lib/chain/onChainConfig";

let inProgress = {};

Expand Down Expand Up @@ -143,6 +144,19 @@ class GatewayActions {
return {};
}
}

temporarilyDisable({backer}) {
return dispatch => {
dispatch({backer});
};
}

loadOnChainGatewayConfig() {
return dispatch => {
// fixme: access to onchain config should be cut out into a separate store or similar, this is abusing gatewaystore for a quick fix
getOnChainConfig().then(config => dispatch(config));
};
}
}

export default alt.createActions(GatewayActions);
Loading

0 comments on commit d240ed9

Please sign in to comment.