Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions development/software-requirements/dns-example.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,41 @@ contract DNS {
}
```
{% endcode-tabs-item %}
{% code-tabs-item title="DNS.vy" %}
```python
"""
@title DNS Registrar
"""

# Store the owner of a particular domain
domainOwner: public(map(string[40], address))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't you need @imp for all the fields?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep... haha

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, the original example doesn't have it either? Might be an internal-only thing or a missing requirement

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be a note in a comment if its an internal-only thing, or maybe something like @imp internal

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, sometimes we called such things "derived requirements" if they're an implementation detail that doesn't directly link to an upstream requirement but helps implement one in practice.

Do all public getters need a requirement?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check out Line 20

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, idk, I've never done requirement before lol. But it seems logical that all public things need to be tied to requirements. And I guess private functions are implementation details and don't really matter.

Unless you start changing a private function and it affects a bunch of public methods - then you need to go over all of them...


# Store the resolution of a particular domain
# @imp fffc `public` provides access method for domain resolver
domainResolution: public(mapping(string => address))

@public
def setDomainResolution(
_domain: string[40],
_resolution: address,
):
"""
@title setDomainResolution Allows user to set resolution for address
@param _domain Domain name as ASCII string
@param _resolution Address domain will resolve to
"""
# @imp c84d Check if name has been previously registered
if (self.domainOwner[_domain] != ZERO_ADDRESS):
# @imp 35a4 Reject if domain has been registered to another user
assert self.domainOwner[_domain] == msg.sender
else: # domain owner is unset for this domain
# @imp c84d Keep track of newly registered domain
self.domainOwner[_domain] = msg.sender

# @imp c84d Allow user to set resolution for newly registered domain
# @imp e532 Allow user to change resolution for a domain they own
self.domainResolution[_domain] = _resolution
```
{% endcode-tabs-item %}
{% endcode-tabs %}