From 36dcab9fb60f90cee7f7d1e0d34a9ff673b4396e Mon Sep 17 00:00:00 2001 From: ControlCplusControlV Date: Fri, 19 Jan 2024 17:39:26 -0700 Subject: [PATCH 1/2] fixed issue #3675 --- docs/interfaces.rst | 4 +-- docs/release-notes.rst | 2 +- examples/factory/Exchange.vy | 2 +- examples/factory/Factory.vy | 2 +- .../market_maker/on_chain_market_maker.vy | 2 +- examples/tokens/ERC1155ownable.vy | 2 +- examples/tokens/ERC20.vy | 4 +-- examples/tokens/ERC4626.vy | 4 +-- examples/tokens/ERC721.vy | 4 +-- .../test_external_contract_calls.py | 2 +- .../modules/test_stateless_functions.py | 2 +- tests/functional/codegen/test_interfaces.py | 4 +-- .../functional/syntax/test_functions_call.py | 2 +- tests/functional/syntax/test_interfaces.py | 32 +++++++++---------- vyper/semantics/analysis/module.py | 8 ++--- 15 files changed, 38 insertions(+), 38 deletions(-) diff --git a/docs/interfaces.rst b/docs/interfaces.rst index b4182cced7..ab220272d8 100644 --- a/docs/interfaces.rst +++ b/docs/interfaces.rst @@ -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 `_ and `ERC721 `_. These are imported from ``vyper.interfaces``: +Vyper includes common built-in interfaces such as `ERC20 `_ and `ERC721 `_. These are imported from ``ethereum.ercs``: .. code-block:: python - from vyper.interfaces import ERC20 + from ethereum.ercs import ERC20 implements: ERC20 diff --git a/docs/release-notes.rst b/docs/release-notes.rst index 3db11dc451..7de4130757 100644 --- a/docs/release-notes.rst +++ b/docs/release-notes.rst @@ -927,7 +927,7 @@ Here is the old changelog: * **2019.04.05**: Add stricter checking of unbalanced return statements. (`#590 `_) * **2019.03.04**: ``create_with_code_of`` has been renamed to ``create_forwarder_to``. (`#1177 `_) * **2019.02.14**: Assigning a persistent contract address can only be done using the ``bar_contact = ERC20(
)`` syntax. -* **2019.02.12**: ERC20 interface has to be imported using ``from vyper.interfaces import ERC20`` to use. +* **2019.02.12**: ERC20 interface has to be imported using ``from ethereum.ercs import ERC20`` to use. * **2019.01.30**: Byte array literals need to be annoted using ``b""``, strings are represented as `""`. * **2018.12.12**: Disallow use of ``None``, disallow use of ``del``, implemented ``clear()`` built-in function. * **2018.11.19**: Change mapping syntax to use ``map()``. (`VIP564 `_) diff --git a/examples/factory/Exchange.vy b/examples/factory/Exchange.vy index acdcfd6d4e..77f47984bc 100644 --- a/examples/factory/Exchange.vy +++ b/examples/factory/Exchange.vy @@ -1,4 +1,4 @@ -from vyper.interfaces import ERC20 +from ethereum.ercs import ERC20 interface Factory: diff --git a/examples/factory/Factory.vy b/examples/factory/Factory.vy index d08a5eb7ee..c3eec69807 100644 --- a/examples/factory/Factory.vy +++ b/examples/factory/Factory.vy @@ -1,4 +1,4 @@ -from vyper.interfaces import ERC20 +from ethereum.ercs import ERC20 interface Exchange: def token() -> ERC20: view diff --git a/examples/market_maker/on_chain_market_maker.vy b/examples/market_maker/on_chain_market_maker.vy index d385d2e0c6..4f9859584c 100644 --- a/examples/market_maker/on_chain_market_maker.vy +++ b/examples/market_maker/on_chain_market_maker.vy @@ -1,4 +1,4 @@ -from vyper.interfaces import ERC20 +from ethereum.ercs import ERC20 totalEthQty: public(uint256) diff --git a/examples/tokens/ERC1155ownable.vy b/examples/tokens/ERC1155ownable.vy index e105a79133..d1e88dcd04 100644 --- a/examples/tokens/ERC1155ownable.vy +++ b/examples/tokens/ERC1155ownable.vy @@ -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. diff --git a/examples/tokens/ERC20.vy b/examples/tokens/ERC20.vy index c3809dbb60..77550c3f5a 100644 --- a/examples/tokens/ERC20.vy +++ b/examples/tokens/ERC20.vy @@ -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 diff --git a/examples/tokens/ERC4626.vy b/examples/tokens/ERC4626.vy index 0a0a698bf0..73721fdb98 100644 --- a/examples/tokens/ERC4626.vy +++ b/examples/tokens/ERC4626.vy @@ -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 diff --git a/examples/tokens/ERC721.vy b/examples/tokens/ERC721.vy index 152b94b046..4c7f2f4358 100644 --- a/examples/tokens/ERC721.vy +++ b/examples/tokens/ERC721.vy @@ -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 diff --git a/tests/functional/codegen/calling_convention/test_external_contract_calls.py b/tests/functional/codegen/calling_convention/test_external_contract_calls.py index 0af4f9f937..a7cf4d0ecf 100644 --- a/tests/functional/codegen/calling_convention/test_external_contract_calls.py +++ b/tests/functional/codegen/calling_convention/test_external_contract_calls.py @@ -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) diff --git a/tests/functional/codegen/modules/test_stateless_functions.py b/tests/functional/codegen/modules/test_stateless_functions.py index 2abc164689..26c3f338fb 100644 --- a/tests/functional/codegen/modules/test_stateless_functions.py +++ b/tests/functional/codegen/modules/test_stateless_functions.py @@ -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 diff --git a/tests/functional/codegen/test_interfaces.py b/tests/functional/codegen/test_interfaces.py index 7d363fadc0..3344ff113b 100644 --- a/tests/functional/codegen/test_interfaces.py +++ b/tests/functional/codegen/test_interfaces.py @@ -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 @@ -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 diff --git a/tests/functional/syntax/test_functions_call.py b/tests/functional/syntax/test_functions_call.py index a1a23b6bc2..c585572c63 100644 --- a/tests/functional/syntax/test_functions_call.py +++ b/tests/functional/syntax/test_functions_call.py @@ -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 diff --git a/tests/functional/syntax/test_interfaces.py b/tests/functional/syntax/test_interfaces.py index ca96adca91..584e497534 100644 --- a/tests/functional/syntax/test_interfaces.py +++ b/tests/functional/syntax/test_interfaces.py @@ -15,7 +15,7 @@ fail_list = [ ( """ -from vyper.interfaces import ERC20 +from ethereum.ercs import ERC20 a: public(ERC20) @external def test(): @@ -25,7 +25,7 @@ def test(): ), ( """ -from vyper.interfaces import ERC20 +from ethereum.ercs import ERC20 aba: public(ERC20) @external def test(): @@ -35,7 +35,7 @@ def test(): ), ( """ -from vyper.interfaces import ERC20 +from ethereum.ercs import ERC20 a: address(ERC20) # invalid syntax now. """, @@ -43,7 +43,7 @@ def test(): ), ( """ -from vyper.interfaces import ERC20 +from ethereum.ercs import ERC20 @external def test(): @@ -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() @@ -72,7 +72,7 @@ def test(a: address): ), ( """ -from vyper.interfaces import ERC20 +from ethereum.ercs import ERC20 implements: ERC20 = 1 """, @@ -109,7 +109,7 @@ def foo(): nonpayable ), ( """ -from vyper.interfaces import ERC20 +from ethereum.ercs import ERC20 interface A: def f(): view @@ -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 @@ -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 @@ -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 @@ -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) @@ -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 @@ -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 @@ -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(): diff --git a/vyper/semantics/analysis/module.py b/vyper/semantics/analysis/module.py index 100819526b..a83c2f3b7d 100644 --- a/vyper/semantics/analysis/module.py +++ b/vyper/semantics/analysis/module.py @@ -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): @@ -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") From 84341931ca578467e4aa93b0c20b4e36257a7f9a Mon Sep 17 00:00:00 2001 From: ControlCplusControlV <44706811+ControlCplusControlV@users.noreply.github.com> Date: Tue, 30 Jan 2024 10:19:40 -0700 Subject: [PATCH 2/2] oops --- docs/release-notes.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/release-notes.rst b/docs/release-notes.rst index 7de4130757..3db11dc451 100644 --- a/docs/release-notes.rst +++ b/docs/release-notes.rst @@ -927,7 +927,7 @@ Here is the old changelog: * **2019.04.05**: Add stricter checking of unbalanced return statements. (`#590 `_) * **2019.03.04**: ``create_with_code_of`` has been renamed to ``create_forwarder_to``. (`#1177 `_) * **2019.02.14**: Assigning a persistent contract address can only be done using the ``bar_contact = ERC20(
)`` syntax. -* **2019.02.12**: ERC20 interface has to be imported using ``from ethereum.ercs import ERC20`` to use. +* **2019.02.12**: ERC20 interface has to be imported using ``from vyper.interfaces import ERC20`` to use. * **2019.01.30**: Byte array literals need to be annoted using ``b""``, strings are represented as `""`. * **2018.12.12**: Disallow use of ``None``, disallow use of ``del``, implemented ``clear()`` built-in function. * **2018.11.19**: Change mapping syntax to use ``map()``. (`VIP564 `_)