From 7ba595a6216f73a74ce2e142adee120f148b507d Mon Sep 17 00:00:00 2001 From: Alex <49351943+afagella@users.noreply.github.com> Date: Tue, 1 Oct 2019 16:09:12 -0400 Subject: [PATCH] Update DigitalSecretary.sol MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Line 318: add changeFee functionality, sets cost of payable change functions for entities Line 320: update mapping to store entities by ETH address instead of uint256 filing number Line 325: add ETH address to Entity structure Line 336: add annualFee functionality to track if entity paid annual fee Line 367: add changeFee to constructor Line 391: address of entity is msg.sender Line 396: annualFee bool defaults “false” until annual fee is paid with function “payAnnualFee” Line 400, 412: add ETH address and annualFee bool to structure Line 439, 446, 453, 459, 467, 474, 478: add payable to change functions, change functions charge “changeFee”, “msg.sender” can only make changes to “msg.sender” entity --- DigitalSecretary.sol | 56 ++++++++++++++++++++++++++++++-------------- 1 file changed, 39 insertions(+), 17 deletions(-) diff --git a/DigitalSecretary.sol b/DigitalSecretary.sol index e4c6387..ff6acb2 100644 --- a/DigitalSecretary.sol +++ b/DigitalSecretary.sol @@ -315,12 +315,14 @@ contract DigitalSecretary is SecretaryRole { address public feeTokenAddress; // fee token address for paying filing and other administration fees / default testnet: "0x8ad3aa5d5ff084307d28c8f514d7a193b2bfe725" address public secretary; // administrator of digital secretary contract address public treasuryAddress; // receives filing and other administrative fees generated by digital secretary + uint256 public changeFee; // fee charged for any changes - mapping (uint256 => Entity) public entities; // mapping registered entities to filing numbers + mapping (address => Entity) public entities; // mapping registered entities to filing numbers event entityRegistered(uint256 fileNumber, uint256 filingDate, string entityName, uint8 entityKind, bool domestic); struct Entity { + address _address; // eth address of organization uint256 fileNumber; // latest successful registration function call uint256 filingDate; // blocktime of successful registration function call string entityName; // Full Legal Name / e.g., "ACME LLC" @@ -331,6 +333,7 @@ contract DigitalSecretary is SecretaryRole { string filingDetails; // could be IPFS hash, plaintext, or JSON detailing articles or certificate of incorporation uint256 feesPaid; // running tally of fees paid to digital secretary by registered entity bool goodStanding; // default "true" on successful registration function call + bool annualFee; // default "false" turns "true" when entity pays annual filing fee } // compare: Delaware resource: https://icis.corp.delaware.gov/Ecorp/FieldDesc.aspx#ENTITY%20TYPE @@ -361,11 +364,12 @@ contract DigitalSecretary is SecretaryRole { /** * @dev Sets the initial values for `filingFeeAmount`, `feeTokenAddress`, `treasuryAddress`. */ - constructor (uint256 _filingFeeAmount, address _feeTokenAddress, address _treasuryAddress) public { + constructor (uint256 _filingFeeAmount, address _feeTokenAddress, address _treasuryAddress, uint256 _changeFee) public { filingFeeAmount = _filingFeeAmount; feeTokenAddress = _feeTokenAddress; secretary = msg.sender; treasuryAddress = _treasuryAddress; + changeFee = _changeFee; } // public function to register entity with digital secretary @@ -384,14 +388,17 @@ contract DigitalSecretary is SecretaryRole { Kind(entityKind); Type(entityType); + address _address = msg.sender; uint256 fileNumber = entityFilings.add(1); // tallies from running total uint256 filingDate = block.timestamp; // "now" uint256 feesPaid = filingFeeAmount; // pushes fee amount to entity tally bool goodStanding = true; // default value for new entity + bool annualFee = false; // default value for new entity, can be updated with function "annualFee" entityFilings = entityFilings.add(1); // tallies new filing to running total - entities[fileNumber] = Entity( + entities[_address] = Entity( + _address, fileNumber, filingDate, entityName, @@ -401,7 +408,8 @@ contract DigitalSecretary is SecretaryRole { registeredAgentdetails, filingDetails, feesPaid, - goodStanding); + goodStanding, + annualFee); emit entityRegistered(fileNumber, filingDate, entityName, entityKind, domestic); } @@ -428,38 +436,52 @@ contract DigitalSecretary is SecretaryRole { ENTITY MGMT ***************/ // digital secretary can update entity name - function updateEntityName(uint256 fileNumber, string memory newName) public onlySecretary { - Entity storage entity = entities[fileNumber]; + function updateEntityName(string memory newName) public payable { + require(msg.value == changeFee); + Entity storage entity = entities[msg.sender]; entity.entityName = newName; } // digital secretary can update registered agent details - function updateRegisteredAgent(uint256 fileNumber, string memory registeredAgentdetails) public onlySecretary { - Entity storage entity = entities[fileNumber]; + function updateRegisteredAgent(string memory registeredAgentdetails) public payable { + require(msg.value == changeFee); + Entity storage entity = entities[msg.sender]; entity.registeredAgentdetails = registeredAgentdetails; } // digital secretary can convert entity kind - function convertEntityKind(uint256 fileNumber, uint8 newKind) public onlySecretary { - Entity storage entity = entities[fileNumber]; + function convertEntityKind(uint8 newKind) public payable { + require(msg.value == changeFee); + Entity storage entity = entities[msg.sender]; entity.entityKind = newKind; } - // digital secretary can convert entity type - function convertEntityType(uint256 fileNumber, uint8 newType) public onlySecretary { - Entity storage entity = entities[fileNumber]; + // digital secretary can convert entity type + function convertEntityType(uint8 newType) public payable { + require(msg.value == changeFee); + Entity storage entity = entities[msg.sender]; entity.entityType = newType; } // digital secretary can convert entity domicile - function convertEntityDomicile(uint256 fileNumber, bool domestic) public onlySecretary { - Entity storage entity = entities[fileNumber]; + function convertEntityDomicile(bool domestic) public payable { + require(msg.value == changeFee); + Entity storage entity = entities[msg.sender]; entity.domestic = domestic; } // digital secretary can convert entity standing - function convertEntityStanding(uint256 fileNumber, bool goodStanding) public onlySecretary { - Entity storage entity = entities[fileNumber]; + function convertEntityStanding(address entityAddress, bool goodStanding) public onlySecretary { + Entity storage entity = entities[entityAddress]; entity.goodStanding = goodStanding; } + + // pay filing fee and update annualFee + function payAnnualFee() public payable { + require(msg.value == filingFeeAmount); + Entity storage entity = entities[msg.sender]; + entity.annualFee == true; + } } + +