Skip to content

Commit 134981d

Browse files
committed
Update dependencies in Cargo.toml, refactor notarization.move functions to return values directly, and restructure notarization module. Introduce new package management utilities and enhance client functionality for notarization operations.
1 parent 03a6f1c commit 134981d

File tree

21 files changed

+1212
-1096
lines changed

21 files changed

+1212
-1096
lines changed

Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@ members = ["notarization-rs"]
1414
anyhow = "1.0"
1515
async-trait = "0.1.88"
1616
cfg-if = "1.0"
17+
bcs = { version = "0.1.6" }
1718
fastcrypto = { git = "https://github.com/MystenLabs/fastcrypto", rev = "2f502fd8570fe4e9cff36eea5bbd6fef22002898", package = "fastcrypto" }
18-
iota_interaction = { git = "ssh://git@github.com/iotaledger/product-core.git", branch = "feat/extensions-needed-for-notarization", package = "iota_interaction" }
19+
iota_interaction = { git = "https://github.com/iotaledger/product-core.git", branch = "feat/add-dev-inspect-tx", package = "iota_interaction" }
1920
#iota_interaction = { path = "../product-core/iota_interaction" }
20-
iota_interaction_rust = { git = "ssh://git@github.com/iotaledger/product-core.git", branch = "feat/extensions-needed-for-notarization", package = "iota_interaction_rust" }
21+
iota_interaction_rust = { git = "https://github.com/iotaledger/product-core.git", branch = "feat/add-dev-inspect-tx", package = "iota_interaction_rust" }
2122
#iota_interaction_rust = { path = "../product-core/iota_interaction_rust" }
2223
phf = { version = "0.11.2", features = ["macros"] }
23-
product_common = { git = "ssh://git@github.com/iotaledger/product-core.git", branch = "feat/extensions-needed-for-notarization", package = "product_common" }
24+
product_common = { git = "https://github.com/iotaledger/product-core.git", branch = "feat/add-dev-inspect-tx", package = "product_common" }
2425
#product_common = { path = "../product-core/product_common" }
2526
serde = { version = "1.0", default-features = false, features = [
2627
"alloc",

notarization-move/sources/notarization.move

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -350,12 +350,12 @@ public fun version_count<D: store + drop + copy>(self: &Notarization<D>): u64 {
350350
self.state_version_count
351351
}
352352

353-
public fun description<D: store + drop + copy>(self: &Notarization<D>): &Option<String> {
354-
&self.immutable_metadata.description
353+
public fun description<D: store + drop + copy>(self: &Notarization<D>): Option<String> {
354+
self.immutable_metadata.description
355355
}
356356

357-
public fun updateable_metadata<D: store + drop + copy>(self: &Notarization<D>): &Option<String> {
358-
&self.updateable_metadata
357+
public fun updateable_metadata<D: store + drop + copy>(self: &Notarization<D>): Option<String> {
358+
self.updateable_metadata
359359
}
360360

361361
public fun notarization_method<D: store + drop + copy>(self: &Notarization<D>): NotarizationMethod {
@@ -425,7 +425,7 @@ public fun is_destroy_allowed<D: store + drop + copy>(self: &Notarization<D>, cl
425425
/// See fun `are_locked_notarization_invariants_ok()` and
426426
/// `are_dynamic_notarization_invariants_ok()`
427427
/// for more details.
428-
public fun assert_method_specific_invariants<D: store + drop + copy>(self: &Notarization<D>) {
428+
public(package) fun assert_method_specific_invariants<D: store + drop + copy>(self: &Notarization<D>) {
429429
if (self.method.is_dynamic()) {
430430
assert!(
431431
are_dynamic_notarization_invariants_ok(&self.immutable_metadata),
@@ -443,7 +443,7 @@ public fun assert_method_specific_invariants<D: store + drop + copy>(self: &Nota
443443
///
444444
/// - `self.immutable_metadata.locking` must exist.
445445
/// - `updated_lock` and `transfer_lock` must be `TimeLock::UntilDestroyed`.
446-
public fun are_locked_notarization_invariants_ok(immutable_metadata: &ImmutableMetadata): bool {
446+
public(package) fun are_locked_notarization_invariants_ok(immutable_metadata: &ImmutableMetadata): bool {
447447
if (immutable_metadata.locking.is_some()) {
448448
let lock_metadata = option::borrow(&immutable_metadata.locking);
449449
timelock::is_until_destroyed(&lock_metadata.transfer_lock) && timelock::is_until_destroyed(&lock_metadata.update_lock)
@@ -459,7 +459,7 @@ public fun are_locked_notarization_invariants_ok(immutable_metadata: &ImmutableM
459459
/// If `immutable_metadata.locking` exists, all locks except `transfer_lock`
460460
/// must be `TimeLock::None`
461461
/// and the `transfer_lock` must not be `TimeLock::None`.
462-
public fun are_dynamic_notarization_invariants_ok(immutable_metadata: &ImmutableMetadata): bool {
462+
public(package) fun are_dynamic_notarization_invariants_ok(immutable_metadata: &ImmutableMetadata): bool {
463463
if (immutable_metadata.locking.is_some()) {
464464
let lock_metadata = option::borrow(&immutable_metadata.locking);
465465

notarization-rs/Cargo.toml

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,34 +16,45 @@ anyhow.workspace = true
1616
cfg-if.workspace = true
1717
fastcrypto.workspace = true
1818
phf.workspace = true
19-
product_common.workspace = true
19+
product_common = { workspace = true, features = ["transaction"] }
2020
serde.workspace = true
2121
serde_json.workspace = true
2222
thiserror.workspace = true
2323
strum.workspace = true
24+
async-trait.workspace = true
25+
bcs.workspace = true
2426

2527
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
26-
iota_interaction.workspace = true
27-
iota_interaction_rust.workspace = true
28+
iota_interaction = { git = "https://github.com/iotaledger/product-core.git", branch = "feat/add-dev-inspect-tx", package = "iota_interaction", default-features = false }
29+
iota_interaction_rust = { git = "https://github.com/iotaledger/product-core.git", branch = "feat/add-dev-inspect-tx", package = "iota_interaction_rust", default-features = false }
2830
iota-config = { git = "https://github.com/iotaledger/iota.git", package = "iota-config", tag = "v0.11.6-rc" }
2931
iota-sdk = { git = "https://github.com/iotaledger/iota.git", package = "iota-sdk", tag = "v0.11.6-rc" }
3032
move-core-types = { git = "https://github.com/iotaledger/iota.git", package = "move-core-types", tag = "v0.11.6-rc" }
31-
secret-storage = { git = "https://github.com/iotaledger/secret-storage.git", tag = "v0.3.0" }
33+
secret-storage = { git = "https://github.com/iotaledger/secret-storage.git", tag = "v0.3.0", default-features = false }
3234
shared-crypto = { git = "https://github.com/iotaledger/iota.git", package = "shared-crypto", tag = "v0.11.6-rc" }
33-
tokio = { version = "1.29.0", default-features = false, features = ["macros", "sync", "rt", "process"] }
35+
tokio = { version = "1.29.0", default-features = false, features = [
36+
"macros",
37+
"sync",
38+
"rt",
39+
"process",
40+
] }
3441

3542
[target.'cfg(target_arch = "wasm32")'.dependencies]
36-
iota_interaction = { git = "ssh://git@github.com/iotaledger/product-core.git", branch = "feat/extensions-needed-for-notarization", package = "iota_interaction", default-features = false }
37-
#iota_interaction = { path = "../../product-core/iota_interaction", default-features = false }
38-
iota_interaction_ts = { git = "ssh://git@github.com/iotaledger/product-core.git", branch = "feat/extensions-needed-for-notarization", package = "iota_interaction_ts" }
39-
#iota_interaction_ts = { path = "../../product-core/bindings/wasm/iota_interaction_ts" }
40-
secret-storage = { git = "https://github.com/iotaledger/secret-storage.git", default-features = false, tag = "v0.3.0" }
43+
iota_interaction = { git = "https://github.com/iotaledger/product-core.git", branch = "feat/add-dev-inspect-tx", package = "iota_interaction", default-features = false }
44+
iota_interaction_ts = { git = "https://github.com/iotaledger/product-core.git", branch = "feat/add-dev-inspect-tx", package = "iota_interaction_ts" }
45+
4146

4247
[dev-dependencies]
4348
async-trait.workspace = true
4449
identity_jose = { git = "https://github.com/iotaledger/identity.rs.git", branch = "feat/identity-rebased-alpha-public-interaction-rust", package = "identity_jose" }
45-
identity_storage = { git = "https://github.com/iotaledger/identity.rs.git", branch = "feat/identity-rebased-alpha-public-interaction-rust", package = "identity_storage", features = ["send-sync-storage", "storage-signer"] }
46-
iota_interaction = { git = "ssh://git@github.com/iotaledger/product-core.git", branch = "feat/extensions-needed-for-notarization", package = "iota_interaction", features = ["keytool-signer"] }
47-
#iota_interaction = { path = "../../product-core/iota_interaction", features = ["keytool-signer"] }
50+
identity_storage = { git = "https://github.com/iotaledger/identity.rs.git", branch = "feat/identity-rebased-alpha-public-interaction-rust", package = "identity_storage", features = [
51+
"send-sync-storage",
52+
"storage-signer",
53+
] }
54+
iota_interaction = { git = "https://github.com/iotaledger/product-core.git", branch = "feat/add-dev-inspect-tx", package = "iota_interaction" }
4855
lazy_static = "1.5.0"
4956

57+
[features]
58+
send-sync = ["send-sync-storage"]
59+
# Enables `Send` + `Sync` bounds for the storage traits.
60+
send-sync-storage = ["secret-storage/send-sync-storage"]
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
use std::ops::Deref;
2+
3+
use iota_interaction::types::base_types::{IotaAddress, ObjectID};
4+
use iota_interaction::types::crypto::PublicKey;
5+
use iota_interaction::{IotaKeySignature, OptionalSync};
6+
use iota_interaction_rust::IotaClientAdapter;
7+
use product_common::core_client::{CoreClient, CoreClientReadOnly};
8+
use product_common::network_name::NetworkName;
9+
use secret_storage::Signer;
10+
11+
use super::read_only::NotarizationClientReadOnly;
12+
use crate::error::Error;
13+
14+
/// A client for interacting with the IOTA network.
15+
#[derive(Clone)]
16+
pub struct NotarizationClient<S> {
17+
/// [`NotarizationClientReadOnly`] instance, used for read-only operations.
18+
read_client: NotarizationClientReadOnly,
19+
/// The public key of the client.
20+
public_key: PublicKey,
21+
/// The signer of the client.
22+
signer: S,
23+
}
24+
25+
impl<S> Deref for NotarizationClient<S> {
26+
type Target = NotarizationClientReadOnly;
27+
fn deref(&self) -> &Self::Target {
28+
&self.read_client
29+
}
30+
}
31+
32+
impl<S> NotarizationClient<S>
33+
where
34+
S: Signer<IotaKeySignature>,
35+
{
36+
/// Create a new [`NotarizationClient`].
37+
pub async fn new(client: NotarizationClientReadOnly, signer: S) -> Result<Self, Error> {
38+
let public_key = signer
39+
.public_key()
40+
.await
41+
.map_err(|e| Error::InvalidKey(e.to_string()))?;
42+
43+
Ok(Self {
44+
public_key,
45+
read_client: client,
46+
signer,
47+
})
48+
}
49+
}
50+
51+
impl<S> CoreClientReadOnly for NotarizationClient<S>
52+
where
53+
S: OptionalSync,
54+
{
55+
fn client_adapter(&self) -> &IotaClientAdapter {
56+
&self.read_client
57+
}
58+
59+
fn package_id(&self) -> ObjectID {
60+
self.read_client.package_id()
61+
}
62+
63+
fn network_name(&self) -> &NetworkName {
64+
self.read_client.network()
65+
}
66+
}
67+
68+
impl<S> CoreClient<S> for NotarizationClient<S>
69+
where
70+
S: Signer<IotaKeySignature> + OptionalSync,
71+
{
72+
fn sender_address(&self) -> IotaAddress {
73+
IotaAddress::from(&self.public_key)
74+
}
75+
76+
fn signer(&self) -> &S {
77+
&self.signer
78+
}
79+
80+
fn sender_public_key(&self) -> &PublicKey {
81+
&self.public_key
82+
}
83+
}

notarization-rs/src/client/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pub mod full_client;
2+
pub mod read_only;

0 commit comments

Comments
 (0)