Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
tsachiherman committed Jan 29, 2024
1 parent 1b27f34 commit 7286f1a
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions registry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pub mod error;
use std::str::FromStr;

use error::ContactOperationError;
use ethers::types::U256;
use ethers::types::{H160, U256};
use ethers::{core::types::Signature, providers::Middleware, types::Address};
use gateway_types::GrantInstallationResult;
use lib_didethresolver::{
Expand All @@ -24,6 +24,13 @@ where
Self { registry }
}

fn resolve_did_address(&self, did: String) -> Result<H160, ContactOperationError<M>> {
// for now, we will just assume the DID is a valid ethereum wallet address
// TODO: Parse or resolve the actual DID
let address = Address::from_str(&did)?;
Ok(address)
}

pub async fn grant_installation(
&self,
did: String,
Expand All @@ -32,11 +39,7 @@ where
signature: Signature,
validity: U256,
) -> Result<GrantInstallationResult, ContactOperationError<M>> {
// for now, we will just assume the DID is a valid ethereum wallet address
// TODO: Parse or resolve the actual DID
// Note that it should be refactored along with revoke_installation that uses the very
// same logic.
let address = Address::from_str(&did)?;
let address = self.resolve_did_address(did)?;
let attribute: [u8; 32] = Attribute::from(name).into();

Check warning on line 43 in registry/src/lib.rs

View check run for this annotation

Codecov / codecov/patch

registry/src/lib.rs#L34-L43

Added lines #L34 - L43 were not covered by tests
log::debug!(
"setting attribute {:#?}",
Expand Down Expand Up @@ -71,9 +74,7 @@ where
value: Vec<u8>,
signature: Signature,
) -> Result<(), ContactOperationError<M>> {
// for now, we will just assume the DID is a valid ethereum wallet address
// TODO: Parse or resolve the actual DID
let address = Address::from_str(&did)?;
let address = self.resolve_did_address(did)?;
let attribute: [u8; 32] = Attribute::from(name).into();
log::debug!(
"Revoking attribute {:#?}",
Expand Down

0 comments on commit 7286f1a

Please sign in to comment.