Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix gRPC binding build issues #1483

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion bindings/grpc/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ async fn main() -> anyhow::Result<()> {

let iota_client = iota_sdk::IotaClientBuilder::default().build(api_endpoint).await?;

let read_only_client = IdentityClientReadOnly::new(iota_client, identity_pkg_id).await?;
let read_only_client = IdentityClientReadOnly::new_with_pkg_id(iota_client, identity_pkg_id).await?;

let stronghold = init_stronghold()?;

Expand Down
21 changes: 6 additions & 15 deletions bindings/grpc/src/services/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ use _document::document_service_server::DocumentServiceServer;
use _document::CreateDidRequest;
use _document::CreateDidResponse;
use identity_iota::core::ToJson;
use identity_iota::iota::rebased::client::IdentityClient;
use identity_iota::iota::rebased::client::IdentityClientReadOnly;
use identity_iota::iota::rebased::transaction::Transaction;
use identity_iota::iota::IotaDID;
use identity_iota::iota::IotaDocument;
use identity_iota::iota::StateMetadataDocument;
use identity_iota::iota::StateMetadataEncoding;
use identity_iota::storage::JwkDocumentExt;
use identity_iota::storage::JwkStorageDocumentError;
use identity_iota::storage::Storage;
Expand All @@ -18,11 +19,9 @@ use identity_iota::verification::MethodScope;
use identity_storage::KeyId;
use identity_storage::KeyStorageErrorKind;
use identity_storage::StorageSigner;
use identity_stronghold::StrongholdKeyType;
use identity_stronghold::StrongholdStorage;
use identity_stronghold::ED25519_KEY_TYPE;
use identity_iota::iota::rebased::client::IdentityClient;
use identity_iota::iota::rebased::client::IdentityClientReadOnly;
use identity_iota::iota::rebased::transaction::Transaction;
use tonic::Code;
use tonic::Request;
use tonic::Response;
Expand Down Expand Up @@ -82,7 +81,7 @@ impl DocumentService for DocumentSvc {
let pub_key = self
.storage
.key_id_storage()
.get_public_key(&key_id)
.get_public_key_with_type(&key_id, StrongholdKeyType::Ed25519)
.await
.map_err(Error::StrongholdError)?;

Expand All @@ -94,16 +93,8 @@ impl DocumentService for DocumentSvc {
.await
.map_err(Error::IdentityClientError)?;

let iota_doc = {
let doc = IotaDocument::new(network_name);

let iota_doc_md = StateMetadataDocument::from(doc);

iota_doc_md.pack(StateMetadataEncoding::Json).expect("shouldn't fail")
};

let mut created_identity = identity_client
.create_identity(&iota_doc)
.create_identity(IotaDocument::new(network_name))
.finish()
.execute(&identity_client)
.await
Expand Down
7 changes: 6 additions & 1 deletion bindings/grpc/src/services/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use _utils::DataSigningResponse;
use identity_iota::storage::JwkStorage;
use identity_iota::storage::KeyId;
use identity_iota::storage::KeyStorageError;
use identity_stronghold::StrongholdKeyType;
use identity_stronghold::StrongholdStorage;
use tonic::Request;
use tonic::Response;
Expand Down Expand Up @@ -51,7 +52,11 @@ impl SigningSvc for SigningService {
async fn sign(&self, req: Request<DataSigningRequest>) -> Result<Response<DataSigningResponse>, Status> {
let DataSigningRequest { data, key_id } = req.into_inner();
let key_id = KeyId::new(key_id);
let public_key_jwk = self.storage.get_public_key(&key_id).await.map_err(Error)?;
let public_key_jwk = self
.storage
.get_public_key_with_type(&key_id, StrongholdKeyType::Ed25519)
.await
.map_err(Error)?;
let signature = self
.storage
.sign(&key_id, &data, &public_key_jwk)
Expand Down
Loading