refactor(client-auth): introduce ClientId newtype to avoid client_id/nonce confusion

refactor(user-agent): replace manual terminality helper with fatality::Fatality
This commit is contained in:
CleverWild
2026-03-19 19:07:19 +01:00
parent e1a8553142
commit 971db0e919
4 changed files with 112 additions and 43 deletions

View File

@@ -27,6 +27,7 @@ rustls.workspace = true
smlang.workspace = true
miette.workspace = true
thiserror.workspace = true
fatality = "0.1.1"
diesel_migrations = { version = "2.3.1", features = ["sqlite"] }
async-trait.workspace = true
secrecy = "0.10.3"

View File

@@ -15,7 +15,7 @@ use tracing::{error, info};
use crate::{
actors::{
GlobalActors,
client::{ClientConnection, ClientError},
client::{ClientConnection, ClientError, auth::ClientId},
evm::ClientSignTransaction,
router::RegisterClient,
},
@@ -24,11 +24,11 @@ use crate::{
pub struct ClientSession {
props: ClientConnection,
client_id: i32,
client_id: ClientId,
}
impl ClientSession {
pub(crate) fn new(props: ClientConnection, client_id: i32) -> Self {
pub(crate) fn new(props: ClientConnection, client_id: ClientId) -> Self {
Self { props, client_id }
}
@@ -54,7 +54,7 @@ impl ClientSession {
.actors
.evm
.ask(ClientSignTransaction {
client_id: self.client_id,
client_id: self.client_id.as_i32(),
wallet_address: Address::from_slice(&wallet_address),
transaction: tx,
})
@@ -145,7 +145,7 @@ impl ClientSession {
let props = ClientConnection::new(db, transport, actors);
Self {
props,
client_id: 0,
client_id: ClientId::new(0),
}
}
}

View File

@@ -4,6 +4,7 @@ use arbiter_proto::{
},
transport::Bi,
};
use fatality::Fatality;
use kameo::actor::Spawn as _;
use tracing::{error, info};
@@ -38,8 +39,8 @@ pub enum TransportResponseError {
ConnectionRegistrationFailed,
}
impl TransportResponseError {
pub fn is_terminal(&self) -> bool {
impl Fatality for TransportResponseError {
fn is_fatal(&self) -> bool {
!matches!(
self,
Self::SdkClientApprove(_) | Self::SdkClientList(_) | Self::SdkClientRevoke(_)