diff --git a/gui/backend/get_bot_info.go b/gui/backend/get_bot_info.go index 87c3fbb95..91331a5c9 100644 --- a/gui/backend/get_bot_info.go +++ b/gui/backend/get_bot_info.go @@ -175,6 +175,7 @@ func (s *APIServer) runGetBotInfoDirect(w http.ResponseWriter, botName string) { bi := query.BotInfo{ LastUpdated: time.Now().Format("1/_2/2006 15:04:05"), Strategy: buysell, + IsTestnet: strings.Contains(botConfig.HorizonURL, "test"), TradingPair: tradingPair, AssetBase: assetBase, AssetQuote: assetQuote, diff --git a/gui/web/src/components/atoms/Badge/Badge.js b/gui/web/src/components/atoms/Badge/Badge.js index c3e88ec3c..e3ce744ee 100644 --- a/gui/web/src/components/atoms/Badge/Badge.js +++ b/gui/web/src/components/atoms/Badge/Badge.js @@ -1,15 +1,11 @@ import React, { Component } from 'react'; import styles from './Badge.module.scss'; - - - class Badge extends Component { render() { - return ( - - {this.props.test ? 'Test' : 'Main'} + + {this.props.testnet ? 'Testnet' : 'Pubnet'} ); } diff --git a/gui/web/src/components/atoms/BotExchangeInfo/BotExchangeInfo.js b/gui/web/src/components/atoms/BotExchangeInfo/BotExchangeInfo.js index fba75cb7b..f6baadd35 100644 --- a/gui/web/src/components/atoms/BotExchangeInfo/BotExchangeInfo.js +++ b/gui/web/src/components/atoms/BotExchangeInfo/BotExchangeInfo.js @@ -6,7 +6,7 @@ class BotExchangeInfo extends Component { render() { return (
- + SDEX {this.props.strategy} diff --git a/gui/web/src/components/molecules/BotCard/BotCard.js b/gui/web/src/components/molecules/BotCard/BotCard.js index e170e881e..a3e7d3e77 100644 --- a/gui/web/src/components/molecules/BotCard/BotCard.js +++ b/gui/web/src/components/molecules/BotCard/BotCard.js @@ -22,6 +22,7 @@ import getBotInfo from '../../../kelp-ops-api/getBotInfo'; let defaultBotInfo = { "last_updated": "Never", "strategy": "buysell", + "is_testnet": true, "trading_pair": { "Base": "?", "Quote": "?" @@ -67,6 +68,7 @@ class BotCard extends Component { this.tick = this.tick.bind(this); this.toggleOptions = this.toggleOptions.bind(this); this.editBot = this.editBot.bind(this); + this.showMarket = this.showMarket.bind(this); this.callDeleteBot = this.callDeleteBot.bind(this); this._asyncRequests = {}; @@ -272,6 +274,16 @@ class BotCard extends Component { this.props.history.push('/edit?bot_name=' + encodeURIComponent(this.props.name)) } + showMarket() { + let baseCode = this.state.botInfo.asset_base.asset_type === "native" ? "XLM/native" : this.state.botInfo.asset_base.asset_code + "/" + this.state.botInfo.asset_base.asset_issuer; + let quoteCode = this.state.botInfo.asset_quote.asset_type === "native" ? "XLM/native" : this.state.botInfo.asset_quote.asset_code + "/" + this.state.botInfo.asset_quote.asset_issuer; + let link = "https://testnet.interstellar.exchange/app/#/trade/guest/" + baseCode + "/" + quoteCode; + if (!this.state.botInfo.is_testnet) { + link = "https://interstellar.exchange/app/#/trade/guest/" + baseCode + "/" + quoteCode; + } + window.open(link); + } + render() { let popover = ""; if (this.state.popoverVisible) { @@ -281,6 +293,8 @@ class BotCard extends Component {

{this.props.name}

- +
+ {this.props.enableMarket ?
Show Market
:
Show Market
} {this.props.enableEdit ?
Edit
:
Edit
} {this.props.enableCopy ?
Copy
:
Copy
} {this.props.enableDelete ?
Delete
:
Delete
} diff --git a/gui/web/src/components/screens/Bots/Bots.js b/gui/web/src/components/screens/Bots/Bots.js index 37b35a802..5a0322d4f 100644 --- a/gui/web/src/components/screens/Bots/Bots.js +++ b/gui/web/src/components/screens/Bots/Bots.js @@ -41,6 +41,10 @@ class Bots extends Component { } fetchBots() { + if (this._asyncRequests["listBots"]) { + return + } + var _this = this this._asyncRequests["listBots"] = listBots(this.props.baseUrl).then(bots => { if (!_this._asyncRequests["listBots"]) { @@ -51,8 +55,7 @@ class Bots extends Component { delete _this._asyncRequests["listBots"]; if (bots.hasOwnProperty('error')) { console.log("error in listBots: " + bots.error); - // retry - setTimeout(_this.fetchBots, 5000); + _this.fetchBots(); } else { _this.setState(prevState => ({ bots: bots @@ -118,7 +121,7 @@ class Bots extends Component {
); } else { - setTimeout(this.fetchBots, 5000); + setTimeout(this.fetchBots, 500); } return ( diff --git a/gui/web/src/components/screens/NewBot/NewBot.js b/gui/web/src/components/screens/NewBot/NewBot.js index b5b782f5c..0422d642b 100644 --- a/gui/web/src/components/screens/NewBot/NewBot.js +++ b/gui/web/src/components/screens/NewBot/NewBot.js @@ -38,6 +38,10 @@ class NewBot extends Component { } loadOptionsMetadata() { + if (this._asyncRequests["optionsMetadata"]) { + return + } + var _this = this; this._asyncRequests["optionsMetadata"] = fetchOptionsMetadata(this.props.baseUrl).then(optionsMetadata => { if (!_this._asyncRequests["optionsMetadata"]) { @@ -48,8 +52,7 @@ class NewBot extends Component { delete _this._asyncRequests["optionsMetadata"]; if (optionsMetadata.hasOwnProperty('error')) { console.log("error when loading optionsMetadata: " + optionsMetadata.error); - // retry - setTimeout(_this.loadOptionsMetadata, 5000); + setTimeout(_this.loadOptionsMetadata, 1000); } else { _this.setState(prevState => ({ optionsMetadata: optionsMetadata, diff --git a/query/botInfo.go b/query/botInfo.go index 79b90cab6..7f3c57f3c 100644 --- a/query/botInfo.go +++ b/query/botInfo.go @@ -2,6 +2,7 @@ package query import ( "fmt" + "strings" "time" hProtocol "github.com/stellar/go/protocols/horizon" @@ -13,6 +14,7 @@ import ( type BotInfo struct { LastUpdated string `json:"last_updated"` Strategy string `json:"strategy"` + IsTestnet bool `json:"is_testnet"` TradingPair *model.TradingPair `json:"trading_pair"` AssetBase hProtocol.Asset `json:"asset_base"` AssetQuote hProtocol.Asset `json:"asset_quote"` @@ -66,6 +68,7 @@ func (s *Server) getBotInfo() (*BotInfo, error) { return &BotInfo{ LastUpdated: time.Now().Format("1/_2/2006 15:04:05"), Strategy: s.strategyName, + IsTestnet: strings.Contains(s.sdex.API.HorizonURL, "test"), TradingPair: s.tradingPair, AssetBase: assetBase, AssetQuote: assetQuote,