From 75f1cfc20d2873ad220592e6f13921feb19b93ac Mon Sep 17 00:00:00 2001 From: Nicholas Molnar <65710+neekolas@users.noreply.github.com> Date: Thu, 16 Nov 2023 15:09:47 -0800 Subject: [PATCH] Update README --- examples/cli/README.md | 25 ++++++++++++++++++------- examples/cli/cli-client.rs | 2 +- xmtp_mls/src/groups/mod.rs | 5 +---- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/examples/cli/README.md b/examples/cli/README.md index 89369634b..b7c5ff42b 100644 --- a/examples/cli/README.md +++ b/examples/cli/README.md @@ -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 @@ -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 "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. diff --git a/examples/cli/cli-client.rs b/examples/cli/cli-client.rs index 6faa23ddb..2705368de 100644 --- a/examples/cli/cli-client.rs +++ b/examples/cli/cli-client.rs @@ -219,7 +219,7 @@ async fn main() { .expect("failed to find group"); group - .add_members_by_wallet_address(vec![wallet_address.clone()]) + .add_members(vec![wallet_address.clone()]) .await .expect("failed to add member"); diff --git a/xmtp_mls/src/groups/mod.rs b/xmtp_mls/src/groups/mod.rs index d6f02360f..a87aad33b 100644 --- a/xmtp_mls/src/groups/mod.rs +++ b/xmtp_mls/src/groups/mod.rs @@ -434,10 +434,7 @@ where Ok(()) } - pub async fn add_members_by_wallet_address( - &self, - wallet_addresses: Vec, - ) -> Result<(), GroupError> { + pub async fn add_members(&self, wallet_addresses: Vec) -> Result<(), GroupError> { let conn = &mut self.client.store.conn()?; let key_packages = self .client