Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
neekolas committed Nov 16, 2023
1 parent 86d5420 commit 75f1cfc
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
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.
2 changes: 1 addition & 1 deletion examples/cli/cli-client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
5 changes: 1 addition & 4 deletions xmtp_mls/src/groups/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,10 +434,7 @@ where
Ok(())
}

pub async fn add_members_by_wallet_address(
&self,
wallet_addresses: Vec<String>,
) -> Result<(), GroupError> {
pub async fn add_members(&self, wallet_addresses: Vec<String>) -> Result<(), GroupError> {
let conn = &mut self.client.store.conn()?;
let key_packages = self
.client
Expand Down

0 comments on commit 75f1cfc

Please sign in to comment.