Skip to content
This repository was archived by the owner on Feb 28, 2025. It is now read-only.

Revoke Installation Companion PR #35

Merged
merged 45 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
394ddd4
add xmtp did:ethr extension
insipx Jan 19, 2024
44bae7b
QoL changes for working with did:ethr types
insipx Jan 19, 2024
ebc2dcd
set query before pushing auth method
insipx Jan 19, 2024
39455e1
Merge branch 'main' of github.com:xmtp/didethresolver into insipx/rev…
insipx Jan 19, 2024
c6fce58
into [u8;32]
insipx Jan 19, 2024
5d5288c
make attr names even more flexible
insipx Jan 19, 2024
616e28c
test asserts
insipx Jan 19, 2024
80f3167
add sign attribute method to DIDRegistry
insipx Jan 22, 2024
5836996
remove generic from sign_attribute
insipx Jan 22, 2024
2c9ae3e
make sign_attribute an extension trait on Signer
insipx Jan 22, 2024
36e1fd2
fix attribute conversions
insipx Jan 22, 2024
d2fb53d
logs
insipx Jan 22, 2024
2dd6964
typo
insipx Jan 22, 2024
480958c
add integration test for setting and revoking xmtp attribute
insipx Jan 22, 2024
7a16c47
fix signing of data for registry fns
insipx Jan 23, 2024
79f92fa
fmt and clippy
insipx Jan 23, 2024
3e4a2dc
typo
insipx Jan 23, 2024
badd01b
try_into() unnecessary
insipx Jan 23, 2024
328d584
improve coverage
insipx Jan 24, 2024
afcc915
missing metadata should result in error
insipx Jan 24, 2024
92ab760
remove unnecessary todo
insipx Jan 24, 2024
53e4716
formalize and decouple XMTP attributes from did:ethr
insipx Jan 24, 2024
fe4c3a4
fmt
insipx Jan 24, 2024
6a2a1c3
cleanup and tests
insipx Jan 25, 2024
4a808ae
improve logs
insipx Jan 25, 2024
2a1f331
remove unused fn
insipx Jan 25, 2024
fb875c5
make coverage include logs
insipx Jan 25, 2024
e83a3df
make some attrs sigAuth
insipx Jan 25, 2024
e268b71
add tests for is_valid
insipx Jan 25, 2024
44be5cd
make coverage use trace logs
insipx Jan 25, 2024
a39dc77
add test for owner
insipx Jan 25, 2024
371052a
some more small tests
insipx Jan 25, 2024
77b10ae
make sure to take care of workflows
insipx Jan 25, 2024
534415e
fix failing test b/c of typo
insipx Jan 25, 2024
649a16b
Merge branch 'main' of github.com:xmtp/didethresolver into insipx/rev…
insipx Jan 25, 2024
f29c77b
removed unused
insipx Jan 25, 2024
931e32c
docs
insipx Jan 25, 2024
962ce95
test for encoding
insipx Jan 25, 2024
3648ce2
more tests
insipx Jan 25, 2024
c440429
re-run coverage
insipx Jan 25, 2024
2415275
re-run coverage
insipx Jan 25, 2024
cdea415
update docs
insipx Jan 25, 2024
3533c5b
sign_data -> signed_typed_data
insipx Jan 25, 2024
f24bbbf
lower verbosity from trace to info
insipx Jan 25, 2024
bf348f5
re-run coverage
insipx Jan 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions .github/workflows/ci-image.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
name: Build Dev Image CI

on:
workflow_dispatch:
pull_request:
Expand All @@ -8,21 +7,16 @@ on:
push:
branches:
- "*"

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: Build and Push
uses: docker/build-push-action@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Install cargo-llvm-cov
run: curl -LsSf https://github.com/taiki-e/cargo-llvm-cov/releases/latest/download/cargo-llvm-cov-x86_64-unknown-linux-gnu.tar.gz | tar xzf - -C ~/.cargo/bin
- name: Generate code coverage
run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info
run: RUST_LOG=lib_didethresolver=trace cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
Expand Down
12 changes: 1 addition & 11 deletions .github/workflows/github-pages.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
name: GitHub Pages

on:
workflow_run:
workflows: ["Build Dev Image CI"]
branches: ["main"]
types:
types:
- completed
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow one concurrent deployment
concurrency:
group: "github-pages"
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -28,25 +24,21 @@ jobs:
uses: actions/checkout@v3
with:
submodules: recursive

- name: Setup Pages
uses: actions/configure-pages@v2
- uses: actions/setup-python@v2

- name: Install rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true

- name: Run tests
env:
CARGO_INCREMENTAL: 0
run: |
cargo test --workspace --all-features --tests tests
id: test

