Skip to content
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
4 changes: 2 additions & 2 deletions Earthfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
VERSION 0.8

IMPORT github.com/input-output-hk/catalyst-ci/earthly/mdlint:v3.5.28 AS mdlint-ci
IMPORT github.com/input-output-hk/catalyst-ci/earthly/cspell:v3.5.28 AS cspell-ci
IMPORT github.com/input-output-hk/catalyst-ci/earthly/mdlint:v3.6.1 AS mdlint-ci
IMPORT github.com/input-output-hk/catalyst-ci/earthly/cspell:v3.6.1 AS cspell-ci


# cspell: words livedocs sitedocs
Expand Down
2 changes: 1 addition & 1 deletion docs/Earthfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
VERSION 0.8

IMPORT github.com/input-output-hk/catalyst-ci/earthly/docs:v3.5.28 AS docs-ci
IMPORT github.com/input-output-hk/catalyst-ci/earthly/docs:v3.6.1 AS docs-ci

IMPORT .. AS repo
IMPORT ../hermes AS hermes
Expand Down
2 changes: 1 addition & 1 deletion hermes/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ default-members = [
]

[workspace.package]
edition = "2021"
edition = "2024"
version = "0.0.1"
authors = [
"Steven Johnson <[email protected]>"
Expand Down
2 changes: 1 addition & 1 deletion hermes/Earthfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
VERSION 0.8

IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.5.28 AS rust-ci
IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.6.1 AS rust-ci

# Use when debugging cat-ci locally.
# IMPORT ../../catalyst-ci/earthly/rust AS rust-ci
Expand Down
2 changes: 1 addition & 1 deletion hermes/apps/athena/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ resolver = "2"
members = ["shared", "modules/*"]

[workspace.package]
edition = "2021"
edition = "2024"

[workspace.lints.rust]
warnings = "deny"
Expand Down
2 changes: 1 addition & 1 deletion hermes/apps/athena/Earthfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
VERSION 0.8

IMPORT ../../../wasm AS wasm
IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.5.28 AS rust-ci
IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.6.1 AS rust-ci

# Make an artifact which consists of the common code shared by Athena modules.
workspace-src:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ use shared::{
};

use crate::database::{
query_builder::QueryBuilder, RBAC_REGISTRATION_PERSISTENT_TABLE_NAME,
RBAC_REGISTRATION_VOLATILE_TABLE_NAME, RBAC_STAKE_ADDRESS_PERSISTENT_TABLE_NAME,
RBAC_STAKE_ADDRESS_VOLATILE_TABLE_NAME,
RBAC_REGISTRATION_PERSISTENT_TABLE_NAME, RBAC_REGISTRATION_VOLATILE_TABLE_NAME,
RBAC_STAKE_ADDRESS_PERSISTENT_TABLE_NAME, RBAC_STAKE_ADDRESS_VOLATILE_TABLE_NAME,
query_builder::QueryBuilder,
};

/// Create a persistent `rbac_registration` and `rbac_stake_address` table.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ use shared::{
};

use crate::database::{
RBAC_REGISTRATION_PERSISTENT_TABLE_NAME, RBAC_REGISTRATION_VOLATILE_TABLE_NAME,
RBAC_STAKE_ADDRESS_PERSISTENT_TABLE_NAME, RBAC_STAKE_ADDRESS_VOLATILE_TABLE_NAME,
create::{create_rbac_persistent_tables, create_rbac_volatile_tables},
data::{rbac_db::RbacDbData, rbac_stake_db::RbacStakeDbData},
delete::{
Expand All @@ -52,8 +54,6 @@ use crate::database::{
rbac_table::{insert_rbac_registration, prepare_insert_rbac_registration},
stake_addr_table::{insert_rbac_stake_address, prepare_insert_rbac_stake_address},
},
RBAC_REGISTRATION_PERSISTENT_TABLE_NAME, RBAC_REGISTRATION_VOLATILE_TABLE_NAME,
RBAC_STAKE_ADDRESS_PERSISTENT_TABLE_NAME, RBAC_STAKE_ADDRESS_VOLATILE_TABLE_NAME,
};

/// RBAC registration component.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ use shared::{
log::log_error,
sqlite::{
operation::Operation,
statement::{column_as, DatabaseStatement},
statement::{DatabaseStatement, column_as},
},
},
};

