Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
5,914 changes: 5,914 additions & 0 deletions .github/notarization.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 7 additions & 7 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,13 @@ jobs:
awk '$1 ~ /[0-9].*/' | \
parallel -k -j 4 --retries 3 --joblog report.log ./target/release/examples/{}
cat report.log
# - name: Run Rust Readme examples
# # run examples only on ubuntu for now
# if: matrix.os == 'ubuntu-24.04'
# run: |
# cd bindings/wasm/notarization_wasm
# npm ci
# npm run test:readme:rust
# - name: Run Rust Readme examples
# # run examples only on ubuntu for now
# if: matrix.os == 'ubuntu-24.04'
# run: |
# cd bindings/wasm/notarization_wasm
# npm ci
# npm run test:readme:rust

- name: Archive server logs
if: ${{ env.IOTA_SERVER_LOGFILE }}
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ strum = { version = "0.27", default-features = false, features = ["std", "derive
thiserror = { version = "2.0", default-features = false }

secret-storage = { git = "https://github.com/iotaledger/secret-storage.git", tag = "v0.3.0", default-features = false }
tokio = { version = "1.43", default-features = false, features = ["macros", "sync", "rt", "process"] }
tokio = { version = "1.44.2", default-features = false, features = ["macros", "sync", "rt", "process"] }

[profile.release.package.iota_interaction_ts]
opt-level = 's'
328 changes: 33 additions & 295 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bindings/wasm/build/replace_paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function replace(tsconfig, dist, artifact, mode) {
value = path.relative(absoluteFilePath, absoluteIncludePath).replace(/\\/g, "/");
}

if(key.endsWith('*')) {
if (key.endsWith("*")) {
console.log(`\t dropping '*' from ${key}`);
key = key.slice(0, -1);
}
Expand Down
2 changes: 1 addition & 1 deletion bindings/wasm/notarization_wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ serde-wasm-bindgen = "0.6.5"
serde_json = { version = "1.0", default-features = false }
serde_repr = { version = "0.1", default-features = false }
# Want to use the nice API of tokio::sync::RwLock for now even though we can't use threads.
tokio = { version = "1.43", default-features = false, features = ["sync"] }
tokio = { version = "1.44.2", default-features = false, features = ["sync"] }
tsify = "0.4.5"
wasm-bindgen = { version = "0.2.100", features = ["serde-serialize"] }
wasm-bindgen-futures = { version = "0.4", default-features = false }
Expand Down
3 changes: 1 addition & 2 deletions bindings/wasm/notarization_wasm/src/wasm_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

use js_sys::Uint8Array;
use notarization::core::types::{Data, ImmutableMetadata, LockMetadata, State};
use notarization::core::NotarizationMethod;
use notarization::core::types::{Data, ImmutableMetadata, LockMetadata, NotarizationMethod, State};
use serde::{Deserialize, Serialize};
use wasm_bindgen::prelude::*;

Expand Down
5 changes: 2 additions & 3 deletions examples/01_create_locked_notarization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ use std::time::{SystemTime, UNIX_EPOCH};

use anyhow::Result;
use examples::get_funded_client;
use notarization::core::NotarizationMethod;
use notarization::core::types::{State, TimeLock};
use notarization::core::types::{NotarizationMethod, State, TimeLock};

#[tokio::main]
async fn main() -> Result<()> {
Expand All @@ -19,7 +18,7 @@ async fn main() -> Result<()> {
let now_ts = SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs();
let unlock_at = now_ts + 86400; // 24 hours

println!("Creating locked notarization with delete lock until: {}", unlock_at);
println!("Creating locked notarization with delete lock until: {unlock_at}");

// Create a locked notarization with state and delete lock
let locked_notarization = notarization_client
Expand Down
5 changes: 2 additions & 3 deletions examples/02_create_dynamic_notarization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ use std::time::{SystemTime, UNIX_EPOCH};

use anyhow::Result;
use examples::get_funded_client;
use notarization::core::NotarizationMethod;
use notarization::core::types::{State, TimeLock};
use notarization::core::types::{NotarizationMethod, State, TimeLock};

#[tokio::main]
async fn main() -> Result<()> {
Expand Down Expand Up @@ -65,7 +64,7 @@ async fn main() -> Result<()> {

println!("\n📊 Notarization Status:");
println!("Simple notarization - Method: {:?}", simple_notarization.method);
println!("Transfer-locked notarization - Transfer locked: {}", is_transfer_locked);
println!("Transfer-locked notarization - Transfer locked: {is_transfer_locked}");
println!("\n🔄 Dynamic notarizations can be updated and transferred (unless transfer-locked)");
println!("📝 State and metadata can be modified over time");

Expand Down
6 changes: 3 additions & 3 deletions examples/03_update_dynamic_notarization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async fn main() -> Result<()> {
.output
.id;

println!("✅ Dynamic notarization created with ID: {:?}", dynamic_notarization_id);
println!("✅ Dynamic notarization created with ID: {dynamic_notarization_id:?}");

let current_state = notarization_client.state(*dynamic_notarization_id.object_id()).await?;
println!("Initial state: {}", current_state.data.as_text()?);
Expand All @@ -44,7 +44,7 @@ async fn main() -> Result<()> {

match state_update_result {
Ok(_) => println!("✅ State update succeeded"),
Err(e) => println!("❌ State update failed - {}", e),
Err(e) => println!("❌ State update failed - {e}"),
}

println!("\n📝 Updating metadata on dynamic notarization...");
Expand All @@ -57,7 +57,7 @@ async fn main() -> Result<()> {

match metadata_update_result {
Ok(_) => println!("✅ Metadata update succeeded"),
Err(e) => println!("❌ Metadata update failed - {}", e),
Err(e) => println!("❌ Metadata update failed - {e}"),
}

let current_state = notarization_client.state(*dynamic_notarization_id.object_id()).await?;
Expand Down
30 changes: 12 additions & 18 deletions examples/04_destroy_notarization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ async fn main() -> Result<()> {
.output
.id;

println!("✅ Created unlocked dynamic notarization: {:?}", unlocked_dynamic_id);
println!("✅ Created unlocked dynamic notarization: {unlocked_dynamic_id:?}");

// Check if destroy is allowed
let is_destroy_allowed = notarization_client
.is_destroy_allowed(*unlocked_dynamic_id.object_id())
.await?;

println!("🔍 Destroy allowed: {}", is_destroy_allowed);
println!("🔍 Destroy allowed: {is_destroy_allowed}");

// Destroy the unlocked notarization
let destroy_result = notarization_client
Expand All @@ -44,7 +44,7 @@ async fn main() -> Result<()> {

match destroy_result {
Ok(_) => println!("✅ Successfully destroyed unlocked dynamic notarization"),
Err(e) => println!("❌ Failed to destroy: {}", e),
Err(e) => println!("❌ Failed to destroy: {e}"),
}

// Scenario 2: Try to destroy a transfer-locked dynamic notarization (should fail)
Expand All @@ -64,16 +64,13 @@ async fn main() -> Result<()> {
.output
.id;

println!(
"✅ Created transfer-locked dynamic notarization: {:?}",
transfer_locked_id
);
println!("✅ Created transfer-locked dynamic notarization: {transfer_locked_id:?}");

let is_destroy_allowed = notarization_client
.is_destroy_allowed(*transfer_locked_id.object_id())
.await?;

println!("🔍 Destroy allowed: {}", is_destroy_allowed);
println!("🔍 Destroy allowed: {is_destroy_allowed}");

// Try to destroy the transfer-locked notarization
let destroy_result = notarization_client
Expand All @@ -83,7 +80,7 @@ async fn main() -> Result<()> {

match destroy_result {
Ok(_) => println!("❌ Unexpected: Destruction succeeded (should have failed)"),
Err(e) => println!("✅ Expected: Destruction failed - {}", e),
Err(e) => println!("✅ Expected: Destruction failed - {e}"),
}

// Scenario 3: Create and try to destroy a time-locked locked notarization (should fail)
Expand All @@ -100,13 +97,13 @@ async fn main() -> Result<()> {
.output
.id;

println!("✅ Created delete-locked locked notarization: {:?}", delete_locked_id);
println!("✅ Created delete-locked locked notarization: {delete_locked_id:?}");

let is_destroy_allowed = notarization_client
.is_destroy_allowed(*delete_locked_id.object_id())
.await?;

println!("🔍 Destroy allowed: {}", is_destroy_allowed);
println!("🔍 Destroy allowed: {is_destroy_allowed}");

// Try to destroy the delete-locked notarization
let destroy_result = notarization_client
Expand All @@ -116,7 +113,7 @@ async fn main() -> Result<()> {

match destroy_result {
Ok(_) => println!("❌ Unexpected: Destruction succeeded (should have failed)"),
Err(e) => println!("✅ Expected: Destruction failed - {}", e),
Err(e) => println!("✅ Expected: Destruction failed - {e}"),
}

// Scenario 4: Create and destroy a locked notarization with no delete lock (should succeed)
Expand All @@ -133,16 +130,13 @@ async fn main() -> Result<()> {
.output
.id;

println!(
"✅ Created locked notarization with no delete lock: {:?}",
no_delete_lock_id
);
println!("✅ Created locked notarization with no delete lock: {no_delete_lock_id:?}");

let is_destroy_allowed = notarization_client
.is_destroy_allowed(*no_delete_lock_id.object_id())
.await?;

println!("🔍 Destroy allowed: {}", is_destroy_allowed);
println!("🔍 Destroy allowed: {is_destroy_allowed}");

// Destroy the notarization with no delete lock
let destroy_result = notarization_client
Expand All @@ -152,7 +146,7 @@ async fn main() -> Result<()> {

match destroy_result {
Ok(_) => println!("✅ Successfully destroyed locked notarization with no delete lock"),
Err(e) => println!("❌ Failed to destroy: {}", e),
Err(e) => println!("❌ Failed to destroy: {e}"),
}

println!("\n📋 Summary:");
Expand Down
14 changes: 7 additions & 7 deletions examples/05_update_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ async fn main() -> Result<()> {
.output
.id;

println!("✅ Created dynamic notarization: {:?}", notarization_id);
println!("✅ Created dynamic notarization: {notarization_id:?}");

// Show initial state
let initial_state = notarization_client.state(*notarization_id.object_id()).await?;
Expand All @@ -39,13 +39,13 @@ async fn main() -> Result<()> {
println!("\n📄 Initial State:");
println!("Content: {}", initial_state.data.as_text()?);
println!("Metadata: {:?}", initial_state.metadata);
println!("Version count: {}", initial_version_count);
println!("Version count: {initial_version_count}");

// Perform multiple state updates
println!("\n🔄 Performing state updates...");

for i in 1..=3 {
println!("\n--- Update {} ---", i);
println!("\n--- Update {i} ---");

let new_state = State::from_string(
format!("Updated document version {}", i + 1),
Expand All @@ -58,7 +58,7 @@ async fn main() -> Result<()> {
.build_and_execute(&notarization_client)
.await?;

println!("✅ State update {} completed", i);
println!("✅ State update {i} completed");

// Verify the update
let current_state = notarization_client.state(*notarization_id.object_id()).await?;
Expand All @@ -69,7 +69,7 @@ async fn main() -> Result<()> {

println!("Updated content: {}", current_state.data.as_text()?);
println!("Updated metadata: {:?}", current_state.metadata);
println!("New version count: {}", version_count);
println!("New version count: {version_count}");

// Verify version count incremented
assert_eq!(version_count, i as u64);
Expand All @@ -83,15 +83,15 @@ async fn main() -> Result<()> {
let final_state = notarization_client.state(*notarization_id.object_id()).await?;

println!("\n📊 Final Statistics:");
println!("Total updates performed: {}", final_version_count);
println!("Total updates performed: {final_version_count}");
println!("Final metadata: {:?}", final_state.metadata);

// Get last state change timestamp
let last_change = notarization_client
.last_state_change_ts(*notarization_id.object_id())
.await?;

println!("Last state change timestamp: {}", last_change);
println!("Last state change timestamp: {last_change}");

println!("\n🎯 Key Points:");
println!("✓ Dynamic notarizations support state updates");
Expand Down
20 changes: 10 additions & 10 deletions examples/06_update_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async fn main() -> Result<()> {
.output
.id;

println!("✅ Created dynamic notarization: {:?}", notarization_id);
println!("✅ Created dynamic notarization: {notarization_id:?}");

// Show initial metadata
let initial_updatable_metadata = notarization_client
Expand All @@ -42,9 +42,9 @@ async fn main() -> Result<()> {
.await?;

println!("\n📄 Initial Metadata:");
println!("Immutable description: {:?}", initial_description);
println!("Updatable metadata: {:?}", initial_updatable_metadata);
println!("State version count: {}", initial_version_count);
println!("Immutable description: {initial_description:?}");
println!("Updatable metadata: {initial_updatable_metadata:?}");
println!("State version count: {initial_version_count}");

// Update metadata multiple times
println!("\n🔄 Performing metadata updates...");
Expand Down Expand Up @@ -77,8 +77,8 @@ async fn main() -> Result<()> {
.state_version_count(*notarization_id.object_id())
.await?;

println!("Updated metadata: {:?}", current_metadata);
println!("Version count (should remain unchanged): {}", version_count);
println!("Updated metadata: {current_metadata:?}");
println!("Version count (should remain unchanged): {version_count}");

// Verify that state version count doesn't change with metadata updates
assert_eq!(version_count, initial_version_count);
Expand All @@ -92,7 +92,7 @@ async fn main() -> Result<()> {

let final_description = notarization_client.description(*notarization_id.object_id()).await?;

println!("Final description: {:?}", final_description);
println!("Final description: {final_description:?}");
assert_eq!(final_description, initial_description);

// Show that state content is unaffected by metadata updates
Expand All @@ -111,16 +111,16 @@ async fn main() -> Result<()> {
.await?;

println!("\n⏰ Timestamps:");
println!("Created at: {}", created_at);
println!("Last state change: {}", last_state_change);
println!("Created at: {created_at}");
println!("Last state change: {last_state_change}");

// Final metadata state
let final_updatable_metadata = notarization_client
.updatable_metadata(*notarization_id.object_id())
.await?;

println!("\n📊 Final State:");
println!("Final updatable metadata: {:?}", final_updatable_metadata);
println!("Final updatable metadata: {final_updatable_metadata:?}");
println!(
"State version count: {}",
notarization_client
Expand Down
Loading
Loading