Skip to content

Commit

Permalink
Merge pull request #36 from Elnaril/v1.0.1.dev0
Browse files Browse the repository at this point in the history
fix #35 - SDK fails to decode input data when there is too many commands
  • Loading branch information
Elnaril authored Dec 28, 2023
2 parents b0c2fb3 + 2914183 commit af911af
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
---

## Release Notes
### v1.0.1
- Fix issue #35 - fails to decode input data when there is too many commands
### v1.0.0
- Add support for SWEEP and PAY_PORTION
- Fix decoding issues
Expand Down Expand Up @@ -171,8 +173,8 @@ The result is a tuple, starting with the "in-token" and ending with the "out-tok
The Universal Router allows the chaining of several functions in the same transaction.
This codec supports it (at least for supported functions) and exposes public methods that can be chained.

The chaining starts with the `encode.chain()` method and ends with the `build()` one which return the full encoded data to be included in the transaction.
Below some examples of encoded input for one function and one example for 2 functions.
The chaining starts with the `encode.chain()` method and ends with the `build()` one which returns the full encoded data to be included in the transaction.
Below some examples of encoded data for one function and one example for 2 functions.

Default values for deadlines and expirations can be computed with the static methods `get_default_deadline()` and `get_default_expiration()` respectively.
```python
Expand Down Expand Up @@ -357,3 +359,6 @@ transaction["data"] = encoded_data

# you can now sign and send the transaction to the UR
```

## Tutorials and Recipes:
See the [SDK Wiki](https://github.com/Elnaril/uniswap-universal-router-decoder/wiki).
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ build-backend = "setuptools.build_meta"

[project]
name = "uniswap-universal-router-decoder"
version = "1.0.0"
version = "1.0.1"
authors = [
{ name="Elnaril", email="[email protected]" },
]
description = "Decode & Encode transaction data sent to Uniswap Universal Router"
readme = "README.md"
requires-python = ">=3.8"
classifiers = [
"Development Status :: 2 - Pre-Alpha",
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Natural Language :: English",
Expand All @@ -27,7 +27,7 @@ license = {text = "MIT License"}
dependencies = [
"web3>=6.0.0,<7.0.0",
]
keywords = ["blockchain", "ethereum", "uniswap", "universal router", "decoder", "encoder", "codec", "wrapper"]
keywords = ["blockchain", "ethereum", "uniswap", "universal router", "decoder", "encoder", "codec", "wrapper", "SDK"]

[tool.setuptools]
packages = ["uniswap_universal_router_decoder"]
Expand Down
4 changes: 4 additions & 0 deletions tests/test_decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
trx_hash_09 = HexStr("0x2b6af8ef8fe18829a0fcf2b0f391c55daf76f53bb68369ecaefdb1f38045f919")
expected_function_names_09 = ("PERMIT2_PERMIT", "V2_SWAP_EXACT_IN", "V2_SWAP_EXACT_IN", "V3_SWAP_EXACT_IN", "V2_SWAP_EXACT_IN", "V3_SWAP_EXACT_IN", "SWEEP") # noqa

trx_hash_10 = HexStr("0x586d51e2f92bd16573f0e7e302755ed02b7c2a4b721d63f46bcdcf7179d2f40e")
expected_function_names_10 = ("WRAP_ETH", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", "V3_SWAP_EXACT_OUT", None, "UNWRAP_WETH", "SWEEP") # noqa


@pytest.mark.parametrize(
"trx_hash, w3, rpc_endpoint, expected_fct_names",
Expand All @@ -53,6 +56,7 @@
(trx_hash_07, w3_instance, None, expected_function_names_07),
(trx_hash_08, w3_instance, None, expected_function_names_08),
(trx_hash_09, w3_instance, None, expected_function_names_09),
(trx_hash_10, w3_instance, None, expected_function_names_10),
)
)
def test_decode_transaction(trx_hash, w3, rpc_endpoint, expected_fct_names):
Expand Down
2 changes: 1 addition & 1 deletion uniswap_universal_router_decoder/_decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def function_input(self, input_data: Union[HexStr, HexBytes]) -> Tuple[ContractF
command = decoded_input["commands"]
command_input = decoded_input["inputs"]
decoded_command_input = []
for i, b in enumerate(command[-7:]):
for i, b in enumerate(command):
# iterating over bytes produces integers
try:
abi_mapping = self._abi_map[_RouterFunction(b)]
Expand Down

0 comments on commit af911af

Please sign in to comment.