diff --git a/src/autostake/NetworkRunner.mjs b/src/autostake/NetworkRunner.mjs
index 6a3fcf2c..f2c4821c 100644
--- a/src/autostake/NetworkRunner.mjs
+++ b/src/autostake/NetworkRunner.mjs
@@ -11,7 +11,7 @@ export default class NetworkRunner {
this.operator = operator
this.signingClient = signingClient
this.queryClient = network.queryClient
- this.opts = {
+ this.opts = _.merge({
batchPageSize: 100,
batchQueries: 25,
batchTxs: 50,
@@ -19,9 +19,7 @@ export default class NetworkRunner {
queryTimeout: network.data.autostake?.delegatorTimeout || 5000, // deprecate delegatorTimeout
queryThrottle: 100,
gasModifier: 1.1,
- ...network.data.autostake,
- ...opts
- }
+ }, network.data.autostake, opts)
this.batch = {}
this.messages = []
this.processed = {}
diff --git a/src/autostake/index.mjs b/src/autostake/index.mjs
index 3a78b342..1fecb1f7 100644
--- a/src/autostake/index.mjs
+++ b/src/autostake/index.mjs
@@ -132,7 +132,7 @@ export default function Autostake(mnemonic, opts) {
if (!network.authzSupport) return timeStamp('No Authz support')
- await network.connect()
+ await network.connect({ timeout: opts.delegationsTimeout || 20000 })
const { restUrl, usingDirectory } = network
diff --git a/src/components/ValidatorModal.js b/src/components/ValidatorModal.js
index a0609685..38b57a2a 100644
--- a/src/components/ValidatorModal.js
+++ b/src/components/ValidatorModal.js
@@ -19,24 +19,30 @@ import ValidatorGrants from './ValidatorGrants';
function ValidatorModal(props) {
const { redelegate, undelegate, validator, delegations, operators, network, validators, grants } = props
- const [selectedValidator, setSelectedValidator] = useState(!redelegate && validator);
- const [activeTab, setActiveTab] = useState();
const navigate = useNavigate()
const params = useParams();
+ const [selectedValidator, setSelectedValidator] = useState(!redelegate && validator);
+ const [activeTab, setActiveTab] = useState(params.section);
useEffect(() => {
if(params.network !== network.name) return
- if (props.show && selectedValidator && validator?.operator_address === selectedValidator.operator_address && params.validator !== selectedValidator.operator_address) {
- navigate(`/${network.name}/${selectedValidator.operator_address}`)
+ const shouldShow = props.show && selectedValidator && validator?.operator_address === selectedValidator.operator_address
+ const shouldChangeValidator = params.validator !== selectedValidator?.operator_address
+ const shouldChangeTab = activeTab === 'profile' ? !!params.section : params.section !== activeTab
+ const shouldChangeUrl = shouldShow && (shouldChangeValidator || shouldChangeTab)
+ if (shouldChangeUrl) {
+ navigate(`/${network.name}/${selectedValidator.operator_address}${activeTab === 'profile' ? '' : `/${activeTab}`}`)
} else if (params.validator && props.show === false) {
navigate(`/${network.name}`)
}
- }, [props.show, params.validator, selectedValidator])
+ }, [props.show, params.validator, params.section, activeTab, selectedValidator])
useEffect(() => {
if (props.activeTab && props.activeTab != activeTab) {
setActiveTab(props.activeTab)
+ } else if (params.section && params.section != activeTab) {
+ setActiveTab(params.section)
} else if (redelegate || undelegate) {
setActiveTab('delegate')
} else if (!activeTab) {
diff --git a/src/index.js b/src/index.js
index 2531b46b..9b6914ab 100644
--- a/src/index.js
+++ b/src/index.js
@@ -24,6 +24,7 @@ const app = (
} />
} />
} />
+ } />
diff --git a/src/networks.json b/src/networks.json
index 468b357e..3b593eca 100644
--- a/src/networks.json
+++ b/src/networks.json
@@ -21,8 +21,9 @@
},
{
"name": "chihuahua",
- "gasPrice": "0.025uhuahua",
- "ownerAddress": "chihuahuavaloper19vwcee000fhazmpt4ultvnnkhfh23ppwxll8zz"
+ "ownerAddress": "chihuahuavaloper19vwcee000fhazmpt4ultvnnkhfh23ppwxll8zz",
+ "gasPrice": "1uhuahua",
+ "gasPricePrefer": "1uhuahua"
},
{
"name": "gravitybridge",
diff --git a/src/utils/Network.mjs b/src/utils/Network.mjs
index b9236d36..7be0eabc 100644
--- a/src/utils/Network.mjs
+++ b/src/utils/Network.mjs
@@ -102,9 +102,9 @@ class Network {
this.txTimeout = this.data.txTimeout || 60_000
}
- async connect() {
+ async connect(opts) {
try {
- this.queryClient = await QueryClient(this.chain.chainId, this.restUrl)
+ this.queryClient = await QueryClient(this.chain.chainId, this.restUrl, { connectTimeout: opts?.timeout })
this.restUrl = this.queryClient.restUrl
this.connected = this.queryClient.connected && (!this.usingDirectory || this.connectedDirectory())
} catch (error) {
diff --git a/src/utils/QueryClient.mjs b/src/utils/QueryClient.mjs
index 56f01388..f645a0fc 100644
--- a/src/utils/QueryClient.mjs
+++ b/src/utils/QueryClient.mjs
@@ -1,8 +1,11 @@
import axios from "axios";
import _ from "lodash";
-const QueryClient = async (chainId, restUrls) => {
- let restUrl = await findAvailableUrl(restUrls, "rest")
+const QueryClient = async (chainId, restUrls, opts) => {
+ const config = _.merge({
+ connectTimeout: 10000,
+ }, opts)
+ const restUrl = await findAvailableUrl(restUrls, "rest", { timeout: config.connectTimeout })
const getAllValidators = (pageSize, opts, pageCallback) => {
return getAllPages((nextKey) => {
@@ -209,7 +212,7 @@ const QueryClient = async (chainId, restUrls) => {
return pages;
};
- async function findAvailableUrl(urls, type) {
+ async function findAvailableUrl(urls, type, opts) {
if(!urls) return
if (!Array.isArray(urls)) {
@@ -220,10 +223,11 @@ const QueryClient = async (chainId, restUrls) => {
}
}
const path = type === "rest" ? "/blocks/latest" : "/block";
+ const { timeout } = opts || {}
return Promise.any(urls.map(async (url) => {
url = url.replace(/\/$/, '')
try {
- let data = await axios.get(url + path, { timeout: 10000 })
+ let data = await axios.get(url + path, { timeout })
.then((res) => res.data)
if (type === "rpc") data = data.result;
if (data.block?.header?.chain_id === chainId) {