Skip to content

Commit 1dc2a79

Browse files
authored
feat(dips): implement error reporting (#665)
Signed-off-by: Lorenzo Delgado <[email protected]>
1 parent 6040383 commit 1dc2a79

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

crates/dips/src/lib.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ const CHAIN_ID_ARBITRUM_ONE: ChainId = 0xa4b1; // 42161
3434
const EIP712_DOMAIN_SALT: B256 =
3535
b256!("b4632c657c26dce5d4d7da1d65bda185b14ff8f905ddbb03ea0382ed06c5ef28");
3636

37+
/// DIPs Protocol version
38+
pub const PROTOCOL_VERSION: u64 = 1; // MVP
39+
3740
/// Create an EIP-712 domain given a chain ID and dispute manager address.
3841
pub fn dips_agreement_eip712_domain() -> Eip712Domain {
3942
eip712_domain! {
@@ -132,7 +135,7 @@ sol! {
132135

133136
#[derive(Error, Debug)]
134137
pub enum DipsError {
135-
// agreement cration
138+
// agreement creation
136139
#[error("signature is not valid, error: {0}")]
137140
InvalidSignature(String),
138141
#[error("payer {0} not authorised")]
@@ -167,11 +170,10 @@ pub enum DipsError {
167170
InvalidVoucher(String),
168171
}
169172

170-
// TODO: send back messages
171173
#[cfg(feature = "rpc")]
172174
impl From<DipsError> for tonic::Status {
173-
fn from(_val: DipsError) -> Self {
174-
tonic::Status::internal("unknown errr")
175+
fn from(value: DipsError) -> Self {
176+
tonic::Status::internal(format!("{}", value))
175177
}
176178
}
177179

crates/dips/src/server.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use crate::{
1919
},
2020
signers::SignerValidator,
2121
store::AgreementStore,
22-
validate_and_cancel_agreement, validate_and_create_agreement,
22+
validate_and_cancel_agreement, validate_and_create_agreement, PROTOCOL_VERSION,
2323
};
2424

2525
#[derive(Debug)]
@@ -78,7 +78,7 @@ impl IndexerDipsService for DipsServer {
7878
} = request.into_inner();
7979

8080
// Ensure the version is 1
81-
if version != 1 {
81+
if version != PROTOCOL_VERSION {
8282
return Err(Status::invalid_argument("invalid version"));
8383
}
8484

@@ -93,10 +93,9 @@ impl IndexerDipsService for DipsServer {
9393
&self.allowed_payers,
9494
signed_voucher,
9595
)
96-
.await
97-
.map_err(Into::<tonic::Status>::into)?;
96+
.await?;
9897

99-
Ok(tonic::Response::new(SubmitAgreementProposalResponse {
98+
Ok(Response::new(SubmitAgreementProposalResponse {
10099
response: ProposalResponse::Accept.into(),
101100
}))
102101
}

0 commit comments

Comments
 (0)