Skip to content
Open
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
11 changes: 6 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ async-trait = "0.1"
bcs = "0.1"
chrono = { version = "0.4", default-features = false }
hyper = "1"
iota-sdk = { git = "https://github.com/iotaledger/iota.git", package = "iota-sdk", tag = "v1.24.0" }
iota_interaction = { git = "https://github.com/iotaledger/product-core.git", tag = "v0.8.20", default-features = false, package = "iota_interaction" }
iota_interaction_rust = { git = "https://github.com/iotaledger/product-core.git", tag = "v0.8.20", default-features = false, package = "iota_interaction_rust" }
iota_interaction_ts = { git = "https://github.com/iotaledger/product-core.git", tag = "v0.8.20", default-features = false, package = "iota_interaction_ts" }
product_common = { git = "https://github.com/iotaledger/product-core.git", tag = "v0.8.20", default-features = false, package = "product_common" }
iota-sdk = { git = "https://github.com/iotaledger/iota.git", package = "iota-sdk", tag = "v1.25.0" }
iota-sdk-types = { git = "https://github.com/iotaledger/iota-rust-sdk.git", rev = "35a27488b887e28e844a1e46d7edb78605871155", default-features = false }
iota_interaction = { git = "https://github.com/iotaledger/product-core.git", branch = "feat/iota-v1-25-rc-upstream-merge", default-features = false, package = "iota_interaction" }
iota_interaction_rust = { git = "https://github.com/iotaledger/product-core.git", branch = "feat/iota-v1-25-rc-upstream-merge", default-features = false, package = "iota_interaction_rust" }
iota_interaction_ts = { git = "https://github.com/iotaledger/product-core.git", branch = "feat/iota-v1-25-rc-upstream-merge", default-features = false, package = "iota_interaction_ts" }
product_common = { git = "https://github.com/iotaledger/product-core.git", branch = "feat/iota-v1-25-rc-upstream-merge", default-features = false, package = "product_common" }
secret-storage = { git = "https://github.com/iotaledger/secret-storage.git", tag = "v0.3.0", default-features = false }
serde = { version = "1.0", default-features = false, features = ["alloc", "derive"] }
serde-aux = { version = "4.7.0", default-features = false }
Expand Down
1 change: 1 addition & 0 deletions audit-trail-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ anyhow.workspace = true
async-trait.workspace = true
bcs.workspace = true
iota-caip = { git = "https://github.com/iotaledger/iota-caip.git", default-features = false, features = ["iota"], optional = true }
iota-sdk-types.workspace = true
iota_interaction = { workspace = true, default-features = false }
product_common = { workspace = true, default-features = false, features = ["transaction"] }
secret-storage = { workspace = true, default-features = false }
Expand Down
11 changes: 6 additions & 5 deletions audit-trail-rs/src/client/full_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,13 @@ use std::ops::Deref;
use async_trait::async_trait;
#[cfg(not(target_arch = "wasm32"))]
use iota_interaction::IotaClient;
use iota_interaction::types::base_types::{IotaAddress, ObjectID};
use iota_interaction::types::base_types::IotaAddress;
use iota_interaction::types::crypto::PublicKey;
use iota_interaction::types::transaction::ProgrammableTransaction;
use iota_interaction::{IotaKeySignature, OptionalSync};
#[cfg(target_arch = "wasm32")]
use iota_interaction_ts::bindings::WasmIotaClient as IotaClient;
use iota_sdk_types::ObjectId;
use product_common::core_client::{CoreClient, CoreClientReadOnly};
use product_common::network_name::NetworkName;
use secret_storage::Signer;
Expand Down Expand Up @@ -249,12 +250,12 @@ impl<S> AuditTrailClient<S> {
}

/// Returns a typed handle bound to a specific trail object ID.
pub fn trail<'a>(&'a self, trail_id: ObjectID) -> AuditTrailHandle<'a, Self> {
pub fn trail<'a>(&'a self, trail_id: ObjectId) -> AuditTrailHandle<'a, Self> {
AuditTrailHandle::new(self, trail_id)
}

