Guest User

Untitled

a guest
Apr 23rd, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.93 KB | None | 0 0
  1. pragma solidity ^0.4.13;
  2.  
  3. /*
  4. WiltonEcosystemServicesAuthority is the governing contract for EcosystemServicesDAO. It holds two important pieces of data--
  5. the NaturalCapitalCSR, which is the crypto-spatial registry contract for all NaturalCapitalAnchors, and the user membership
  6. list, which keeps track of all of the registered users of the DAO. It has the sole authority to extend these
  7. two registries.
  8. */
  9.  
  10. import "zeppelin-solidity/contracts/ownership/Ownable.sol";
  11.  
  12. import "./EcosystemServicesAnchor.sol";
  13. import "./FoamCSR.sol";
  14. import "./User.sol";
  15.  
  16. contract WiltonEcosystemServicesAuthority is Ownable {
  17.  
  18. FoamCSR public parkingCSR;
  19. mapping(address => bool) public anchors;
  20. mapping(address => bool) public users;
  21.  
  22. event RegisteredWiltonEcosystemServicesAnchor(address owner, address anchor, bytes8 geohash, bytes32 anchorId);
  23. event RegisteredWiltonEcosystemServicesUser(address owner, address user);
  24.  
  25. // Decide whether or not to give the user EcosystemServices access to the zone. Mocked for now.
  26. modifier shouldGiveAccess(bytes4 _zone) {
  27. _;
  28. }
  29.  
  30. modifier callerIsUser() {
  31. require(users[msg.sender]);
  32. _;
  33. }
  34.  
  35. // Deploy a new WiltonEcosystemServices authority.
  36. function EcosystemServicesAuthority(FoamCSR foamCSR) public Ownable() {
  37. EcosystemServicesCSR = foamCSR;
  38. }
  39.  
  40. // A function user to verify a WiltonEcosystemServicesAnchor, currently mocked.
  41. function validateParkingAnchor(bytes8 /* _geohash */, bytes32 /* _anchorId */) internal pure returns(bool) {
  42. return true;
  43. }
  44.  
  45. // Deploy a WiltonEcosystemServicesAnchor at the given geohash with the given anchorId. Transfer ownership of the
  46. // anchor to the sender of the transaction.
  47. function registerEcosystemServicesAnchor(bytes8 _geohash, bytes32 _anchorId) public {
  48. require(validateEcosystemServicesAnchor(_geohash, _anchorId));
  49. EcosystemServicesAnchor anchor = new EcosystemServicesAnchor(_geohash, _anchorId);
  50. EcosystemServicesCSR.register(anchor);
  51. anchors[address(anchor)] = true;
  52. RegisteredEcosystemServicesAnchor(msg.sender, address(anchor), _geohash, _anchorId);
  53. anchor.transferOwnership(msg.sender);
  54. }
  55.  
  56. function validateUserApplication(address /* _applicant */) internal pure returns(bool) {
  57. return true;
  58. }
  59.  
  60. // Create a new user and transer ownership of the account to the message sender.
  61. function registerUser() public {
  62. require(validateUserApplication(msg.sender));
  63. User newUser = new User();
  64. newUser.transferOwnership(msg.sender);
  65. users[address(newUser)] = true;
  66. RegisterEcosystemServicesUser(msg.sender, address(newUser));
  67. }
  68.  
  69. // This function is called by a user when they want to add a zone to their listed of
  70. // licensed zones.
  71. function addZone(bytes4 _zone) public shouldGiveAccess(_zone) callerIsUser() {
  72. User user = User(msg.sender);
  73. user.addZone(_zone);
  74. }
Add Comment
Please, Sign In to add comment