use crate::{
database::{
query_builder::QueryBuilder, select::TableSource, RBAC_REGISTRATION_PERSISTENT_TABLE_NAME,
RBAC_REGISTRATION_VOLATILE_TABLE_NAME,
RBAC_REGISTRATION_PERSISTENT_TABLE_NAME, RBAC_REGISTRATION_VOLATILE_TABLE_NAME,
query_builder::QueryBuilder, select::TableSource,
},
rbac::{rbac_chain_metadata::RbacChainMetadata, registration_location::RegistrationLocation},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@
use cardano_blockchain_types::StakeAddress;
use shared::{
bindings::hermes::{
logging::api::{log, Level},
logging::api::{Level, log},
sqlite::api::{Sqlite, Statement, StepResult, Value},
},
sqlite_bind_parameters,
utils::{
log::log_error,
sqlite::{
operation::Operation,
statement::{column_as, DatabaseStatement},
statement::{DatabaseStatement, column_as},
},
},
};

use crate::{
database::{
query_builder::QueryBuilder, select::cat_id::select_rbac_registration_chain_from_cat_id,
RBAC_REGISTRATION_PERSISTENT_TABLE_NAME, RBAC_REGISTRATION_VOLATILE_TABLE_NAME,
RBAC_STAKE_ADDRESS_PERSISTENT_TABLE_NAME, RBAC_STAKE_ADDRESS_VOLATILE_TABLE_NAME,
query_builder::QueryBuilder, select::cat_id::select_rbac_registration_chain_from_cat_id,
},
rbac::{rbac_chain_metadata::RbacChainMetadata, registration_location::RegistrationLocation},
};
Expand Down Expand Up @@ -264,7 +264,7 @@ fn get_registration_info_from_txn_id(
DatabaseStatement::reset_statement(stmt, FUNCTION_NAME)?;
sqlite_bind_parameters!(stmt, FUNCTION_NAME, txn_id.to_vec() => "txn_id")?;

let result = match stmt.step() {
match stmt.step() {
// This should have data since txn_id is extract from `rbac_stake_address`
Ok(StepResult::Row) => {
Ok(Some((
Expand All @@ -274,9 +274,7 @@ fn get_registration_info_from_txn_id(
column_as::<u16>(stmt, 3, FUNCTION_NAME, "txn_idx")?,
)))
},
Ok(StepResult::Done) => {
return Ok(None);
},
Ok(StepResult::Done) => Ok(None),
Err(e) => {
let error = format!("Failed to step: {e}");
log_error(
Expand All @@ -288,8 +286,7 @@ fn get_registration_info_from_txn_id(
);
anyhow::bail!(error);
},
};
result
}
}

/// Construct a registration chain by walking back a chain
Expand Down
2 changes: 1 addition & 1 deletion hermes/apps/athena/modules/rbac-registration/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl exports::hermes::http_gateway::event::Guest for RbacRegistrationComponent {
Some(HttpGatewayResponse::Http(HttpResponse {
code,
headers: vec![("content-type".to_string(), vec![
"application/json".to_string()
"application/json".to_string(),
])],
body: Bstr::from(match result.to_json() {
Ok(json) => json,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! RBAC chain metadata.

use cardano_blockchain_types::{hashes::TransactionId, Slot};
use cardano_blockchain_types::{Slot, hashes::TransactionId};

/// RBAC chain metadata.
#[derive(Debug, Clone, Default)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! A RBAC registration chain information.

use cardano_blockchain_types::{hashes::TransactionId, Network, Slot};
use cardano_blockchain_types::{Network, Slot, hashes::TransactionId};
use rbac_registration::registration::cardano::RegistrationChain;

/// A RBAC registration chain along with additional information.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//!
//! More information can be found in [CIP-19](https://cips.cardano.org/cip/CIP-19)

use cardano_blockchain_types::{pallas_addresses::Address, StakeAddress};
use cardano_blockchain_types::{StakeAddress, pallas_addresses::Address};

/// Length of the decoded address.
const DECODED_ADDR_LEN: usize = 29;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Transaction ID.

use cardano_blockchain_types::hashes::{TransactionId, BLAKE_2B256_SIZE};
use cardano_blockchain_types::hashes::{BLAKE_2B256_SIZE, TransactionId};
use serde::Serialize;

/// A Cardano transaction ID.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ fn is_valid(uuidv4: &str) -> bool {
#[allow(clippy::unwrap_used)] // Safe because the Regex is constant.
static RE: LazyLock<Regex> = LazyLock::new(|| Regex::new(PATTERN).unwrap());

if RE.is_match(uuidv4) {
if let Ok(uuid) = uuid::Uuid::parse_str(uuidv4) {
return uuid.get_version() == Some(uuid::Version::Random);
}
if RE.is_match(uuidv4)
&& let Ok(uuid) = uuid::Uuid::parse_str(uuidv4)
{
return uuid.get_version() == Some(uuid::Version::Random);
}
false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

use shared::{
cardano_blockchain_types::{
MultiEraBlock, Network, StakeAddress,
hashes::{Blake2b256Hash, TransactionId},
pallas_addresses::{Address, ShelleyDelegationPart},
pallas_traverse::{MultiEraOutput, MultiEraTx},
MultiEraBlock, Network, StakeAddress,
},
database::staked_ada::{TxiByTxnIdRow, TxoAssetsByStakeRow, TxoByStakeRow},
utils::log::{error, warn},
Expand Down
12 changes: 6 additions & 6 deletions hermes/apps/athena/modules/staked-ada/src/api/assets_get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use std::collections::{HashMap, HashSet};
use cardano_blockchain_types::StakeAddress;
use shared::{
database::staked_ada::{
get_txi_by_txn_ids, get_txo_assets_by_stake_address, get_txo_by_stake_address,
update_txo_spent, UpdateTxoSpentParams,
UpdateTxoSpentParams, get_txi_by_txn_ids, get_txo_assets_by_stake_address,
get_txo_by_stake_address, update_txo_spent,
},
utils::{
common::{
Expand Down Expand Up @@ -241,10 +241,10 @@ fn build_stake_info(
continue;
}
// Filter out spent TXOs.
if let Some(spent_slot) = txo_info.spent_slot_no {
if spent_slot <= slot_num {
continue;
}
if let Some(spent_slot) = txo_info.spent_slot_no
&& spent_slot <= slot_num
{
continue;
}

let value = AdaValue::try_from(txo_info.value)
Expand Down
2 changes: 1 addition & 1 deletion hermes/apps/athena/modules/staked-ada/src/api/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use std::collections::HashMap;

use cardano_blockchain_types::{hashes::TransactionId, Slot, TxnIndex};
use cardano_blockchain_types::{Slot, TxnIndex, hashes::TransactionId};
use shared::utils::common::{
objects::cardano::stake_info::FullStakeInfo, responses::WithErrorResponses,
};
Expand Down
4 changes: 2 additions & 2 deletions hermes/apps/athena/modules/staked-ada/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ shared::bindings_generate!({
});
export!(CatGatewayAPI);

use http::{header::CONTENT_TYPE, StatusCode};
use http::{StatusCode, header::CONTENT_TYPE};
use mime::{APPLICATION_JSON, TEXT_HTML};
use regex::Regex;
use shared::utils::{
Expand All @@ -39,7 +39,7 @@ use shared::utils::{
};

use crate::{
api::{staked_ada_get, types::Responses, GetStakedAdaRequest},
api::{GetStakedAdaRequest, staked_ada_get, types::Responses},
config::messages,
error::{Result, StakedAdaError},
};
Expand Down
2 changes: 1 addition & 1 deletion hermes/apps/athena/shared/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
edition = "2021"
edition = "2024"
name = "shared"
version = "0.1.0"
license = "MIT OR Apache-2.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! `SELECT` queries.

use cardano_blockchain_types::{hashes::TransactionId, StakeAddress};
use cardano_blockchain_types::{StakeAddress, hashes::TransactionId};

use crate::{
database::{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! `SQLite` queries types.

use cardano_blockchain_types::{hashes::TransactionId, pallas_primitives::PolicyId, StakeAddress};
use cardano_blockchain_types::{StakeAddress, hashes::TransactionId, pallas_primitives::PolicyId};
use derive_more::From;
use num_bigint::{BigInt, BigUint};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ use std::{
time::Duration,
};

use anyhow::{anyhow, Context, Result};
use base64::{prelude::BASE64_URL_SAFE_NO_PAD, Engine};
use anyhow::{Context, Result, anyhow};
use base64::{Engine, prelude::BASE64_URL_SAFE_NO_PAD};
use cardano_blockchain_types::Network;
use catalyst_types::catalyst_id::CatalystId;
use chrono::{TimeDelta, Utc};
use ed25519_dalek::{ed25519::signature::Signer, Signature, SigningKey, VerifyingKey};
use ed25519_dalek::{Signature, SigningKey, VerifyingKey, ed25519::signature::Signer};
use rbac_registration::registration::cardano::RegistrationChain;
use regex::Regex;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub struct AsAt((String, u64, SlotNo));

impl From<AsAt> for SlotNo {
fn from(value: AsAt) -> Self {
value.0 .2
value.0.2
}
}

Expand All @@ -29,6 +29,6 @@ impl Display for AsAt {
&self,
f: &mut fmt::Formatter<'_>,
) -> fmt::Result {
write!(f, "{}:{}", self.0 .0, self.0 .1)
write!(f, "{}:{}", self.0.0, self.0.1)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! More information can be found in [CIP-19](https://cips.cardano.org/cip/CIP-19)
use anyhow::bail;
use cardano_blockchain_types::{pallas_addresses::Address, StakeAddress};
use cardano_blockchain_types::{StakeAddress, pallas_addresses::Address};

use crate::utils::common::types::string_types::impl_string_types;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Transaction ID.

use cardano_blockchain_types::hashes::{TransactionId, BLAKE_2B256_SIZE};
use cardano_blockchain_types::hashes::{BLAKE_2B256_SIZE, TransactionId};

use crate::utils::{common::types::string_types::impl_string_types, hex::as_hex_string};

Expand Down
2 changes: 1 addition & 1 deletion hermes/apps/athena/shared/src/utils/hex.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Hex helper functions

use anyhow::{bail, Result};
use anyhow::{Result, bail};

/// Convert bytes to hex string with the `0x` prefix
pub(crate) fn as_hex_string<T: AsRef<[u8]>>(bytes: T) -> String {
Expand Down
2 changes: 1 addition & 1 deletion hermes/apps/athena/shared/src/utils/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use std::sync::Once;

use log::Log;
pub use log::{debug, error, info, log_enabled, trace, warn, LevelFilter};
pub use log::{LevelFilter, debug, error, info, log_enabled, trace, warn};

/// Compatibility between [`crate::bindings::hermes::logging`] and [`log`].
mod compat {
Expand Down
6 changes: 2 additions & 4 deletions hermes/apps/athena/shared/src/utils/settings/str_env_var.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,17 +132,15 @@ impl StringEnvVar {
(default.to_string().as_str(), redacted, choices.as_str()).into(),
);

let value = match T::from_str(choice.as_str()) {
match T::from_str(choice.as_str()) {
Ok(var) => var,
Err(error) => {
error!(
"Invalid choice. Using Default.; error={error}, default={default}, choices={choices:?}, choice={choice}"
);
default
},
};

value
}
}

/// Get the read env var as a str.
Expand Down
Loading