Skip to content

Commit

Permalink
feat: rename vyper.interfaces to ethereum.ercs (vyperlang#3741)
Browse files Browse the repository at this point in the history
rename the builtin interfaces `vyper.interfaces` to `ethereum.ercs`.
  • Loading branch information
ControlCplusControlV authored Jan 31, 2024
1 parent a2df088 commit db8ac3c
Show file tree
Hide file tree
Showing 14 changed files with 37 additions and 37 deletions.
4 changes: 2 additions & 2 deletions docs/interfaces.rst
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,11 @@ In the above example, the ``my_project`` folder is set as the root path. A contr
Built-in Interfaces
===================

Vyper includes common built-in interfaces such as `ERC20 <https://eips.ethereum.org/EIPS/eip-20>`_ and `ERC721 <https://eips.ethereum.org/EIPS/eip-721>`_. These are imported from ``vyper.interfaces``:
Vyper includes common built-in interfaces such as `ERC20 <https://eips.ethereum.org/EIPS/eip-20>`_ and `ERC721 <https://eips.ethereum.org/EIPS/eip-721>`_. These are imported from ``ethereum.ercs``:

.. code-block:: python
from vyper.interfaces import ERC20
from ethereum.ercs import ERC20
implements: ERC20
Expand Down
2 changes: 1 addition & 1 deletion examples/factory/Exchange.vy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from vyper.interfaces import ERC20
from ethereum.ercs import ERC20


interface Factory:
Expand Down
2 changes: 1 addition & 1 deletion examples/factory/Factory.vy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from vyper.interfaces import ERC20
from ethereum.ercs import ERC20

interface Exchange:
def token() -> ERC20: view
Expand Down
2 changes: 1 addition & 1 deletion examples/market_maker/on_chain_market_maker.vy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from vyper.interfaces import ERC20
from ethereum.ercs import ERC20


totalEthQty: public(uint256)
Expand Down
2 changes: 1 addition & 1 deletion examples/tokens/ERC1155ownable.vy
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"""

############### imports ###############
from vyper.interfaces import ERC165
from ethereum.ercs import ERC165

############### variables ###############
# maximum items in a batch call. Set to 128, to be determined what the practical limits are.
Expand Down
4 changes: 2 additions & 2 deletions examples/tokens/ERC20.vy
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
# @author Takayuki Jimba (@yudetamago)
# https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md

from vyper.interfaces import ERC20
from vyper.interfaces import ERC20Detailed
from ethereum.ercs import ERC20
from ethereum.ercs import ERC20Detailed

implements: ERC20
implements: ERC20Detailed
Expand Down
4 changes: 2 additions & 2 deletions examples/tokens/ERC4626.vy
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
## THIS IS EXAMPLE CODE, NOT MEANT TO BE USED IN PRODUCTION! CAVEAT EMPTOR!
###########################################################################

from vyper.interfaces import ERC20
from vyper.interfaces import ERC4626
from ethereum.ercs import ERC20
from ethereum.ercs import ERC4626

implements: ERC20
implements: ERC4626
Expand Down
4 changes: 2 additions & 2 deletions examples/tokens/ERC721.vy
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
# @author Ryuya Nakamura (@nrryuya)
# Modified from: https://github.com/vyperlang/vyper/blob/de74722bf2d8718cca46902be165f9fe0e3641dd/examples/tokens/ERC721.vy

from vyper.interfaces import ERC165
from vyper.interfaces import ERC721
from ethereum.ercs import ERC165
from ethereum.ercs import ERC721

implements: ERC721
implements: ERC165
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2370,7 +2370,7 @@ def transfer(receiver: address, amount: uint256):
"""

code = """
from vyper.interfaces import ERC20
from ethereum.ercs import ERC20
@external
def safeTransfer(erc20: ERC20, receiver: address, amount: uint256) -> uint256:
assert erc20.transfer(receiver, amount, default_return_value=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def qux() -> library.SomeStruct:
# test calls to library functions in statement position
def test_library_statement_calls(get_contract, make_input_bundle, tx_failed):
library_source = """
from vyper.interfaces import ERC20
from ethereum.ercs import ERC20
@internal
def check_adds_to_ten(x: uint256, y: uint256):
assert x + y == 10
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/codegen/test_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def test(_owner: address): nonpayable

def test_basic_interface_implements(assert_compile_failed):
code = """
from vyper.interfaces import ERC20
from ethereum.ercs import ERC20
implements: ERC20
Expand Down Expand Up @@ -382,7 +382,7 @@ def transfer(to: address, amount: uint256) -> bool:
"""

code = """
from vyper.interfaces import ERC20
from ethereum.ercs import ERC20
token_address: ERC20
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/syntax/test_functions_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def foo(x: int128) -> uint256:
return convert(x, uint256)
""",
"""
from vyper.interfaces import ERC20
from ethereum.ercs import ERC20
interface Factory:
def getExchange(token_addr: address) -> address: view
Expand Down
32 changes: 16 additions & 16 deletions tests/functional/syntax/test_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
fail_list = [
(
"""
from vyper.interfaces import ERC20
from ethereum.ercs import ERC20
a: public(ERC20)
@external
def test():
Expand All @@ -25,7 +25,7 @@ def test():
),
(
"""
from vyper.interfaces import ERC20
from ethereum.ercs import ERC20
aba: public(ERC20)
@external
def test():
Expand All @@ -35,15 +35,15 @@ def test():
),
(
"""
from vyper.interfaces import ERC20
from ethereum.ercs import ERC20
a: address(ERC20) # invalid syntax now.
""",
SyntaxException,
),
(
"""
from vyper.interfaces import ERC20
from ethereum.ercs import ERC20
@external
def test():
Expand All @@ -63,7 +63,7 @@ def test(): # may not call normal address
),
(
"""
from vyper.interfaces import ERC20
from ethereum.ercs import ERC20
@external
def test(a: address):
my_address: address = ERC20()
Expand All @@ -72,7 +72,7 @@ def test(a: address):
),
(
"""
from vyper.interfaces import ERC20
from ethereum.ercs import ERC20
implements: ERC20 = 1
""",
Expand Down Expand Up @@ -109,7 +109,7 @@ def foo(): nonpayable
),
(
"""
from vyper.interfaces import ERC20
from ethereum.ercs import ERC20
interface A:
def f(): view
Expand Down Expand Up @@ -137,7 +137,7 @@ def f(a: uint256): # visibility is nonpayable instead of view
(
# `receiver` of `Transfer` event should be indexed
"""
from vyper.interfaces import ERC20
from ethereum.ercs import ERC20
implements: ERC20
Expand Down Expand Up @@ -175,7 +175,7 @@ def approve(_spender : address, _value : uint256) -> bool:
(
# `value` of `Transfer` event should not be indexed
"""
from vyper.interfaces import ERC20
from ethereum.ercs import ERC20
implements: ERC20
Expand Down Expand Up @@ -221,14 +221,14 @@ def test_interfaces_fail(bad_code):

valid_list = [
"""
from vyper.interfaces import ERC20
from ethereum.ercs import ERC20
b: ERC20
@external
def test(input: address):
assert self.b.totalSupply() == ERC20(input).totalSupply()
""",
"""
from vyper.interfaces import ERC20
from ethereum.ercs import ERC20
interface Factory:
def getExchange(token_addr: address) -> address: view
Expand All @@ -253,12 +253,12 @@ def test() -> (bool, Foo):
return True, x
"""
"""
from vyper.interfaces import ERC20
from ethereum.ercs import ERC20
a: public(ERC20)
""",
"""
from vyper.interfaces import ERC20
from ethereum.ercs import ERC20
a: public(ERC20)
Expand All @@ -267,7 +267,7 @@ def test() -> address:
return self.a.address
""",
"""
from vyper.interfaces import ERC20
from ethereum.ercs import ERC20
a: public(ERC20)
b: address
Expand All @@ -277,7 +277,7 @@ def test():
self.b = self.a.address
""",
"""
from vyper.interfaces import ERC20
from ethereum.ercs import ERC20
struct aStruct:
my_address: address
Expand All @@ -291,7 +291,7 @@ def test() -> address:
return self.b.my_address
""",
"""
from vyper.interfaces import ERC20
from ethereum.ercs import ERC20
a: public(ERC20)
@external
def test():
Expand Down
8 changes: 4 additions & 4 deletions vyper/semantics/analysis/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ def _import_to_path(level: int, module_str: str) -> PurePath:


# can add more, e.g. "vyper.builtins.interfaces", etc.
BUILTIN_PREFIXES = ["vyper.interfaces"]
BUILTIN_PREFIXES = ["ethereum.ercs"]


def _is_builtin(module_str):
Expand All @@ -524,10 +524,10 @@ def _load_builtin_import(level: int, module_str: str) -> InterfaceT:
input_bundle = FilesystemInputBundle([search_path])

# remap builtins directory --
# vyper/interfaces => vyper/builtins/interfaces
# ethereum/ercs => vyper/builtins/interfaces
remapped_module = module_str
if remapped_module.startswith("vyper.interfaces"):
remapped_module = remapped_module.removeprefix("vyper.interfaces")
if remapped_module.startswith("ethereum.ercs"):
remapped_module = remapped_module.removeprefix("ethereum.ercs")
remapped_module = vyper.builtins.interfaces.__package__ + remapped_module

path = _import_to_path(level, remapped_module).with_suffix(".vyi")
Expand Down

0 comments on commit db8ac3c

Please sign in to comment.