- name: Invoke cargo doc
run: |
rm -rf ./_site
Expand All @@ -57,10 +49,8 @@ jobs:
echo "Taking care of pedantic permissions requirements required by GitHub Pages"
chmod -R +rX _site
id: docgen

- name: Upload artifact
uses: actions/upload-pages-artifact@v2

# Deployment job
deploy:
environment:
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ smart-default = "0.7"
sha3 = "0.10"
peg = "0.8"
rustc-hex = "2.1"
tiny-keccak = { version = "2.0.2", default-features = false }

[dev-dependencies]
tracing-subscriber.workspace = true
Expand All @@ -51,7 +52,6 @@ futures = "0.3"
ctor = "0.2.5"
surf = "2.3"


[features]
default = []
client = ["jsonrpsee/client"]
Expand Down
25 changes: 22 additions & 3 deletions lib/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
use ethers::{contract::ContractError, providers::Middleware};
use ethers::{
abi::EncodePackedError,
contract::ContractError,
providers::{Middleware, ProviderError},
signers::WalletError,
};
use jsonrpsee::types::ErrorObjectOwned;
use thiserror::Error;

Expand All @@ -14,7 +19,7 @@ pub enum ResolverError<M: Middleware> {
}

/// Errors originating from the parsing of a did url identifier, [`Did`](crate::types::DidUrl)
#[derive(Error, Debug)]
#[derive(Error, Debug, PartialEq)]
pub enum DidError {
#[error("Parsing of ethr:did failed, {0}")]
Parse(#[from] peg::error::ParseError<peg::str::LineCol>),
Expand All @@ -23,7 +28,7 @@ pub enum DidError {
}

/// Errors originating during the construction of a ethr:did document [`EthrBuilder`](crate::types::EthrBuilder)
#[derive(Error, Debug)]
#[derive(Error, Debug, PartialEq)]
pub enum EthrBuilderError {
#[error(transparent)]
Did(#[from] DidError),
Expand All @@ -33,10 +38,24 @@ pub enum EthrBuilderError {
Hex(#[from] hex::FromHexError),
#[error("Parsing part of ethr:did failed, {0}")]
Parse(#[from] peg::error::ParseError<peg::str::LineCol>),
#[error("XMTP Key is missing key purpose metadata")]
MissingMetadata,
}

impl<M: Middleware> From<ResolverError<M>> for ErrorObjectOwned {
fn from(err: ResolverError<M>) -> Self {
ErrorObjectOwned::owned(-31000, err.to_string(), None::<()>)
}
}

#[derive(Error, Debug)]
pub enum RegistrySignerError<M: Middleware> {
#[error(transparent)]
Encode(#[from] EncodePackedError),
#[error("{0}")]
ContractError(#[from] ContractError<M>),
#[error(transparent)]
Provider(#[from] ProviderError),
#[error(transparent)]
Wallet(#[from] WalletError),
}
8 changes: 8 additions & 0 deletions lib/src/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ pub struct Resolver<M> {
}

impl<M: Middleware + 'static> Resolver<M> {
/// Instantiate a new did:ethr resolver
pub async fn new(middleware: M, registry: Address) -> Result<Self, ResolverError<M>> {
let signer = Arc::new(middleware);
let registry = DIDRegistry::new(registry, signer.clone());
log::debug!("Using deployed registry at {}", registry.address());
Ok(Self { signer, registry })
}

/// Resolve a did:ethr identifier
pub async fn resolve_did(
&self,
public_key: H160,
Expand All @@ -53,6 +55,8 @@ impl<M: Middleware + 'static> Resolver<M> {
.as_u64()
.into();

log::trace!("Previous Change for {}: {:?}", public_key, previous_change);

let mut history = Vec::new();

loop {
Expand All @@ -70,6 +74,7 @@ impl<M: Middleware + 'static> Resolver<M> {
.await?;

for (event, meta) in events {
log::trace!("Adding {:?} event to history", event);
if event.previous_change() < previous_change {
previous_change = event.previous_change();
}
Expand All @@ -90,12 +95,15 @@ impl<M: Middleware + 'static> Resolver<M> {
) {
let res = match event {
DIDRegistryEvents::DiddelegateChangedFilter(delegate_changed) => {
log::trace!("Delegate Changed {:?}", delegate_changed);
doc.delegate_event(delegate_changed)
}
DIDRegistryEvents::DidattributeChangedFilter(attribute_event) => {
log::trace!("Attribute Changed {:?}", attribute_event);
doc.attribute_event(attribute_event)
}
DIDRegistryEvents::DidownerChangedFilter(owner_changed) => {
log::trace!("Owner Changed {:?}", owner_changed);
doc.owner_event(owner_changed)
}
};
Expand Down
Loading