Last active
May 11, 2020 18:57
-
-
Save mariano-aguero/2e7607293263d53dba6041f7f1e50ed4 to your computer and use it in GitHub Desktop.
Ownership mechanism
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type action is AddOwner of (address) | |
// An unordered collections of owner accounts | |
type store is record | |
owners: set(address); | |
end | |
type return is list(operation) * store | |
// Function that checks if an account is an owner | |
// Must be integrated into functions that can only be used by an owner | |
function isOwner (const addressOwner : address; var store : store) : bool is store.owners contains addressOwner; | |
// Function that add an owner to the unordered collections of owners in the storage | |
function addOwner (const newOwnerAddress : address; var store : store) : return is | |
block { | |
const newOwners : set(address) = Set.add(newOwnerAddress, store.owners) | |
} with ((nil : list (operation)), store with record [owners = newOwners;]); | |
function main (const action: action; var store: store): return is | |
block { | |
skip | |
} with case action of | |
AddOwner(n) -> addOwner(n, store) | |
end; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment