Skip to content
This repository has been archived by the owner on Apr 15, 2024. It is now read-only.

v2.0.0: User overhaul

Latest
Compare
Choose a tag to compare
@kwek20 kwek20 released this 31 Oct 20:33

Changelog

All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog,
and this project adheres to Semantic Versioning.

[2.0.0] - 2022-10-28

This version is not reverse compatible with v1.2.0

Large changes to the API to make the streams Library easier to use.
The previous version can be found under branch V1

This release is not compatible with stardust.

Effort towards this will be made in the branch named stardust, but as of yet is not functional. (See #284)

Added

- Generalized Author and Subscriber into User
- Created a User builder pattern for convenient creation
- Created a Message builder for sending messages
- User permission (Read/Write/Admin)
- Branch topics (Set a name for your stream and sub branches)
- Usage of DID Identifier using fragments
- A smaller Tangle client called uTangle (Nano-tangle)

Removed

- Old API

Changed

- Concrete Error types for each Streams crate
- Documentation on all public methods
- Merged crates into a more manageable layout
- Split Identifier into Identity and Identifier

Other

Bindings

  • Bindings temporarily removed. Once Rust API is stable, effort will be put into getting them back.

Protocol

  • The message index with the binary digest of the blake2b256 hash of the Message's Address has been slightly decreased in size again. This change was needed in order to have correct hex format whilst fitting in the 64 character limit. This results in indexes from a seed beeing different from their 1.2.0 counterpart

Quick start example

This example shows how to Create a User and send a message in the new system. For further use for now we would like to refer to our scenarios

Cargo.toml:

streams = { git = "https://github.com/iotaledger/streams", branch = "main" }
anyhow = {version = "1.0", default-features = false}
tokio = {version = "1.5", features = ["rt-multi-thread", "macros"]}
hex = {version = "0.4", default-features = false}
use streams::{
    transport::utangle::Client,
    id::Ed25519, User,
};

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let seed = std::env::var("SEED")?;
    let node_url = "https://api.lb-0.h.chrysalis-devnet.iota.cafe";
    let transport: Client = Client::new(node_url);
    let mut author = User::builder()
        .with_transport(transport)
        .with_identity(Ed25519::from_seed(seed))
        .build();

    let base_branch = "BASE_BRANCH";
    let _announcement = author.create_stream(base_branch).await?;

    let payload = b"PUBLICPAYLOAD";
    // Create and send public message with payload (unencrypted)
    let message = author.message().public().with_payload(*payload).send().await?;
    // You can look this index up on the explorer: https://explorer.iota.org/devnet
    println!("message index: {}", hex::encode(message.address().to_msg_index()));
    Ok(())
}