Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Salka1988 committed Feb 12, 2025
1 parent db5dd0a commit 5b77e23
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 38 deletions.
4 changes: 1 addition & 3 deletions e2e/src/fuel_node.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use crate::client::HttpClient;
use anyhow::Context;
use fuel_core_types::{
fuel_tx::AssetId,
};
use fuel_core_types::fuel_tx::AssetId;
use fuels::accounts::Account;
use fuels::crypto::SecretKey;
use fuels::prelude::{Bech32Address, Provider, TxPolicies, WalletUnlocked};
Expand Down
6 changes: 3 additions & 3 deletions e2e/src/kms.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use anyhow::Context;
use fuels::accounts::aws::{AwsClient, AwsConfig, KmsData};
use testcontainers::{core::ContainerPort, runners::AsyncRunner};
use tokio::io::AsyncBufReadExt;
use fuels::accounts::aws::{AwsClient, AwsConfig, KmsData};

#[derive(Default)]
pub struct Kms {
Expand Down Expand Up @@ -106,8 +106,8 @@ pub struct KmsProcess {
impl KmsProcess {
pub async fn create_key(&self) -> anyhow::Result<KmsKey> {
let response = self
.client.
inner()
.client
.inner()
.create_key()
.key_usage(aws_sdk_kms::types::KeyUsageType::SignVerify)
.key_spec(aws_sdk_kms::types::KeySpec::EccSecgP256K1)
Expand Down
41 changes: 24 additions & 17 deletions e2e/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
#[cfg(test)]
mod client;
#[cfg(test)]
mod e2e_helpers;
#[cfg(test)]
mod fuel_node;
#[cfg(test)]
mod kms;

Check warning on line 8 in e2e/src/lib.rs

View workflow job for this annotation

GitHub Actions / cargo-verifications (check_typos)

"kms" should be "km".
#[cfg(test)]
mod e2e_helpers;


#[cfg(test)]
mod tests {
use crate::e2e_helpers::{create_and_fund_kms_keys, start_fuel_node, start_kms};

Check warning on line 12 in e2e/src/lib.rs

View workflow job for this annotation

GitHub Actions / cargo-verifications (check_typos)

"kms" should be "km".

Check warning on line 12 in e2e/src/lib.rs

View workflow job for this annotation

GitHub Actions / cargo-verifications (check_typos)

"kms" should be "km".
use anyhow::Result;
use fuels::prelude::{AssetId, Provider};
use std::str::FromStr;
use fuels_accounts::aws::AwsWallet;
use fuels_accounts::ViewOnlyAccount;
use crate::e2e_helpers::{create_and_fund_kms_keys, start_fuel_node, start_kms};
use std::str::FromStr;

#[tokio::test]
async fn fund_aws_wallet() -> Result<()> {
Expand All @@ -35,7 +34,12 @@ mod tests {
let provider = Provider::connect(fuel_node.url()).await?;
let wallet = AwsWallet::from_kms_key_id(kms_key.id, Some(provider)).await?;

let founded_coins = wallet.get_coins(asset_id).await?.first().expect("No coins found").amount;
let founded_coins = wallet
.get_coins(asset_id)
.await?
.first()
.expect("No coins found")
.amount;
assert_eq!(founded_coins, 5000000000);
Ok(())
}
Expand All @@ -60,28 +64,31 @@ mod tests {
let provider = Provider::connect(fuel_node.url()).await?;
let wallet = AwsWallet::from_kms_key_id(kms_key.id, Some(provider)).await?;

let founded_coins = wallet.get_coins(asset_id).await?.first().expect("No coins found").amount;
let founded_coins = wallet
.get_coins(asset_id)
.await?
.first()
.expect("No coins found")
.amount;
assert_eq!(founded_coins, 5000000000);

let contract_id = Contract::load_from(
"../e2e/sway/contracts/contract_test/out/release/contract_test.bin",
LoadConfiguration::default(),
)?
.deploy(&wallet, TxPolicies::default())
.await?;
.deploy(&wallet, TxPolicies::default())
.await?;

println!("Contract deployed @ {contract_id}");

let founded_coins = wallet.get_coins(asset_id).await?.first().expect("No coins found").amount;
let founded_coins = wallet
.get_coins(asset_id)
.await?
.first()
.expect("No coins found")
.amount;
assert_eq!(founded_coins, 4999983198);

Ok(())
}







}
7 changes: 0 additions & 7 deletions e2e/tests/wallets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -557,10 +557,3 @@ async fn wallet_transfer_respects_maturity_and_expiration() -> Result<()> {

Ok(())
}

#[tokio::test]
async fn aws_kms() -> Result<()> {
FuelNode::start().await.expect("TODO: panic message");

Ok(())
}
2 changes: 1 addition & 1 deletion packages/fuels-accounts/src/aws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ mod aws_client;
mod aws_signer;

pub use aws_client::*;
pub use aws_signer::*;
pub use aws_signer::*;
14 changes: 9 additions & 5 deletions packages/fuels-accounts/src/aws/aws_signer.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use aws_sdk_kms::{
primitives::Blob,
types::{KeySpec, MessageType, SigningAlgorithmSpec},
// Client as AwsClient,
};
use fuel_crypto::{Message, PublicKey, Signature};
use fuel_types::AssetId;
Expand All @@ -21,8 +20,8 @@ use k256::{
PublicKey as K256PublicKey,
};

use crate::{provider::Provider, wallet::Wallet, Account, ViewOnlyAccount};
use crate::aws::{AwsClient, AwsConfig};
use crate::{provider::Provider, wallet::Wallet, Account, ViewOnlyAccount};

const AWS_KMS_ERROR_PREFIX: &str = "AWS KMS Error";

Expand All @@ -36,7 +35,7 @@ pub struct AwsWallet {
pub struct KmsData {
id: String,
client: AwsClient,
pub public_key: Vec<u8>,
public_key: Vec<u8>,
pub address: Bech32Address,
}

Expand Down Expand Up @@ -74,7 +73,12 @@ impl KmsData {
}

async fn fetch_public_key(client: &AwsClient, key_id: &str) -> anyhow::Result<Vec<u8>> {
let response = client.inner().get_public_key().key_id(key_id).send().await?;
let response = client
.inner()
.get_public_key()
.key_id(key_id)
.send()
.await?;

let public_key = response
.public_key()
Expand Down Expand Up @@ -247,4 +251,4 @@ impl Account for AwsWallet {
tb.add_signer(self.clone())?;
Ok(())
}
}
}
1 change: 0 additions & 1 deletion packages/fuels-accounts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ mod coin_cache;

pub mod predicate;


#[cfg(test)]
mod test {
#[test]
Expand Down
2 changes: 1 addition & 1 deletion scripts/change-log/src/get_full_changelog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub async fn get_changelog_info(
.as_ref()
.map_or("misc", |title| title.split(':').next().unwrap_or("misc"))
.to_string();
let is_breaking = pr.title.as_ref().map_or(false, |title| title.contains('!'));
let is_breaking = pr.title.as_ref().is_some_and(|title| title.contains('!'));

let title_description = pr
.title
Expand Down

0 comments on commit 5b77e23

Please sign in to comment.