Skip to content

Commit

Permalink
feat: add support for .http_uri and .ws_uri in ProviderAPI v0.6.19
Browse files Browse the repository at this point in the history
  • Loading branch information
fubuloubu committed Sep 8, 2023
1 parent 9ba4a32 commit a442e6e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ape_alchemy/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@ def uri(self):
self.network_uris[(ecosystem_name, network_name)] = uri
return uri

@property
def http_uri(self) -> str:
# NOTE: Overriding `Web3Provider.http_uri` implementation
return self.uri

@property
def ws_uri(self) -> str:
# NOTE: Overriding `Web3Provider.ws_uri` implementation
return "ws" + self.uri[4:] # Remove `http` in default URI w/ `ws`

@property
def connection_str(self) -> str:
return self.uri
Expand Down
2 changes: 2 additions & 0 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ def test_alchemy(ecosystem, network):
ecosystem_cls = networks.get_ecosystem(ecosystem)
network_cls = ecosystem_cls.get_network(network)
with network_cls.use_provider("alchemy") as provider:
assert provider.http_uri.startswith("https")
assert provider.ws_uri.startswith("wss")
assert isinstance(provider, Alchemy)
assert provider.get_balance(ZERO_ADDRESS) > 0
assert provider.get_block(0)

0 comments on commit a442e6e

Please sign in to comment.