did:cow, a proposal for an ID resolution method with most of the convenience of did:plc/did:web and the robustness of a public blockchain
3
fork

Configure Feed

Select the types of activity you want to include in your feed.

make deactivate syntax like the other upates

+19 -14
+2 -1
README.md
··· 175 175 - `updateWrappedDIDByHash(cowHash, newWrappedDID)` — update wrapped DID by pre-computed hash 176 176 - `updateController(controller, wrappedDID, newController)` — transfer control, registering if needed 177 177 - `updateControllerByHash(cowHash, newController)` — transfer control by pre-computed hash 178 - - `deactivate(cowHash)` — permanently deactivate 178 + - `deactivate(controller, wrappedDID)` — permanently deactivate, registering if needed 179 + - `deactivateByHash(cowHash)` — permanently deactivate by pre-computed hash 179 180 180 181 **CLI tool (`cli/cow.py`):** 181 182 - `resolve <did>` — resolve to current state and fetch wrapped DID document
+2 -4
cli/cow.py
··· 272 272 contract = _contract(w3) 273 273 account = _account(w3) 274 274 275 - cow_hash = contract.functions.calculateCowHash( 275 + tx = contract.functions.deactivate( 276 276 _controller_address(controller_hex), 277 277 initial_wrapped, 278 - ).call() 279 - 280 - tx = contract.functions.deactivate(cow_hash).build_transaction({"from": account.address}) 278 + ).build_transaction({"from": account.address}) 281 279 282 280 _send(w3, account, tx) 283 281 click.echo("deactivated.")
+12 -7
src/CowRegistry.sol
··· 32 32 emit ControllerUpdated(_cowHash, _controller); 33 33 } 34 34 35 + function deactivateByHash(bytes32 _cowHash) public { 36 + require(msg.sender == cows[_cowHash].controller); 37 + 38 + cows[_cowHash].wrappedDID = DEACTIVATED; 39 + cows[_cowHash].controller = address(0); 40 + 41 + emit CowDeactivated(_cowHash); 42 + } 43 + 35 44 function calculateCowHash(address _controller, string memory _wrappedDID) public pure returns (bytes32) { 36 45 return keccak256(abi.encodePacked(_controller, _wrappedDID)); 37 46 } ··· 70 79 updateControllerByHash(cowHash, _newController); 71 80 } 72 81 73 - function deactivate(bytes32 _cowHash) external { 74 - require(msg.sender == cows[_cowHash].controller); 75 - 76 - cows[_cowHash].wrappedDID = DEACTIVATED; 77 - cows[_cowHash].controller = address(0); 78 - 79 - emit CowDeactivated(_cowHash); 82 + function deactivate(address _controller, string memory _wrappedDID) external { 83 + bytes32 cowHash = _ensureCowInitialized(_controller, _wrappedDID); 84 + deactivateByHash(cowHash); 80 85 } 81 86 }
+3 -2
test/CowRegistry.t.sol
··· 294 294 } 295 295 296 296 function test_updateWrappedDID_rejectsAfterDeactivation() public { 297 - bytes32 cowHash = _init(controller1, plcDID1); 297 + _init(controller1, plcDID1); 298 298 299 299 vm.prank(controller1); 300 - registry.deactivate(cowHash); 300 + registry.deactivate(controller1, plcDID1); 301 301 302 + bytes32 cowHash = registry.calculateCowHash(controller1, plcDID1); 302 303 vm.prank(controller1); 303 304 vm.expectRevert(); 304 305 registry.updateWrappedDIDByHash(cowHash, plcDID2);