Merge pull request #1265 from chaotixkilla/fix-infura-to-geth-provider-reset

Reset web3 provider when changing between ETH wallets
This commit is contained in:
Rafael Taranto 2022-06-22 15:23:58 +01:00 committed by GitHub
commit f2f4683ae5
4 changed files with 12 additions and 10 deletions

View file

@ -11,7 +11,6 @@ const pify = require('pify')
const BN = require('../../../bn')
const ABI = require('../../tokens')
const NAME = 'geth'
exports.SUPPORTED_MODULES = ['wallet']
const paymentPrefixPath = "m/44'/60'/0'/0'"
@ -19,7 +18,6 @@ const defaultPrefixPath = "m/44'/60'/1'/0'"
let lastUsedNonces = {}
module.exports = {
NAME,
balance,
sendCoins,
newAddress,
@ -35,9 +33,7 @@ module.exports = {
}
function connect (url) {
if (!web3.isConnected()) {
web3.setProvider(new web3.providers.HttpProvider(url))
}
return web3.setProvider(new web3.providers.HttpProvider(url))
}
const hex = bigNum => '0x' + bigNum.integerValue(BN.ROUND_DOWN).toString(16)

View file

@ -1,9 +1,15 @@
const _ = require('lodash/fp')
const base = require('./base')
const { utils: coinUtils } = require('@lamassu/coins')
const cryptoRec = coinUtils.getCryptoCurrency('ETH')
const defaultPort = cryptoRec.defaultPort
base.connect(`http://localhost:${defaultPort}`)
const NAME = 'geth'
module.exports = base
function run (account) {
base.connect(`http://localhost:${defaultPort}`)
}
module.exports = _.merge(base, { NAME, run })

View file

@ -1,6 +1,8 @@
const _ = require('lodash/fp')
const base = require('../geth/base')
const NAME = 'infura'
function run (account) {
if (!account.endpoint) throw new Error('Need to configure API endpoint for Infura')
@ -10,4 +12,4 @@ function run (account) {
base.connect(endpoint)
}
module.exports = _.merge(base, {run})
module.exports = _.merge(base, { NAME, run })

View file

@ -61,8 +61,6 @@ const Wallet = ({ name: SCREEN_KEY }) => {
const [advancedSettings, setAdvancedSettings] = useState(false)
const { data } = useQuery(GET_INFO)
console.log(data)
const [saveConfig, { error }] = useMutation(SAVE_CONFIG, {
onCompleted: () => setWizard(false),
refetchQueries: () => ['getData']