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

Update AbstractProvider and contract.methods TS definitions #3521

Merged
merged 3 commits into from
May 18, 2020

Conversation

cgewecke
Copy link
Collaborator

@cgewecke cgewecke commented May 14, 2020

Description

⚠️ PR targets release/1.2.8 branch ⚠️

Addresses tsc compilation errors generated while E2E testing 1.2.8 release vs. gnosis/dex-react as noted in this review comment.

As discussed in chat, the error thrown by the AbstractProvider definition is a little confusing.

ERROR in /Users/cgewecke/code/ef/synII/dex-react/src/api/wallet/WalletApi.ts
ERROR in /Users/cgewecke/code/ef/synII/dex-react/src/api/wallet/WalletApi.ts(184,27):
TS2339: Property 'connected' does not exist on type 'HttpProvider | IpcProvider | WebsocketProvider | AbstractProvider'.
  Property 'connected' does not exist on type 'AbstractProvider'.

The problematic code can be found here and looks like:

// needed if Web3 was pre-instantiated with wss | WebsocketProvider
const closeOpenWebSocketConnection = (web3: Web3): void => {
  if (
    web3 &&
    typeof web3.currentProvider === 'object' &&
    web3.currentProvider?.connected &&
    'disconnect' in web3.currentProvider
  ) {
    // code=1000 - Normal Closure
    web3.currentProvider.disconnect(1000, 'Switching provider')
  }
}

All the other Web3 providers have a connected property. Idk if the change in this PR is the right solution (...it squashes the tsc complaint though).

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • I have selected the correct base branch.
  • I have performed a self-review of my own code.

@cgewecke cgewecke changed the title Fix/release tsc errors Update AbstractProvider and contract.methods TS definitions May 14, 2020
@cgewecke cgewecke added 1.x 1.0 related issues Release Patch Types Incorrect or missing types labels May 14, 2020
Copy link
Collaborator

@ryanio ryanio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.x 1.0 related issues Release Patch Types Incorrect or missing types
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants