diff --git a/.gitignore b/.gitignore index f26b01e..e2fc0b5 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,6 @@ notes/ .mypy_cache .pytest_cache .tox + +media/ +tutorials/ diff --git a/coverage.json b/coverage.json index 90b5cd4..6076653 100644 --- a/coverage.json +++ b/coverage.json @@ -1 +1 @@ -{"meta": {"version": "7.3.4", "timestamp": "2023-12-26T21:08:23.104645", "branch_coverage": false, "show_contexts": false}, "files": {"uniswap_universal_router_decoder/__init__.py": {"executed_lines": [1], "summary": {"covered_lines": 0, "num_statements": 0, "percent_covered": 100.0, "percent_covered_display": "100", "missing_lines": 0, "excluded_lines": 0}, "missing_lines": [], "excluded_lines": []}, "uniswap_universal_router_decoder/router_decoder.py": {"executed_lines": [1, 8, 10, 14, 15, 16, 17, 29, 30, 34, 35, 36, 37, 46, 47, 48, 50, 51, 54, 55, 56, 57, 58, 59, 60, 62, 63, 65, 72, 73, 74, 75, 76, 78, 79, 80, 81, 82, 83, 84, 85, 86, 88, 97, 98, 99, 100, 101, 103, 104, 113, 114, 115, 116, 117, 118, 119, 126, 128, 129, 131, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 147, 148, 149, 151, 152, 153, 154, 155, 157, 164, 165, 166, 167, 168, 170, 177, 178, 179, 180, 181, 183, 190, 191, 192, 193, 194, 195, 197, 204, 205, 206, 207, 208, 209, 211, 212, 216, 218, 219, 220, 221, 223, 232, 233, 240, 242, 259, 260, 261, 268, 275, 277, 294, 295, 296, 303, 310, 312, 330, 331, 332, 339, 346, 348, 366, 367, 368, 375, 382, 384, 385, 387, 388, 398, 400, 401, 402, 403, 404, 406, 407, 408, 409, 410, 412, 413, 414, 415, 416, 417, 418, 419, 421, 422, 423, 424, 426, 427, 428, 429, 430, 432, 433, 434, 435, 437, 438, 439, 440, 441, 443, 444, 445, 446, 447, 450, 451, 452, 453, 454, 456, 457, 458, 459, 460, 462, 463, 466, 467, 468, 469, 472, 473, 474, 475, 476, 477, 478, 479, 482, 485, 486, 487, 489, 490, 491, 493, 494, 495, 497, 498, 499, 501, 502, 503, 505, 506, 508, 509, 510, 512, 513, 514, 516, 517, 518, 521], "summary": {"covered_lines": 240, "num_statements": 240, "percent_covered": 100.0, "percent_covered_display": "100", "missing_lines": 0, "excluded_lines": 0}, "missing_lines": [], "excluded_lines": []}}, "totals": {"covered_lines": 240, "num_statements": 240, "percent_covered": 100.0, "percent_covered_display": "100", "missing_lines": 0, "excluded_lines": 0}} \ No newline at end of file +{"meta": {"format": 2, "version": "7.4.1", "timestamp": "2024-02-02T14:18:03.674879", "branch_coverage": false, "show_contexts": false}, "files": {"uniswap_universal_router_decoder/__init__.py": {"executed_lines": [1], "summary": {"covered_lines": 0, "num_statements": 0, "percent_covered": 100.0, "percent_covered_display": "100", "missing_lines": 0, "excluded_lines": 0}, "missing_lines": [], "excluded_lines": []}, "uniswap_universal_router_decoder/router_decoder.py": {"executed_lines": [1, 8, 10, 14, 15, 16, 17, 29, 30, 34, 35, 36, 37, 46, 47, 48, 50, 51, 54, 55, 56, 57, 58, 59, 60, 62, 63, 65, 72, 73, 74, 75, 76, 78, 79, 80, 81, 82, 83, 84, 85, 86, 88, 97, 98, 99, 100, 101, 103, 104, 113, 114, 115, 116, 117, 118, 119, 126, 128, 129, 131, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 147, 148, 149, 151, 152, 153, 154, 155, 157, 164, 165, 166, 167, 168, 170, 177, 178, 179, 180, 181, 183, 190, 191, 192, 193, 194, 195, 197, 204, 205, 206, 207, 208, 209, 211, 212, 216, 218, 219, 220, 221, 223, 232, 233, 240, 242, 259, 260, 261, 268, 275, 277, 294, 295, 296, 303, 310, 312, 330, 331, 332, 339, 346, 348, 366, 367, 368, 375, 382, 384, 385, 387, 388, 398, 400, 401, 402, 403, 404, 406, 407, 408, 409, 410, 412, 413, 414, 415, 416, 417, 418, 419, 421, 422, 423, 424, 426, 427, 428, 429, 430, 432, 433, 434, 435, 437, 438, 439, 440, 441, 443, 444, 445, 446, 447, 450, 451, 452, 453, 454, 456, 457, 458, 459, 460, 462, 463, 466, 467, 468, 469, 472, 473, 474, 475, 476, 477, 478, 479, 482, 485, 486, 487, 489, 490, 491, 493, 494, 495, 497, 498, 499, 501, 502, 503, 505, 506, 508, 509, 510, 512, 513, 514, 516, 517, 518, 521], "summary": {"covered_lines": 240, "num_statements": 240, "percent_covered": 100.0, "percent_covered_display": "100", "missing_lines": 0, "excluded_lines": 0}, "missing_lines": [], "excluded_lines": []}}, "totals": {"covered_lines": 240, "num_statements": 240, "percent_covered": 100.0, "percent_covered_display": "100", "missing_lines": 0, "excluded_lines": 0}} \ No newline at end of file diff --git a/tests/test_router_decoder.py b/tests/test_router_decoder.py index 1ee6cc1..0c262c4 100644 --- a/tests/test_router_decoder.py +++ b/tests/test_router_decoder.py @@ -55,6 +55,9 @@ def test_build_abi_map(command_id, expected_fct_abi, expected_selector): 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", None) # 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", None) # noqa + @pytest.mark.parametrize( "trx_hash, w3, rpc_endpoint, expected_fct_names", @@ -65,6 +68,7 @@ def test_build_abi_map(command_id, expected_fct_abi, expected_selector): (trx_hash_04, w3_instance, None, expected_function_names_04), (trx_hash_05, w3_instance, None, expected_function_names_05), (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): diff --git a/uniswap_universal_router_decoder/router_decoder.py b/uniswap_universal_router_decoder/router_decoder.py index 98d92a4..498acad 100644 --- a/uniswap_universal_router_decoder/router_decoder.py +++ b/uniswap_universal_router_decoder/router_decoder.py @@ -73,7 +73,7 @@ def decode_function_input(self, input_data: Union[HexStr, HexBytes]) -> Tuple[Co 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)]