xmtp / didethresolver

XMTP Registry Resolver
MIT License
3 stars 1 forks source link

add resolveDid #6

Closed insipx closed 9 months ago

insipx commented 10 months ago

closes #4

Not implementing for this PR

related to roadmap#23

Example

Run against Sepolia with RUST_LOG=didethresolver=debug ./target/release/didethresolver -p "wss://ethereum-sepolia.publicnode.com"

example query: ❯ curl -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "did_resolveDid", "params": ["0x423B6F365C14F4b233928088FF937e01c143A328"]}' http://localhost:9944

Pretty print the result: ❯ curl -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "did_resolveDid", "params": ["0x423B6F365C14F4b233928088FF937e01c143A328"]}' http://localhost:9944 | jq .result

insipx commented 10 months ago

This looks like a pretty good start! I hit a few snags because the tests dont appear to build and there are a few warnings outstanding.

This project may be helpful: https://github.com/OwnYourData/didlint

It appears there is a network api as well.

thanks! Definitely cleanup to do and still working on generating the actual did document from the did history. There is a network endpoint, did_resolveDid that can be called:

curl -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "did_resolveDid", "params": ["0x6CEb0bF1f28ca4165d5C0A04f61DC733987eD6ad"]}' http://localhost:9944/ | jq .result

After starting with cargo run --release -- p "wss://ethereum-spolia.publicnode.com" (need to change to env variables)

but currently only returns a stub did document until wrap_did_document is finished, although it does log the event history if you run the server with RUST_LOG=didethresolver=debug.

The tests don't build because i haven't updated the with_client harness yet. It requires starting a eth server now which can be done in-code with Foundry, but maybe should be moved to integration tests. While I get the first iteration of wrap_did_document finished i'm just testing against the already-deployed sepolia contract and server

I'll also make sure to test everything with did-lint. In the future, it would be nice to have did-lint run automatically on CI push against Sepolia to verify our documents

insipx commented 9 months ago

This could use some more tests, but overall I feel like it's in a pretty good place. I'll create a ticket for the cases I'd like to create tests for

codecov-commenter commented 9 months ago

Codecov Report

Attention: 97 lines in your changes are missing coverage. Please review.

Comparison is base (ed3cedb) 91.37% compared to head (19d0af0) 91.62%.

Files Patch % Lines
src/types/ethr.rs 95.00% 25 Missing :warning:
src/lib.rs 0.00% 15 Missing :warning:
src/types.rs 87.50% 15 Missing :warning:
src/types/did_url.rs 91.30% 12 Missing :warning:
src/rpc/methods.rs 54.54% 10 Missing :warning:
src/util.rs 40.00% 6 Missing :warning:
src/types/did_parser.rs 98.10% 5 Missing :warning:
src/resolver/did_registry.rs 80.00% 4 Missing :warning:
src/main.rs 0.00% 3 Missing :warning:
src/resolver.rs 97.50% 2 Missing :warning:

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #6 +/- ## ========================================== + Coverage 91.37% 91.62% +0.24% ========================================== Files 5 11 +6 Lines 58 1182 +1124 ========================================== + Hits 53 1083 +1030 - Misses 5 99 +94 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.