Skip to content

Commit

Permalink
MLS CLI (#338)
Browse files Browse the repository at this point in the history
  • Loading branch information
neekolas authored Nov 17, 2023
1 parent c2eab48 commit 945205f
Show file tree
Hide file tree
Showing 9 changed files with 219 additions and 111 deletions.
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
**/target/**
**/node_modules
**/.build/**
**/build/**
**/build/**
rust-toolchain.toml
3 changes: 2 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 6 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
FROM ghcr.io/xmtp/rust:latest
USER xmtp

RUN ~xmtp/.cargo/bin/rustup toolchain install stable
RUN ~xmtp/.cargo/bin/rustup component add rustfmt
RUN ~xmtp/.cargo/bin/rustup component add clippy
RUN sudo apt update && sudo apt install -y pkg-config openssl

WORKDIR /workspaces/libxmtp
COPY --chown=xmtp:xmtp . .

ENV PATH=~xmtp/.cargo/bin:$PATH
ENV USER=xmtp

RUN ~xmtp/.cargo/bin/cargo check
RUN ~xmtp/.cargo/bin/cargo fmt --check
RUN ~xmtp/.cargo/bin/cargo clippy --all-features --no-deps
RUN ~xmtp/.cargo/bin/cargo clippy --all-features --no-deps --manifest-path xmtp/Cargo.toml
RUN cargo check
RUN cargo fmt --check
RUN cargo clippy --all-features --no-deps
RUN cargo clippy --all-features --no-deps --manifest-path xmtp/Cargo.toml
# some tests are setup as integration tests 👀 xmtp_mls
RUN for crate in xmtp xmtp_api_grpc xmtp_api_grpc_gateway xmtp_cryptography xmtp_proto xmtp_v2; do cd ${crate}; ~xmtp/.cargo/bin/cargo test; done
RUN for crate in xmtp_cryptography xmtp_proto xmtp_v2; do cd ${crate}; cargo test; done

LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.name="rustdev" \
Expand Down
13 changes: 8 additions & 5 deletions examples/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ name = "cli-client"
path = "cli-client.rs"

[dependencies]
clap = {version = "4.3.0", features=["derive"]}
clap = { version = "4.4.6", features = ["derive"] }
ethers = "2.0.4"
ethers-core = "2.0.4"
env_logger = "0.10.0"
Expand All @@ -18,10 +18,13 @@ log = "0.4.17"
thiserror = "1.0.40"
tokio = "1.28.1"
url = "2.3.1"
walletconnect = {git="https://github.com/nlordell/walletconnect-rs.git", features=["qr", "transport"]}
xmtp = { path = "../../xmtp", features = ["grpc", "native"] }
xmtp_cryptography = { path = "../../xmtp_cryptography"}
walletconnect = { git = "https://github.com/nlordell/walletconnect-rs.git", features = [
"qr",
"transport",
] }
xmtp_mls = { path = "../../xmtp_mls", features = ["grpc", "native"] }
xmtp_cryptography = { path = "../../xmtp_cryptography" }
xmtp_api_grpc = { path = "../../xmtp_api_grpc" }
xmtp_proto = { path = "../../xmtp_proto", features = ["proto_full", "grpc"] }
timeago = "0.4.1"

hex = "0.4.3"
25 changes: 18 additions & 7 deletions examples/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

![Status](https://img.shields.io/badge/Project_status-Alpha-orange)

This is a demo XMTP v3-alpha console client (CLI) that you can use to send and receive messages via the command line. Specifically, you can use it to try out [double ratchet messaging](https://github.com/xmtp/libxmtp/blob/main/README.md#double-ratchet-messaging) and [installation key bundles](https://github.com/xmtp/libxmtp/blob/main/README.md#installation-key-bundles) enabled by XMTP v3-alpha.
This is a demo XMTP MLS console client (CLI) that you can use to send and receive messages via the command line.

> **Important**
> This software is in **alpha** status and ready for you to start experimenting with. Expect frequent changes as we add features and iterate based on feedback.
## Send a double ratchet message
## Create a MLS group

Use the CLI to send a [double ratchet message](https://github.com/xmtp/libxmtp/blob/main/README.md#double-ratchet-messaging) between test wallets on the XMTP `dev` network.

1. Go to the `examples/cli` directory.

2. Create a sender wallet account (user1). Create an [installation key bundle](https://github.com/xmtp/libxmtp/blob/main/README.md#installation-key-bundles) and store it in the database. Grant the installation key bundle permission to message on behalf of the sender address. This will allow the CLI to message on behalf of the sender address.
2. Create a sender wallet account (user1). Create an [XMTP identity](../../xmtp_mls/IDENTITY.md) and store it in the database. Grant the installation key bundle permission to message on behalf of the sender address. This will allow the CLI to message on behalf of the sender address.

```bash
./xli.sh --db user1.db3 register
Expand All @@ -31,16 +31,27 @@ Use the CLI to send a [double ratchet message](https://github.com/xmtp/libxmtp/b
./xli.sh --db user2.db3 info
```

5. Send a message into the conversation. The message is sent using [one session between each installation](https://github.com/xmtp/libxmtp/blob/main/README.md#installation-key-bundles) associated with the sender and recipient. The message is encrypted using a per-message encryption key derived using the [double ratchet algorithm](https://github.com/xmtp/libxmtp/blob/main/README.md#double-ratchet-messaging).
5. Create a new group and take note of the group ID.

```bash
./xli.sh --db user1.db3 send <user2_address> "hello"
./xli.sh --db user1.db3 create-group
```

6. List conversations and messages.
6. Add user 2 to the group

```bash
./xli.sh --db user1.db3 list-conversations
./xli.sh --db user1.db3 add-group-member $GROUP_ID $USER_2_WALLET_ADDRESS
```

7. Send a message
```bash
./xli.sh --db user1.db3 send $GROUP_ID "hello world"
```

8. Have User 2 read the message

```bash
./xli.sh --db user2.db3 list-group-messages $GROUP_ID
```

If you want to run the CLI against localhost, go to the root directory and run `dev/up` to start a local server. Then run the CLI commands using the `--local` flag.
Binary file added examples/cli/alice.db
Binary file not shown.
Loading

0 comments on commit 945205f

Please sign in to comment.