Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make sure the initialization to throw an exception when there is no match url #718

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions packages/network/src/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,27 @@ describe('Network', () => {
let connector: Network
let mockConnector: MockJsonRpcProvider

describe('no url', () => {
beforeEach(() => {
let actions: Actions
;[store, actions] = createWeb3ReactStoreAndActions()
connector = new Network({ actions, urlMap: {} })
})

describe('#activate', () => {
test('works', async () => {
let error = null
try {
await connector.activate()
} catch (err) {
error = err
}

expect(error).not.toBeNull()
})
})
})

describe('single url', () => {
beforeEach(() => {
let actions: Actions
Expand Down
2 changes: 2 additions & 0 deletions packages/network/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ export class Network extends Connector {

const urls = this.urlMap[chainId]

if (!urls) return Promise.reject('fail to initialize provider')

// early return if we have a single jsonrpc provider already
if (urls.length === 1 && !isUrl(urls[0])) {
return (this.providerCache[chainId] = Promise.resolve(urls[0]))
Expand Down