Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite56b1d5

Browse files
committed
fix: fixed type annotations
1 parent750ee74 commite56b1d5

File tree

3 files changed

+22
-14
lines changed

3 files changed

+22
-14
lines changed

‎tests/test_uniswap.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,9 @@ def test_get_price_output(self, client, token0, token1, qty, kwargs):
177177
# ------ ERC20 Pool ----------------------------------------------------------------
178178
@pytest.mark.parametrize("token", [(bat), (dai)])
179179
deftest_get_ex_eth_balance(
180-
self,client:Uniswap,token,
180+
self,
181+
client:Uniswap,
182+
token,
181183
):
182184
ifnotclient.version==1:
183185
pytest.skip("Tested method only supported on Uniswap v1")
@@ -186,7 +188,9 @@ def test_get_ex_eth_balance(
186188

187189
@pytest.mark.parametrize("token", [(bat), (dai)])
188190
deftest_get_ex_token_balance(
189-
self,client:Uniswap,token,
191+
self,
192+
client:Uniswap,
193+
token,
190194
):
191195
ifnotclient.version==1:
192196
pytest.skip("Tested method only supported on Uniswap v1")
@@ -195,7 +199,9 @@ def test_get_ex_token_balance(
195199

196200
@pytest.mark.parametrize("token", [(bat), (dai)])
197201
defget_exchange_rate(
198-
self,client:Uniswap,token,
202+
self,
203+
client:Uniswap,
204+
token,
199205
):
200206
r=client.get_exchange_rate(token)
201207
assertr
@@ -213,7 +219,7 @@ def get_exchange_rate(
213219
deftest_add_liquidity(self,client:Uniswap,web3:Web3,token,max_eth):
214220
r=client.add_liquidity(token,max_eth)
215221
tx=web3.eth.waitForTransactionReceipt(r,timeout=6000)
216-
asserttx.status# type: ignore
222+
asserttx.status
217223

218224
@pytest.mark.skip
219225
@pytest.mark.parametrize(
@@ -230,7 +236,7 @@ def test_remove_liquidity(
230236
withexpectation:
231237
r=client.remove_liquidity(token,max_token)
232238
tx=web3.eth.waitForTransactionReceipt(r)
233-
asserttx.status# type: ignore
239+
asserttx.status
234240

235241
# ------ Make Trade ----------------------------------------------------------------
236242
@pytest.mark.parametrize(
@@ -266,9 +272,9 @@ def test_make_trade(
266272
withexpectation():
267273
bal_in_before=client.get_token_balance(input_token)
268274

269-
r=client.make_trade(input_token,output_token,qty,recipient)
270-
tx=web3.eth.waitForTransactionReceipt(r)
271-
asserttx.status# type: ignore
275+
txid=client.make_trade(input_token,output_token,qty,recipient)
276+
tx=web3.eth.waitForTransactionReceipt(txid)
277+
asserttx.status
272278

273279
# TODO: Checks for ETH, taking gas into account
274280
bal_in_after=client.get_token_balance(input_token)
@@ -318,7 +324,7 @@ def test_make_trade_output(
318324

319325
r=client.make_trade_output(input_token,output_token,qty,recipient)
320326
tx=web3.eth.waitForTransactionReceipt(r,timeout=30)
321-
asserttx.status# type: ignore
327+
asserttx.status
322328

323329
# TODO: Checks for ETH, taking gas into account
324330
balance_after=client.get_token_balance(output_token)

‎uniswap/decorators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
defcheck_approval(method:Callable)->Callable:
1111
"""Decorator to check if user is approved for a token. It approves them if they
12-
need to be approved."""
12+
need to be approved."""
1313

1414
@functools.wraps(method)
1515
defapproved(self:Any,*args:Any,**kwargs:Any)->Any:

‎uniswap/uniswap.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ def __init__(
130130
)
131131
# Documented here: https://uniswap.org/docs/v2/smart-contracts/router02/
132132
self.router=_load_contract(
133-
self.w3,abi_name="uniswap-v2/router02",address=self.router_address,
133+
self.w3,
134+
abi_name="uniswap-v2/router02",
135+
address=self.router_address,
134136
)
135137
elifself.version==3:
136138
# https://github.com/Uniswap/uniswap-v3-periphery/blob/main/deploys.md
@@ -774,7 +776,7 @@ def _token_to_token_swap_output(
774776
# ------ Wallet balance ------------------------------------------------------------
775777
defget_eth_balance(self)->Wei:
776778
"""Get the balance of ETH for your address."""
777-
returnself.w3.eth.getBalance(self.address)
779+
returnself.w3.eth.get_balance(self.address)
778780

779781
defget_token_balance(self,token:AddressLike)->int:
780782
"""Get the balance of a token for your address."""
@@ -790,7 +792,7 @@ def get_token_balance(self, token: AddressLike) -> int:
790792
defget_ex_eth_balance(self,token:AddressLike)->int:
791793
"""Get the balance of ETH in an exchange contract."""
792794
ex_addr:AddressLike=self._exchange_address_from_token(token)
793-
returnself.w3.eth.getBalance(ex_addr)
795+
returnself.w3.eth.get_balance(ex_addr)
794796

795797
@supports([1])
796798
defget_ex_token_balance(self,token:AddressLike)->int:
@@ -888,7 +890,7 @@ def _build_and_send_tx(
888890
# TODO: This needs to get more complicated if we want to support replacing a transaction
889891
# FIXME: This does not play nice if transactions are sent from other places using the same wallet.
890892
try:
891-
returnself.w3.eth.sendRawTransaction(signed_txn.rawTransaction)
893+
returnself.w3.eth.send_raw_transaction(signed_txn.rawTransaction)
892894
finally:
893895
logger.debug(f"nonce:{tx_params['nonce']}")
894896
self.last_nonce=Nonce(tx_params["nonce"]+1)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp