Skip to content

Commit

Permalink
fix: import Web3Provider from the right place and set headers
Browse files Browse the repository at this point in the history
  • Loading branch information
z80dev committed Dec 13, 2023
1 parent 97b8901 commit f1e7a60
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
7 changes: 6 additions & 1 deletion ape_frame/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ def accounts(self) -> Iterator[AccountAPI]:
class FrameAccount(AccountAPI):
@property
def web3(self) -> Web3:
return Web3(HTTPProvider("http://127.0.0.1:1248"))
headers = {
"Origin": "Ape",
"User-Agent": "ape-frame/0.1.0",
"Content-Type": "application/json"
}
return Web3(HTTPProvider("http://127.0.0.1:1248", request_kwargs={"headers": headers}))

@property
def alias(self) -> str:
Expand Down
10 changes: 8 additions & 2 deletions ape_frame/providers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import Any

from ape.api import UpstreamProvider, Web3Provider
from ape.api import UpstreamProvider
from ape_ethereum.provider import Web3Provider
from ape.exceptions import ProviderError
from eth_utils import to_hex
from requests import HTTPError # type: ignore[import]
Expand All @@ -24,7 +25,12 @@ def connection_str(self) -> str:
return self.uri

def connect(self):
self._web3 = Web3(HTTPProvider(self.uri))
headers = {
"Origin": "Ape",
"User-Agent": "ape-frame/0.1.0",
"Content-Type": "application/json"
}
self._web3 = Web3(HTTPProvider(self.uri, request_kwargs={"headers": headers}))

if "Frame" not in self._web3.client_version:
raise FrameNotConnectedError()
Expand Down

0 comments on commit f1e7a60

Please sign in to comment.