Skip to content

Commit

Permalink
refactor: no solidity interfaces required (#22)
Browse files Browse the repository at this point in the history
Was removed in #21
  • Loading branch information
fubuloubu committed Jul 25, 2023
1 parent 6bba3f9 commit d2f591b
Showing 1 changed file with 0 additions and 43 deletions.
43 changes: 0 additions & 43 deletions scripts/make_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,6 @@
ERC4626_URL = "https://raw.githubusercontent.com/ethereum/EIPs/master/EIPS/eip-4626.md"


def make_solidity_interface(spec):
interfaces = []
for abi in spec:
if abi["type"] == "function":
inputs = ", ".join(f"{i['type']} {i['name']}" for i in abi["inputs"])
interface = f"function {abi['name']}({inputs}) external"
if abi["stateMutability"] != "nonpayable":
interface += " " + abi["stateMutability"]
if "outputs" in abi:
outputs = ", ".join(f"{i['type']} {i['name']}" for i in abi["outputs"])
interface += f" returns ({outputs})"
interfaces.append(interface)

elif abi["type"] == "event":
inputs = ", ".join(
f"{i['type']} indexed {i['name']}"
if i["indexed"]
else f"{i['type']} {i['name']}"
for i in abi["inputs"]
)
interface = f"event {abi['name']}({inputs})"
interfaces.append(interface)

else:
raise Exception(f"Can't handle '{abi['type']}'")
return interfaces


def main():
yaml_string = requests.get(ERC4626_URL).content.decode("utf-8")
yaml_sections = [
Expand All @@ -52,19 +24,4 @@ def main():
opts = jsbeautifier.default_options()
opts.indent_size = 2
interface_text = jsbeautifier.beautify(json.dumps(spec), opts)
# HACK: "caller" is illegal keyword in Vyper
interface_text = interface_text.replace("caller", "_caller")
interface_file.write_text(interface_text)

# Write Solidity interface
interface_file = Path("contracts") / "ERC4626.sol"
print(f"Writing {interface_file}")
interface_file.write_text(
"""interface IERC4626 {open}
{interfaces};
{close}""".format(
open="{",
interfaces=";\n ".join(make_solidity_interface(spec)),
close="}",
)
)

0 comments on commit d2f591b

Please sign in to comment.