Skip to content

Commit

Permalink
Merge pull request #33 from eco-stake/bug-fixes
Browse files Browse the repository at this point in the history
Error handling and removing CORS blocked endpoints
  • Loading branch information
tombeynon authored Mar 4, 2022
2 parents bbd9dd5 + e2c5b58 commit 162a2f1
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 38 deletions.
2 changes: 1 addition & 1 deletion src/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ class App extends React.Component {
}));
localStorage.setItem(validator.operator_address, imageUrl)
}
})
}, error => { })
}else{
return null
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/ClaimRewards.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function ClaimRewards(props) {
}, (error) => {
console.log('Failed to broadcast:', error)
props.setLoading(false)
props.setError('Failed to broadcast TX')
props.setError('Failed to broadcast: ' + error.message)
})
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/DelegateForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class DelegateForm extends React.Component {
this.props.onDelegate()
}, (error) => {
console.log('Failed to broadcast:', error)
this.setState({ loading: false, error: 'Failed to broadcast TX' })
this.setState({ loading: false, error: error.message })
})
}

Expand Down Expand Up @@ -82,7 +82,7 @@ class DelegateForm extends React.Component {
}

async setAvailableAmount(){
const messages = this.buildMessages(this.props.availableBalance.amount / 1_000_000.0)
const messages = this.buildMessages(parseInt(this.props.availableBalance.amount * 0.95) / 1_000_000.0)
this.props.stargateClient.simulate(this.props.address, messages).then(gas => {
const saveTxFeeNum = (this.props.redelegate || this.props.undelegate) ? 0 : 10
const gasPrice = this.props.stargateClient.getFee(gas).amount[0].amount
Expand Down
2 changes: 1 addition & 1 deletion src/components/GrantRestake.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function GrantRestake(props) {
}, (error) => {
console.log('Failed to broadcast:', error)
setLoading(false)
props.setError('Failed to broadcast TX')
props.setError('Failed to broadcast: ' + error.message)
})
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/RevokeRestake.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function RevokeRestake(props) {
}, (error) => {
console.log('Failed to broadcast:', error)
setLoading(false)
props.setError('Failed to broadcast TX')
props.setError('Failed to broadcast: ' + error.message)
})
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/Wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class Wallet extends React.Component {
});
},
(error) => {
if([404, 500].includes(error.response.status)){
if(error.response && [404, 500].includes(error.response.status)){
this.setState({
isLoaded: true,
delegations: {},
Expand Down
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import reportWebVitals from './utils/reportWebVitals';

Bugsnag.start({
apiKey: '5cda10bb1c98f351cd0b722a1535d8c2',
plugins: [new BugsnagPluginReact()]
plugins: [new BugsnagPluginReact()],
enabledReleaseStages: [ 'production', 'staging' ]
})

const ErrorBoundary = Bugsnag.getPlugin('react')
Expand Down
39 changes: 11 additions & 28 deletions src/networks.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
],
"rpcUrl": [
"https://osmosis.validator.network",
"https://osmosis-1.technofractal.com:443",
"https://rpc-osmosis.blockapsis.com"
],
"image": "https://raw.githubusercontent.com/osmosis-labs/assetlists/main/images/osmo.svg",
Expand Down Expand Up @@ -100,12 +99,10 @@
"prefix": "juno",
"denom": "ujuno",
"restUrl": [
"https://lcd-juno.itastakers.com",
"https://lcd.juno-1.technofractal.com/"
"https://lcd-juno.itastakers.com"
],
"rpcUrl": [
"https://rpc-juno.itastakers.com",
"https://juno-1.technofractal.com:443"
"https://rpc-juno.itastakers.com"
],
"image": "https://raw.githubusercontent.com/osmosis-labs/assetlists/main/images/juno.svg",
"gasPrice": "0.0025ujuno",
Expand Down Expand Up @@ -203,8 +200,6 @@
],
"rpcUrl": [
"https://cosmoshub.validator.network",
"https://cosmoshub-4.technofractal.com:443",
"https://rpc.cosmos.network:443",
"https://rpc-cosmoshub.blockapsis.com"
],
"image": "https://raw.githubusercontent.com/osmosis-labs/assetlists/main/images/atom.svg",
Expand Down Expand Up @@ -436,12 +431,10 @@
"prefix": "regen",
"denom": "uregen",
"restUrl": [
"https://rest.cosmos.directory/regen",
"https://regen.stakesystems.io"
"https://rest.cosmos.directory/regen"
],
"rpcUrl": [
"https://rpc.cosmos.directory/regen",
"https://regen.stakesystems.io:2053"
"https://rpc.cosmos.directory/regen"
],
"image": "https://raw.githubusercontent.com/osmosis-labs/assetlists/main/images/regen.png",
"gasPrice": "0.002uregen",
Expand Down Expand Up @@ -497,8 +490,7 @@
"https://lcd-sentinel.keplr.app"
],
"rpcUrl": [
"https://rpc-sentinel.keplr.app",
"https://sentinelhub-2.technofractal.com:443"
"https://rpc-sentinel.keplr.app"
],
"image": "https://raw.githubusercontent.com/osmosis-labs/assetlists/main/images/dvpn.png",
"gasPrice": "0.02udvpn",
Expand Down Expand Up @@ -532,12 +524,10 @@
"prefix": "dig",
"denom": "udig",
"restUrl": [
"https://api-1-dig.notional.ventures",
"https://api-2-dig.notional.ventures"
"https://api-1-dig.notional.ventures"
],
"rpcUrl": [
"https://rpc-1-dig.notional.ventures",
"https://rpc-2-dig.notional.ventures"
"https://rpc-1-dig.notional.ventures"
],
"image": "https://raw.githubusercontent.com/osmosis-labs/assetlists/main/images/dig.png",
"gasPrice": "0.0025udig",
Expand Down Expand Up @@ -693,7 +683,6 @@
"prefix": "cro",
"denom": "basecro",
"restUrl": [
"https://mainnet.crypto.org/",
"https://lcd-crypto-org.keplr.app/"
],
"rpcUrl": [
Expand Down Expand Up @@ -807,13 +796,11 @@
"denom": "ustars",
"restUrl": [
"https://rest.stargaze-apis.com",
"https://api.stargaze.ezstaking.io",
"https://api.stars.kingnodes.com"
"https://api.stargaze.ezstaking.io"
],
"rpcUrl": [
"https://rpc.stargaze-apis.com",
"https://rpc.stargaze.ezstaking.io",
"https://rpc.stars.kingnodes.com"
"https://rpc.stargaze.ezstaking.io"
],
"image": "https://raw.githubusercontent.com/public-awesome/assets/main/images/stars.png",
"operators": [
Expand All @@ -834,15 +821,11 @@
"denom": "ucmdx",
"restUrl": [
"https://api.comdex.audit.one/rest",
"https://rest.comdex.one",
"http://comdex.node.vitwit.com:1317",
"https://api-comdex.zenchainlabs.io"
"https://rest.comdex.one"
],
"rpcUrl": [
"https://api.comdex.audit.one/rpc/",
"https://rpc.comdex.one",
"http://comdex.node.vitwit.com:26657",
"https://rpc-comdex.zenchainlabs.io"
"https://rpc.comdex.one"
],
"image": "https://raw.githubusercontent.com/osmosis-labs/assetlists/main/images/cmdx.png",
"operators": [
Expand Down
8 changes: 6 additions & 2 deletions src/utils/SigningClient.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,12 @@ const SigningClient = async (rpcUrl, chainId, defaultGasPrice, signer, key) => {
}

const simulate = async (address, msgs, memo, modifier) => {
const estimate = await client.simulate(address, msgs, memo)
return parseInt(estimate * (modifier || 1.5))
try{
const estimate = await client.simulate(address, msgs, memo)
return (parseInt(estimate * (modifier || 1.5)))
}catch (error){
return undefined
}
}

function findAvailableUrl(urls){
Expand Down

0 comments on commit 162a2f1

Please sign in to comment.