From fe609dc19d5e451ac5f60a0071fa180eb34f98b5 Mon Sep 17 00:00:00 2001 From: Alberto Date: Tue, 5 Nov 2024 19:10:20 +0100 Subject: [PATCH 1/4] merge interfaces --- vyper/builtins/interfaces/IERC20.vyi | 19 +++++++++++++++++++ vyper/builtins/interfaces/IERC20Detailed.vyi | 18 ------------------ 2 files changed, 19 insertions(+), 18 deletions(-) delete mode 100644 vyper/builtins/interfaces/IERC20Detailed.vyi diff --git a/vyper/builtins/interfaces/IERC20.vyi b/vyper/builtins/interfaces/IERC20.vyi index 3f150d13e8..010b29ab08 100644 --- a/vyper/builtins/interfaces/IERC20.vyi +++ b/vyper/builtins/interfaces/IERC20.vyi @@ -36,3 +36,22 @@ def transferFrom(_from: address, _to: address, _value: uint256) -> bool: @external def approve(_spender: address, _value: uint256) -> bool: ... + +#NOTE: interface uses `String[1]` where 1 is the lower bound of the string returned by the function. +# For end-users this means they can't use `implements: ERC20Detailed` unless their implementation +# uses a value n >= 1. Regardless this is fine as one can't do String[0] where n == 0. + +@view +@external +def name() -> String[1]: + ... + +@view +@external +def symbol() -> String[1]: + ... + +@view +@external +def decimals() -> uint8: + ... diff --git a/vyper/builtins/interfaces/IERC20Detailed.vyi b/vyper/builtins/interfaces/IERC20Detailed.vyi deleted file mode 100644 index 0be1c6f153..0000000000 --- a/vyper/builtins/interfaces/IERC20Detailed.vyi +++ /dev/null @@ -1,18 +0,0 @@ -#NOTE: interface uses `String[1]` where 1 is the lower bound of the string returned by the function. -# For end-users this means they can't use `implements: ERC20Detailed` unless their implementation -# uses a value n >= 1. Regardless this is fine as one can't do String[0] where n == 0. - -@view -@external -def name() -> String[1]: - ... - -@view -@external -def symbol() -> String[1]: - ... - -@view -@external -def decimals() -> uint8: - ... From b9753841bd6eac200458aeadc5a00f9385727dd8 Mon Sep 17 00:00:00 2001 From: Alberto Date: Tue, 5 Nov 2024 19:34:16 +0100 Subject: [PATCH 2/4] Revert "merge interfaces" This reverts commit fe609dc19d5e451ac5f60a0071fa180eb34f98b5. --- vyper/builtins/interfaces/IERC20.vyi | 19 ------------------- vyper/builtins/interfaces/IERC20Detailed.vyi | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 19 deletions(-) create mode 100644 vyper/builtins/interfaces/IERC20Detailed.vyi diff --git a/vyper/builtins/interfaces/IERC20.vyi b/vyper/builtins/interfaces/IERC20.vyi index 010b29ab08..3f150d13e8 100644 --- a/vyper/builtins/interfaces/IERC20.vyi +++ b/vyper/builtins/interfaces/IERC20.vyi @@ -36,22 +36,3 @@ def transferFrom(_from: address, _to: address, _value: uint256) -> bool: @external def approve(_spender: address, _value: uint256) -> bool: ... - -#NOTE: interface uses `String[1]` where 1 is the lower bound of the string returned by the function. -# For end-users this means they can't use `implements: ERC20Detailed` unless their implementation -# uses a value n >= 1. Regardless this is fine as one can't do String[0] where n == 0. - -@view -@external -def name() -> String[1]: - ... - -@view -@external -def symbol() -> String[1]: - ... - -@view -@external -def decimals() -> uint8: - ... diff --git a/vyper/builtins/interfaces/IERC20Detailed.vyi b/vyper/builtins/interfaces/IERC20Detailed.vyi new file mode 100644 index 0000000000..0be1c6f153 --- /dev/null +++ b/vyper/builtins/interfaces/IERC20Detailed.vyi @@ -0,0 +1,18 @@ +#NOTE: interface uses `String[1]` where 1 is the lower bound of the string returned by the function. +# For end-users this means they can't use `implements: ERC20Detailed` unless their implementation +# uses a value n >= 1. Regardless this is fine as one can't do String[0] where n == 0. + +@view +@external +def name() -> String[1]: + ... + +@view +@external +def symbol() -> String[1]: + ... + +@view +@external +def decimals() -> uint8: + ... From e1c2ac051fe54003e994ac063bac0b52f65eb205 Mon Sep 17 00:00:00 2001 From: Alberto Date: Tue, 5 Nov 2024 19:36:50 +0100 Subject: [PATCH 3/4] add ERC20 to ERC20Detailed --- vyper/builtins/interfaces/IERC20Detailed.vyi | 43 ++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/vyper/builtins/interfaces/IERC20Detailed.vyi b/vyper/builtins/interfaces/IERC20Detailed.vyi index 0be1c6f153..63750aea82 100644 --- a/vyper/builtins/interfaces/IERC20Detailed.vyi +++ b/vyper/builtins/interfaces/IERC20Detailed.vyi @@ -16,3 +16,46 @@ def symbol() -> String[1]: @external def decimals() -> uint8: ... + +import IERC20 + +implements: IERC20 + +# Events +event Transfer: + sender: indexed(address) + receiver: indexed(address) + value: uint256 + +event Approval: + owner: indexed(address) + spender: indexed(address) + value: uint256 + +# Functions +@view +@external +def totalSupply() -> uint256: + ... + +@view +@external +def balanceOf(_owner: address) -> uint256: + ... + +@view +@external +def allowance(_owner: address, _spender: address) -> uint256: + ... + +@external +def transfer(_to: address, _value: uint256) -> bool: + ... + +@external +def transferFrom(_from: address, _to: address, _value: uint256) -> bool: + ... + +@external +def approve(_spender: address, _value: uint256) -> bool: + ... From 675083d591b65e81df48e59cb642bee32865be98 Mon Sep 17 00:00:00 2001 From: Alberto Date: Tue, 5 Nov 2024 19:48:27 +0100 Subject: [PATCH 4/4] fix --- vyper/builtins/interfaces/IERC20Detailed.vyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vyper/builtins/interfaces/IERC20Detailed.vyi b/vyper/builtins/interfaces/IERC20Detailed.vyi index 63750aea82..7d20b99fa9 100644 --- a/vyper/builtins/interfaces/IERC20Detailed.vyi +++ b/vyper/builtins/interfaces/IERC20Detailed.vyi @@ -17,7 +17,7 @@ def symbol() -> String[1]: def decimals() -> uint8: ... -import IERC20 +from ethereum.ercs import IERC20 implements: IERC20