diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml
index 89d8ef3..26dfcb2 100644
--- a/.github/workflows/coverage.yml
+++ b/.github/workflows/coverage.yml
@@ -20,6 +20,6 @@ jobs:
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
- token: ${{ secrets.CODECOV_TOKEN }}
+ token: ${{ secrets.CODECOV_TOKEN }}
files: lcov.info
fail_ci_if_error: true
diff --git a/.github/workflows/ghcr-image.yml b/.github/workflows/ghcr-image.yml
index d95cc2d..2f4ba8c 100644
--- a/.github/workflows/ghcr-image.yml
+++ b/.github/workflows/ghcr-image.yml
@@ -1,41 +1,32 @@
name: Docker Image Build Push
-
on:
push:
tags:
- "*"
-
concurrency:
group: "docker-image"
cancel-in-progress: true
-
jobs:
build:
runs-on: ubuntu-latest
steps:
- -
- name: Checkout
+ - name: Checkout
uses: actions/checkout@v3
- -
- name: Set up QEMU
+ - name: Set up QEMU
uses: docker/setup-qemu-action@v2
- -
- name: Set up Docker Buildx
+ - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
- name: Generate repository name
run: |
echo "REPOSITORY_PATH=$( echo ${GITHUB_REPOSITORY} | tr '[:upper:]' '[:lower:]' )" >> ${GITHUB_ENV}
echo "REPOSITORY_SHA=$( echo ${GITHUB_SHA} | cut -c 1-8 )" >> ${GITHUB_ENV}
- -
- name: Login to GitHub Container Registry
+ - name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- -
- name: Build and Push
+ - name: Build and Push
uses: docker/build-push-action@v3
with:
context: .
@@ -49,8 +40,7 @@ jobs:
ghcr.io/${{ env.REPOSITORY_PATH }}:v${{ github.ref_name }}
ghcr.io/${{ env.REPOSITORY_PATH }}:${{ env.REPOSITORY_SHA }}
ghcr.io/${{ env.REPOSITORY_PATH }}:latest
- -
- name: GitHub Release
+ - name: GitHub Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff --git a/.github/workflows/github-pages.yml b/.github/workflows/github-pages.yml
index c245849..69b12d5 100644
--- a/.github/workflows/github-pages.yml
+++ b/.github/workflows/github-pages.yml
@@ -37,15 +37,19 @@ jobs:
env:
CARGO_INCREMENTAL: 0
run: |
- cargo test --workspace --all-features --tests tests
+ cargo test -p lib-didethresolver --all-features --tests tests
id: test
- name: Invoke cargo doc
run: |
rm -rf ./_site
- cargo doc --workspace --no-deps
+ RUSTDOCFLAGS="-D warnings" cargo doc --workspace --all-features --no-deps
rm -f target/doc/.lock
cp -r target/doc _site
- echo "" > _site/index.html
+ if [ ! -d _site/lib_didethresolver ]; then
+ echo "Error: _site/lib_didethresolver does not exist"
+ exit 1
+ fi
+ echo "" > _site/index.html
echo "Taking care of pedantic permissions requirements required by GitHub Pages"
chmod -R +rX _site
id: docgen
diff --git a/.github/workflows/prod-ci-image.yml b/.github/workflows/prod-ci-image.yml
index e838484..d3b2d4a 100644
--- a/.github/workflows/prod-ci-image.yml
+++ b/.github/workflows/prod-ci-image.yml
@@ -21,7 +21,7 @@ jobs:
uses: docker/build-push-action@v3
with:
context: .
- file: prod/Dockerfile
+ file: prod/Dockerfile
platforms: linux/amd64
push: false
build-args: |
diff --git a/.vscode/launch.json b/.vscode/launch.json
index f4719eb..4bcaa7e 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -29,7 +29,6 @@
"cargo": {
"args": [
"build",
- "--bin=resolver",
"--package=resolver"
],
"filter": {
@@ -38,6 +37,9 @@
}
},
"args": [],
+ "env": {
+ "RPC_URL": "wss://eth-sepolia.g.alchemy.com/v2/",
+ },
"cwd": "${workspaceFolder}"
},
]
diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 0000000..90537fe
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,4 @@
+{
+ "rust-analyzer.cargo.buildScripts.overrideCommand": null,
+ "rust-analyzer.cargo.features": "all"
+}
\ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 32d3bdc..5897625 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,10 @@
+# 0.1.1 (2024-02-09)
+
+* parsing improvements
+
# 0.1.0 (2024-01-24)
* inital production support
* light refactor
* command line and environment variables
-* url parser
\ No newline at end of file
+* url parser
diff --git a/Cargo.lock b/Cargo.lock
index f60501f..f3de1f0 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -342,7 +342,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.48",
+ "syn 2.0.49",
]
[[package]]
@@ -359,7 +359,7 @@ checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.48",
+ "syn 2.0.49",
]
[[package]]
@@ -387,7 +387,7 @@ checksum = "823b8bb275161044e2ac7a25879cb3e2480cb403e3943022c7c769c599b756aa"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.48",
+ "syn 2.0.49",
]
[[package]]
@@ -541,9 +541,9 @@ dependencies = [
[[package]]
name = "bumpalo"
-version = "3.14.0"
+version = "3.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec"
+checksum = "d32a994c2b3ca201d9b263612a374263f05e7adde37c4707f693dcd375076d1f"
[[package]]
name = "byte-slice-cast"
@@ -676,9 +676,9 @@ dependencies = [
[[package]]
name = "clap"
-version = "4.5.0"
+version = "4.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "80c21025abd42669a92efc996ef13cfb2c5c627858421ea58d5c3b331a6c134f"
+checksum = "c918d541ef2913577a0f9566e9ce27cb35b6df072075769e0b26cb5a554520da"
dependencies = [
"clap_builder",
"clap_derive",
@@ -686,9 +686,9 @@ dependencies = [
[[package]]
name = "clap_builder"
-version = "4.5.0"
+version = "4.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "458bf1f341769dfcf849846f65dffdf9146daa56bcd2a47cb4e1de9915567c99"
+checksum = "9f3e7391dad68afb0c2ede1bf619f579a3dc9c2ec67f089baa397123a2f3d1eb"
dependencies = [
"anstream",
"anstyle",
@@ -705,7 +705,7 @@ dependencies = [
"heck",
"proc-macro2",
"quote",
- "syn 2.0.48",
+ "syn 2.0.49",
]
[[package]]
@@ -939,7 +939,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "30d2b3721e861707777e3195b0158f950ae6dc4a27e4d02ff9f67e3eb3de199e"
dependencies = [
"quote",
- "syn 2.0.48",
+ "syn 2.0.49",
]
[[package]]
@@ -1341,7 +1341,7 @@ dependencies = [
"reqwest",
"serde",
"serde_json",
- "syn 2.0.48",
+ "syn 2.0.49",
"toml",
"walkdir",
]
@@ -1359,7 +1359,7 @@ dependencies = [
"proc-macro2",
"quote",
"serde_json",
- "syn 2.0.48",
+ "syn 2.0.49",
]
[[package]]
@@ -1385,7 +1385,7 @@ dependencies = [
"serde",
"serde_json",
"strum",
- "syn 2.0.48",
+ "syn 2.0.49",
"tempfile",
"thiserror",
"tiny-keccak",
@@ -1771,7 +1771,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.48",
+ "syn 2.0.49",
]
[[package]]
@@ -2341,9 +2341,9 @@ dependencies = [
[[package]]
name = "jsonrpsee"
-version = "0.22.0"
+version = "0.22.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4a95f7cc23d5fab0cdeeaf6bad8c8f5e7a3aa7f0d211957ea78232b327ab27b0"
+checksum = "16fcc9dd231e72d22993f1643d5f7f0db785737dbe3c3d7ca222916ab4280795"
dependencies = [
"jsonrpsee-client-transport",
"jsonrpsee-core",
@@ -2359,9 +2359,9 @@ dependencies = [
[[package]]
name = "jsonrpsee-client-transport"
-version = "0.22.0"
+version = "0.22.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6b1736cfa3845fd9f8f43751f2b8e0e83f7b6081e754502f7d63b6587692cc83"
+checksum = "0476c96eb741b40d39dcb39d0124e3b9be9840ec77653c42a0996563ae2a53f7"
dependencies = [
"futures-channel",
"futures-util",
@@ -2383,9 +2383,9 @@ dependencies = [
[[package]]
name = "jsonrpsee-core"
-version = "0.22.0"
+version = "0.22.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "82030d038658974732103e623ba2e0abec03bbbe175b39c0a2fafbada60c5868"
+checksum = "b974d8f6139efbe8425f32cb33302aba6d5e049556b5bfc067874e7a0da54a2e"
dependencies = [
"anyhow",
"async-lock 3.3.0",
@@ -2410,9 +2410,9 @@ dependencies = [
[[package]]
name = "jsonrpsee-http-client"
-version = "0.22.0"
+version = "0.22.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "36a06ef0de060005fddf772d54597bb6a8b0413da47dcffd304b0306147b9678"
+checksum = "19dc795a277cff37f27173b3ca790d042afcc0372c34a7ca068d2e76de2cb6d1"
dependencies = [
"async-trait",
"hyper",
@@ -2430,9 +2430,9 @@ dependencies = [
[[package]]
name = "jsonrpsee-proc-macros"
-version = "0.22.0"
+version = "0.22.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "69fc56131589f82e57805f7338b87023db4aafef813555708b159787e34ad6bc"
+checksum = "68e79a7109506831bf0cbeaad08729cdf0e592300c00f626bccd6d479974221e"
dependencies = [
"heck",
"proc-macro-crate 3.1.0",
@@ -2443,9 +2443,9 @@ dependencies = [
[[package]]
name = "jsonrpsee-server"
-version = "0.22.0"
+version = "0.22.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d85be77fe5b2a94589e3164fb780017f7aff7d646b49278c0d0346af16975c8e"
+checksum = "344440ccd8492c1ca65f1391c5aa03f91189db38d602d189b9266a1a5c6a4d22"
dependencies = [
"futures-util",
"http",
@@ -2467,9 +2467,9 @@ dependencies = [
[[package]]
name = "jsonrpsee-types"
-version = "0.22.0"
+version = "0.22.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9a48fdc1202eafc51c63e00406575e59493284ace8b8b61aa16f3a6db5d64f1a"
+checksum = "b13dac43c1a9fc2648b37f306b0a5b0e29b2a6e1c36a33b95c1948da2494e9c5"
dependencies = [
"anyhow",
"beef",
@@ -2480,9 +2480,9 @@ dependencies = [
[[package]]
name = "jsonrpsee-wasm-client"
-version = "0.22.0"
+version = "0.22.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d36eb0e312840c69af0e5c6624fe959864d2e8b80bec194d2e20a39839ceef31"
+checksum = "30593c401de5940c0267a3c5e9c7eb76d8a1b80590d6ccaa59d910ea688b4d5e"
dependencies = [
"jsonrpsee-client-transport",
"jsonrpsee-core",
@@ -2491,9 +2491,9 @@ dependencies = [
[[package]]
name = "jsonrpsee-ws-client"
-version = "0.22.0"
+version = "0.22.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c5ce25d70a8e4d3cc574bbc3cad0137c326ad64b194793d5e7bbdd3fa4504181"
+checksum = "b1bbaaf4ce912654081d997ade417c3155727db106c617c0612e85f504c2f744"
dependencies = [
"http",
"jsonrpsee-client-transport",
@@ -2829,10 +2829,10 @@ version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b"
dependencies = [
- "proc-macro-crate 3.1.0",
+ "proc-macro-crate 1.3.1",
"proc-macro2",
"quote",
- "syn 2.0.48",
+ "syn 2.0.49",
]
[[package]]
@@ -3097,7 +3097,7 @@ dependencies = [
"phf_shared 0.11.2",
"proc-macro2",
"quote",
- "syn 2.0.48",
+ "syn 2.0.49",
]
[[package]]
@@ -3135,7 +3135,7 @@ checksum = "266c042b60c9c76b8d53061e52b2e0d1116abc57cefc8c5cd671619a56ac3690"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.48",
+ "syn 2.0.49",
]
[[package]]
@@ -3243,7 +3243,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a41cf62165e97c7f814d2221421dbb9afcbcdb0a88068e5ea206e19951c2cbb5"
dependencies = [
"proc-macro2",
- "syn 2.0.48",
+ "syn 2.0.49",
]
[[package]]
@@ -3276,7 +3276,7 @@ version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e8366a6159044a37876a2b9817124296703c586a5c92e2c53751fa06d8d43e8"
dependencies = [
- "toml_edit 0.20.7",
+ "toml_edit 0.20.2",
]
[[package]]
@@ -3547,7 +3547,7 @@ dependencies = [
[[package]]
name = "resolver"
-version = "0.1.0"
+version = "0.1.1"
dependencies = [
"anyhow",
"async-trait",
@@ -3760,7 +3760,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f1fb85efa936c42c6d5fc28d2629bb51e4b2f4b8a5211e297d599cc5a093792"
dependencies = [
"openssl-probe",
- "rustls-pemfile 2.0.0",
+ "rustls-pemfile 2.1.0",
"rustls-pki-types",
"schannel",
"security-framework",
@@ -3777,9 +3777,9 @@ dependencies = [
[[package]]
name = "rustls-pemfile"
-version = "2.0.0"
+version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "35e4980fa29e4c4b212ffb3db068a564cbf560e51d3944b7c88bd8bf5bec64f4"
+checksum = "3c333bb734fcdedcea57de1602543590f545f127dc8b533324318fd492c5c70b"
dependencies = [
"base64 0.21.7",
"rustls-pki-types",
@@ -3993,7 +3993,7 @@ checksum = "33c85360c95e7d137454dc81d9a4ed2b8efd8fbe19cee57357b32b9771fccb67"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.48",
+ "syn 2.0.49",
]
[[package]]
@@ -4183,7 +4183,7 @@ checksum = "0eb01866308440fc64d6c44d9e86c5cc17adfe33c4d6eed55da9145044d0ffc1"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.48",
+ "syn 2.0.49",
]
[[package]]
@@ -4369,7 +4369,7 @@ dependencies = [
"proc-macro2",
"quote",
"rustversion",
- "syn 2.0.48",
+ "syn 2.0.49",
]
[[package]]
@@ -4434,9 +4434,9 @@ dependencies = [
[[package]]
name = "syn"
-version = "2.0.48"
+version = "2.0.49"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f"
+checksum = "915aea9e586f80826ee59f8453c1101f9d1c4b3964cd2460185ee8e299ada496"
dependencies = [
"proc-macro2",
"quote",
@@ -4516,7 +4516,7 @@ checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.48",
+ "syn 2.0.49",
]
[[package]]
@@ -4647,7 +4647,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.48",
+ "syn 2.0.49",
]
[[package]]
@@ -4728,14 +4728,14 @@ dependencies = [
[[package]]
name = "toml"
-version = "0.8.10"
+version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9a9aad4a3066010876e8dcf5a8a06e70a558751117a145c6ce2b82c2e2054290"
+checksum = "185d8ab0dfbb35cf1399a6344d8484209c088f75f8f68230da55d48d95d43e3d"
dependencies = [
"serde",
"serde_spanned",
"toml_datetime",
- "toml_edit 0.22.5",
+ "toml_edit 0.20.2",
]
[[package]]
@@ -4755,18 +4755,20 @@ checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421"
dependencies = [
"indexmap",
"toml_datetime",
- "winnow 0.5.40",
+ "winnow",
]
[[package]]
name = "toml_edit"
-version = "0.20.7"
+version = "0.20.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "70f427fce4d84c72b5b732388bf4a9f4531b53f74e2887e3ecb2481f68f66d81"
+checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338"
dependencies = [
"indexmap",
+ "serde",
+ "serde_spanned",
"toml_datetime",
- "winnow 0.5.40",
+ "winnow",
]
[[package]]
@@ -4777,20 +4779,7 @@ checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1"
dependencies = [
"indexmap",
"toml_datetime",
- "winnow 0.5.40",
-]
-
-[[package]]
-name = "toml_edit"
-version = "0.22.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "99e68c159e8f5ba8a28c4eb7b0c0c190d77bb479047ca713270048145a9ad28a"
-dependencies = [
- "indexmap",
- "serde",
- "serde_spanned",
- "toml_datetime",
- "winnow 0.6.1",
+ "winnow",
]
[[package]]
@@ -4840,7 +4829,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.48",
+ "syn 2.0.49",
]
[[package]]
@@ -5116,7 +5105,7 @@ dependencies = [
"once_cell",
"proc-macro2",
"quote",
- "syn 2.0.48",
+ "syn 2.0.49",
"wasm-bindgen-shared",
]
@@ -5150,7 +5139,7 @@ checksum = "642f325be6301eb8107a83d12a8ac6c1e1c54345a7ef1a9261962dfefda09e66"
dependencies = [
"proc-macro2",
"quote",
- "syn 2.0.48",
+ "syn 2.0.49",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
@@ -5367,15 +5356,6 @@ dependencies = [
"memchr",
]
-[[package]]
-name = "winnow"
-version = "0.6.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d90f4e0f530c4c69f62b80d839e9ef3855edc9cba471a160c4d692deed62b401"
-dependencies = [
- "memchr",
-]
-
[[package]]
name = "winreg"
version = "0.50.0"
diff --git a/Dockerfile b/Dockerfile
index f84123f..77da2e2 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -15,11 +15,15 @@ COPY --from=ghcr.io/xmtp/foundry:latest /usr/local/bin/anvil /usr/local/bin/anvi
COPY --chown=xmtp:xmtp . .
+RUN yamlfmt -lint .github/workflows/*.yml
+
ENV CARGO_INCREMENTAL=${CARGO_INCREMENTAL:-1}
RUN cargo check --all-features
RUN cargo fmt --check --all
RUN cargo clippy --all-features --no-deps -- -D warnings
RUN cargo test --workspace --all-features
+ENV RUSTDOCFLAGS="-D warnings"
+RUN cargo doc --all-features --workspace --no-deps
RUN CARGO_TARGET_DIR=/workspaces/${PROJECT}/target cargo install --path resolver --bin=resolver --root ~${USER}/.cargo/
RUN valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose ~${USER}/.cargo/bin/resolver --help
diff --git a/lib/src/resolver.rs b/lib/src/resolver.rs
index 44cec3c..aff92cf 100644
--- a/lib/src/resolver.rs
+++ b/lib/src/resolver.rs
@@ -65,27 +65,20 @@ impl Resolver {
/// Resolve a did:ethr identifier
pub async fn resolve_did(
&self,
- public_key: H160,
+ address: H160,
version_id: Option,
) -> Result> {
- let history = self.changelog(public_key).await?;
- self.wrap_did_resolution(public_key, version_id, history)
- .await
+ let history = self.changelog(address).await?;
+ self.wrap_did_resolution(address, version_id, history).await
}
async fn changelog(
&self,
- public_key: H160,
+ address: H160,
) -> Result, ResolverError> {
- let mut previous_change: U64 = self
- .registry
- .changed(public_key)
- .call()
- .await?
- .as_u64()
- .into();
+ let mut previous_change: U64 = self.registry.changed(address).call().await?.as_u64().into();
- log::trace!("Previous Change for {}: {:?}", public_key, previous_change);
+ log::trace!("Previous Change for {}: {:?}", address, previous_change);
let mut history = Vec::new();
@@ -99,7 +92,7 @@ impl Resolver {
.events()
.from_block(previous_change)
.to_block(previous_change)
- .topic1(H256::from(public_key))
+ .topic1(H256::from(address))
.query_with_meta()
.await?;
@@ -119,7 +112,7 @@ impl Resolver {
async fn dispatch_event(
&self,
doc: &mut EthrBuilder,
- public_key: H160,
+ address: H160,
event: DIDRegistryEvents,
meta: LogMeta,
) -> Result<(), ResolverError> {
@@ -147,7 +140,7 @@ impl Resolver {
if let Err(e) = res {
log::error!(
"Error while resolving for {} at event block={}, log index={}, incorrect format?: {}",
- public_key, meta.block_number, meta.log_index, e,
+ address, meta.block_number, meta.log_index, e,
);
};
Ok(())
@@ -155,12 +148,12 @@ impl Resolver {
async fn wrap_did_resolution(
&self,
- public_key: H160,
+ address: H160,
version_id: Option,
history: Vec<(DIDRegistryEvents, LogMeta)>,
) -> Result> {
let mut base_document = DidDocument::ethr_builder();
- base_document.account_address(&public_key)?;
+ base_document.account_address(&address)?;
let current_block = self
.signer()
@@ -185,7 +178,7 @@ impl Resolver {
if version_id.unwrap_or_default() > U64::zero() {
if meta.block_number <= version_id.unwrap_or_default() {
// 1. delegate events
- Resolver::dispatch_event(self, &mut base_document, public_key, event, meta)
+ Resolver::dispatch_event(self, &mut base_document, address, event, meta)
.await?;
// 2. set latest version
if current_version_id < block_number {
@@ -198,7 +191,7 @@ impl Resolver {
}
} else {
// 1. delegate events
- Resolver::dispatch_event(self, &mut base_document, public_key, event, meta).await?;
+ Resolver::dispatch_event(self, &mut base_document, address, event, meta).await?;
// 2. set latest version
if current_version_id < block_number {
current_version_id = block_number;
diff --git a/lib/src/resolver/did_registry.rs b/lib/src/resolver/did_registry.rs
index 7680569..22d2eed 100644
--- a/lib/src/resolver/did_registry.rs
+++ b/lib/src/resolver/did_registry.rs
@@ -1,4 +1,5 @@
//! Generated ABI Functions, along with some extra to make it easier to interact with the registry.
+use std::ffi::CStr;
use crate::error::RegistrySignerError;
use ethers::{
@@ -56,6 +57,11 @@ impl DidattributeChangedFilter {
/// Get the name of the attribute as a string. non-UTF8 bytes will be replaced with the unicode replacement character, �.
pub fn name_string_lossy(&self) -> String {
+ let is_cstr = self.name.iter().rev().any(|&c| c == 0);
+ if is_cstr {
+ let cstr = CStr::from_bytes_until_nul(self.name.as_ref()).expect("Nul check succeeded");
+ return cstr.to_string_lossy().to_string();
+ }
String::from_utf8_lossy(self.name.as_ref()).to_string()
}
diff --git a/lib/src/rpc/api.rs b/lib/src/rpc/api.rs
index abc27ab..18578fa 100644
--- a/lib/src/rpc/api.rs
+++ b/lib/src/rpc/api.rs
@@ -11,7 +11,7 @@ pub trait DidRegistry {
#[method(name = "resolveDid")]
async fn resolve_did(
&self,
- public_key: String,
+ address: String,
version_id: Option,
) -> Result;
}
@@ -23,7 +23,7 @@ pub trait DidRegistry {
#[method(name = "resolveDid")]
async fn resolve_did(
&self,
- public_key: String,
+ address: String,
version_id: Option,
) -> Result;
}
diff --git a/lib/src/rpc/methods.rs b/lib/src/rpc/methods.rs
index a47dca0..ea2a727 100644
--- a/lib/src/rpc/methods.rs
+++ b/lib/src/rpc/methods.rs
@@ -29,23 +29,26 @@ impl DidRegistryMethods {
impl DidRegistryServer for DidRegistryMethods {
async fn resolve_did(
&self,
- public_key: String,
+ address: String,
version_id: Option,
) -> Result {
log::debug!("did_resolveDid called");
+ log::trace!("Resolving for key {}", &address);
+
// parse the version_id
let parsed_version_id = version_id.map(|str| U64::from(u64::from_str(&str).unwrap()));
let resolution_result = self
.resolver
.resolve_did(
- H160::from_str(&public_key).map_err(RpcError::from)?,
+ H160::from_str(&address).map_err(RpcError::from)?,
parsed_version_id,
)
- .await?;
+ .await;
+ log::debug!("Resolution Result {:?}", resolution_result);
- Ok(resolution_result)
+ Ok(resolution_result?)
}
}
diff --git a/lib/src/types/did_parser.rs b/lib/src/types/did_parser.rs
index af228da..7c6bb98 100644
--- a/lib/src/types/did_parser.rs
+++ b/lib/src/types/did_parser.rs
@@ -1,5 +1,4 @@
//! Parsing Expression Grammer (PEG) parsing rules for parts of a Decentralized Identifier
-
use ethers::types::Address;
use crate::types::*;
@@ -235,8 +234,11 @@ peg::parser! {
#[cfg(test)]
mod tests {
+
use super::*;
+ use std::ffi::CStr;
+
#[test]
fn test_did_attribute_parser() {
let keys = [
@@ -285,6 +287,32 @@ mod tests {
}
}
+ #[test]
+ fn test_parse_hex_c_string_svc() {
+ let decoded_data =
+ hex::decode("6469642f7376632f4d6573736167696e67536572766963650000000000000000")
+ .unwrap();
+ let cstr = CStr::from_bytes_until_nul(decoded_data.as_slice()).unwrap();
+ let parsed = parse_attribute(&cstr.as_ref().to_str().unwrap());
+ assert_eq!(parsed, Ok(Attribute::Service(ServiceType::Messaging)));
+ }
+
+ #[test]
+ fn test_parse_hex_c_string_pub() {
+ let decoded_data =
+ hex::decode("6469642f7075622f456432353531392f766572694b65792f62617365353800").unwrap();
+ let cstr = CStr::from_bytes_until_nul(decoded_data.as_slice()).unwrap();
+ let parsed = parse_attribute(&cstr.as_ref().to_str().unwrap());
+ assert_eq!(
+ parsed,
+ Ok(Attribute::PublicKey(PublicKey {
+ key_type: KeyType::Ed25519VerificationKey2020,
+ purpose: KeyPurpose::VerificationKey,
+ encoding: KeyEncoding::Base58
+ }))
+ );
+ }
+
#[test]
fn test_did_xmtp_attribute_parser() {
let keys = [
diff --git a/lib/src/types/did_url.rs b/lib/src/types/did_url.rs
index e33179f..a5ac061 100644
--- a/lib/src/types/did_url.rs
+++ b/lib/src/types/did_url.rs
@@ -40,7 +40,7 @@ pub struct DidUrl {
pub fragment: Option,
}
-/// The `did` part of a [did:ethr](https://github.com/decentralized-identity/ethr-did-resolver/blob/master/doc/did-method-spec.md) URL. returned by [`parse_ethr_did`]
+/// The `did` part of a [did:ethr](https://github.com/decentralized-identity/ethr-did-resolver/blob/master/doc/did-method-spec.md) URL. returned by [`super::parse_ethr_did`]
#[derive(Debug, Clone, PartialEq, Eq, SmartDefault)]
pub struct Did {
pub method: Method,
@@ -245,7 +245,7 @@ impl DidUrl {
/// Retrieves the chainId for an DID:ETHR URL, as defined in the [did-ethr](https://github.com/decentralized-identity/ethr-did-resolver/blob/master/doc/did-method-spec.md).
///
/// # Returns
- /// A enum [`ChainId`] indicating the chain this DID belongs to.
+ /// A enum [`Network`] indicating the chain this DID belongs to.
///
/// # Examples
/// ```
@@ -261,7 +261,7 @@ impl DidUrl {
/// Retrieves the identity part from the DID URL, as defined in the [did-ethr spec](https://github.com/decentralized-identity/ethr-did-resolver/blob/master/doc/did-method-spec.md)).
///
/// # Returns
- /// A Enum [`AddressOrHexKey`] which identifies the DID. This can be either an 20-byte [`Address`] or a 33-byte [`Vec`].
+ /// A Enum [`Account`] which identifies the DID. This can be either an 20-byte [`Address`] or a 33-byte [`Vec`].
///
/// # Examples
/// ```
diff --git a/lib/src/types/ethr.rs b/lib/src/types/ethr.rs
index a236c1b..3300571 100644
--- a/lib/src/types/ethr.rs
+++ b/lib/src/types/ethr.rs
@@ -189,16 +189,19 @@ impl EthrBuilder {
context: &EventContext,
) -> Result<(), EthrBuilderError> {
let name = event.name_string_lossy();
- let attribute = types::parse_attribute(&name).unwrap_or(Attribute::Other(name.to_string()));
-
- log::trace!(
- "Attribute Event name={}, value={}, now={}, valid_to={}, attr={:?}",
- name,
- event.value,
- self.now,
- event.valid_to,
- attribute
- );
+
+ if log::log_enabled!(log::Level::Trace) {
+ log::trace!(
+ "Attribute Event name={}, value={}, now={}, valid_to={}",
+ name.clone(),
+ event.value_string_lossy(),
+ self.now,
+ event.valid_to
+ );
+ }
+
+ let attribute =
+ types::parse_attribute(&name).unwrap_or_else(|_err| Attribute::Other(name.to_owned()));
let key = Key::Attribute {
name: event.name,
@@ -321,6 +324,12 @@ impl EthrBuilder {
value: V,
encoding: KeyEncoding,
) -> Result