Skip to content
This repository was archived by the owner on Feb 28, 2025. It is now read-only.

Commit afcc915

Browse files
committed
missing metadata should result in error
1 parent 328d584 commit afcc915

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

lib/src/error.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub enum ResolverError<M: Middleware> {
1919
}
2020

2121
/// Errors originating from the parsing of a did url identifier, [`Did`](crate::types::DidUrl)
22-
#[derive(Error, Debug)]
22+
#[derive(Error, Debug, PartialEq)]
2323
pub enum DidError {
2424
#[error("Parsing of ethr:did failed, {0}")]
2525
Parse(#[from] peg::error::ParseError<peg::str::LineCol>),
@@ -28,7 +28,7 @@ pub enum DidError {
2828
}
2929

3030
/// Errors originating during the construction of a ethr:did document [`EthrBuilder`](crate::types::EthrBuilder)
31-
#[derive(Error, Debug)]
31+
#[derive(Error, Debug, PartialEq)]
3232
pub enum EthrBuilderError {
3333
#[error(transparent)]
3434
Did(#[from] DidError),
@@ -38,6 +38,8 @@ pub enum EthrBuilderError {
3838
Hex(#[from] hex::FromHexError),
3939
#[error("Parsing part of ethr:did failed, {0}")]
4040
Parse(#[from] peg::error::ParseError<peg::str::LineCol>),
41+
#[error("XMTP Key is missing key purpose metadata")]
42+
MissingMetadata,
4143
}
4244

4345
impl<M: Middleware> From<ResolverError<M>> for ErrorObjectOwned {

lib/src/types/ethr.rs

+20-1
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ impl EthrBuilder {
298298
//TODO: Formalize XMTP metadata into typed enum
299299
method.id.set_query("meta", Some("installation_key"))
300300
}
301-
_ => method.id.set_query("meta", None),
301+
_ => return Err(EthrBuilderError::MissingMetadata),
302302
}
303303
self.authentication.push(method.id.clone());
304304
}
@@ -933,4 +933,23 @@ mod tests {
933933
);
934934
assert_eq!(doc.verification_method[1].id.path(), "/xmtp");
935935
}
936+
937+
#[test]
938+
fn test_xmtp_keys_no_metadata() {
939+
let identity = address("0x7e575682a8e450e33eb0493f9972821ae333cd7f");
940+
let attributes = vec![DidattributeChangedFilter {
941+
name: *b"did/pub/ed25519/xmtp/hex ",
942+
value: b"02b97c30de767f084ce3080168ee293053ba33b235d7116a3263d29f1450936b71".into(),
943+
..base_attr_changed(identity, None)
944+
}];
945+
946+
let mut builder = EthrBuilder::default();
947+
builder.public_key(&identity).unwrap();
948+
builder.now(U256::zero());
949+
950+
for attr in attributes {
951+
builder.attribute_event(attr).unwrap()
952+
}
953+
assert_eq!(builder.build(), Err(EthrBuilderError::MissingMetadata));
954+
}
936955
}

0 commit comments

Comments
 (0)