Skip to content

Commit

Permalink
Support tuple array (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
kigawas authored Nov 10, 2022
1 parent 9f625c1 commit fadf774
Show file tree
Hide file tree
Showing 13 changed files with 612 additions and 900 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repos:
exclude: venv

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.982
rev: v0.990
hooks:
- id: mypy
entry: mypy web3_input_decoder/
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 Weiliang Li
Copyright (c) 2021-2022 Weiliang Li

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
221 changes: 114 additions & 107 deletions poetry.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "web3-input-decoder"
version = "0.1.5"
version = "0.1.6"
# doc
authors = ["Weiliang Li <[email protected]>"]
description = "A simple offline web3 transaction input decoder for functions and constructors"
Expand Down Expand Up @@ -35,7 +35,7 @@ pycryptodome = "^3.15.0"
black = "^22.10.0"
flake8 = "^5.0.4"
ipython = {version = "^8.6.0", python = "^3.8"}
mypy = "^0.982"
mypy = "^0.990"

# stubs
eth-typing = "^3.2.0"
Expand Down
45 changes: 44 additions & 1 deletion tests/data/defi.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,31 @@
{"name": "deadline", "type": "uint256"},
],
"outputs": [{"name": "amounts", "type": "uint256[]"}],
}
},
{
"inputs": [
{"internalType": "uint256", "name": "amountIn", "type": "uint256"},
{"internalType": "uint256", "name": "amountOutMin", "type": "uint256"},
{
"components": [
{"internalType": "address", "name": "from", "type": "address"},
{"internalType": "address", "name": "to", "type": "address"},
{"internalType": "bool", "name": "stable", "type": "bool"},
],
"internalType": "struct BaseV1Router01.route[]",
"name": "routes",
"type": "tuple[]",
},
{"internalType": "address", "name": "to", "type": "address"},
{"internalType": "uint256", "name": "deadline", "type": "uint256"},
],
"name": "swapExactTokensForTokens",
"outputs": [
{"internalType": "uint256[]", "name": "amounts", "type": "uint256[]"}
],
"stateMutability": "nonpayable",
"type": "function",
},
]

ROUTER_SWAP_CALL_INPUT = "0xa2a1623d000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000006ef4158bf7304b966929945248927fb400ece8b500000000000000000000000000000000000000000000000000000000622bc5e10000000000000000000000000000000000000000000000000000000000000002000000000000000000000000b31f66aa3c1e785363f0875a1b74e27b85fd66c70000000000000000000000003df307e8e9a897da488211682430776cdf0f17cc"
Expand All @@ -26,3 +50,22 @@
("address", "to", "0x6ef4158bf7304b966929945248927fb400ece8b5"),
("uint256", "deadline", 1647035873),
]

ROUTER_TOKENS_SWAP_CALL_INPUT = "0xf41766d80000000000000000000000000000000000000000000000000000000002dc6c000000000000000000000000000000000000000000000000001bbc2e22c5c1c2cb00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000007c77b132a0cd0ad1c694ab8645affa26c2787d6600000000000000000000000000000000000000000000000000000000636aaa2f0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000ea32a96608495e54156ae48931a7c20f0dcc1a21000000000000000000000000deaddeaddeaddeaddeaddeaddeaddeaddead00000000000000000000000000000000000000000000000000000000000000000000"
ROUTER_TOKENS_SWAP_CALL_ARGUMENT = [
("uint256", "amountIn", 48000000),
("uint256", "amountOutMin", 1998523061527233227),
(
"(address,address,bool)[]",
"routes",
(
(
"0xea32a96608495e54156ae48931a7c20f0dcc1a21",
"0xdeaddeaddeaddeaddeaddeaddeaddeaddead0000",
False,
),
),
),
("address", "to", "0x7c77b132a0cd0ad1c694ab8645affa26c2787d66"),
("uint256", "deadline", 1667934767),
]
Loading

0 comments on commit fadf774

Please sign in to comment.