This repository was archived by the owner on Feb 28, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Revoke Installation #38
Merged
Merged
Changes from 3 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
53c0a92
revoke installation
insipx ecdbc04
Merge branch 'main' of github.com:xmtp/xps-gateway into insipx/revoke…
insipx fbc885d
integration testing
insipx b2162da
fmt
insipx 3a12d32
a version of signing which works
insipx a83e204
docs
insipx 7fcd629
update for new didethresolver format
insipx dcd9f28
Merge branch 'main' of github.com:xmtp/xps-gateway into insipx/revoke…
insipx 93703b1
change back to git repo
insipx d6317c9
typo
insipx fae2319
include anvil in Dockerfile; do not run integration tests in github p…
insipx 1ff759b
anvil in coverage
insipx 85ac24e
add test for Gateway Constructor
insipx 85f5e92
add test for Gateway Constructor
insipx 6468aa3
Merge branch 'main' of github.com:xmtp/xps-gateway into insipx/revoke…
insipx 66d59f3
fix debugging logic
insipx 275758c
fix debugging logic
insipx d99052c
fmt
insipx 72d3ba7
re-run coverage
insipx d6ba48b
change didethresolver branch to main
insipx 4fc2bf5
coverage verbosity to info
insipx a0f30f6
Merge branch 'main' of github.com:xmtp/xps-gateway into insipx/revoke…
insipx 1536bf5
re-add anvil to coverage
insipx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,33 @@ | ||
[workspace] | ||
|
||
members = [ | ||
"xps-gateway", | ||
"messaging", | ||
"inbox", | ||
"registry", | ||
"xps-gateway", | ||
"messaging", | ||
"inbox", | ||
"registry", | ||
"gateway-types", | ||
] | ||
|
||
exclude = [ ] | ||
|
||
# Make the feature resolver explicit. | ||
# See https://doc.rust-lang.org/edition-guide/rust-2021/default-cargo-resolver.html#details | ||
resolver = "2" | ||
|
||
[workspace.dependencies] | ||
log = "0.4" | ||
tracing = "0.1" | ||
tracing-subscriber = { version = "0.3.18", features = ["fmt", "env-filter"] } | ||
serde = "1.0" | ||
serde_json = "1.0" | ||
tokio = { version = "1.0", features = ["macros", "rt-multi-thread"] } | ||
async-trait = "0.1" | ||
jsonrpsee = { version = "0.21", features = ["macros", "server", "client-core"] } | ||
anyhow = "1.0" | ||
thiserror = "1.0" | ||
ethers = { version = "2", features = ["abigen"] } | ||
ctor = "0.2" | ||
lib-didethresolver = { git = "https://github.com/xmtp/didethresolver", branch = "insipx/revoke-installation", package = "lib-didethresolver" } | ||
gateway-types = { path = "./gateway-types" } | ||
rustc-hex = "2.1" | ||
hex = "0.4" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[package] | ||
name = "gateway-types" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
serde.workspace = true | ||
lib-didethresolver.workspace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
use lib_didethresolver::types::{ | ||
Attribute, KeyEncoding, KeyMetadata, KeyPurpose, KeyType, PublicKey, | ||
}; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
/// Address of the did:ethr Registry on Sepolia | ||
pub const DID_ETH_REGISTRY: &str = "0xd1D374DDE031075157fDb64536eF5cC13Ae75000"; | ||
|
||
/// A message sent to a conversation | ||
#[derive(Serialize, Deserialize)] | ||
pub struct Message { | ||
// Unique identifier for a conversation | ||
#[serde(rename = "conversationId")] | ||
pub conversation_id: Vec<u8>, | ||
/// message content in bytes | ||
pub payload: Vec<u8>, | ||
/// Signature of V | ||
pub v: Vec<u8>, | ||
/// Signature of R | ||
pub r: Vec<u8>, | ||
/// Signature of S | ||
pub s: Vec<u8>, | ||
} | ||
|
||
/// The XMTP-specific attribute type | ||
#[derive(Serialize, Deserialize)] | ||
pub enum XmtpAttributeType { | ||
InstallationKey, | ||
} | ||
|
||
impl From<XmtpAttributeType> for Attribute { | ||
fn from(attribute: XmtpAttributeType) -> Self { | ||
match attribute { | ||
XmtpAttributeType::InstallationKey => Attribute::PublicKey(PublicKey { | ||
key_type: KeyType::Ed25519VerificationKey2020, | ||
purpose: KeyPurpose::Xmtp, | ||
encoding: KeyEncoding::Hex, | ||
metadata: Some(KeyMetadata::Installation), | ||
}), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1 @@ | ||
pub fn add(left: usize, right: usize) -> usize { | ||
left + right | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
#[test] | ||
fn it_works() { | ||
let result = add(2, 2); | ||
assert_eq!(result, 4); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
//! Contact Operations | ||
|
||
use std::str::FromStr; | ||
|
||
use ethers::{core::types::Signature, providers::Middleware, types::Address}; | ||
use gateway_types::XmtpAttributeType; | ||
use lib_didethresolver::{did_registry::DIDRegistry, types::Attribute}; | ||
|
||
use crate::error::ContactOperationError; | ||
|
||
pub struct ContactOperations<Middleware> { | ||
registry: DIDRegistry<Middleware>, | ||
} | ||
|
||
impl<M> ContactOperations<M> | ||
where | ||
M: Middleware + 'static, | ||
{ | ||
/// Creates a new ContactOperations instance | ||
pub fn new(registry: DIDRegistry<M>) -> Self { | ||
Self { registry } | ||
} | ||
|
||
pub async fn revoke_installation( | ||
&self, | ||
did: String, | ||
name: XmtpAttributeType, | ||
value: Vec<u8>, | ||
signature: Signature, | ||
) -> Result<(), ContactOperationError<M>> { | ||
// for now, we will just assume the DID is a valid ethereum wallet address | ||
// TODO: Parse or resolve the actual DID | ||
// TODO: Remove unwraps | ||
let address = Address::from_str(&did)?; | ||
self.registry | ||
.revoke_attribute_signed( | ||
address, | ||
signature.v.try_into().unwrap(), | ||
signature.r.try_into().unwrap(), | ||
signature.s.try_into().unwrap(), | ||
Attribute::from(name).into(), | ||
value.into(), | ||
) | ||
.send() | ||
.await? | ||
.await?; | ||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
use ethers::{ | ||
contract::ContractError, | ||
providers::{Middleware, ProviderError}, | ||
}; | ||
use thiserror::Error; | ||
|
||
#[derive(Error, Debug)] | ||
pub enum ContactOperationError<M: Middleware> { | ||
#[error("Invalid address {0}")] | ||
BadAddress(#[from] rustc_hex::FromHexError), | ||
#[error(transparent)] | ||
ContractError(#[from] ContractError<M>), | ||
#[error(transparent)] | ||
ProviderError(#[from] ProviderError), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,9 @@ | ||
pub fn add(left: usize, right: usize) -> usize { | ||
left + right | ||
} | ||
mod contact_operations; | ||
pub mod error; | ||
|
||
pub use contact_operations::*; | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
#[test] | ||
fn it_works() { | ||
let result = add(2, 2); | ||
assert_eq!(result, 4); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