Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Salka1988 committed Mar 3, 2025
1 parent e70fffd commit c712ce6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 37 deletions.
5 changes: 2 additions & 3 deletions packages/fuels-accounts/src/kms/google.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
mod client;
mod wallet;

pub use client::*;
pub use wallet::*;

pub use google_cloud_kms;
27 changes: 0 additions & 27 deletions packages/fuels-accounts/src/kms/google/client.rs

This file was deleted.

12 changes: 5 additions & 7 deletions packages/fuels-accounts/src/kms/google/wallet.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::accounts_utils::try_provider_error;
use crate::kms::google::client::GoogleClient;
use crate::provider::Provider;
use crate::wallet::Wallet;
use crate::{Account, ViewOnlyAccount};
Expand All @@ -15,6 +14,7 @@ use fuels_core::{
transaction_builders::TransactionBuilder,
},
};
use google_cloud_kms::client::Client;
use google_cloud_kms::grpc::kms::v1::crypto_key_version::CryptoKeyVersionAlgorithm::EcSignSecp256k1Sha256;
use google_cloud_kms::grpc::kms::v1::digest::Digest::Sha256;
use google_cloud_kms::grpc::kms::v1::{AsymmetricSignRequest, Digest, GetPublicKeyRequest};
Expand All @@ -36,7 +36,7 @@ pub struct GoogleWallet {
#[derive(Clone, Debug)]
pub struct GcpKey {
key_path: String,
client: GoogleClient,
client: Client,
public_key_pem: String,
fuel_address: Bech32Address,
}
Expand Down Expand Up @@ -94,7 +94,7 @@ impl GcpKey {
/// Creates a new GcpKey from a Google Cloud KMS key path.
/// The key_path should be in the format:
/// projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{key}/cryptoKeyVersions/{version}
pub async fn new(key_path: String, client: &GoogleClient) -> Result<Self> {
pub async fn new(key_path: String, client: &Client) -> Result<Self> {
let public_key_pem = Self::retrieve_public_key(client, &key_path).await?;
let fuel_address = Self::derive_fuel_address(&public_key_pem)?;
Ok(Self {
Expand All @@ -106,13 +106,12 @@ impl GcpKey {
}

/// Retrieves the public key PEM from Google Cloud KMS and verifies the key algorithm.
async fn retrieve_public_key(client: &GoogleClient, key_path: &str) -> Result<String> {
async fn retrieve_public_key(client: &Client, key_path: &str) -> Result<String> {
let request = GetPublicKeyRequest {
name: key_path.to_string(),
};

let response = client
.inner()
.get_public_key(request, None)
.await
.map_err(|e| format_gcp_error(format!("Failed to get public key: {}", e)))?;
Expand Down Expand Up @@ -153,7 +152,6 @@ impl GcpKey {

let response = self
.client
.inner()
.asymmetric_sign(request, None)
.await
.map_err(|e| format_gcp_error(format!("Signing failed: {}", e)))?;
Expand Down Expand Up @@ -241,7 +239,7 @@ impl GoogleWallet {
/// Creates a new GoogleWallet with the given KMS key path.
pub async fn with_kms_key(
key_path: CryptoKeyVersionName,
google_client: &GoogleClient,
google_client: &Client,
provider: Option<Provider>,
) -> Result<Self> {
let kms_key = GcpKey::new(key_path.to_string(), google_client).await?;
Expand Down

0 comments on commit c712ce6

Please sign in to comment.