Skip to content

Commit

Permalink
Merge pull request #20 from XDeFi-tech/fix/hash-router-pages
Browse files Browse the repository at this point in the history
feat: add hash router
  • Loading branch information
GarageInc authored Jul 21, 2022
2 parents 3d680a6 + efe1c9b commit f6e6a5d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
14 changes: 9 additions & 5 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react'
import styled from 'styled-components'

import {
BrowserRouter as Router,
HashRouter as Router,
Routes,
Route,
Link,
Expand Down Expand Up @@ -30,20 +30,24 @@ const LinkStyled = styled(Link)<{ current?: boolean }>`
`

const PATHS = {
multi: '/walletconnect/multi',
single: '/walletconnect/single'
multi: 'multi',
single: 'single'
}

const Navigation = () => {
const location = useLocation()

console.log(location)
return (
<Nav>
<LinkStyled current={location.pathname === PATHS.multi} to={PATHS.multi}>
<LinkStyled
current={location.pathname === `/${PATHS.multi}`}
to={PATHS.multi}
>
Multi Wallets Connection
</LinkStyled>
<LinkStyled
current={location.pathname === PATHS.single}
current={location.pathname === `/${PATHS.single}`}
to={PATHS.single}
>
Single Wallet Connection
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@xdefi/wallets-connector",
"version": "1.2.6",
"version": "1.2.8",
"description": "Cross chain wallets connector with react hooks",
"author": "garageinc",
"license": "MIT",
Expand Down
14 changes: 5 additions & 9 deletions src/wallets/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class WalletsConnector {
const ethereum = this.getEthereumProvider(providerId)
if (ethereum) {
ethereum.on('accountsChanged', (accounts: string[]) => {
this.loadAccounts(providerId, undefined, accounts)
this.loadAccounts(providerId, undefined)
})
ethereum.on('disconnect', () => {
this.disconnect()
Expand Down Expand Up @@ -142,8 +142,7 @@ export class WalletsConnector {

private loadAccounts = async (
providerId: string,
c: IProviderConfigs | undefined,
updatedAccounts: string[] | undefined = undefined
c: IProviderConfigs | undefined
) => {
if (!canInject()) {
return
Expand All @@ -155,12 +154,9 @@ export class WalletsConnector {
let ethAccounts: string[] = []

try {
ethAccounts =
updatedAccounts && updatedAccounts.length > 0
? updatedAccounts
: await ethereum.request({
method: 'eth_requestAccounts'
})
ethAccounts = await ethereum.request({
method: 'eth_requestAccounts'
})
} catch (e) {
ethAccounts = Array.isArray(ethereum.accounts) ? ethereum.accounts : []
}
Expand Down

0 comments on commit f6e6a5d

Please sign in to comment.