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.

switch param order of resolveCow, prepend did:

+12 -12
+7 -6
cli/cow.py
··· 180 180 w3 = _w3() 181 181 contract = _contract(w3) 182 182 183 - controller, wrapped_did = contract.functions.resolveCow( 183 + wrapped_did, controller = contract.functions.resolveCow( 184 184 _controller_address(controller_hex), 185 185 initial_wrapped, 186 186 ).call() 187 187 188 - if wrapped_did == ":": 188 + if wrapped_did == "did::": 189 189 click.echo("status: deactivated") 190 190 return 191 191 192 - on_chain = wrapped_did != initial_wrapped or controller != _controller_address(controller_hex) 192 + initial_full = f"did:{initial_wrapped}" 193 + on_chain = wrapped_did != initial_full or controller != _controller_address(controller_hex) 193 194 if not on_chain: 194 195 click.echo("status: not yet registered on-chain") 195 - click.echo(f"wrapped: did:{wrapped_did} (from DID)") 196 + click.echo(f"wrapped: {wrapped_did} (from DID)") 196 197 click.echo(f"controller: {controller} (initial)") 197 198 else: 198 199 click.echo("status: active") 199 - click.echo(f"wrapped: did:{wrapped_did}") 200 + click.echo(f"wrapped: {wrapped_did}") 200 201 click.echo(f"controller: {controller}") 201 202 202 - current_wrapped = wrapped_did 203 + current_wrapped = _strip_did_prefix(wrapped_did) 203 204 204 205 if not no_doc: 205 206 click.echo("")
+5 -6
src/CowRegistry.sol
··· 94 94 return cowHash; 95 95 } 96 96 97 - /// @notice Resolve a did:cow identifier to its current controller and wrapped DID. 97 + /// @notice Resolve a did:cow identifier to its current wrapped DID and controller. 98 98 /// @dev Returns the initial values if the cow has never been registered on-chain. 99 - /// Prepend "did:" to the returned wrappedDID to form the full wrapped DID string. 100 99 /// @param _controller The initial controller address from the did:cow identifier. 101 100 /// @param _wrappedDID The initial wrapped DID from the did:cow identifier, without "did:". 101 + /// @return wrappedDID The current full wrapped DID (with "did:" prepended), or "did::" if deactivated. 102 102 /// @return controller The current controller address. 103 - /// @return wrappedDID The current wrapped DID (without "did:"), or ":" if deactivated. 104 - function resolveCow(address _controller, string memory _wrappedDID) external view returns (address controller, string memory wrappedDID) { 103 + function resolveCow(address _controller, string memory _wrappedDID) external view returns (string memory wrappedDID, address controller) { 105 104 bytes32 cowHash = calculateCowHash(_controller, _wrappedDID); 106 105 Cow storage cow = cows[cowHash]; 107 106 if (bytes(cow.wrappedDID).length == 0) { 108 - return (_controller, _wrappedDID); 107 + return (string.concat("did:", _wrappedDID), _controller); 109 108 } 110 - return (cow.controller, cow.wrappedDID); 109 + return (string.concat("did:", cow.wrappedDID), cow.controller); 111 110 } 112 111 113 112 /// @notice Optionally pre-register a cow on-chain before its first update.