Skip to content

Commit

Permalink
fix: Compatible with @ethersproject/experimental 5.6.0 (#464)
Browse files Browse the repository at this point in the history
* fix: Compatible with @ethersproject/experimental 5.6.0

* update to latest ethers

Co-authored-by: Noah Zinsmeister <[email protected]>
  • Loading branch information
karllevine and NoahZinsmeister authored Mar 14, 2022
1 parent b42b8fc commit 2b95e1a
Show file tree
Hide file tree
Showing 18 changed files with 2,033 additions and 2,048 deletions.
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@
"react": ">=16.8"
},
"optionalDependencies": {
"@ethersproject/providers": "^5.5.1"
"@ethersproject/providers": "^5.6.0"
}
}
336 changes: 168 additions & 168 deletions packages/core/yarn.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/eip1193/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
"@web3-react/types": "^8.0.10-beta.0"
},
"devDependencies": {
"@ethersproject/experimental": "^5.5.0",
"@ethersproject/providers": "^5.5.1",
"@ethersproject/experimental": "^5.6.0",
"@ethersproject/providers": "^5.6.0",
"@web3-react/store": "^8.0.13-beta.0"
}
}
716 changes: 358 additions & 358 deletions packages/eip1193/yarn.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions packages/example-next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
"start": "next dev"
},
"dependencies": {
"@ethersproject/bignumber": "^5.4.2",
"@ethersproject/experimental": "^5.5.0",
"@ethersproject/providers": "^5.5.1",
"@ethersproject/units": "^5.4.0",
"@ethersproject/bignumber": "^5.6.0",
"@ethersproject/experimental": "^5.6.0",
"@ethersproject/providers": "^5.6.0",
"@ethersproject/units": "^5.6.0",
"@web3-react/core": "8.0.18-beta.0",
"@web3-react/eip1193": "8.0.13-beta.0",
"@web3-react/empty": "8.0.10-beta.0",
Expand Down
716 changes: 358 additions & 358 deletions packages/example-next/yarn.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/magic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"start": "tsc --watch"
},
"dependencies": {
"@ethersproject/experimental": "^5.5.0",
"@ethersproject/providers": "^5.5.1",
"@ethersproject/experimental": "^5.6.0",
"@ethersproject/providers": "^5.6.0",
"@web3-react/types": "^8.0.10-beta.0"
},
"peerDependencies": {
Expand Down
716 changes: 358 additions & 358 deletions packages/magic/yarn.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/network/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"start": "tsc --watch"
},
"dependencies": {
"@ethersproject/experimental": "^5.5.0",
"@ethersproject/providers": "^5.5.1",
"@ethersproject/experimental": "^5.6.0",
"@ethersproject/providers": "^5.6.0",
"@web3-react/types": "^8.0.10-beta.0"
},
"devDependencies": {
Expand Down
18 changes: 9 additions & 9 deletions packages/network/src/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createWeb3ReactStoreAndActions } from '@web3-react/store'
import type { Actions, Web3ReactStore } from '@web3-react/types'
import { MockEip1193Bridge } from '../../url/src/index.spec'
import { MockEIP1193Provider } from '../../eip1193/src/index.spec'
import { Network } from './'

jest.mock('@ethersproject/providers', () => ({
Expand All @@ -11,7 +11,7 @@ jest.mock('@ethersproject/providers', () => ({
}))

jest.mock('@ethersproject/experimental', () => ({
Eip1193Bridge: MockEip1193Bridge,
Eip1193Bridge: MockEIP1193Provider,
}))

const chainId = '0x1'
Expand All @@ -20,7 +20,7 @@ const accounts: string[] = []
describe('Network', () => {
let store: Web3ReactStore
let connector: Network
let mockConnector: MockEip1193Bridge
let mockConnector: MockEIP1193Provider

describe('connectEagerly = true', () => {
beforeEach(() => {
Expand All @@ -30,7 +30,7 @@ describe('Network', () => {
})

beforeEach(async () => {
mockConnector = connector.provider as unknown as MockEip1193Bridge
mockConnector = connector.provider as unknown as MockEIP1193Provider
mockConnector.chainId = chainId
mockConnector.accounts = accounts
})
Expand Down Expand Up @@ -67,7 +67,7 @@ describe('Network', () => {
beforeEach(async () => {
// testing hack to ensure the provider is set
await connector.activate()
mockConnector = connector.provider as unknown as MockEip1193Bridge
mockConnector = connector.provider as unknown as MockEIP1193Provider
mockConnector.chainId = chainId
mockConnector.accounts = accounts
})
Expand All @@ -93,7 +93,7 @@ describe('Network', () => {
})

beforeEach(async () => {
mockConnector = connector.provider as unknown as MockEip1193Bridge
mockConnector = connector.provider as unknown as MockEIP1193Provider
mockConnector.chainId = chainId
mockConnector.accounts = accounts
})
Expand All @@ -118,14 +118,14 @@ describe('Network', () => {
})

beforeEach(async () => {
mockConnector = connector.provider as unknown as MockEip1193Bridge
mockConnector = connector.provider as unknown as MockEIP1193Provider
mockConnector.chainId = chainId
mockConnector.accounts = accounts
})

describe('#activate', () => {
test('chainId = 1', async () => {
mockConnector = connector.provider as unknown as MockEip1193Bridge
mockConnector = connector.provider as unknown as MockEIP1193Provider
mockConnector.chainId = chainId
mockConnector.accounts = accounts
await connector.activate()
Expand All @@ -141,7 +141,7 @@ describe('Network', () => {
test('chainId = 2', async () => {
// testing hack to ensure the provider is set
await connector.activate(2)
mockConnector = connector.provider as unknown as MockEip1193Bridge
mockConnector = connector.provider as unknown as MockEIP1193Provider
mockConnector.chainId = '0x2'
mockConnector.accounts = accounts

Expand Down
8 changes: 6 additions & 2 deletions packages/network/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import { Connector } from '@web3-react/types'

type url = string | ConnectionInfo

function parseChainId(chainId: string) {
return Number.parseInt(chainId, 16)
}

export class Network extends Connector {
/** {@inheritdoc Connector.provider} */
public provider: Eip1193Bridge | undefined
Expand Down Expand Up @@ -73,8 +77,8 @@ export class Network extends Connector {

return this.provider
.request({ method: 'eth_chainId' })
.then((chainId: number) => {
this.actions.update({ chainId, accounts: [] })
.then((chainId: string) => {
this.actions.update({ chainId: parseChainId(chainId), accounts: [] })
})
.catch((error: Error) => {
this.actions.reportError(error)
Expand Down
Loading

0 comments on commit 2b95e1a

Please sign in to comment.