/// Returns the TfComponents package ID used by this client.
pub fn tf_components_package_id(&self) -> ObjectID {
pub fn tf_components_package_id(&self) -> ObjectId {
self.read_client.tf_components_package_id()
}

Expand Down Expand Up @@ -289,11 +290,11 @@ where
#[cfg_attr(feature = "send-sync", async_trait)]
#[cfg_attr(not(feature = "send-sync"), async_trait(?Send))]
impl<S> CoreClientReadOnly for AuditTrailClient<S> {
fn package_id(&self) -> ObjectID {
fn package_id(&self) -> ObjectId {
self.read_client.package_id()
}

fn tf_components_package_id(&self) -> Option<ObjectID> {
fn tf_components_package_id(&self) -> Option<ObjectId> {
Some(self.read_client.tf_components_package_id())
}

Expand Down
25 changes: 13 additions & 12 deletions audit-trail-rs/src/client/read_only.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ use std::ops::Deref;
#[cfg(not(target_arch = "wasm32"))]
use iota_interaction::IotaClient;
use iota_interaction::IotaClientTrait;
use iota_interaction::types::base_types::{IotaAddress, ObjectID};
use iota_interaction::types::base_types::IotaAddress;
use iota_interaction::types::transaction::{ProgrammableTransaction, TransactionKind};
#[cfg(target_arch = "wasm32")]
use iota_interaction_ts::bindings::WasmIotaClient;
use iota_sdk_types::ObjectId;
use product_common::core_client::CoreClientReadOnly;
use product_common::network_name::NetworkName;
use serde::de::DeserializeOwned;
Expand All @@ -33,9 +34,9 @@ use crate::package;
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
pub struct PackageOverrides {
/// Override for the audit-trail package itself.
pub audit_trail: Option<ObjectID>,
pub audit_trail: Option<ObjectId>,
/// Override for the `tf_components` package used by time locks and capabilities.
pub tf_component: Option<ObjectID>,
pub tf_component: Option<ObjectId>,
}

/// A read-only client for interacting with audit-trail objects on a specific network.
Expand All @@ -49,10 +50,10 @@ pub struct PackageOverrides {
pub struct AuditTrailClientReadOnly {
/// The underlying IOTA client adapter used for communication.
iota_client: IotaClientAdapter,
/// The [`ObjectID`] of the deployed Audit Trail Package (smart contract).
audit_trail_pkg_id: ObjectID,
/// The [`ObjectID`] of the deployed TfComponents package used by Audit Trail.
pub(crate) tf_components_pkg_id: ObjectID,
/// The [`ObjectId`] of the deployed Audit Trail Package (smart contract).
audit_trail_pkg_id: ObjectId,
/// The [`ObjectId`] of the deployed TfComponents package used by Audit Trail.
pub(crate) tf_components_pkg_id: ObjectId,
/// The name of the network this client is connected to (e.g., "mainnet", "testnet").
network: NetworkName,
/// Raw chain identifier returned by the IOTA node.
Expand Down Expand Up @@ -80,12 +81,12 @@ impl AuditTrailClientReadOnly {
/// Returns the package ID used by this client.
///
/// This is the deployed audit-trail Move package ID, not a trail object ID.
pub fn package_id(&self) -> ObjectID {
pub fn package_id(&self) -> ObjectId {
self.audit_trail_pkg_id
}

/// Returns the TfComponents package ID used by this client.
pub fn tf_components_package_id(&self) -> ObjectID {
pub fn tf_components_package_id(&self) -> ObjectId {
self.tf_components_pkg_id
}

Expand All @@ -98,7 +99,7 @@ impl AuditTrailClientReadOnly {
///
/// Creating the handle is cheap. Reads only happen when you call methods on the returned
/// [`AuditTrailHandle`], such as [`AuditTrailHandle::get`].
pub fn trail<'a>(&'a self, trail_id: ObjectID) -> AuditTrailHandle<'a, Self> {
pub fn trail<'a>(&'a self, trail_id: ObjectId) -> AuditTrailHandle<'a, Self> {
AuditTrailHandle::new(self, trail_id)
}

Expand Down Expand Up @@ -164,11 +165,11 @@ impl AuditTrailClientReadOnly {
#[cfg_attr(not(feature = "send-sync"), async_trait::async_trait(?Send))]
#[cfg_attr(feature = "send-sync", async_trait::async_trait)]
impl CoreClientReadOnly for AuditTrailClientReadOnly {
fn package_id(&self) -> ObjectID {
fn package_id(&self) -> ObjectId {
self.audit_trail_pkg_id
}

fn tf_components_package_id(&self) -> Option<ObjectID> {
fn tf_components_package_id(&self) -> Option<ObjectId> {
Some(self.tf_components_pkg_id)
}

Expand Down
28 changes: 14 additions & 14 deletions audit-trail-rs/src/core/access/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
//! records a role may operate on, but they do not replace the underlying permission checks enforced by the Move
//! package.

use iota_interaction::types::base_types::ObjectID;
use iota_interaction::{IotaKeySignature, OptionalSync};
use iota_sdk_types::ObjectId;
use product_common::core_client::CoreClient;
use product_common::transaction::transaction_builder::TransactionBuilder;
use secret_storage::Signer;
Expand All @@ -35,12 +35,12 @@ pub use transactions::{
#[derive(Debug, Clone)]
pub struct TrailAccess<'a, C> {
pub(crate) client: &'a C,
pub(crate) trail_id: ObjectID,
pub(crate) selected_capability_id: Option<ObjectID>,
pub(crate) trail_id: ObjectId,
pub(crate) selected_capability_id: Option<ObjectId>,
}

impl<'a, C> TrailAccess<'a, C> {
pub(crate) fn new(client: &'a C, trail_id: ObjectID, selected_capability_id: Option<ObjectID>) -> Self {
pub(crate) fn new(client: &'a C, trail_id: ObjectId, selected_capability_id: Option<ObjectId>) -> Self {
Self {
client,
trail_id,
Expand All @@ -49,7 +49,7 @@ impl<'a, C> TrailAccess<'a, C> {
}

/// Uses the provided capability as the auth capability for subsequent write operations.
pub fn using_capability(mut self, capability_id: ObjectID) -> Self {
pub fn using_capability(mut self, capability_id: ObjectId) -> Self {
self.selected_capability_id = Some(capability_id);
self
}
Expand All @@ -68,7 +68,7 @@ impl<'a, C> TrailAccess<'a, C> {
/// when it is known so later cleanup keeps the same expiry semantics.
pub fn revoke_capability<S>(
&self,
capability_id: ObjectID,
capability_id: ObjectId,
capability_valid_until: Option<u64>,
) -> TransactionBuilder<RevokeCapability>
where
Expand All @@ -89,7 +89,7 @@ impl<'a, C> TrailAccess<'a, C> {
///
/// This consumes the owned capability object itself. It uses the generic capability-destruction path and
/// therefore must not be used for initial-admin capabilities.
pub fn destroy_capability<S>(&self, capability_id: ObjectID) -> TransactionBuilder<DestroyCapability>
pub fn destroy_capability<S>(&self, capability_id: ObjectId) -> TransactionBuilder<DestroyCapability>
where
C: AuditTrailFull + CoreClient<S>,
S: Signer<IotaKeySignature> + OptionalSync,
Expand All @@ -109,7 +109,7 @@ impl<'a, C> TrailAccess<'a, C> {
/// destroy path.
pub fn destroy_initial_admin_capability<S>(
&self,
capability_id: ObjectID,
capability_id: ObjectId,
) -> TransactionBuilder<DestroyInitialAdminCapability>
where
C: AuditTrailFull + CoreClient<S>,
Expand All @@ -124,7 +124,7 @@ impl<'a, C> TrailAccess<'a, C> {
/// because initial-admin capability IDs are protected separately.
pub fn revoke_initial_admin_capability<S>(
&self,
capability_id: ObjectID,
capability_id: ObjectId,
capability_valid_until: Option<u64>,
) -> TransactionBuilder<RevokeInitialAdminCapability>
where
Expand Down Expand Up @@ -166,17 +166,17 @@ impl<'a, C> TrailAccess<'a, C> {
#[derive(Debug, Clone)]
pub struct RoleHandle<'a, C> {
pub(crate) client: &'a C,
pub(crate) trail_id: ObjectID,
pub(crate) trail_id: ObjectId,
pub(crate) name: String,
pub(crate) selected_capability_id: Option<ObjectID>,
pub(crate) selected_capability_id: Option<ObjectId>,
}

impl<'a, C> RoleHandle<'a, C> {
pub(crate) fn new(
client: &'a C,
trail_id: ObjectID,
trail_id: ObjectId,
name: String,
selected_capability_id: Option<ObjectID>,
selected_capability_id: Option<ObjectId>,
) -> Self {
Self {
client,
Expand All @@ -187,7 +187,7 @@ impl<'a, C> RoleHandle<'a, C> {
}

/// Uses the provided capability as the auth capability for subsequent write operations.
pub fn using_capability(mut self, capability_id: ObjectID) -> Self {
pub fn using_capability(mut self, capability_id: ObjectId) -> Self {
self.selected_capability_id = Some(capability_id);
self
}
Expand Down
47 changes: 24 additions & 23 deletions audit-trail-rs/src/core/access/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
//! These helpers encode Rust-side access inputs into the exact Move call shapes expected by the audit-trail
//! package and apply the lightweight preflight checks that are cheaper to surface before submission.

use iota_interaction::types::base_types::{IotaAddress, ObjectID};
use iota_interaction::types::base_types::IotaAddress;
use iota_interaction::types::transaction::{CallArg, ProgrammableTransaction};
use iota_interaction::{OptionalSync, ident_str};
use iota_sdk_types::ObjectId;
use product_common::core_client::CoreClientReadOnly;

use crate::core::internal::{trail as trail_reader, tx};
Expand All @@ -30,12 +31,12 @@ impl AccessOps {
/// Rust side fails early with `Error::InvalidArgument` instead of relying on a later Move abort.
pub(super) async fn create_role<C>(
client: &C,
trail_id: ObjectID,
trail_id: ObjectId,
owner: IotaAddress,
name: String,
permissions: PermissionSet,
role_tags: Option<RoleTags>,
selected_capability_id: Option<ObjectID>,
selected_capability_id: Option<ObjectId>,
) -> Result<ProgrammableTransaction, Error>
where
C: CoreClientReadOnly + OptionalSync,
Expand Down Expand Up @@ -83,12 +84,12 @@ impl AccessOps {
/// on-chain as part of the role definition.
pub(super) async fn update_role<C>(
client: &C,
trail_id: ObjectID,
trail_id: ObjectId,
owner: IotaAddress,
name: String,
permissions: PermissionSet,
role_tags: Option<RoleTags>,
selected_capability_id: Option<ObjectID>,
selected_capability_id: Option<ObjectId>,
) -> Result<ProgrammableTransaction, Error>
where
C: CoreClientReadOnly + OptionalSync,
Expand Down Expand Up @@ -137,10 +138,10 @@ impl AccessOps {
/// access-control invariant enforced by the Move package.
pub(super) async fn delete_role<C>(
client: &C,
trail_id: ObjectID,
trail_id: ObjectId,
owner: IotaAddress,
name: String,
selected_capability_id: Option<ObjectID>,
selected_capability_id: Option<ObjectId>,
) -> Result<ProgrammableTransaction, Error>
where
C: CoreClientReadOnly + OptionalSync,
Expand Down Expand Up @@ -168,11 +169,11 @@ impl AccessOps {
/// `valid_until` semantics remains on-chain.
pub(super) async fn issue_capability<C>(
client: &C,
trail_id: ObjectID,
trail_id: ObjectId,
owner: IotaAddress,
role_name: String,
options: CapabilityIssueOptions,
selected_capability_id: Option<ObjectID>,
selected_capability_id: Option<ObjectId>,
) -> Result<ProgrammableTransaction, Error>
where
C: CoreClientReadOnly + OptionalSync,
Expand Down Expand Up @@ -203,11 +204,11 @@ impl AccessOps {
/// losing the capability's original expiry boundary.
pub(super) async fn revoke_capability<C>(
client: &C,
trail_id: ObjectID,
trail_id: ObjectId,
owner: IotaAddress,
capability_id: ObjectID,
capability_id: ObjectId,
capability_valid_until: Option<u64>,
selected_capability_id: Option<ObjectID>,
selected_capability_id: Option<ObjectId>,
) -> Result<ProgrammableTransaction, Error>
where
C: CoreClientReadOnly + OptionalSync,
Expand Down Expand Up @@ -236,10 +237,10 @@ impl AccessOps {
/// capability object rather than only its ID.
pub(super) async fn destroy_capability<C>(
client: &C,
trail_id: ObjectID,
trail_id: ObjectId,
owner: IotaAddress,
capability_id: ObjectID,
selected_capability_id: Option<ObjectID>,
capability_id: ObjectId,
selected_capability_id: Option<ObjectId>,
) -> Result<ProgrammableTransaction, Error>
where
C: CoreClientReadOnly + OptionalSync,
Expand Down Expand Up @@ -271,8 +272,8 @@ impl AccessOps {
/// capability path.
pub(super) async fn destroy_initial_admin_capability<C>(
client: &C,
trail_id: ObjectID,
capability_id: ObjectID,
trail_id: ObjectId,
capability_id: ObjectId,
) -> Result<ProgrammableTransaction, Error>
where
C: CoreClientReadOnly + OptionalSync,
Expand All @@ -294,11 +295,11 @@ impl AccessOps {
/// separate Move entry point reserved for tracked initial-admin IDs.
pub(super) async fn revoke_initial_admin_capability<C>(
client: &C,
trail_id: ObjectID,
trail_id: ObjectId,
owner: IotaAddress,
capability_id: ObjectID,
capability_id: ObjectId,
capability_valid_until: Option<u64>,
selected_capability_id: Option<ObjectID>,
selected_capability_id: Option<ObjectId>,
) -> Result<ProgrammableTransaction, Error>
where
C: CoreClientReadOnly + OptionalSync,
Expand Down Expand Up @@ -327,9 +328,9 @@ impl AccessOps {
/// objects and does not revoke any additional IDs.
pub(super) async fn cleanup_revoked_capabilities<C>(
client: &C,
trail_id: ObjectID,
trail_id: ObjectId,
owner: IotaAddress,
selected_capability_id: Option<ObjectID>,
selected_capability_id: Option<ObjectId>,
) -> Result<ProgrammableTransaction, Error>
where
C: CoreClientReadOnly + OptionalSync,
Expand All @@ -354,7 +355,7 @@ impl AccessOps {
///
/// Roles may only reference tags that are defined on the trail itself so later record-tag checks
/// stay consistent with the registry stored on-chain.
async fn assert_role_tags_defined<C>(client: &C, trail_id: ObjectID, role_tags: &Option<RoleTags>) -> Result<(), Error>
async fn assert_role_tags_defined<C>(client: &C, trail_id: ObjectId, role_tags: &Option<RoleTags>) -> Result<(), Error>
where
C: CoreClientReadOnly + OptionalSync,
{
Expand Down
Loading
Loading