diff --git a/Cargo.lock b/Cargo.lock index 3b99e0e..4f0d63b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3536,7 +3536,7 @@ dependencies = [ [[package]] name = "resolver" -version = "0.1.0" +version = "0.1.1" dependencies = [ "anyhow", "async-trait", diff --git a/lib/src/resolver.rs b/lib/src/resolver.rs index ea61702..7559ac6 100644 --- a/lib/src/resolver.rs +++ b/lib/src/resolver.rs @@ -39,27 +39,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(); @@ -73,7 +66,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?; @@ -93,7 +86,7 @@ impl Resolver { fn dispatch_event( &self, doc: &mut EthrBuilder, - public_key: H160, + address: H160, event: DIDRegistryEvents, meta: LogMeta, ) { @@ -120,19 +113,19 @@ 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, ); }; } 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() @@ -157,7 +150,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); // 2. set latest version if current_version_id < block_number { current_version_id = block_number; @@ -169,7 +162,7 @@ impl Resolver { } } else { // 1. delegate events - Resolver::dispatch_event(self, &mut base_document, public_key, event, meta); + Resolver::dispatch_event(self, &mut base_document, address, event, meta); // 2. set latest version if current_version_id < block_number { current_version_id = block_number; 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..a9449c4 100644 --- a/lib/src/rpc/methods.rs +++ b/lib/src/rpc/methods.rs @@ -29,7 +29,7 @@ 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"); @@ -40,7 +40,7 @@ impl DidRegistryServer for DidRegistryMethods { 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?; diff --git a/resolver/src/main.rs b/resolver/src/main.rs index b269de5..c316f04 100644 --- a/resolver/src/main.rs +++ b/resolver/src/main.rs @@ -12,14 +12,14 @@ //! //! ### Request Format //! -//! The request should be a JSON object containing one field: `publicKey`. +//! The request should be a JSON object containing one field: `address`. //! -//! - `publicKey` (string, required): The Ethereum public key (starting with '0x'). +//! - `address` (string, required): The Ethereum address (starting with '0x'). //! //! Example Request: //! ```json //! { -//! "publicKey": "0x123abc..." +//! "address": "0x123abc..." //! } //! ``` //! @@ -61,7 +61,7 @@ //! Example Error Response: //! ```json //! { -//! "error": "Invalid public key format" +//! "error": "Invalid address format" //! } //! ``` //!