-
-
Notifications
You must be signed in to change notification settings - Fork 803
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
VIP: remove reduntand syntax for address to contract #748
Comments
I like version 1 best. I think it's still intuitive for the use case in version 2, i.e. the input arg is an address type that is assumed to be a contract that implements the I think we should summarize this as interfaces instead of contracts. |
Related issue: modifiable/static attributes are currently not applied for syntax 2/3. Only for 1. |
I still wish |
As discussed, we are going with option 1. |
I will create a separate VIP to address my last comment "denote static call per method in contract interface definition" |
Starting work on this, the syntax will be as follows: Stored contracts defined as: bar_contract: modifiable(Bar)
token: modifiable(ERC20) Stored contract assigned as: def foo(contract_address: address) -> int128:
self.bar_contract.address = contract_address And on demand contract remain the same: return Foo(arg1).foo() |
Can I know the relationship between ERC20 and address type? I am confused about it. I have a storage: initilize with an address: contract Factory: assert self.factory.getExchange(self.token) == self We I can getExchange and got this error: vyper.exceptions.TypeMismatchException: Typecasting from base type address(ERC20) to address unavailable |
This is the suggested template for new VIPs.
Preamble
Simple Summary
There are at least 3 syntaxes for defining an address to a contract. Only one should be allowed for uniformity.
Motivation
Syntax redundancies should be eliminated to simplify the language and avoid confusion.
Specification
Right now there are at least 3 syntaxes to define an address to a contract:
For storage variables: https://github.com/ethereum/vyper/blob/5b70797a31ffcbdd90b1dfd98f7b38d306bca7a0/tests/parser/features/external_contracts/test_external_contract_calls.py#L390
For function parameters: https://github.com/ethereum/vyper/blob/5b70797a31ffcbdd90b1dfd98f7b38d306bca7a0/tests/parser/features/external_contracts/test_external_contract_calls.py#L393
For hardcoded
ERC20
contract: https://github.com/ethereum/vyper/blob/5b70797a31ffcbdd90b1dfd98f7b38d306bca7a0/tests/parser/features/external_contracts/test_erc20_abi.py#L20There's another aspect to consider. The syntax of casting to contract address: https://github.com/ethereum/vyper/blob/9eebb7c575545fcf880d815b9c888665dccbea51/tests/parser/features/external_contracts/test_external_contract_calls.py#L19
The option most coherent syntax of casting is 1:
bar_contract: Bar
. However option 3 looks best in isolation:bar_contract: address(Bar)
. So I suggest either keeping option 1, or adopting option 3, but changing the syntax of casting to something else. Is it possible to haveaddress(Bar)(bar_contract).foo()
?Backwards Compatibility
Versions no longer allowed will be replaced.
Copyright
Copyright and related rights waived via CC0
The text was updated successfully, but these errors were encountered: