-
-
Notifications
You must be signed in to change notification settings - Fork 804
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: Custom Storage Types #1954
Comments
Meeting notes: Come back to this when it's more concrete. |
Right now the thinking is if a contract has storage variables in it, then it's one of these (storage variables + methods on them), otherwise it's a stateless "library" as in #2431. Unclear if there should be syntactic difference from a regular contract. |
One question is: should components be instantiable in memory? Or can they have HashMaps as members. |
In Solidity, it is possible to define a struct with a mapping as a member, however it implicitly precludes it from being used as a memory variable, which is weird. |
i ported an example solidity contract (https://github.com/tellor-io/TellorPlayground/blob/575cfc565c9526df1320d3389fcb015bc86d1107/contracts/TellorPlayground.sol#L224-L279) to play around with this idea. so far, the encapsulation looks good, but it might be more natural if the "component" could access the parent contract's methods. compare methods |
Simple Summary
Allow logical components of a program to be specified separately from a main contract file
Motivation
It is very important to larger contracts to be able to break apart functionality from the main file for logical separation. This means we have to find an appropriate way to allow to break out logical functionality that has a high degree of separation. This could also simplify the implementation of several proposed features such as #484 and #1020 by making them internal library components.
Specification
A Component is defined very similarly to a contract, with certain features disallowed:
Examples
Constructor methods are defined using
__init__(self, *args)
:Components can have internal storage:
Components can use environment variables:
Usage
A Component can be imported into a contract file similar to an interface:
It is defined similar to Python objects, and must be instantiated:
Their implementation would be similar to structs, but with the addition of methods as struct members. They can be used in the same way as structs:
Backwards Compatibility
No backwards incompatibilities.
Dependencies
No dependencies.
References
https://diligence.consensys.net/blog/2020/05/an-experiment-in-designing-a-new-smart-contract-language/
Copyright
Copyright and related rights waived via CC0
The text was updated successfully, but these errors were encountered: