Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MLS CLI #338

Merged
merged 10 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

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

RUN ~xmtp/.cargo/bin/rustup toolchain install stable
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These components are already in the base image, so we don't need to install them again. For some reason the re-install is failing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems related to this issue (same error). Dockerignoring the rust-toolchain.toml file does avoid the issue, at the cost of forcing us to use the rust toolchain from the base docker file instead of the one specified in the rust-toolchain.toml

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jac18281828 might be able to help, maybe because of some updates?

RUN ~xmtp/.cargo/bin/rustup component add rustfmt
RUN ~xmtp/.cargo/bin/rustup component add clippy

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

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
Loading