diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 49751b178..c7da6ebe4 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -77,7 +77,7 @@ jobs: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - name: doctests run: | - cargo test --doc + make test-docs - name: rustdoc run: | - cargo doc --all-features --workspace --no-deps + make build-docs diff --git a/Cargo.toml b/Cargo.toml index 18df955b9..f4a0f2f1f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,3 +25,9 @@ serde_json = "1.0.128" test-strategy = "0.4.0" thiserror = "2.0" tokio = "1.40.0" + +iota-crypto = { version = "0.0.1", package = "iota-sdk-crypto", path = "crates/iota-sdk-crypto", default-features = false } +iota-graphql-client = { version = "0.0.1", package = "iota-sdk-graphql-client", path = "crates/iota-sdk-graphql-client", default-features = false } +iota-graphql-client-build = { version = "0.0.1", package = "iota-sdk-graphql-client-build", path = "crates/iota-sdk-graphql-client-build", default-features = false } +iota-transaction-builder = { version = "0.0.1", package = "iota-sdk-transaction-builder", path = "crates/iota-sdk-transaction-builder", default-features = false } +iota-types = { version = "0.0.1", package = "iota-sdk-types", path = "crates/iota-sdk-types", default-features = false } diff --git a/Makefile b/Makefile index 2a74cc6e4..ddd6e96e8 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ all:: ci ## Default target, runs the CI process .PHONY: check-features check-features: ## Check feature flags for crates $(MAKE) -C crates/iota-sdk-types check-features - $(MAKE) -C crates/iota-crypto check-features + $(MAKE) -C crates/iota-sdk-crypto check-features .PHONY: check-fmt check-fmt: ## Check code formatting @@ -21,22 +21,29 @@ clippy: ## Run Clippy linter .PHONY: test test: ## Run unit tests - cargo nextest run --all-features -p iota-sdk-types -p iota-crypto + cargo nextest run --all-features -p iota-sdk-types -p iota-sdk-crypto + +.PHONY: test-docs +test-docs: ## Run doc tests cargo test --all-features --doc -package_%.json: crates/iota-transaction-builder/tests/%/Move.toml crates/iota-transaction-builder/tests/%/sources/*.move ## Generate JSON files for tests - cd crates/iota-transaction-builder/tests/$(*F) && iota move build --ignore-chain --dump-bytecode-as-base64 > ../../$@ +.PHONY: build-docs +build-docs: ## Build docs + cargo doc --all-features --workspace --no-deps + +package_%.json: crates/iota-sdk-transaction-builder/tests/%/Move.toml crates/iota-sdk-transaction-builder/tests/%/sources/*.move ## Generate JSON files for tests + cd crates/iota-sdk-transaction-builder/tests/$(*F) && iota move build --ignore-chain --dump-bytecode-as-base64 > ../../$@ .PHONY: test-with-localnet test-with-localnet: package_test_example_v1.json package_test_example_v2.json ## Run tests with localnet - cargo nextest run -p iota-graphql-client -p iota-transaction-builder + cargo nextest run -p iota-sdk-graphql-client -p iota-sdk-transaction-builder .PHONY: wasm wasm: ## Build WASM modules - $(MAKE) -C crates/iota-crypto wasm - $(MAKE) -C crates/iota-graphql-client wasm + $(MAKE) -C crates/iota-sdk-crypto wasm + $(MAKE) -C crates/iota-sdk-graphql-client wasm $(MAKE) -C crates/iota-sdk-types wasm - $(MAKE) -C crates/iota-transaction-builder wasm + $(MAKE) -C crates/iota-sdk-transaction-builder wasm .PHONY: doc doc: ## Generate documentation diff --git a/README.md b/README.md index 0b06e41b0..ed020d352 100644 --- a/README.md +++ b/README.md @@ -19,20 +19,24 @@ A few of the project's high-level goals are as follows: ## Crates -In an effort to be modular, functionality is split between a number of crates. +In an effort to be modular, functionality is split between a number of crates. The main crate, `iota-sdk`, contains the others. +- [`iota-sdk`](crates/iota-sdk) + [![iota-sdk on crates.io](https://img.shields.io/crates/v/iota-sdk)](https://crates.io/crates/iota-sdk) + [![Documentation (latest release)](https://img.shields.io/badge/docs-latest-brightgreen)](https://docs.rs/iota-sdk) + [![Documentation (develop)](https://img.shields.io/badge/docs-develop-59f)](https://github.com/iotaledger/iota-rust-sdk/iota_sdk_types/) - [`iota-sdk-types`](crates/iota-sdk-types) [![iota-sdk-types on crates.io](https://img.shields.io/crates/v/iota-sdk-types)](https://crates.io/crates/iota-sdk-types) [![Documentation (latest release)](https://img.shields.io/badge/docs-latest-brightgreen)](https://docs.rs/iota-sdk-types) - [![Documentation (develop)](https://img.shields.io/badge/docs-develop-59f)](https://github.com/iotaledger/iota-rust-sdk/iota_sdk_types/) -- [`iota-crypto`](crates/iota-crypto) - [![iota-crypto on crates.io](https://img.shields.io/crates/v/iota-crypto)](https://crates.io/crates/iota-crypto) - [![Documentation (latest release)](https://img.shields.io/badge/docs-latest-brightgreen)](https://docs.rs/iota-crypto) - [![Documentation (develop)](https://img.shields.io/badge/docs-develop-59f)](https://github.com/iotaledger/iota-rust-sdk/iota_crypto/) -- [`iota-graphql-client`](crates/iota-crypto) - [![iota-graphql-client on crates.io](https://img.shields.io/crates/v/iota-graphql-client)](https://crates.io/crates/iota-graphql-client) - [![Documentation (latest release)](https://img.shields.io/badge/docs-latest-brightgreen)](https://docs.rs/iota-graphql-client) - [![Documentation (develop)](https://img.shields.io/badge/docs-develop-59f)](https://github.com/iotaledger/iota-rust-sdk/iota-graphql-client/) +- [`iota-sdk-crypto`](crates/iota-sdk-crypto) + [![iota-sdk-crypto on crates.io](https://img.shields.io/crates/v/iota-sdk-crypto)](https://crates.io/crates/iota-sdk-crypto) + [![Documentation (latest release)](https://img.shields.io/badge/docs-latest-brightgreen)](https://docs.rs/iota-sdk-crypto) +- [`iota-sdk-graphql-client`](crates/iota-sdk-graphql-client) + [![iota-sdk-graphql-client on crates.io](https://img.shields.io/crates/v/iota-sdk-graphql-client)](https://crates.io/crates/iota-sdk-graphql-client) + [![Documentation (latest release)](https://img.shields.io/badge/docs-latest-brightgreen)](https://docs.rs/iota-sdk-graphql-client) +- [`iota-sdk-transaction-builder`](crates/iota-sdk-transaction-builder) + [![iota-sdk-transaction-builder on crates.io](https://img.shields.io/crates/v/iota-sdk-transaction-builder)](https://crates.io/crates/iota-sdk-transaction-builder) + [![Documentation (latest release)](https://img.shields.io/badge/docs-latest-brightgreen)](https://docs.rs/iota-sdk-transaction-builder) ## License diff --git a/crates/iota-crypto/Cargo.toml b/crates/iota-sdk-crypto/Cargo.toml similarity index 92% rename from crates/iota-crypto/Cargo.toml rename to crates/iota-sdk-crypto/Cargo.toml index b46d1b2b1..2e3df7c78 100644 --- a/crates/iota-crypto/Cargo.toml +++ b/crates/iota-sdk-crypto/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "iota-crypto" +name = "iota-sdk-crypto" version = "0.0.1" authors = ["IOTA Foundation "] edition = "2021" @@ -56,7 +56,7 @@ pem = [ bls12381 = ["dep:blst", "dep:rand_core", "dep:roaring", "signature/std"] [dependencies] -iota-sdk-types = { path = "../iota-sdk-types", default-features = false, features = ["hash", "serde"] } +iota-types = { version = "0.0.1", package = "iota-sdk-types", path = "../iota-sdk-types", default-features = false, features = ["hash", "serde"] } signature = "2.2" thiserror.workspace = true @@ -106,8 +106,8 @@ rand.workspace = true serde_json.workspace = true # proptest support in tests -iota-sdk-types = { path = "../iota-sdk-types", default-features = false, features = ["proptest"] } -proptest = { workspace = true, default-features = false, features = ["std"] } +iota-types = { workspace = true, features = ["proptest"] } +proptest = { workspace = true, features = ["std"] } test-strategy.workspace = true [target.wasm32-unknown-unknown.dev-dependencies] diff --git a/crates/iota-crypto/Makefile b/crates/iota-sdk-crypto/Makefile similarity index 100% rename from crates/iota-crypto/Makefile rename to crates/iota-sdk-crypto/Makefile diff --git a/crates/iota-crypto/README.md b/crates/iota-sdk-crypto/README.md similarity index 100% rename from crates/iota-crypto/README.md rename to crates/iota-sdk-crypto/README.md diff --git a/crates/iota-crypto/src/bls12381.rs b/crates/iota-sdk-crypto/src/bls12381.rs similarity index 99% rename from crates/iota-crypto/src/bls12381.rs rename to crates/iota-sdk-crypto/src/bls12381.rs index f4bf5e0ca..88fa9c04d 100644 --- a/crates/iota-crypto/src/bls12381.rs +++ b/crates/iota-sdk-crypto/src/bls12381.rs @@ -3,7 +3,7 @@ // SPDX-License-Identifier: Apache-2.0 use blst::min_sig::{PublicKey, SecretKey, Signature}; -use iota_sdk_types::{ +use iota_types::{ Bls12381PublicKey, Bls12381Signature, CheckpointSummary, SignatureScheme, ValidatorSignature, }; diff --git a/crates/iota-crypto/src/ed25519.rs b/crates/iota-sdk-crypto/src/ed25519.rs similarity index 99% rename from crates/iota-crypto/src/ed25519.rs rename to crates/iota-sdk-crypto/src/ed25519.rs index eb672f4bc..f3ddc4f2c 100644 --- a/crates/iota-crypto/src/ed25519.rs +++ b/crates/iota-sdk-crypto/src/ed25519.rs @@ -2,7 +2,7 @@ // Modifications Copyright (c) 2025 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -use iota_sdk_types::{ +use iota_types::{ Ed25519PublicKey, Ed25519Signature, SignatureScheme, SimpleSignature, UserSignature, }; @@ -290,7 +290,7 @@ impl Verifier for Ed25519Verifier { #[cfg(test)] mod tests { - use iota_sdk_types::{PersonalMessage, Transaction}; + use iota_types::{PersonalMessage, Transaction}; use test_strategy::proptest; use super::*; diff --git a/crates/iota-crypto/src/lib.rs b/crates/iota-sdk-crypto/src/lib.rs similarity index 96% rename from crates/iota-crypto/src/lib.rs rename to crates/iota-sdk-crypto/src/lib.rs index 72527c6bd..8ddc0f23a 100644 --- a/crates/iota-crypto/src/lib.rs +++ b/crates/iota-sdk-crypto/src/lib.rs @@ -4,7 +4,7 @@ #![cfg_attr(doc_cfg, feature(doc_cfg))] -use iota_sdk_types::{PersonalMessage, Transaction, UserSignature}; +use iota_types::{PersonalMessage, Transaction, UserSignature}; pub use signature::{Error as SignatureError, Signer, Verifier}; /// Error type for private key encoding/decoding operations @@ -185,10 +185,10 @@ pub const IOTA_PRIV_KEY_PREFIX: &str = "iotaprivkey"; /// Extension trait for private key types pub trait PrivateKeyExt { /// The signature scheme for this key type - const SCHEME: iota_sdk_types::SignatureScheme; + const SCHEME: iota_types::SignatureScheme; /// Returns the signature scheme for this private key - fn scheme(&self) -> iota_sdk_types::SignatureScheme { + fn scheme(&self) -> iota_types::SignatureScheme { Self::SCHEME } @@ -218,7 +218,7 @@ pub trait PrivateKeyExt { return Err(PrivateKeyError::EmptyData("flagged bytes".to_string())); } - let flag = iota_sdk_types::SignatureScheme::from_byte(bytes[0]) + let flag = iota_types::SignatureScheme::from_byte(bytes[0]) .map_err(|e| PrivateKeyError::InvalidScheme(format!("{e:?}")))?; if flag != Self::SCHEME { diff --git a/crates/iota-crypto/src/multisig.rs b/crates/iota-sdk-crypto/src/multisig.rs similarity index 98% rename from crates/iota-crypto/src/multisig.rs rename to crates/iota-sdk-crypto/src/multisig.rs index 8d99a451e..f4a426ca1 100644 --- a/crates/iota-crypto/src/multisig.rs +++ b/crates/iota-sdk-crypto/src/multisig.rs @@ -2,7 +2,7 @@ // Modifications Copyright (c) 2025 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -use iota_sdk_types::{ +use iota_types::{ MultisigAggregatedSignature, MultisigCommittee, MultisigMemberPublicKey, MultisigMemberSignature, UserSignature, }; @@ -263,7 +263,7 @@ pub struct MultisigAggregator { impl MultisigAggregator { pub fn new_with_transaction( committee: MultisigCommittee, - transaction: &iota_sdk_types::Transaction, + transaction: &iota_types::Transaction, ) -> Self { Self { committee, @@ -276,7 +276,7 @@ impl MultisigAggregator { pub fn new_with_message( committee: MultisigCommittee, - message: &iota_sdk_types::PersonalMessage<'_>, + message: &iota_types::PersonalMessage<'_>, ) -> Self { Self { committee, @@ -356,7 +356,7 @@ impl MultisigAggregator { fn multisig_pubkey_and_signature_from_user_signature( signature: UserSignature, ) -> Result<(MultisigMemberPublicKey, MultisigMemberSignature), SignatureError> { - use iota_sdk_types::SimpleSignature; + use iota_types::SimpleSignature; match signature { UserSignature::Simple(SimpleSignature::Ed25519 { signature, diff --git a/crates/iota-crypto/src/passkey.rs b/crates/iota-sdk-crypto/src/passkey.rs similarity index 96% rename from crates/iota-crypto/src/passkey.rs rename to crates/iota-sdk-crypto/src/passkey.rs index a6026a9c4..4ab6c3ec5 100644 --- a/crates/iota-crypto/src/passkey.rs +++ b/crates/iota-sdk-crypto/src/passkey.rs @@ -2,7 +2,7 @@ // Modifications Copyright (c) 2025 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -use iota_sdk_types::{PasskeyAuthenticator, SimpleSignature, UserSignature}; +use iota_types::{PasskeyAuthenticator, SimpleSignature, UserSignature}; use signature::Verifier; use crate::{SignatureError, secp256r1::Secp256r1VerifyingKey}; @@ -66,7 +66,7 @@ impl Verifier for PasskeyVerifier { #[cfg(test)] mod tests { - use iota_sdk_types::Transaction; + use iota_types::Transaction; #[cfg(target_arch = "wasm32")] use wasm_bindgen_test::wasm_bindgen_test as test; diff --git a/crates/iota-crypto/src/secp256k1.rs b/crates/iota-sdk-crypto/src/secp256k1.rs similarity index 99% rename from crates/iota-crypto/src/secp256k1.rs rename to crates/iota-sdk-crypto/src/secp256k1.rs index d2de07e06..ec94dd93e 100644 --- a/crates/iota-crypto/src/secp256k1.rs +++ b/crates/iota-sdk-crypto/src/secp256k1.rs @@ -2,7 +2,7 @@ // Modifications Copyright (c) 2025 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -use iota_sdk_types::{ +use iota_types::{ Secp256k1PublicKey, Secp256k1Signature, SignatureScheme, SimpleSignature, UserSignature, }; use k256::{ @@ -293,7 +293,7 @@ impl Verifier for Secp256k1Verifier { #[cfg(test)] mod tests { - use iota_sdk_types::PersonalMessage; + use iota_types::PersonalMessage; use test_strategy::proptest; #[cfg(target_arch = "wasm32")] use wasm_bindgen_test::wasm_bindgen_test as test; diff --git a/crates/iota-crypto/src/secp256r1.rs b/crates/iota-sdk-crypto/src/secp256r1.rs similarity index 99% rename from crates/iota-crypto/src/secp256r1.rs rename to crates/iota-sdk-crypto/src/secp256r1.rs index 6eac52bd9..8195ad683 100644 --- a/crates/iota-crypto/src/secp256r1.rs +++ b/crates/iota-sdk-crypto/src/secp256r1.rs @@ -2,7 +2,7 @@ // Modifications Copyright (c) 2025 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -use iota_sdk_types::{ +use iota_types::{ Secp256r1PublicKey, Secp256r1Signature, SignatureScheme, SimpleSignature, UserSignature, }; use p256::{ @@ -293,7 +293,7 @@ impl Verifier for Secp256r1Verifier { #[cfg(test)] mod tests { - use iota_sdk_types::PersonalMessage; + use iota_types::PersonalMessage; use test_strategy::proptest; #[cfg(target_arch = "wasm32")] use wasm_bindgen_test::wasm_bindgen_test as test; diff --git a/crates/iota-crypto/src/simple.rs b/crates/iota-sdk-crypto/src/simple.rs similarity index 99% rename from crates/iota-crypto/src/simple.rs rename to crates/iota-sdk-crypto/src/simple.rs index 12ba37c78..9e5ab01dc 100644 --- a/crates/iota-crypto/src/simple.rs +++ b/crates/iota-sdk-crypto/src/simple.rs @@ -2,7 +2,7 @@ // Modifications Copyright (c) 2025 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -use iota_sdk_types::{SimpleSignature, UserSignature}; +use iota_types::{SimpleSignature, UserSignature}; use signature::Verifier; use crate::SignatureError; @@ -77,7 +77,7 @@ pub use keypair::{SimpleKeypair, SimpleVerifyingKey}; doc(cfg(any(feature = "ed25519", feature = "secp256r1", feature = "secp256k1",))) )] mod keypair { - use iota_sdk_types::{ + use iota_types::{ MultisigMemberPublicKey, PublicKeyExt, SignatureScheme, SimpleSignature, UserSignature, }; use signature::{Signer, Verifier}; diff --git a/crates/iota-crypto/src/validator.rs b/crates/iota-sdk-crypto/src/validator.rs similarity index 99% rename from crates/iota-crypto/src/validator.rs rename to crates/iota-sdk-crypto/src/validator.rs index 999e77362..402c40b5f 100644 --- a/crates/iota-crypto/src/validator.rs +++ b/crates/iota-sdk-crypto/src/validator.rs @@ -5,7 +5,7 @@ use std::collections::HashMap; use blst::min_sig::{AggregatePublicKey, AggregateSignature, Signature}; -use iota_sdk_types::{ +use iota_types::{ Bls12381PublicKey, Bls12381Signature, CheckpointSummary, ValidatorAggregatedSignature, ValidatorCommittee, ValidatorSignature, }; @@ -320,7 +320,7 @@ impl ValidatorCommitteeSignatureAggregator { #[cfg(test)] mod tests { - use iota_sdk_types::ValidatorCommitteeMember; + use iota_types::ValidatorCommitteeMember; use test_strategy::proptest; use super::*; diff --git a/crates/iota-crypto/src/zklogin/mod.rs b/crates/iota-sdk-crypto/src/zklogin/mod.rs similarity index 97% rename from crates/iota-crypto/src/zklogin/mod.rs rename to crates/iota-sdk-crypto/src/zklogin/mod.rs index 8127586c6..2d95d8b02 100644 --- a/crates/iota-crypto/src/zklogin/mod.rs +++ b/crates/iota-sdk-crypto/src/zklogin/mod.rs @@ -4,7 +4,7 @@ use std::collections::HashMap; -use iota_sdk_types::{Jwk, JwkId, UserSignature, ZkLoginAuthenticator}; +use iota_types::{Jwk, JwkId, UserSignature, ZkLoginAuthenticator}; use poseidon::POSEIDON; use signature::Verifier; diff --git a/crates/iota-crypto/src/zklogin/poseidon/constants.rs b/crates/iota-sdk-crypto/src/zklogin/poseidon/constants.rs similarity index 100% rename from crates/iota-crypto/src/zklogin/poseidon/constants.rs rename to crates/iota-sdk-crypto/src/zklogin/poseidon/constants.rs diff --git a/crates/iota-crypto/src/zklogin/poseidon/mod.rs b/crates/iota-sdk-crypto/src/zklogin/poseidon/mod.rs similarity index 100% rename from crates/iota-crypto/src/zklogin/poseidon/mod.rs rename to crates/iota-sdk-crypto/src/zklogin/poseidon/mod.rs diff --git a/crates/iota-crypto/src/zklogin/tests.rs b/crates/iota-sdk-crypto/src/zklogin/tests.rs similarity index 98% rename from crates/iota-crypto/src/zklogin/tests.rs rename to crates/iota-sdk-crypto/src/zklogin/tests.rs index a6b143ddd..20e017dec 100644 --- a/crates/iota-crypto/src/zklogin/tests.rs +++ b/crates/iota-sdk-crypto/src/zklogin/tests.rs @@ -2,7 +2,7 @@ // Modifications Copyright (c) 2025 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -use iota_sdk_types::{PersonalMessage, ZkLoginInputs}; +use iota_types::{PersonalMessage, ZkLoginInputs}; use signature::Signer; use super::*; diff --git a/crates/iota-crypto/src/zklogin/verify.rs b/crates/iota-sdk-crypto/src/zklogin/verify.rs similarity index 99% rename from crates/iota-crypto/src/zklogin/verify.rs rename to crates/iota-sdk-crypto/src/zklogin/verify.rs index eef69a6e0..f3ef19f13 100644 --- a/crates/iota-crypto/src/zklogin/verify.rs +++ b/crates/iota-sdk-crypto/src/zklogin/verify.rs @@ -7,7 +7,7 @@ use std::str::FromStr; use ark_bn254::{Fq, Fq2, Fr, G1Affine, G1Projective, G2Affine, G2Projective}; use ark_ff::PrimeField; use ark_groth16::{PreparedVerifyingKey, Proof}; -use iota_sdk_types::{ +use iota_types::{ Bn254FieldElement, CircomG1, CircomG2, Ed25519PublicKey, Jwk, Secp256k1PublicKey, Secp256r1PublicKey, SimpleSignature, ZkLoginInputs, ZkLoginProof, }; @@ -511,7 +511,7 @@ pub(crate) fn gen_address_seed_with_salt_hash( #[cfg(test)] mod tests { - use iota_sdk_types::Ed25519Signature; + use iota_types::Ed25519Signature; #[cfg(test)] #[cfg(target_arch = "wasm32")] use wasm_bindgen_test::wasm_bindgen_test as test; diff --git a/crates/iota-sdk-ffi/Cargo.toml b/crates/iota-sdk-ffi/Cargo.toml index 60a731188..fd89549f4 100644 --- a/crates/iota-sdk-ffi/Cargo.toml +++ b/crates/iota-sdk-ffi/Cargo.toml @@ -4,6 +4,7 @@ version = "0.0.1" authors = ["IOTA Foundation "] edition = "2024" license = "Apache-2.0" +publish = false [[bin]] name = "iota_sdk_bindings" @@ -27,7 +28,4 @@ serde_json.workspace = true tokio = { workspace = true, features = ["time"] } uniffi = { version = "0.29", features = ["cli", "tokio"] } -iota-crypto = { path = "../iota-crypto", features = ["bls12381", "ed25519", "secp256r1", "passkey", "secp256k1", "zklogin", "pem", "bech32"] } -iota-graphql-client = { path = "../iota-graphql-client" } -iota-transaction-builder = { path = "../iota-transaction-builder" } -iota-types = { package = "iota-sdk-types", path = "../iota-sdk-types", features = ["hash", "rand"] } +iota-sdk = { version = "3.0.0", path = "../iota-sdk" } diff --git a/crates/iota-sdk-ffi/README.md b/crates/iota-sdk-ffi/README.md index a32010604..f55e119bb 100644 --- a/crates/iota-sdk-ffi/README.md +++ b/crates/iota-sdk-ffi/README.md @@ -90,7 +90,7 @@ These methods set various metadata which may be needed for the execution. ### Finalization and Execution -There are several ways to finish the builder. First, the [finish](transaction_builder::TransactionBuilder::finish) method can be used to return the resulting [Transaction](iota_types::Transaction), which can be manually serialized, executed, etc. +There are several ways to finish the builder. First, the [finish](transaction_builder::TransactionBuilder::finish) method can be used to return the resulting [Transaction](iota_sdk::types::Transaction), which can be manually serialized, executed, etc. Additionally, the builder can directly [dry_run](transaction_builder::TransactionBuilder::dry_run) or [execute](transaction_builder::TransactionBuilder::execute) the transaction. diff --git a/crates/iota-sdk-ffi/src/crypto/bls12381.rs b/crates/iota-sdk-ffi/src/crypto/bls12381.rs index c0c406321..daeb31aaf 100644 --- a/crates/iota-sdk-ffi/src/crypto/bls12381.rs +++ b/crates/iota-sdk-ffi/src/crypto/bls12381.rs @@ -3,7 +3,7 @@ use std::sync::RwLock; -use iota_types::SignatureScheme; +use iota_sdk::types::SignatureScheme; use rand::rngs::OsRng; use crate::{ @@ -16,13 +16,13 @@ use crate::{ }; #[derive(derive_more::From, derive_more::Deref, uniffi::Object)] -pub struct Bls12381PrivateKey(pub iota_crypto::bls12381::Bls12381PrivateKey); +pub struct Bls12381PrivateKey(pub iota_sdk::crypto::bls12381::Bls12381PrivateKey); #[uniffi::export] impl Bls12381PrivateKey { #[uniffi::constructor] pub fn new(bytes: Vec) -> Result { - Ok(Self(iota_crypto::bls12381::Bls12381PrivateKey::new( + Ok(Self(iota_sdk::crypto::bls12381::Bls12381PrivateKey::new( bytes.try_into().map_err(|v: Vec| { SdkFfiError::custom(format!("expected bytes of length 32, found {}", v.len())) })?, @@ -43,7 +43,9 @@ impl Bls12381PrivateKey { #[uniffi::constructor] pub fn generate() -> Self { - Self(iota_crypto::bls12381::Bls12381PrivateKey::generate(OsRng)) + Self(iota_sdk::crypto::bls12381::Bls12381PrivateKey::generate( + OsRng, + )) } pub fn sign_checkpoint_summary(&self, summary: &CheckpointSummary) -> ValidatorSignature { @@ -52,20 +54,22 @@ impl Bls12381PrivateKey { pub fn try_sign(&self, message: &[u8]) -> Result { Ok( - iota_crypto::Signer::::try_sign(&self.0, message)? - .into(), + iota_sdk::crypto::Signer::::try_sign( + &self.0, message, + )? + .into(), ) } } #[derive(derive_more::From, uniffi::Object)] -pub struct Bls12381VerifyingKey(pub iota_crypto::bls12381::Bls12381VerifyingKey); +pub struct Bls12381VerifyingKey(pub iota_sdk::crypto::bls12381::Bls12381VerifyingKey); #[uniffi::export] impl Bls12381VerifyingKey { #[uniffi::constructor] pub fn new(public_key: &Bls12381PublicKey) -> Result { - Ok(iota_crypto::bls12381::Bls12381VerifyingKey::new(&public_key.0).map(Self)?) + Ok(iota_sdk::crypto::bls12381::Bls12381VerifyingKey::new(&public_key.0).map(Self)?) } pub fn public_key(&self) -> Bls12381PublicKey { @@ -73,12 +77,8 @@ impl Bls12381VerifyingKey { } pub fn verify(&self, message: &[u8], signature: &Bls12381Signature) -> Result<()> { - Ok( - iota_crypto::Verifier::::verify( - &self.0, - message, - &signature.0, - )?, - ) + Ok(iota_sdk::crypto::Verifier::< + iota_sdk::types::Bls12381Signature, + >::verify(&self.0, message, &signature.0)?) } } diff --git a/crates/iota-sdk-ffi/src/crypto/ed25519.rs b/crates/iota-sdk-ffi/src/crypto/ed25519.rs index 157fb18d6..bc3ec465f 100644 --- a/crates/iota-sdk-ffi/src/crypto/ed25519.rs +++ b/crates/iota-sdk-ffi/src/crypto/ed25519.rs @@ -1,8 +1,7 @@ // Copyright (c) 2025 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -use iota_crypto::PrivateKeyExt; -use iota_types::SignatureScheme; +use iota_sdk::{crypto::PrivateKeyExt, types::SignatureScheme}; use rand::rngs::OsRng; use crate::{ @@ -14,13 +13,13 @@ use crate::{ }; #[derive(derive_more::From, derive_more::Deref, uniffi::Object)] -pub struct Ed25519PrivateKey(iota_crypto::ed25519::Ed25519PrivateKey); +pub struct Ed25519PrivateKey(iota_sdk::crypto::ed25519::Ed25519PrivateKey); #[uniffi::export] impl Ed25519PrivateKey { #[uniffi::constructor] pub fn new(bytes: Vec) -> Result { - Ok(Self(iota_crypto::ed25519::Ed25519PrivateKey::new( + Ok(Self(iota_sdk::crypto::ed25519::Ed25519PrivateKey::new( bytes.try_into().map_err(|v: Vec| { SdkFfiError::custom(format!("expected bytes of length 32, found {}", v.len())) })?, @@ -41,14 +40,16 @@ impl Ed25519PrivateKey { #[uniffi::constructor] pub fn generate() -> Self { - Self(iota_crypto::ed25519::Ed25519PrivateKey::generate(OsRng)) + Self(iota_sdk::crypto::ed25519::Ed25519PrivateKey::generate( + OsRng, + )) } /// Deserialize PKCS#8 private key from ASN.1 DER-encoded data (binary /// format). #[uniffi::constructor] pub fn from_der(bytes: &[u8]) -> Result { - Ok(iota_crypto::ed25519::Ed25519PrivateKey::from_der(bytes)?.into()) + Ok(iota_sdk::crypto::ed25519::Ed25519PrivateKey::from_der(bytes)?.into()) } /// Serialize this private key as DER-encoded PKCS#8 @@ -59,7 +60,7 @@ impl Ed25519PrivateKey { /// Deserialize PKCS#8-encoded private key from PEM. #[uniffi::constructor] pub fn from_pem(s: &str) -> Result { - Ok(iota_crypto::ed25519::Ed25519PrivateKey::from_pem(s)?.into()) + Ok(iota_sdk::crypto::ed25519::Ed25519PrivateKey::from_pem(s)?.into()) } /// Serialize this private key as PEM-encoded PKCS#8 @@ -82,30 +83,43 @@ impl Ed25519PrivateKey { /// "iotaprivkey". #[uniffi::constructor] pub fn from_bech32(value: &str) -> Result { - Ok(iota_crypto::ed25519::Ed25519PrivateKey::from_bech32(value)?.into()) + Ok(iota_sdk::crypto::ed25519::Ed25519PrivateKey::from_bech32(value)?.into()) } pub fn try_sign(&self, message: &[u8]) -> Result { - Ok(iota_crypto::Signer::::try_sign(&self.0, message)?.into()) + Ok( + iota_sdk::crypto::Signer::::try_sign( + &self.0, message, + )? + .into(), + ) } pub fn try_sign_simple(&self, message: &[u8]) -> Result { - Ok(iota_crypto::Signer::::try_sign(&self.0, message)?.into()) + Ok( + iota_sdk::crypto::Signer::::try_sign( + &self.0, message, + )? + .into(), + ) } pub fn try_sign_user(&self, message: &[u8]) -> Result { - Ok(iota_crypto::Signer::::try_sign(&self.0, message)?.into()) + Ok( + iota_sdk::crypto::Signer::::try_sign(&self.0, message)? + .into(), + ) } } #[derive(derive_more::From, uniffi::Object)] -pub struct Ed25519VerifyingKey(iota_crypto::ed25519::Ed25519VerifyingKey); +pub struct Ed25519VerifyingKey(iota_sdk::crypto::ed25519::Ed25519VerifyingKey); #[uniffi::export] impl Ed25519VerifyingKey { #[uniffi::constructor] pub fn new(public_key: &Ed25519PublicKey) -> Result { - Ok(iota_crypto::ed25519::Ed25519VerifyingKey::new(&public_key.0).map(Self)?) + Ok(iota_sdk::crypto::ed25519::Ed25519VerifyingKey::new(&public_key.0).map(Self)?) } pub fn public_key(&self) -> Ed25519PublicKey { @@ -115,7 +129,7 @@ impl Ed25519VerifyingKey { /// Deserialize public key from ASN.1 DER-encoded data (binary format). #[uniffi::constructor] pub fn from_der(bytes: &[u8]) -> Result { - Ok(iota_crypto::ed25519::Ed25519VerifyingKey::from_der(bytes)?.into()) + Ok(iota_sdk::crypto::ed25519::Ed25519VerifyingKey::from_der(bytes)?.into()) } /// Serialize this public key as DER-encoded data @@ -126,7 +140,7 @@ impl Ed25519VerifyingKey { /// Deserialize public key from PEM. #[uniffi::constructor] pub fn from_pem(s: &str) -> Result { - Ok(iota_crypto::ed25519::Ed25519VerifyingKey::from_pem(s)?.into()) + Ok(iota_sdk::crypto::ed25519::Ed25519VerifyingKey::from_pem(s)?.into()) } /// Serialize this public key into PEM format @@ -135,58 +149,50 @@ impl Ed25519VerifyingKey { } pub fn verify(&self, message: &[u8], signature: &Ed25519Signature) -> Result<()> { - Ok( - iota_crypto::Verifier::::verify( - &self.0, - message, - &signature.0, - )?, - ) + Ok(iota_sdk::crypto::Verifier::< + iota_sdk::types::Ed25519Signature, + >::verify(&self.0, message, &signature.0)?) } pub fn verify_simple(&self, message: &[u8], signature: &SimpleSignature) -> Result<()> { + Ok(iota_sdk::crypto::Verifier::< + iota_sdk::types::SimpleSignature, + >::verify(&self.0, message, &signature.0)?) + } + + pub fn verify_user(&self, message: &[u8], signature: &UserSignature) -> Result<()> { Ok( - iota_crypto::Verifier::::verify( + iota_sdk::crypto::Verifier::::verify( &self.0, message, &signature.0, )?, ) } - - pub fn verify_user(&self, message: &[u8], signature: &UserSignature) -> Result<()> { - Ok(iota_crypto::Verifier::::verify( - &self.0, - message, - &signature.0, - )?) - } } #[derive(derive_more::From, uniffi::Object)] -pub struct Ed25519Verifier(iota_crypto::ed25519::Ed25519Verifier); +pub struct Ed25519Verifier(iota_sdk::crypto::ed25519::Ed25519Verifier); impl Ed25519Verifier { #[uniffi::constructor] pub fn new() -> Self { - Self(iota_crypto::ed25519::Ed25519Verifier::new()) + Self(iota_sdk::crypto::ed25519::Ed25519Verifier::new()) } fn verify_simple(&self, message: &[u8], signature: &SimpleSignature) -> Result<()> { + Ok(iota_sdk::crypto::Verifier::< + iota_sdk::types::SimpleSignature, + >::verify(&self.0, message, &signature.0)?) + } + + fn verify_user(&self, message: &[u8], signature: &UserSignature) -> Result<()> { Ok( - iota_crypto::Verifier::::verify( + iota_sdk::crypto::Verifier::::verify( &self.0, message, &signature.0, )?, ) } - - fn verify_user(&self, message: &[u8], signature: &UserSignature) -> Result<()> { - Ok(iota_crypto::Verifier::::verify( - &self.0, - message, - &signature.0, - )?) - } } diff --git a/crates/iota-sdk-ffi/src/crypto/multisig.rs b/crates/iota-sdk-ffi/src/crypto/multisig.rs index 57b37a622..26630bfa2 100644 --- a/crates/iota-sdk-ffi/src/crypto/multisig.rs +++ b/crates/iota-sdk-ffi/src/crypto/multisig.rs @@ -6,7 +6,7 @@ use std::{ sync::{Arc, RwLock}, }; -use iota_crypto::{SignatureError, Verifier}; +use iota_sdk::crypto::{SignatureError, Verifier}; use crate::{ crypto::zklogin::ZkloginVerifier, @@ -19,13 +19,13 @@ use crate::{ }; #[derive(derive_more::From, uniffi::Object)] -pub struct MultisigVerifier(pub iota_crypto::multisig::MultisigVerifier); +pub struct MultisigVerifier(pub iota_sdk::crypto::multisig::MultisigVerifier); #[uniffi::export] impl MultisigVerifier { #[uniffi::constructor] pub fn new() -> Self { - Self(iota_crypto::multisig::MultisigVerifier::new()) + Self(iota_sdk::crypto::multisig::MultisigVerifier::new()) } pub fn with_zklogin_verifier(&self, zklogin_verifier: &ZkloginVerifier) -> Self { @@ -49,13 +49,13 @@ impl MultisigVerifier { /// Verifier that will verify all UserSignature variants #[derive(derive_more::From, uniffi::Object)] -pub struct UserSignatureVerifier(pub iota_crypto::multisig::UserSignatureVerifier); +pub struct UserSignatureVerifier(pub iota_sdk::crypto::multisig::UserSignatureVerifier); #[uniffi::export] impl UserSignatureVerifier { #[uniffi::constructor] pub fn new() -> Self { - Self(iota_crypto::multisig::UserSignatureVerifier::new()) + Self(iota_sdk::crypto::multisig::UserSignatureVerifier::new()) } pub fn with_zklogin_verifier(&self, zklogin_verifier: &ZkloginVerifier) -> Self { @@ -78,14 +78,14 @@ impl UserSignatureVerifier { } #[derive(derive_more::From, uniffi::Object)] -pub struct MultisigAggregator(pub iota_crypto::multisig::MultisigAggregator); +pub struct MultisigAggregator(pub iota_sdk::crypto::multisig::MultisigAggregator); #[uniffi::export] impl MultisigAggregator { #[uniffi::constructor] pub fn new_with_transaction(committee: &MultisigCommittee, transaction: &Transaction) -> Self { Self( - iota_crypto::multisig::MultisigAggregator::new_with_transaction( + iota_sdk::crypto::multisig::MultisigAggregator::new_with_transaction( committee.0.clone(), &transaction.0, ), @@ -94,10 +94,12 @@ impl MultisigAggregator { #[uniffi::constructor] pub fn new_with_message(committee: &MultisigCommittee, message: &[u8]) -> Self { - Self(iota_crypto::multisig::MultisigAggregator::new_with_message( - committee.0.clone(), - &iota_types::PersonalMessage(Cow::Borrowed(message)), - )) + Self( + iota_sdk::crypto::multisig::MultisigAggregator::new_with_message( + committee.0.clone(), + &iota_sdk::types::PersonalMessage(Cow::Borrowed(message)), + ), + ) } pub fn verifier(&self) -> MultisigVerifier { diff --git a/crates/iota-sdk-ffi/src/crypto/passkey.rs b/crates/iota-sdk-ffi/src/crypto/passkey.rs index e66048853..9455d4939 100644 --- a/crates/iota-sdk-ffi/src/crypto/passkey.rs +++ b/crates/iota-sdk-ffi/src/crypto/passkey.rs @@ -1,7 +1,7 @@ // Copyright (c) 2025 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -use iota_crypto::Verifier; +use iota_sdk::crypto::Verifier; use crate::{ error::Result, @@ -9,13 +9,13 @@ use crate::{ }; #[derive(uniffi::Object)] -pub struct PasskeyVerifier(iota_crypto::passkey::PasskeyVerifier); +pub struct PasskeyVerifier(iota_sdk::crypto::passkey::PasskeyVerifier); #[uniffi::export] impl PasskeyVerifier { #[uniffi::constructor] pub fn new() -> Self { - Self(iota_crypto::passkey::PasskeyVerifier::new()) + Self(iota_sdk::crypto::passkey::PasskeyVerifier::new()) } pub fn verify(&self, message: &[u8], authenticator: &PasskeyAuthenticator) -> Result<()> { diff --git a/crates/iota-sdk-ffi/src/crypto/secp256k1.rs b/crates/iota-sdk-ffi/src/crypto/secp256k1.rs index fe82bde4e..efa7ebb02 100644 --- a/crates/iota-sdk-ffi/src/crypto/secp256k1.rs +++ b/crates/iota-sdk-ffi/src/crypto/secp256k1.rs @@ -1,8 +1,7 @@ // Copyright (c) 2025 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -use iota_crypto::PrivateKeyExt; -use iota_types::SignatureScheme; +use iota_sdk::{crypto::PrivateKeyExt, types::SignatureScheme}; use rand::rngs::OsRng; use crate::{ @@ -14,13 +13,13 @@ use crate::{ }; #[derive(derive_more::From, derive_more::Deref, uniffi::Object)] -pub struct Secp256k1PrivateKey(iota_crypto::secp256k1::Secp256k1PrivateKey); +pub struct Secp256k1PrivateKey(iota_sdk::crypto::secp256k1::Secp256k1PrivateKey); #[uniffi::export] impl Secp256k1PrivateKey { #[uniffi::constructor] pub fn new(bytes: Vec) -> Result { - Ok(Self(iota_crypto::secp256k1::Secp256k1PrivateKey::new( + Ok(Self(iota_sdk::crypto::secp256k1::Secp256k1PrivateKey::new( bytes.try_into().map_err(|v: Vec| { SdkFfiError::custom(format!("expected bytes of length 32, found {}", v.len())) })?, @@ -41,14 +40,16 @@ impl Secp256k1PrivateKey { #[uniffi::constructor] pub fn generate() -> Self { - Self(iota_crypto::secp256k1::Secp256k1PrivateKey::generate(OsRng)) + Self(iota_sdk::crypto::secp256k1::Secp256k1PrivateKey::generate( + OsRng, + )) } /// Deserialize PKCS#8 private key from ASN.1 DER-encoded data (binary /// format). #[uniffi::constructor] pub fn from_der(bytes: &[u8]) -> Result { - Ok(iota_crypto::secp256k1::Secp256k1PrivateKey::from_der(bytes)?.into()) + Ok(iota_sdk::crypto::secp256k1::Secp256k1PrivateKey::from_der(bytes)?.into()) } /// Serialize this private key as DER-encoded PKCS#8 @@ -59,7 +60,7 @@ impl Secp256k1PrivateKey { /// Deserialize PKCS#8-encoded private key from PEM. #[uniffi::constructor] pub fn from_pem(s: &str) -> Result { - Ok(iota_crypto::secp256k1::Secp256k1PrivateKey::from_pem(s)?.into()) + Ok(iota_sdk::crypto::secp256k1::Secp256k1PrivateKey::from_pem(s)?.into()) } /// Serialize this private key as PEM-encoded PKCS#8 @@ -82,33 +83,43 @@ impl Secp256k1PrivateKey { /// "iotaprivkey". #[uniffi::constructor] pub fn from_bech32(value: &str) -> Result { - Ok(iota_crypto::secp256k1::Secp256k1PrivateKey::from_bech32(value)?.into()) + Ok(iota_sdk::crypto::secp256k1::Secp256k1PrivateKey::from_bech32(value)?.into()) } pub fn try_sign(&self, message: &[u8]) -> Result { Ok( - iota_crypto::Signer::::try_sign(&self.0, message)? - .into(), + iota_sdk::crypto::Signer::::try_sign( + &self.0, message, + )? + .into(), ) } pub fn try_sign_simple(&self, message: &[u8]) -> Result { - Ok(iota_crypto::Signer::::try_sign(&self.0, message)?.into()) + Ok( + iota_sdk::crypto::Signer::::try_sign( + &self.0, message, + )? + .into(), + ) } pub fn try_sign_user(&self, message: &[u8]) -> Result { - Ok(iota_crypto::Signer::::try_sign(&self.0, message)?.into()) + Ok( + iota_sdk::crypto::Signer::::try_sign(&self.0, message)? + .into(), + ) } } #[derive(derive_more::From, uniffi::Object)] -pub struct Secp256k1VerifyingKey(iota_crypto::secp256k1::Secp256k1VerifyingKey); +pub struct Secp256k1VerifyingKey(iota_sdk::crypto::secp256k1::Secp256k1VerifyingKey); #[uniffi::export] impl Secp256k1VerifyingKey { #[uniffi::constructor] pub fn new(public_key: &Secp256k1PublicKey) -> Result { - Ok(iota_crypto::secp256k1::Secp256k1VerifyingKey::new(&public_key.0).map(Self)?) + Ok(iota_sdk::crypto::secp256k1::Secp256k1VerifyingKey::new(&public_key.0).map(Self)?) } pub fn public_key(&self) -> Secp256k1PublicKey { @@ -118,7 +129,7 @@ impl Secp256k1VerifyingKey { /// Deserialize public key from ASN.1 DER-encoded data (binary format). #[uniffi::constructor] pub fn from_der(bytes: &[u8]) -> Result { - Ok(iota_crypto::secp256k1::Secp256k1VerifyingKey::from_der(bytes)?.into()) + Ok(iota_sdk::crypto::secp256k1::Secp256k1VerifyingKey::from_der(bytes)?.into()) } /// Serialize this public key as DER-encoded data @@ -129,7 +140,7 @@ impl Secp256k1VerifyingKey { /// Deserialize public key from PEM. #[uniffi::constructor] pub fn from_pem(s: &str) -> Result { - Ok(iota_crypto::secp256k1::Secp256k1VerifyingKey::from_pem(s)?.into()) + Ok(iota_sdk::crypto::secp256k1::Secp256k1VerifyingKey::from_pem(s)?.into()) } /// Serialize this public key into PEM @@ -138,59 +149,51 @@ impl Secp256k1VerifyingKey { } pub fn verify(&self, message: &[u8], signature: &Secp256k1Signature) -> Result<()> { - Ok( - iota_crypto::Verifier::::verify( - &self.0, - message, - &signature.0, - )?, - ) + Ok(iota_sdk::crypto::Verifier::< + iota_sdk::types::Secp256k1Signature, + >::verify(&self.0, message, &signature.0)?) } pub fn verify_simple(&self, message: &[u8], signature: &SimpleSignature) -> Result<()> { + Ok(iota_sdk::crypto::Verifier::< + iota_sdk::types::SimpleSignature, + >::verify(&self.0, message, &signature.0)?) + } + + pub fn verify_user(&self, message: &[u8], signature: &UserSignature) -> Result<()> { Ok( - iota_crypto::Verifier::::verify( + iota_sdk::crypto::Verifier::::verify( &self.0, message, &signature.0, )?, ) } - - pub fn verify_user(&self, message: &[u8], signature: &UserSignature) -> Result<()> { - Ok(iota_crypto::Verifier::::verify( - &self.0, - message, - &signature.0, - )?) - } } #[derive(derive_more::From, uniffi::Object)] -pub struct Secp256k1Verifier(iota_crypto::secp256k1::Secp256k1Verifier); +pub struct Secp256k1Verifier(iota_sdk::crypto::secp256k1::Secp256k1Verifier); #[uniffi::export] impl Secp256k1Verifier { #[uniffi::constructor] pub fn new() -> Self { - Self(iota_crypto::secp256k1::Secp256k1Verifier::new()) + Self(iota_sdk::crypto::secp256k1::Secp256k1Verifier::new()) } fn verify_simple(&self, message: &[u8], signature: &SimpleSignature) -> Result<()> { + Ok(iota_sdk::crypto::Verifier::< + iota_sdk::types::SimpleSignature, + >::verify(&self.0, message, &signature.0)?) + } + + fn verify_user(&self, message: &[u8], signature: &UserSignature) -> Result<()> { Ok( - iota_crypto::Verifier::::verify( + iota_sdk::crypto::Verifier::::verify( &self.0, message, &signature.0, )?, ) } - - fn verify_user(&self, message: &[u8], signature: &UserSignature) -> Result<()> { - Ok(iota_crypto::Verifier::::verify( - &self.0, - message, - &signature.0, - )?) - } } diff --git a/crates/iota-sdk-ffi/src/crypto/secp256r1.rs b/crates/iota-sdk-ffi/src/crypto/secp256r1.rs index d96bb9db0..0381a8870 100644 --- a/crates/iota-sdk-ffi/src/crypto/secp256r1.rs +++ b/crates/iota-sdk-ffi/src/crypto/secp256r1.rs @@ -3,8 +3,10 @@ use std::sync::Arc; -use iota_crypto::{PrivateKeyExt, Signer, Verifier}; -use iota_types::SignatureScheme; +use iota_sdk::{ + crypto::{PrivateKeyExt, Signer, Verifier}, + types::SignatureScheme, +}; use rand::rngs::OsRng; use crate::{ @@ -16,13 +18,13 @@ use crate::{ }; #[derive(derive_more::From, derive_more::Deref, uniffi::Object)] -pub struct Secp256r1PrivateKey(pub iota_crypto::secp256r1::Secp256r1PrivateKey); +pub struct Secp256r1PrivateKey(pub iota_sdk::crypto::secp256r1::Secp256r1PrivateKey); #[uniffi::export] impl Secp256r1PrivateKey { #[uniffi::constructor] pub fn new(bytes: Vec) -> Result { - Ok(Self(iota_crypto::secp256r1::Secp256r1PrivateKey::new( + Ok(Self(iota_sdk::crypto::secp256r1::Secp256r1PrivateKey::new( bytes.try_into().map_err(|v: Vec| { SdkFfiError::custom(format!("expected bytes of length 32, found {}", v.len())) })?, @@ -41,19 +43,29 @@ impl Secp256r1PrivateKey { /// Sign a message and return a Secp256r1Signature. pub fn try_sign(&self, message: &[u8]) -> Result { Ok( - iota_crypto::Signer::::try_sign(&self.0, message)? - .into(), + iota_sdk::crypto::Signer::::try_sign( + &self.0, message, + )? + .into(), ) } /// Sign a message and return a SimpleSignature. pub fn try_sign_simple(&self, message: &[u8]) -> Result { - Ok(iota_crypto::Signer::::try_sign(&self.0, message)?.into()) + Ok( + iota_sdk::crypto::Signer::::try_sign( + &self.0, message, + )? + .into(), + ) } /// Sign a message and return a UserSignature. pub fn try_sign_user(&self, message: &[u8]) -> Result { - Ok(iota_crypto::Signer::::try_sign(&self.0, message)?.into()) + Ok( + iota_sdk::crypto::Signer::::try_sign(&self.0, message)? + .into(), + ) } pub fn verifying_key(&self) -> Secp256r1VerifyingKey { @@ -63,14 +75,16 @@ impl Secp256r1PrivateKey { /// Generate a new random Secp256r1PrivateKey #[uniffi::constructor] pub fn generate() -> Self { - Self(iota_crypto::secp256r1::Secp256r1PrivateKey::generate(OsRng)) + Self(iota_sdk::crypto::secp256r1::Secp256r1PrivateKey::generate( + OsRng, + )) } /// Deserialize PKCS#8 private key from ASN.1 DER-encoded data (binary /// format). #[uniffi::constructor] pub fn from_der(bytes: Vec) -> Result { - Ok(iota_crypto::secp256r1::Secp256r1PrivateKey::from_der(&bytes)?.into()) + Ok(iota_sdk::crypto::secp256r1::Secp256r1PrivateKey::from_der(&bytes)?.into()) } /// Serialize this private key as DER-encoded PKCS#8 @@ -81,7 +95,7 @@ impl Secp256r1PrivateKey { /// Deserialize PKCS#8-encoded private key from PEM. #[uniffi::constructor] pub fn from_pem(s: &str) -> Result { - Ok(iota_crypto::secp256r1::Secp256r1PrivateKey::from_pem(s)?.into()) + Ok(iota_sdk::crypto::secp256r1::Secp256r1PrivateKey::from_pem(s)?.into()) } /// Serialize this private key as PEM-encoded PKCS#8 @@ -104,18 +118,18 @@ impl Secp256r1PrivateKey { /// "iotaprivkey". #[uniffi::constructor] pub fn from_bech32(value: &str) -> Result { - Ok(iota_crypto::secp256r1::Secp256r1PrivateKey::from_bech32(value)?.into()) + Ok(iota_sdk::crypto::secp256r1::Secp256r1PrivateKey::from_bech32(value)?.into()) } } #[derive(derive_more::From, uniffi::Object)] -pub struct Secp256r1VerifyingKey(pub iota_crypto::secp256r1::Secp256r1VerifyingKey); +pub struct Secp256r1VerifyingKey(pub iota_sdk::crypto::secp256r1::Secp256r1VerifyingKey); #[uniffi::export] impl Secp256r1VerifyingKey { #[uniffi::constructor] pub fn new(public_key: &Secp256r1PublicKey) -> Result { - Ok(iota_crypto::secp256r1::Secp256r1VerifyingKey::new(public_key)?.into()) + Ok(iota_sdk::crypto::secp256r1::Secp256r1VerifyingKey::new(public_key)?.into()) } pub fn public_key(&self) -> Secp256r1PublicKey { @@ -125,7 +139,7 @@ impl Secp256r1VerifyingKey { /// Deserialize public key from ASN.1 DER-encoded data (binary format). #[uniffi::constructor] pub fn from_der(bytes: Vec) -> Result { - Ok(iota_crypto::secp256r1::Secp256r1VerifyingKey::from_der(&bytes)?.into()) + Ok(iota_sdk::crypto::secp256r1::Secp256r1VerifyingKey::from_der(&bytes)?.into()) } /// Serialize this public key as DER-encoded data. @@ -136,7 +150,7 @@ impl Secp256r1VerifyingKey { /// Deserialize public key from PEM. #[uniffi::constructor] pub fn from_pem(s: &str) -> Result { - Ok(iota_crypto::secp256r1::Secp256r1VerifyingKey::from_pem(s)?.into()) + Ok(iota_sdk::crypto::secp256r1::Secp256r1VerifyingKey::from_pem(s)?.into()) } /// Serialize this public key into PEM. @@ -149,49 +163,45 @@ impl Secp256r1VerifyingKey { } pub fn verify_simple(&self, message: Vec, signature: &SimpleSignature) -> Result<()> { + Ok(iota_sdk::crypto::Verifier::< + iota_sdk::types::SimpleSignature, + >::verify(&self.0, &message, &signature.0)?) + } + + pub fn verify_user(&self, message: Vec, signature: &UserSignature) -> Result<()> { Ok( - iota_crypto::Verifier::::verify( + iota_sdk::crypto::Verifier::::verify( &self.0, &message, &signature.0, )?, ) } - - pub fn verify_user(&self, message: Vec, signature: &UserSignature) -> Result<()> { - Ok(iota_crypto::Verifier::::verify( - &self.0, - &message, - &signature.0, - )?) - } } #[derive(derive_more::From, uniffi::Object)] -pub struct Secp256r1Verifier(pub iota_crypto::secp256r1::Secp256r1Verifier); +pub struct Secp256r1Verifier(pub iota_sdk::crypto::secp256r1::Secp256r1Verifier); #[uniffi::export] impl Secp256r1Verifier { #[uniffi::constructor] pub fn new() -> Self { - Self(iota_crypto::secp256r1::Secp256r1Verifier::new()) + Self(iota_sdk::crypto::secp256r1::Secp256r1Verifier::new()) } pub fn verify_simple(&self, message: Vec, signature: &SimpleSignature) -> Result<()> { + Ok(iota_sdk::crypto::Verifier::< + iota_sdk::types::SimpleSignature, + >::verify(&self.0, &message, &signature.0)?) + } + + pub fn verify_user(&self, message: Vec, signature: &UserSignature) -> Result<()> { Ok( - iota_crypto::Verifier::::verify( + iota_sdk::crypto::Verifier::::verify( &self.0, &message, &signature.0, )?, ) } - - pub fn verify_user(&self, message: Vec, signature: &UserSignature) -> Result<()> { - Ok(iota_crypto::Verifier::::verify( - &self.0, - &message, - &signature.0, - )?) - } } diff --git a/crates/iota-sdk-ffi/src/crypto/simple.rs b/crates/iota-sdk-ffi/src/crypto/simple.rs index 49be36417..41d4984a8 100644 --- a/crates/iota-sdk-ffi/src/crypto/simple.rs +++ b/crates/iota-sdk-ffi/src/crypto/simple.rs @@ -1,8 +1,10 @@ // Copyright (c) 2025 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -use iota_crypto::{PrivateKeyExt, Signer, Verifier}; -use iota_types::SignatureScheme; +use iota_sdk::{ + crypto::{PrivateKeyExt, Signer, Verifier}, + types::SignatureScheme, +}; use crate::{ crypto::{ @@ -12,13 +14,13 @@ use crate::{ types::{crypto::multisig::MultisigMemberPublicKey, signature::SimpleSignature}, }; #[derive(derive_more::From, uniffi::Object)] -pub struct SimpleVerifier(iota_crypto::simple::SimpleVerifier); +pub struct SimpleVerifier(iota_sdk::crypto::simple::SimpleVerifier); #[uniffi::export] impl SimpleVerifier { #[uniffi::constructor] pub fn new() -> Self { - Self(iota_crypto::simple::SimpleVerifier) + Self(iota_sdk::crypto::simple::SimpleVerifier) } pub fn verify(&self, message: &[u8], signature: &SimpleSignature) -> Result<()> { @@ -27,27 +29,27 @@ impl SimpleVerifier { } #[derive(derive_more::From, uniffi::Object)] -pub struct SimpleKeypair(pub iota_crypto::simple::SimpleKeypair); +pub struct SimpleKeypair(pub iota_sdk::crypto::simple::SimpleKeypair); #[uniffi::export] impl SimpleKeypair { #[uniffi::constructor] pub fn from_ed25519(keypair: &Ed25519PrivateKey) -> Self { - Self(iota_crypto::simple::SimpleKeypair::from( + Self(iota_sdk::crypto::simple::SimpleKeypair::from( (**keypair).clone(), )) } #[uniffi::constructor] pub fn from_secp256k1(keypair: &Secp256k1PrivateKey) -> Self { - Self(iota_crypto::simple::SimpleKeypair::from( + Self(iota_sdk::crypto::simple::SimpleKeypair::from( (**keypair).clone(), )) } #[uniffi::constructor] pub fn from_secp256r1(keypair: &Secp256r1PrivateKey) -> Self { - Self(iota_crypto::simple::SimpleKeypair::from( + Self(iota_sdk::crypto::simple::SimpleKeypair::from( (**keypair).clone(), )) } @@ -72,7 +74,7 @@ impl SimpleKeypair { /// Decode a SimpleKeypair from `flag || privkey` bytes #[uniffi::constructor] pub fn from_bytes(bytes: &[u8]) -> Result { - Ok(iota_crypto::simple::SimpleKeypair::from_bytes(bytes)?.into()) + Ok(iota_sdk::crypto::simple::SimpleKeypair::from_bytes(bytes)?.into()) } /// Encode a SimpleKeypair as `flag || privkey` in Bech32 starting with @@ -86,14 +88,14 @@ impl SimpleKeypair { /// the private key bytes. #[uniffi::constructor] pub fn from_bech32(value: &str) -> Result { - Ok(iota_crypto::simple::SimpleKeypair::from_bech32(value)?.into()) + Ok(iota_sdk::crypto::simple::SimpleKeypair::from_bech32(value)?.into()) } /// Deserialize PKCS#8 private key from ASN.1 DER-encoded data (binary /// format). #[uniffi::constructor] pub fn from_der(bytes: &[u8]) -> Result { - Ok(iota_crypto::simple::SimpleKeypair::from_der(bytes)?.into()) + Ok(iota_sdk::crypto::simple::SimpleKeypair::from_der(bytes)?.into()) } /// Serialize this private key as DER-encoded PKCS#8 @@ -104,7 +106,7 @@ impl SimpleKeypair { /// Deserialize PKCS#8-encoded private key from PEM. #[uniffi::constructor] pub fn from_pem(s: &str) -> Result { - Ok(iota_crypto::simple::SimpleKeypair::from_pem(s)?.into()) + Ok(iota_sdk::crypto::simple::SimpleKeypair::from_pem(s)?.into()) } /// Serialize this private key as DER-encoded PKCS#8 @@ -113,12 +115,12 @@ impl SimpleKeypair { } fn try_sign(&self, message: &[u8]) -> Result { - Ok(Signer::::try_sign(&self.0, message)?.into()) + Ok(Signer::::try_sign(&self.0, message)?.into()) } } #[derive(derive_more::From, uniffi::Object)] -pub struct SimpleVerifyingKey(iota_crypto::simple::SimpleVerifyingKey); +pub struct SimpleVerifyingKey(iota_sdk::crypto::simple::SimpleVerifyingKey); #[uniffi::export] impl SimpleVerifyingKey { @@ -134,7 +136,7 @@ impl SimpleVerifyingKey { /// format). #[uniffi::constructor] pub fn from_der(bytes: &[u8]) -> Result { - Ok(iota_crypto::simple::SimpleVerifyingKey::from_der(bytes)?.into()) + Ok(iota_sdk::crypto::simple::SimpleVerifyingKey::from_der(bytes)?.into()) } /// Serialize this private key as DER-encoded PKCS#8 @@ -145,7 +147,7 @@ impl SimpleVerifyingKey { /// Deserialize PKCS#8-encoded private key from PEM. #[uniffi::constructor] pub fn from_pem(s: &str) -> Result { - Ok(iota_crypto::simple::SimpleVerifyingKey::from_pem(s)?.into()) + Ok(iota_sdk::crypto::simple::SimpleVerifyingKey::from_pem(s)?.into()) } /// Serialize this private key as DER-encoded PKCS#8 diff --git a/crates/iota-sdk-ffi/src/crypto/validator.rs b/crates/iota-sdk-ffi/src/crypto/validator.rs index 3192e7727..9ef0c77cf 100644 --- a/crates/iota-sdk-ffi/src/crypto/validator.rs +++ b/crates/iota-sdk-ffi/src/crypto/validator.rs @@ -13,7 +13,7 @@ use crate::{ #[derive(derive_more::From, uniffi::Object)] pub struct ValidatorCommitteeSignatureVerifier( - pub iota_crypto::validator::ValidatorCommitteeSignatureVerifier, + pub iota_sdk::crypto::validator::ValidatorCommitteeSignatureVerifier, ); #[uniffi::export] @@ -21,7 +21,9 @@ impl ValidatorCommitteeSignatureVerifier { #[uniffi::constructor] pub fn new(committee: ValidatorCommittee) -> Result { Ok(Self( - iota_crypto::validator::ValidatorCommitteeSignatureVerifier::new(committee.into())?, + iota_sdk::crypto::validator::ValidatorCommitteeSignatureVerifier::new( + committee.into(), + )?, )) } @@ -38,13 +40,9 @@ impl ValidatorCommitteeSignatureVerifier { } pub fn verify(&self, message: &[u8], signature: &ValidatorSignature) -> Result<()> { - Ok( - iota_crypto::Verifier::::verify( - &self.0, - message, - &signature.0, - )?, - ) + Ok(iota_sdk::crypto::Verifier::< + iota_sdk::types::ValidatorSignature, + >::verify(&self.0, message, &signature.0)?) } pub fn verify_aggregated( @@ -52,15 +50,15 @@ impl ValidatorCommitteeSignatureVerifier { message: &[u8], signature: &ValidatorAggregatedSignature, ) -> Result<()> { - Ok(iota_crypto::Verifier::< - iota_types::ValidatorAggregatedSignature, + Ok(iota_sdk::crypto::Verifier::< + iota_sdk::types::ValidatorAggregatedSignature, >::verify(&self.0, message, &signature.0)?) } } #[derive(derive_more::From, uniffi::Object)] pub struct ValidatorCommitteeSignatureAggregator( - pub RwLock, + pub RwLock, ); #[uniffi::export] @@ -71,7 +69,7 @@ impl ValidatorCommitteeSignatureAggregator { summary: &CheckpointSummary, ) -> Result { Ok(Self( - iota_crypto::validator::ValidatorCommitteeSignatureAggregator::new_checkpoint_summary( + iota_sdk::crypto::validator::ValidatorCommitteeSignatureAggregator::new_checkpoint_summary( committee.into(), &summary.0, )? diff --git a/crates/iota-sdk-ffi/src/crypto/zklogin.rs b/crates/iota-sdk-ffi/src/crypto/zklogin.rs index bf046e680..b321db43b 100644 --- a/crates/iota-sdk-ffi/src/crypto/zklogin.rs +++ b/crates/iota-sdk-ffi/src/crypto/zklogin.rs @@ -3,26 +3,28 @@ use std::collections::HashMap; -use iota_crypto::Verifier; -use iota_types::{Jwk, JwkId}; +use iota_sdk::{ + crypto::Verifier, + types::{Jwk, JwkId}, +}; use crate::{error::Result, types::crypto::zklogin::ZkLoginAuthenticator}; #[derive(derive_more::From, uniffi::Object)] -pub struct ZkloginVerifier(pub iota_crypto::zklogin::ZkloginVerifier); +pub struct ZkloginVerifier(pub iota_sdk::crypto::zklogin::ZkloginVerifier); #[uniffi::export] impl ZkloginVerifier { #[uniffi::constructor] pub fn new_mainnet() -> Self { - Self(iota_crypto::zklogin::ZkloginVerifier::new_mainnet()) + Self(iota_sdk::crypto::zklogin::ZkloginVerifier::new_mainnet()) } /// Load a fixed verifying key from zkLogin.vkey output. This is based on a /// local setup and should not be used in production. #[uniffi::constructor] pub fn new_dev() -> Self { - Self(iota_crypto::zklogin::ZkloginVerifier::new_dev()) + Self(iota_sdk::crypto::zklogin::ZkloginVerifier::new_dev()) } pub fn jwks(&self) -> HashMap { diff --git a/crates/iota-sdk-ffi/src/faucet.rs b/crates/iota-sdk-ffi/src/faucet.rs index 96c806c83..822660feb 100644 --- a/crates/iota-sdk-ffi/src/faucet.rs +++ b/crates/iota-sdk-ffi/src/faucet.rs @@ -9,7 +9,7 @@ use crate::{ }; #[derive(uniffi::Object)] -pub struct FaucetClient(iota_graphql_client::faucet::FaucetClient); +pub struct FaucetClient(iota_sdk::graphql_client::faucet::FaucetClient); #[uniffi::export(async_runtime = "tokio")] impl FaucetClient { @@ -22,25 +22,27 @@ impl FaucetClient { /// - /v1/status/taks-uuid is used to check the status of the request #[uniffi::constructor] pub fn new(faucet_url: String) -> Self { - Self(iota_graphql_client::faucet::FaucetClient::new(&faucet_url)) + Self(iota_sdk::graphql_client::faucet::FaucetClient::new( + &faucet_url, + )) } /// Create a new Faucet client connected to the `testnet` faucet. #[uniffi::constructor] pub fn new_testnet() -> Self { - Self(iota_graphql_client::faucet::FaucetClient::new_testnet()) + Self(iota_sdk::graphql_client::faucet::FaucetClient::new_testnet()) } /// Create a new Faucet client connected to the `devnet` faucet. #[uniffi::constructor] pub fn new_devnet() -> Self { - Self(iota_graphql_client::faucet::FaucetClient::new_devnet()) + Self(iota_sdk::graphql_client::faucet::FaucetClient::new_devnet()) } /// Create a new Faucet client connected to a `localnet` faucet. #[uniffi::constructor] pub fn new_localnet() -> Self { - Self(iota_graphql_client::faucet::FaucetClient::new_localnet()) + Self(iota_sdk::graphql_client::faucet::FaucetClient::new_localnet()) } /// Request gas from the faucet. Note that this will return the UUID of the @@ -86,17 +88,17 @@ pub enum BatchSendStatusType { Discarded, } -impl From for BatchSendStatusType { - fn from(value: iota_graphql_client::faucet::BatchSendStatusType) -> Self { +impl From for BatchSendStatusType { + fn from(value: iota_sdk::graphql_client::faucet::BatchSendStatusType) -> Self { match value { - iota_graphql_client::faucet::BatchSendStatusType::InProgress => Self::InProgress, - iota_graphql_client::faucet::BatchSendStatusType::Succeeded => Self::Succeeded, - iota_graphql_client::faucet::BatchSendStatusType::Discarded => Self::Discarded, + iota_sdk::graphql_client::faucet::BatchSendStatusType::InProgress => Self::InProgress, + iota_sdk::graphql_client::faucet::BatchSendStatusType::Succeeded => Self::Succeeded, + iota_sdk::graphql_client::faucet::BatchSendStatusType::Discarded => Self::Discarded, } } } -impl From for iota_graphql_client::faucet::BatchSendStatusType { +impl From for iota_sdk::graphql_client::faucet::BatchSendStatusType { fn from(value: BatchSendStatusType) -> Self { match value { BatchSendStatusType::InProgress => Self::InProgress, @@ -113,8 +115,8 @@ pub struct CoinInfo { pub transfer_tx_digest: Arc, } -impl From for CoinInfo { - fn from(value: iota_graphql_client::faucet::CoinInfo) -> Self { +impl From for CoinInfo { + fn from(value: iota_sdk::graphql_client::faucet::CoinInfo) -> Self { Self { amount: value.amount, id: Arc::new(value.id.into()), @@ -123,7 +125,7 @@ impl From for CoinInfo { } } -impl From for iota_graphql_client::faucet::CoinInfo { +impl From for iota_sdk::graphql_client::faucet::CoinInfo { fn from(value: CoinInfo) -> Self { Self { amount: value.amount, @@ -138,15 +140,15 @@ pub struct FaucetReceipt { pub sent: Vec, } -impl From for FaucetReceipt { - fn from(value: iota_graphql_client::faucet::FaucetReceipt) -> Self { +impl From for FaucetReceipt { + fn from(value: iota_sdk::graphql_client::faucet::FaucetReceipt) -> Self { Self { sent: value.sent.into_iter().map(Into::into).collect(), } } } -impl From for iota_graphql_client::faucet::FaucetReceipt { +impl From for iota_sdk::graphql_client::faucet::FaucetReceipt { fn from(value: FaucetReceipt) -> Self { Self { sent: value.sent.into_iter().map(Into::into).collect(), @@ -160,8 +162,8 @@ pub struct BatchSendStatus { pub transferred_gas_objects: Option, } -impl From for BatchSendStatus { - fn from(value: iota_graphql_client::faucet::BatchSendStatus) -> Self { +impl From for BatchSendStatus { + fn from(value: iota_sdk::graphql_client::faucet::BatchSendStatus) -> Self { Self { status: value.status.into(), transferred_gas_objects: value.transferred_gas_objects.map(Into::into), @@ -169,7 +171,7 @@ impl From for BatchSendStatus { } } -impl From for iota_graphql_client::faucet::BatchSendStatus { +impl From for iota_sdk::graphql_client::faucet::BatchSendStatus { fn from(value: BatchSendStatus) -> Self { Self { status: value.status.into(), diff --git a/crates/iota-sdk-ffi/src/graphql.rs b/crates/iota-sdk-ffi/src/graphql.rs index e54455f4d..34ed0e21d 100644 --- a/crates/iota-sdk-ffi/src/graphql.rs +++ b/crates/iota-sdk-ffi/src/graphql.rs @@ -3,11 +3,13 @@ use std::{str::FromStr, sync::Arc}; -use iota_graphql_client::{ - pagination::PaginationFilter, - query_types::{ObjectKey, ProtocolConfigs, ServiceConfig}, +use iota_sdk::{ + graphql_client::{ + pagination::PaginationFilter, + query_types::{ObjectKey, ProtocolConfigs, ServiceConfig}, + }, + types::{CheckpointSequenceNumber, def_is, iota_names::NameFormat}, }; -use iota_types::{CheckpointSequenceNumber, def_is, iota_names::NameFormat}; use tokio::sync::RwLock; use crate::{ @@ -37,10 +39,10 @@ use crate::{ /// The GraphQL client for interacting with the IOTA blockchain. #[derive(uniffi::Object)] -pub struct GraphQLClient(RwLock); +pub struct GraphQLClient(RwLock); impl GraphQLClient { - pub fn inner(&self) -> &RwLock { + pub fn inner(&self) -> &RwLock { &self.0 } } @@ -54,7 +56,7 @@ impl GraphQLClient { /// Create a new GraphQL client with the provided server address. #[uniffi::constructor] pub fn new(server: String) -> Result { - Ok(Self(RwLock::new(iota_graphql_client::Client::new( + Ok(Self(RwLock::new(iota_sdk::graphql_client::Client::new( &server, )?))) } @@ -63,28 +65,28 @@ impl GraphQLClient { /// {MAINNET_HOST}. #[uniffi::constructor] pub fn new_mainnet() -> Self { - Self(RwLock::new(iota_graphql_client::Client::new_mainnet())) + Self(RwLock::new(iota_sdk::graphql_client::Client::new_mainnet())) } /// Create a new GraphQL client connected to the `testnet` GraphQL server: /// {TESTNET_HOST}. #[uniffi::constructor] pub fn new_testnet() -> Self { - Self(RwLock::new(iota_graphql_client::Client::new_testnet())) + Self(RwLock::new(iota_sdk::graphql_client::Client::new_testnet())) } /// Create a new GraphQL client connected to the `devnet` GraphQL server: /// {DEVNET_HOST}. #[uniffi::constructor] pub fn new_devnet() -> Self { - Self(RwLock::new(iota_graphql_client::Client::new_devnet())) + Self(RwLock::new(iota_sdk::graphql_client::Client::new_devnet())) } /// Create a new GraphQL client connected to the `localhost` GraphQL server: /// {DEFAULT_LOCAL_HOST}. #[uniffi::constructor] pub fn new_localnet() -> Self { - Self(RwLock::new(iota_graphql_client::Client::new_localnet())) + Self(RwLock::new(iota_sdk::graphql_client::Client::new_localnet())) } /// Get the chain identifier. diff --git a/crates/iota-sdk-ffi/src/lib.rs b/crates/iota-sdk-ffi/src/lib.rs index 891a3c777..06752abc3 100644 --- a/crates/iota-sdk-ffi/src/lib.rs +++ b/crates/iota-sdk-ffi/src/lib.rs @@ -45,22 +45,4 @@ pub fn hex_decode(input: String) -> crate::error::Result> { Ok(hex::decode(input)?) } -macro_rules! export_primitive_types_bcs_conversion { - ($($name:ty),+ $(,)?) => { - paste::paste!{$( - #[doc = "Create a " $name " from BCS encoded bytes."] - #[uniffi::export] - pub fn [< $name:snake _from_bcs >](input: &[u8]) -> crate::error::Result<$name> { - Ok(bcs::from_bytes(input)?) - } - - #[doc = "Convert this " $name " to BCS encoded bytes."] - #[uniffi::export] - pub fn [< $name:snake _to_bcs >](input: $name) -> crate::error::Result> { - Ok(bcs::to_bytes(&input)?) - } - )+} - }; -} - -export_primitive_types_bcs_conversion!(u8, u16, u32, u64, i8, i16, i32, i64, bool, String); +crate::export_primitive_types_bcs_conversion!(u8, u16, u32, u64, i8, i16, i32, i64, bool, String); diff --git a/crates/iota-sdk-ffi/src/macros.rs b/crates/iota-sdk-ffi/src/macros.rs index 170842712..02d37e034 100644 --- a/crates/iota-sdk-ffi/src/macros.rs +++ b/crates/iota-sdk-ffi/src/macros.rs @@ -1,43 +1,61 @@ // Copyright (c) 2025 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 +#[macro_export] macro_rules! export_iota_types_bcs_conversion { ($($name:ty),+ $(,)?) => { paste::paste! {$( /// Create this type from BCS encoded bytes. #[uniffi::export] - pub fn [< $name:snake _from_bcs >](bcs: Vec) -> crate::error::Result<$name> { - let data = bcs::from_bytes::(&bcs)?; + pub fn [< $name:snake _from_bcs >](bcs: Vec) -> $crate::error::Result<$name> { + let data = bcs::from_bytes::(&bcs)?; Ok(data.into()) } /// Convert this type to BCS encoded bytes. #[uniffi::export] - pub fn [< $name:snake _to_bcs >](data: $name) -> crate::error::Result> { - let data: iota_types::$name = data.into(); + pub fn [< $name:snake _to_bcs >](data: $name) -> $crate::error::Result> { + let data: iota_sdk::types::$name = data.into(); Ok(bcs::to_bytes(&data)?) } )+} } } +#[macro_export] macro_rules! export_iota_types_objects_bcs_conversion { ($($name:ty),+ $(,)?) => { paste::paste! {$( /// Create this type from BCS encoded bytes. #[uniffi::export] - pub fn [< $name:snake _from_bcs >](bcs: Vec) -> crate::error::Result<$name> { - Ok($name(bcs::from_bytes::(&bcs)?)) + pub fn [< $name:snake _from_bcs >](bcs: Vec) -> $crate::error::Result<$name> { + Ok($name(bcs::from_bytes::(&bcs)?)) } /// Convert this type to BCS encoded bytes. #[uniffi::export] - pub fn [< $name:snake _to_bcs >](data: std::sync::Arc<$name>) -> crate::error::Result> { + pub fn [< $name:snake _to_bcs >](data: std::sync::Arc<$name>) -> $crate::error::Result> { Ok(bcs::to_bytes(&data.0)?) } )+} } } -pub(crate) use export_iota_types_bcs_conversion; -pub(crate) use export_iota_types_objects_bcs_conversion; +#[macro_export] +macro_rules! export_primitive_types_bcs_conversion { + ($($name:ty),+ $(,)?) => { + paste::paste!{$( + #[doc = "Create a " $name " from BCS encoded bytes."] + #[uniffi::export] + pub fn [< $name:snake _from_bcs >](input: &[u8]) -> $crate::error::Result<$name> { + Ok(bcs::from_bytes(input)?) + } + + #[doc = "Convert this " $name " to BCS encoded bytes."] + #[uniffi::export] + pub fn [< $name:snake _to_bcs >](input: $name) -> $crate::error::Result> { + Ok(bcs::to_bytes(&input)?) + } + )+} + }; +} diff --git a/crates/iota-sdk-ffi/src/transaction_builder/mod.rs b/crates/iota-sdk-ffi/src/transaction_builder/mod.rs index 7e8f77398..c0214cd40 100644 --- a/crates/iota-sdk-ffi/src/transaction_builder/mod.rs +++ b/crates/iota-sdk-ffi/src/transaction_builder/mod.rs @@ -7,7 +7,7 @@ use std::{ time::Duration, }; -use iota_types::Input; +use iota_sdk::types::Input; use crate::{ crypto::simple::SimpleKeypair, @@ -31,13 +31,15 @@ pub mod ptb_arg; /// transaction data. #[derive(derive_more::From, uniffi::Object)] pub struct TransactionBuilder( - RwLock>, + RwLock>, ); impl TransactionBuilder { fn read(&self, f: F) -> T where - F: FnOnce(&iota_transaction_builder::TransactionBuilder) -> T, + F: FnOnce( + &iota_sdk::transaction_builder::TransactionBuilder, + ) -> T, { let lock = self.0.read().expect("error reading from builder"); f(&lock) @@ -46,7 +48,7 @@ impl TransactionBuilder { fn write(&self, f: F) -> T where F: FnOnce( - &mut iota_transaction_builder::TransactionBuilder, + &mut iota_sdk::transaction_builder::TransactionBuilder, ) -> T, { let mut lock = self.0.write().expect("error writing to builder"); @@ -60,7 +62,7 @@ impl TransactionBuilder { #[uniffi::constructor(name = "init")] pub async fn new(sender: &Address, client: &GraphQLClient) -> Self { Self( - iota_transaction_builder::TransactionBuilder::new(**sender) + iota_sdk::transaction_builder::TransactionBuilder::new(**sender) .with_client(client.inner().read().await.clone()) .into(), ) @@ -243,7 +245,7 @@ impl TransactionBuilder { type_tag: &TypeTag, name: String, ) -> Arc { - use iota_transaction_builder::unresolved::{Command, MakeMoveVector}; + use iota_sdk::transaction_builder::unresolved::{Command, MakeMoveVector}; self.write(|builder| { let cmd = Command::MakeMoveVector(MakeMoveVector { type_: Some(type_tag.0.clone()), diff --git a/crates/iota-sdk-ffi/src/transaction_builder/ptb_arg.rs b/crates/iota-sdk-ffi/src/transaction_builder/ptb_arg.rs index 9bffbb654..1146fd421 100644 --- a/crates/iota-sdk-ffi/src/transaction_builder/ptb_arg.rs +++ b/crates/iota-sdk-ffi/src/transaction_builder/ptb_arg.rs @@ -3,7 +3,7 @@ use std::sync::Arc; -use iota_transaction_builder::{ +use iota_sdk::transaction_builder::{ PureBytes, Receiving, Shared, SharedMut, builder::ptb_arguments::Res, res, }; use primitive_types::U256; @@ -15,8 +15,8 @@ use crate::{ #[derive(Clone, uniffi::Object)] pub enum MoveArg { - Address(iota_types::Address), - Digest(iota_types::Digest), + Address(iota_sdk::types::Address), + Digest(iota_sdk::types::Digest), Bool(bool), U8(u8), U16(u16), @@ -38,7 +38,7 @@ impl MoveArg { #[uniffi::constructor] pub fn address_from_hex(hex: String) -> Result { - Ok(Self::Address(iota_types::Address::from_hex(hex)?)) + Ok(Self::Address(iota_sdk::types::Address::from_hex(hex)?)) } #[uniffi::constructor] @@ -48,7 +48,7 @@ impl MoveArg { #[uniffi::constructor] pub fn digest_from_base58(base58: String) -> Result { - Ok(Self::Digest(iota_types::Digest::from_base58(base58)?)) + Ok(Self::Digest(iota_sdk::types::Digest::from_base58(base58)?)) } #[uniffi::constructor] @@ -182,7 +182,7 @@ impl MoveArg { } } -impl iota_transaction_builder::types::MoveArg for &MoveArg { +impl iota_sdk::transaction_builder::types::MoveArg for &MoveArg { fn pure_bytes(self) -> PureBytes { match self { MoveArg::Address(address) => address.pure_bytes(), @@ -203,12 +203,12 @@ impl iota_transaction_builder::types::MoveArg for &MoveArg { #[derive(uniffi::Object)] pub enum PTBArgument { - ObjectId(iota_types::ObjectId), + ObjectId(iota_sdk::types::ObjectId), Move(MoveArg), Res(Res), - Shared(Shared), - SharedMut(SharedMut), - Receiving(Receiving), + Shared(Shared), + SharedMut(SharedMut), + Receiving(Receiving), Gas, } @@ -231,7 +231,7 @@ impl PTBArgument { #[uniffi::constructor] pub fn object_id_from_hex(hex: &str) -> Result { - Ok(Self::ObjectId(iota_types::ObjectId::from_hex(hex)?)) + Ok(Self::ObjectId(iota_sdk::types::ObjectId::from_hex(hex)?)) } #[uniffi::constructor] @@ -241,7 +241,9 @@ impl PTBArgument { #[uniffi::constructor] pub fn shared_from_hex(hex: &str) -> Result { - Ok(Self::Shared(Shared(iota_types::ObjectId::from_hex(hex)?))) + Ok(Self::Shared(Shared(iota_sdk::types::ObjectId::from_hex( + hex, + )?))) } #[uniffi::constructor] @@ -251,9 +253,9 @@ impl PTBArgument { #[uniffi::constructor] pub fn shared_mut_from_hex(hex: &str) -> Result { - Ok(Self::SharedMut(SharedMut(iota_types::ObjectId::from_hex( - hex, - )?))) + Ok(Self::SharedMut(SharedMut( + iota_sdk::types::ObjectId::from_hex(hex)?, + ))) } #[uniffi::constructor] @@ -263,9 +265,9 @@ impl PTBArgument { #[uniffi::constructor] pub fn receiving_from_hex(hex: &str) -> Result { - Ok(Self::Receiving(Receiving(iota_types::ObjectId::from_hex( - hex, - )?))) + Ok(Self::Receiving(Receiving( + iota_sdk::types::ObjectId::from_hex(hex)?, + ))) } #[uniffi::constructor] @@ -394,11 +396,11 @@ impl PTBArgument { } } -impl iota_transaction_builder::PTBArgument for &PTBArgument { +impl iota_sdk::transaction_builder::PTBArgument for &PTBArgument { fn arg( self, - ptb: &mut iota_transaction_builder::builder::TransactionBuildData, - ) -> iota_transaction_builder::unresolved::Argument { + ptb: &mut iota_sdk::transaction_builder::builder::TransactionBuildData, + ) -> iota_sdk::transaction_builder::unresolved::Argument { match self { PTBArgument::ObjectId(object_id) => object_id.arg(ptb), PTBArgument::Move(arg) => arg.arg(ptb), @@ -406,7 +408,7 @@ impl iota_transaction_builder::PTBArgument for &PTBArgument { PTBArgument::Shared(shared) => shared.arg(ptb), PTBArgument::SharedMut(shared_mut) => shared_mut.arg(ptb), PTBArgument::Receiving(receiving) => receiving.arg(ptb), - PTBArgument::Gas => iota_transaction_builder::unresolved::Argument::Gas, + PTBArgument::Gas => iota_sdk::transaction_builder::unresolved::Argument::Gas, } } } diff --git a/crates/iota-sdk-ffi/src/types/address.rs b/crates/iota-sdk-ffi/src/types/address.rs index da6bbaa4e..ff554c0f7 100644 --- a/crates/iota-sdk-ffi/src/types/address.rs +++ b/crates/iota-sdk-ffi/src/types/address.rs @@ -49,24 +49,24 @@ use crate::{ /// address = 32OCTET /// ``` #[derive(derive_more::From, derive_more::Deref, uniffi::Object)] -pub struct Address(pub iota_types::Address); +pub struct Address(pub iota_sdk::types::Address); #[uniffi::export] impl Address { #[uniffi::constructor] pub fn from_bytes(bytes: Vec) -> Result { - Ok(Self(iota_types::Address::from_bytes(bytes)?)) + Ok(Self(iota_sdk::types::Address::from_bytes(bytes)?)) } #[uniffi::constructor] pub fn from_hex(hex: &str) -> Result { - Ok(Self(iota_types::Address::from_hex(hex)?)) + Ok(Self(iota_sdk::types::Address::from_hex(hex)?)) } #[uniffi::constructor] pub fn generate() -> Self { let mut rng = rand::thread_rng(); - Self(iota_types::Address::generate(&mut rng)) + Self(iota_sdk::types::Address::generate(&mut rng)) } pub fn to_bytes(&self) -> Vec { @@ -85,7 +85,7 @@ macro_rules! named_address { impl Address {$( #[uniffi::constructor] pub const fn [< $constant:lower >]() -> Self { - Self(iota_types::Address::$constant) + Self(iota_sdk::types::Address::$constant) } )+} } diff --git a/crates/iota-sdk-ffi/src/types/checkpoint.rs b/crates/iota-sdk-ffi/src/types/checkpoint.rs index 8fc67e28e..c59248500 100644 --- a/crates/iota-sdk-ffi/src/types/checkpoint.rs +++ b/crates/iota-sdk-ffi/src/types/checkpoint.rs @@ -3,7 +3,7 @@ use std::sync::Arc; -use iota_types::GasCostSummary; +use iota_sdk::types::GasCostSummary; use crate::{ error::Result, @@ -56,7 +56,7 @@ pub type ProtocolVersion = u64; /// bytes ; version_specific_data /// ``` #[derive(derive_more::From, uniffi::Object)] -pub struct CheckpointSummary(pub iota_types::CheckpointSummary); +pub struct CheckpointSummary(pub iota_sdk::types::CheckpointSummary); #[uniffi::export] impl CheckpointSummary { @@ -74,7 +74,7 @@ impl CheckpointSummary { end_of_epoch_data: Option, version_specific_data: Vec, ) -> Self { - Self(iota_types::CheckpointSummary { + Self(iota_sdk::types::CheckpointSummary { epoch, sequence_number, network_total_transactions, @@ -190,13 +190,13 @@ impl CheckpointSummary { /// ; length as the vector of digests /// ``` #[derive(derive_more::From, uniffi::Object)] -pub struct CheckpointContents(pub iota_types::CheckpointContents); +pub struct CheckpointContents(pub iota_sdk::types::CheckpointContents); #[uniffi::export] impl CheckpointContents { #[uniffi::constructor] pub fn new(transaction_info: Vec>) -> Self { - Self(iota_types::CheckpointContents::new( + Self(iota_sdk::types::CheckpointContents::new( transaction_info.into_iter().map(|v| v.0.clone()).collect(), )) } @@ -218,7 +218,7 @@ impl CheckpointContents { /// Transaction information committed to in a checkpoint #[derive(derive_more::From, uniffi::Object)] -pub struct CheckpointTransactionInfo(pub iota_types::CheckpointTransactionInfo); +pub struct CheckpointTransactionInfo(pub iota_sdk::types::CheckpointTransactionInfo); #[uniffi::export] impl CheckpointTransactionInfo { @@ -228,7 +228,7 @@ impl CheckpointTransactionInfo { effects: &Digest, signatures: Vec>, ) -> Self { - Self(iota_types::CheckpointTransactionInfo { + Self(iota_sdk::types::CheckpointTransactionInfo { transaction: **transaction, effects: **effects, signatures: signatures.into_iter().map(|v| v.0.clone()).collect(), @@ -266,7 +266,7 @@ impl CheckpointTransactionInfo { /// ecmh-live-object-set = %x00 digest /// ``` #[derive(derive_more::From, uniffi::Object)] -pub struct CheckpointCommitment(pub iota_types::CheckpointCommitment); +pub struct CheckpointCommitment(pub iota_sdk::types::CheckpointCommitment); #[uniffi::export] impl CheckpointCommitment { @@ -299,8 +299,8 @@ pub struct EndOfEpochData { pub epoch_supply_change: i64, } -impl From for EndOfEpochData { - fn from(value: iota_types::EndOfEpochData) -> Self { +impl From for EndOfEpochData { + fn from(value: iota_sdk::types::EndOfEpochData) -> Self { Self { next_epoch_committee: value .next_epoch_committee @@ -319,7 +319,7 @@ impl From for EndOfEpochData { } } -impl From for iota_types::EndOfEpochData { +impl From for iota_sdk::types::EndOfEpochData { fn from(value: EndOfEpochData) -> Self { Self { next_epoch_committee: value diff --git a/crates/iota-sdk-ffi/src/types/coin.rs b/crates/iota-sdk-ffi/src/types/coin.rs index f4675484f..e97c7d0fa 100644 --- a/crates/iota-sdk-ffi/src/types/coin.rs +++ b/crates/iota-sdk-ffi/src/types/coin.rs @@ -10,13 +10,13 @@ use crate::{ }; #[derive(derive_more::From, uniffi::Object)] -pub struct Coin(pub iota_types::framework::Coin); +pub struct Coin(pub iota_sdk::types::framework::Coin); #[uniffi::export] impl Coin { #[uniffi::constructor] pub fn try_from_object(object: &Object) -> Result { - Ok(iota_types::framework::Coin::try_from_object(&object.0)?.into()) + Ok(iota_sdk::types::framework::Coin::try_from_object(&object.0)?.into()) } pub fn coin_type(&self) -> TypeTag { diff --git a/crates/iota-sdk-ffi/src/types/crypto/mod.rs b/crates/iota-sdk-ffi/src/types/crypto/mod.rs index 3d427369b..edd1749f3 100644 --- a/crates/iota-sdk-ffi/src/types/crypto/mod.rs +++ b/crates/iota-sdk-ffi/src/types/crypto/mod.rs @@ -7,7 +7,7 @@ pub mod zklogin; use std::sync::Arc; -use iota_types::{PublicKeyExt, SignatureScheme}; +use iota_sdk::types::{PublicKeyExt, SignatureScheme}; use crate::{ error::Result, @@ -18,13 +18,13 @@ macro_rules! impl_crypto_object { ($(#[$meta:meta])* $t:ident) => { $(#[$meta])* #[derive(derive_more::From, derive_more::Deref, uniffi::Object)] - pub struct $t(pub iota_types::$t); + pub struct $t(pub iota_sdk::types::$t); #[uniffi::export] impl $t { #[uniffi::constructor] pub fn from_bytes(bytes: Vec) -> Result { - Ok(Self(iota_types::$t::from_bytes(bytes)?)) + Ok(Self(iota_sdk::types::$t::from_bytes(bytes)?)) } #[uniffi::constructor] @@ -35,7 +35,7 @@ macro_rules! impl_crypto_object { #[uniffi::constructor] pub fn generate() -> Self { let mut rng = rand::thread_rng(); - Self(iota_types::$t::generate(&mut rng)) + Self(iota_sdk::types::$t::generate(&mut rng)) } pub fn to_bytes(&self) -> Vec { diff --git a/crates/iota-sdk-ffi/src/types/crypto/multisig.rs b/crates/iota-sdk-ffi/src/types/crypto/multisig.rs index 4b178baa5..a3e91308c 100644 --- a/crates/iota-sdk-ffi/src/types/crypto/multisig.rs +++ b/crates/iota-sdk-ffi/src/types/crypto/multisig.rs @@ -3,7 +3,7 @@ use std::sync::Arc; -use iota_types::SignatureScheme; +use iota_sdk::types::SignatureScheme; use crate::types::{ address::Address, @@ -32,7 +32,7 @@ use crate::types::{ /// zklogin-multisig-member-signature = %x03 zklogin-authenticator /// ``` #[derive(derive_more::From, uniffi::Object)] -pub struct MultisigMemberSignature(pub iota_types::MultisigMemberSignature); +pub struct MultisigMemberSignature(pub iota_sdk::types::MultisigMemberSignature); #[uniffi::export] impl MultisigMemberSignature { @@ -130,7 +130,7 @@ impl MultisigMemberSignature { /// (secp256r1-flag secp256r1-public-key) /// ``` #[derive(derive_more::From, uniffi::Object)] -pub struct MultisigMemberPublicKey(pub iota_types::MultisigMemberPublicKey); +pub struct MultisigMemberPublicKey(pub iota_sdk::types::MultisigMemberPublicKey); #[uniffi::export] impl MultisigMemberPublicKey { @@ -225,7 +225,7 @@ impl MultisigMemberPublicKey { /// See for the specification for the /// serialized format of RoaringBitmaps. #[derive(derive_more::From, uniffi::Object)] -pub struct MultisigAggregatedSignature(pub iota_types::MultisigAggregatedSignature); +pub struct MultisigAggregatedSignature(pub iota_sdk::types::MultisigAggregatedSignature); #[uniffi::export] impl MultisigAggregatedSignature { @@ -242,7 +242,7 @@ impl MultisigAggregatedSignature { signatures: Vec>, bitmap: u16, ) -> Self { - Self(iota_types::MultisigAggregatedSignature::new( + Self(iota_sdk::types::MultisigAggregatedSignature::new( committee.0.clone(), signatures.into_iter().map(|s| s.0.clone()).collect(), bitmap, @@ -294,7 +294,7 @@ impl MultisigAggregatedSignature { /// u16 ; threshold /// ``` #[derive(derive_more::From, uniffi::Object)] -pub struct MultisigCommittee(pub iota_types::MultisigCommittee); +pub struct MultisigCommittee(pub iota_sdk::types::MultisigCommittee); #[uniffi::export] impl MultisigCommittee { @@ -305,7 +305,7 @@ impl MultisigCommittee { /// `Address` governed by this committee. #[uniffi::constructor] pub fn new(members: Vec>, threshold: u16) -> Self { - Self(iota_types::MultisigCommittee::new( + Self(iota_sdk::types::MultisigCommittee::new( members.into_iter().map(|m| m.0.clone()).collect(), threshold, )) @@ -384,14 +384,14 @@ impl MultisigCommittee { /// u8 ; weight /// ``` #[derive(derive_more::From, uniffi::Object)] -pub struct MultisigMember(pub iota_types::MultisigMember); +pub struct MultisigMember(pub iota_sdk::types::MultisigMember); #[uniffi::export] impl MultisigMember { /// Construct a new member from a `MultisigMemberPublicKey` and a `weight`. #[uniffi::constructor] pub fn new(public_key: &MultisigMemberPublicKey, weight: u8) -> Self { - Self(iota_types::MultisigMember::new( + Self(iota_sdk::types::MultisigMember::new( public_key.0.clone(), weight, )) diff --git a/crates/iota-sdk-ffi/src/types/crypto/passkey.rs b/crates/iota-sdk-ffi/src/types/crypto/passkey.rs index 4cc136e07..568d5fd52 100644 --- a/crates/iota-sdk-ffi/src/types/crypto/passkey.rs +++ b/crates/iota-sdk-ffi/src/types/crypto/passkey.rs @@ -3,7 +3,7 @@ use std::sync::Arc; -use iota_crypto::Verifier; +use iota_sdk::crypto::Verifier; use crate::{ error::Result, @@ -38,7 +38,7 @@ use crate::{ /// as `bytes` meaning it has a length prefix that defines the length of /// the completely serialized signature. #[derive(derive_more::From, uniffi::Object)] -pub struct PasskeyAuthenticator(pub iota_types::PasskeyAuthenticator); +pub struct PasskeyAuthenticator(pub iota_sdk::types::PasskeyAuthenticator); #[uniffi::export] impl PasskeyAuthenticator { @@ -89,13 +89,13 @@ impl PasskeyAuthenticator { /// passkey-public-key = passkey-flag secp256r1-public-key /// ``` #[derive(derive_more::From, uniffi::Object)] -pub struct PasskeyPublicKey(iota_types::PasskeyPublicKey); +pub struct PasskeyPublicKey(iota_sdk::types::PasskeyPublicKey); #[uniffi::export] impl PasskeyPublicKey { #[uniffi::constructor] pub fn new(public_key: &Secp256r1PublicKey) -> Self { - Self(iota_types::PasskeyPublicKey::new(**public_key)) + Self(iota_sdk::types::PasskeyPublicKey::new(**public_key)) } pub fn inner(&self) -> Secp256r1PublicKey { diff --git a/crates/iota-sdk-ffi/src/types/crypto/zklogin.rs b/crates/iota-sdk-ffi/src/types/crypto/zklogin.rs index 500bbded4..eb14dd868 100644 --- a/crates/iota-sdk-ffi/src/types/crypto/zklogin.rs +++ b/crates/iota-sdk-ffi/src/types/crypto/zklogin.rs @@ -3,7 +3,7 @@ use std::sync::Arc; -use iota_types::{Jwk, JwkId, ZkLoginClaim}; +use iota_sdk::types::{Jwk, JwkId, ZkLoginClaim}; use crate::{ error::{Result, SdkFfiError}, @@ -30,13 +30,13 @@ use crate::{ /// as `bytes` meaning it has a length prefix that defines the length of /// the completely serialized signature. #[derive(derive_more::From, uniffi::Object)] -pub struct ZkLoginAuthenticator(pub iota_types::ZkLoginAuthenticator); +pub struct ZkLoginAuthenticator(pub iota_sdk::types::ZkLoginAuthenticator); #[uniffi::export] impl ZkLoginAuthenticator { #[uniffi::constructor] pub fn new(inputs: &ZkLoginInputs, max_epoch: u64, signature: &SimpleSignature) -> Self { - Self(iota_types::ZkLoginAuthenticator { + Self(iota_sdk::types::ZkLoginAuthenticator { inputs: inputs.0.clone(), max_epoch, signature: signature.0.clone(), @@ -107,13 +107,13 @@ impl ZkLoginAuthenticator { /// address-seed-unpadded = %x00 / %x01-ff *31(OCTET) /// ``` #[derive(derive_more::From, uniffi::Object)] -pub struct ZkLoginPublicIdentifier(pub iota_types::ZkLoginPublicIdentifier); +pub struct ZkLoginPublicIdentifier(pub iota_sdk::types::ZkLoginPublicIdentifier); #[uniffi::export] impl ZkLoginPublicIdentifier { #[uniffi::constructor] pub fn new(iss: String, address_seed: &Bn254FieldElement) -> Result { - iota_types::ZkLoginPublicIdentifier::new(iss, address_seed.0.clone()) + iota_sdk::types::ZkLoginPublicIdentifier::new(iss, address_seed.0.clone()) .ok_or_else(|| SdkFfiError::custom("iss length must be <= 255")) .map(Self) } @@ -177,7 +177,7 @@ impl ZkLoginPublicIdentifier { /// bn254-field-element ; address_seed /// ``` #[derive(derive_more::From, uniffi::Object)] -pub struct ZkLoginInputs(pub iota_types::ZkLoginInputs); +pub struct ZkLoginInputs(pub iota_sdk::types::ZkLoginInputs); #[uniffi::export] impl ZkLoginInputs { @@ -188,7 +188,7 @@ impl ZkLoginInputs { header_base64: String, address_seed: &Bn254FieldElement, ) -> Result { - Ok(Self(iota_types::ZkLoginInputs::new( + Ok(Self(iota_sdk::types::ZkLoginInputs::new( proof_points.0.clone(), iss_base64_details, header_base64, @@ -235,13 +235,13 @@ impl ZkLoginInputs { /// zklogin-proof = circom-g1 circom-g2 circom-g1 /// ``` #[derive(derive_more::From, uniffi::Object)] -pub struct ZkLoginProof(pub iota_types::ZkLoginProof); +pub struct ZkLoginProof(pub iota_sdk::types::ZkLoginProof); #[uniffi::export] impl ZkLoginProof { #[uniffi::constructor] pub fn new(a: &CircomG1, b: &CircomG2, c: &CircomG1) -> Self { - Self(iota_types::ZkLoginProof { + Self(iota_sdk::types::ZkLoginProof { a: a.0.clone(), b: b.0.clone(), c: c.0.clone(), @@ -289,7 +289,7 @@ pub struct ZkLoginClaim { /// circom-g1 = %x03 3(bn254-field-element) /// ``` #[derive(derive_more::From, uniffi::Object)] -pub struct CircomG1(pub iota_types::CircomG1); +pub struct CircomG1(pub iota_sdk::types::CircomG1); #[uniffi::export] impl CircomG1 { @@ -299,7 +299,7 @@ impl CircomG1 { el_1: &Bn254FieldElement, el_2: &Bn254FieldElement, ) -> Self { - Self(iota_types::CircomG1([ + Self(iota_sdk::types::CircomG1([ el_0.0.clone(), el_1.0.clone(), el_2.0.clone(), @@ -320,7 +320,7 @@ impl CircomG1 { /// circom-g2 = %x03 3(%x02 2(bn254-field-element)) /// ``` #[derive(derive_more::From, uniffi::Object)] -pub struct CircomG2(pub iota_types::CircomG2); +pub struct CircomG2(pub iota_sdk::types::CircomG2); #[uniffi::export] impl CircomG2 { @@ -333,7 +333,7 @@ impl CircomG2 { el_2_0: &Bn254FieldElement, el_2_1: &Bn254FieldElement, ) -> Self { - Self(iota_types::CircomG2([ + Self(iota_sdk::types::CircomG2([ [el_0_0.0.clone(), el_0_1.0.clone()], [el_1_0.0.clone(), el_1_1.0.clone()], [el_2_0.0.clone(), el_2_1.0.clone()], @@ -355,13 +355,13 @@ impl CircomG2 { /// bn254-field-element = *DIGIT ; which is then interpreted as a radix10 encoded 32-byte value /// ``` #[derive(derive_more::From, uniffi::Object)] -pub struct Bn254FieldElement(pub iota_types::Bn254FieldElement); +pub struct Bn254FieldElement(pub iota_sdk::types::Bn254FieldElement); #[uniffi::export] impl Bn254FieldElement { #[uniffi::constructor] pub fn from_bytes(bytes: Vec) -> Result { - Ok(Self(iota_types::Bn254FieldElement::new( + Ok(Self(iota_sdk::types::Bn254FieldElement::new( bytes.try_into().map_err(|v: Vec| { SdkFfiError::custom(format!("expected bytes of length 32, found {}", v.len())) })?, @@ -375,7 +375,9 @@ impl Bn254FieldElement { #[uniffi::constructor] pub fn from_str_radix_10(s: &str) -> Result { - Ok(Self(iota_types::Bn254FieldElement::from_str_radix_10(s)?)) + Ok(Self(iota_sdk::types::Bn254FieldElement::from_str_radix_10( + s, + )?)) } pub fn unpadded(&self) -> Vec { diff --git a/crates/iota-sdk-ffi/src/types/digest.rs b/crates/iota-sdk-ffi/src/types/digest.rs index 8f06c3873..cfcd7ffdd 100644 --- a/crates/iota-sdk-ffi/src/types/digest.rs +++ b/crates/iota-sdk-ffi/src/types/digest.rs @@ -18,24 +18,24 @@ use crate::error::Result; /// meaning its serialized binary form (in bcs) is 33 bytes long vs a more /// compact 32 bytes. #[derive(derive_more::From, derive_more::Deref, uniffi::Object)] -pub struct Digest(pub iota_types::Digest); +pub struct Digest(pub iota_sdk::types::Digest); #[uniffi::export] impl Digest { #[uniffi::constructor] pub fn from_bytes(bytes: Vec) -> Result { - Ok(Self(iota_types::Digest::from_bytes(bytes)?)) + Ok(Self(iota_sdk::types::Digest::from_bytes(bytes)?)) } #[uniffi::constructor] pub fn from_base58(base58: &str) -> Result { - Ok(Self(iota_types::Digest::from_base58(base58)?)) + Ok(Self(iota_sdk::types::Digest::from_base58(base58)?)) } #[uniffi::constructor] pub fn generate() -> Self { let mut rng = rand::thread_rng(); - Self(iota_types::Digest::generate(&mut rng)) + Self(iota_sdk::types::Digest::generate(&mut rng)) } pub fn to_bytes(&self) -> Vec { diff --git a/crates/iota-sdk-ffi/src/types/events.rs b/crates/iota-sdk-ffi/src/types/events.rs index 7eaa59f63..9f3a52f78 100644 --- a/crates/iota-sdk-ffi/src/types/events.rs +++ b/crates/iota-sdk-ffi/src/types/events.rs @@ -4,10 +4,12 @@ use std::{str::FromStr, sync::Arc}; use base64ct::Encoding; -use iota_graphql_client::query_types::{ - Base64, DateTime, GQLAddress, MoveData, MoveModuleQuery, MovePackageQuery, MoveType, +use iota_sdk::{ + graphql_client::query_types::{ + Base64, DateTime, GQLAddress, MoveData, MoveModuleQuery, MovePackageQuery, MoveType, + }, + types::{Identifier, StructTag}, }; -use iota_types::{Identifier, StructTag}; use crate::{ error::Result, @@ -46,11 +48,11 @@ pub struct Event { pub json: String, } -impl From for Event { - fn from(value: iota_graphql_client::query_types::Event) -> Self { +impl From for Event { + fn from(value: iota_sdk::graphql_client::query_types::Event) -> Self { let sending_module = value.sending_module.as_ref().unwrap(); Self { - package_id: Arc::new(ObjectId(iota_types::ObjectId::from( + package_id: Arc::new(ObjectId(iota_sdk::types::ObjectId::from( sending_module.package.address, ))), module: sending_module.name.clone(), @@ -64,7 +66,7 @@ impl From for Event { } } -impl From for iota_types::Event { +impl From for iota_sdk::types::Event { fn from(value: Event) -> Self { Self { package_id: (**value.package_id), @@ -76,12 +78,12 @@ impl From for iota_types::Event { } } -impl From for iota_graphql_client::query_types::Event { +impl From for iota_sdk::graphql_client::query_types::Event { fn from(value: Event) -> Self { Self { sending_module: Some(MoveModuleQuery { package: MovePackageQuery { - address: iota_types::Address::from(**value.package_id), + address: iota_sdk::types::Address::from(**value.package_id), bcs: None, }, name: value.module.clone(), @@ -100,8 +102,8 @@ impl From for iota_graphql_client::query_types::Event { } } -impl From for Event { - fn from(value: iota_types::Event) -> Self { +impl From for Event { + fn from(value: iota_sdk::types::Event) -> Self { Self { package_id: Arc::new(value.package_id.into()), module: value.module.to_string(), @@ -125,13 +127,13 @@ impl From for Event { /// transaction-events = vector event /// ``` #[derive(derive_more::From, uniffi::Object)] -pub struct TransactionEvents(pub iota_types::TransactionEvents); +pub struct TransactionEvents(pub iota_sdk::types::TransactionEvents); #[uniffi::export] impl TransactionEvents { #[uniffi::constructor] pub fn new(events: Vec) -> Self { - Self(iota_types::TransactionEvents( + Self(iota_sdk::types::TransactionEvents( events.into_iter().map(Into::into).collect(), )) } diff --git a/crates/iota-sdk-ffi/src/types/execution_status.rs b/crates/iota-sdk-ffi/src/types/execution_status.rs index 3082a7276..eca107b35 100644 --- a/crates/iota-sdk-ffi/src/types/execution_status.rs +++ b/crates/iota-sdk-ffi/src/types/execution_status.rs @@ -3,7 +3,7 @@ use std::sync::Arc; -use iota_types::{CommandArgumentError, Identifier, TypeArgumentError}; +use iota_sdk::types::{CommandArgumentError, Identifier, TypeArgumentError}; use crate::{ error::Result, @@ -39,11 +39,11 @@ pub enum ExecutionStatus { }, } -impl From for ExecutionStatus { - fn from(value: iota_types::ExecutionStatus) -> Self { +impl From for ExecutionStatus { + fn from(value: iota_sdk::types::ExecutionStatus) -> Self { match value { - iota_types::ExecutionStatus::Success => Self::Success, - iota_types::ExecutionStatus::Failure { error, command } => Self::Failure { + iota_sdk::types::ExecutionStatus::Success => Self::Success, + iota_sdk::types::ExecutionStatus::Failure { error, command } => Self::Failure { error: error.into(), command, }, @@ -51,7 +51,7 @@ impl From for ExecutionStatus { } } -impl From for iota_types::ExecutionStatus { +impl From for iota_sdk::types::ExecutionStatus { fn from(value: ExecutionStatus) -> Self { match value { ExecutionStatus::Success => Self::Success, @@ -272,104 +272,110 @@ pub enum ExecutionError { InvalidLinkage, } -impl From for ExecutionError { - fn from(value: iota_types::ExecutionError) -> Self { +impl From for ExecutionError { + fn from(value: iota_sdk::types::ExecutionError) -> Self { match value { - iota_types::ExecutionError::InsufficientGas => Self::InsufficientGas, - iota_types::ExecutionError::InvalidGasObject => Self::InvalidGasObject, - iota_types::ExecutionError::InvariantViolation => Self::InvariantViolation, - iota_types::ExecutionError::FeatureNotYetSupported => Self::FeatureNotYetSupported, - iota_types::ExecutionError::ObjectTooBig { + iota_sdk::types::ExecutionError::InsufficientGas => Self::InsufficientGas, + iota_sdk::types::ExecutionError::InvalidGasObject => Self::InvalidGasObject, + iota_sdk::types::ExecutionError::InvariantViolation => Self::InvariantViolation, + iota_sdk::types::ExecutionError::FeatureNotYetSupported => Self::FeatureNotYetSupported, + iota_sdk::types::ExecutionError::ObjectTooBig { object_size, max_object_size, } => Self::ObjectTooBig { object_size, max_object_size, }, - iota_types::ExecutionError::PackageTooBig { + iota_sdk::types::ExecutionError::PackageTooBig { object_size, max_object_size, } => Self::PackageTooBig { object_size, max_object_size, }, - iota_types::ExecutionError::CircularObjectOwnership { object } => { + iota_sdk::types::ExecutionError::CircularObjectOwnership { object } => { Self::CircularObjectOwnership { object: Arc::new(object.into()), } } - iota_types::ExecutionError::InsufficientCoinBalance => Self::InsufficientCoinBalance, - iota_types::ExecutionError::CoinBalanceOverflow => Self::CoinBalanceOverflow, - iota_types::ExecutionError::PublishErrorNonZeroAddress => { + iota_sdk::types::ExecutionError::InsufficientCoinBalance => { + Self::InsufficientCoinBalance + } + iota_sdk::types::ExecutionError::CoinBalanceOverflow => Self::CoinBalanceOverflow, + iota_sdk::types::ExecutionError::PublishErrorNonZeroAddress => { Self::PublishErrorNonZeroAddress } - iota_types::ExecutionError::IotaMoveVerificationError => Self::IotaMoveVerification, - iota_types::ExecutionError::MovePrimitiveRuntimeError { location } => { + iota_sdk::types::ExecutionError::IotaMoveVerificationError => { + Self::IotaMoveVerification + } + iota_sdk::types::ExecutionError::MovePrimitiveRuntimeError { location } => { Self::MovePrimitiveRuntime { location: location.map(Into::into), } } - iota_types::ExecutionError::MoveAbort { location, code } => Self::MoveAbort { + iota_sdk::types::ExecutionError::MoveAbort { location, code } => Self::MoveAbort { location: location.into(), code, }, - iota_types::ExecutionError::VmVerificationOrDeserializationError => { + iota_sdk::types::ExecutionError::VmVerificationOrDeserializationError => { Self::VmVerificationOrDeserialization } - iota_types::ExecutionError::VmInvariantViolation => Self::VmInvariantViolation, - iota_types::ExecutionError::FunctionNotFound => Self::FunctionNotFound, - iota_types::ExecutionError::ArityMismatch => Self::ArityMismatch, - iota_types::ExecutionError::TypeArityMismatch => Self::TypeArityMismatch, - iota_types::ExecutionError::NonEntryFunctionInvoked => Self::NonEntryFunctionInvoked, - iota_types::ExecutionError::CommandArgumentError { argument, kind } => { + iota_sdk::types::ExecutionError::VmInvariantViolation => Self::VmInvariantViolation, + iota_sdk::types::ExecutionError::FunctionNotFound => Self::FunctionNotFound, + iota_sdk::types::ExecutionError::ArityMismatch => Self::ArityMismatch, + iota_sdk::types::ExecutionError::TypeArityMismatch => Self::TypeArityMismatch, + iota_sdk::types::ExecutionError::NonEntryFunctionInvoked => { + Self::NonEntryFunctionInvoked + } + iota_sdk::types::ExecutionError::CommandArgumentError { argument, kind } => { Self::CommandArgument { argument, kind } } - iota_types::ExecutionError::TypeArgumentError { + iota_sdk::types::ExecutionError::TypeArgumentError { type_argument, kind, } => Self::TypeArgument { type_argument, kind, }, - iota_types::ExecutionError::UnusedValueWithoutDrop { result, subresult } => { + iota_sdk::types::ExecutionError::UnusedValueWithoutDrop { result, subresult } => { Self::UnusedValueWithoutDrop { result, subresult } } - iota_types::ExecutionError::InvalidPublicFunctionReturnType { index } => { + iota_sdk::types::ExecutionError::InvalidPublicFunctionReturnType { index } => { Self::InvalidPublicFunctionReturnType { index } } - iota_types::ExecutionError::InvalidTransferObject => Self::InvalidTransferObject, - iota_types::ExecutionError::EffectsTooLarge { + iota_sdk::types::ExecutionError::InvalidTransferObject => Self::InvalidTransferObject, + iota_sdk::types::ExecutionError::EffectsTooLarge { current_size, max_size, } => Self::EffectsTooLarge { current_size, max_size, }, - iota_types::ExecutionError::PublishUpgradeMissingDependency => { + iota_sdk::types::ExecutionError::PublishUpgradeMissingDependency => { Self::PublishUpgradeMissingDependency } - iota_types::ExecutionError::PublishUpgradeDependencyDowngrade => { + iota_sdk::types::ExecutionError::PublishUpgradeDependencyDowngrade => { Self::PublishUpgradeDependencyDowngrade } - iota_types::ExecutionError::PackageUpgradeError { kind } => { + iota_sdk::types::ExecutionError::PackageUpgradeError { kind } => { Self::PackageUpgrade { kind: kind.into() } } - iota_types::ExecutionError::WrittenObjectsTooLarge { + iota_sdk::types::ExecutionError::WrittenObjectsTooLarge { object_size, max_object_size, } => Self::WrittenObjectsTooLarge { object_size, max_object_size, }, - iota_types::ExecutionError::CertificateDenied => Self::CertificateDenied, - iota_types::ExecutionError::IotaMoveVerificationTimeout => { + iota_sdk::types::ExecutionError::CertificateDenied => Self::CertificateDenied, + iota_sdk::types::ExecutionError::IotaMoveVerificationTimeout => { Self::IotaMoveVerificationTimeout } - iota_types::ExecutionError::SharedObjectOperationNotAllowed => { + iota_sdk::types::ExecutionError::SharedObjectOperationNotAllowed => { Self::SharedObjectOperationNotAllowed } - iota_types::ExecutionError::InputObjectDeleted => Self::InputObjectDeleted, - iota_types::ExecutionError::ExecutionCancelledDueToSharedObjectCongestion { + iota_sdk::types::ExecutionError::InputObjectDeleted => Self::InputObjectDeleted, + iota_sdk::types::ExecutionError::ExecutionCancelledDueToSharedObjectCongestion { congested_objects, } => Self::ExecutionCancelledDueToSharedObjectCongestion { congested_objects: congested_objects @@ -378,7 +384,7 @@ impl From for ExecutionError { .map(Arc::new) .collect(), }, - iota_types::ExecutionError::ExecutionCancelledDueToSharedObjectCongestionV2 { + iota_sdk::types::ExecutionError::ExecutionCancelledDueToSharedObjectCongestionV2 { congested_objects, suggested_gas_price, } => Self::ExecutionCancelledDueToSharedObjectCongestionV2 { @@ -389,24 +395,24 @@ impl From for ExecutionError { .collect(), suggested_gas_price, }, - iota_types::ExecutionError::AddressDeniedForCoin { address, coin_type } => { + iota_sdk::types::ExecutionError::AddressDeniedForCoin { address, coin_type } => { Self::AddressDeniedForCoin { address: Arc::new(address.into()), coin_type, } } - iota_types::ExecutionError::CoinTypeGlobalPause { coin_type } => { + iota_sdk::types::ExecutionError::CoinTypeGlobalPause { coin_type } => { Self::CoinTypeGlobalPause { coin_type } } - iota_types::ExecutionError::ExecutionCancelledDueToRandomnessUnavailable => { + iota_sdk::types::ExecutionError::ExecutionCancelledDueToRandomnessUnavailable => { Self::ExecutionCancelledDueToRandomnessUnavailable } - iota_types::ExecutionError::InvalidLinkage => Self::InvalidLinkage, + iota_sdk::types::ExecutionError::InvalidLinkage => Self::InvalidLinkage, } } } -impl From for iota_types::ExecutionError { +impl From for iota_sdk::types::ExecutionError { fn from(value: ExecutionError) -> Self { match value { ExecutionError::InsufficientGas => Self::InsufficientGas, @@ -549,8 +555,8 @@ pub struct MoveLocation { pub function_name: Option, } -impl From for MoveLocation { - fn from(value: iota_types::MoveLocation) -> Self { +impl From for MoveLocation { + fn from(value: iota_sdk::types::MoveLocation) -> Self { Self { package: Arc::new(value.package.into()), module: value.module.to_string(), @@ -561,7 +567,7 @@ impl From for MoveLocation { } } -impl From for iota_types::MoveLocation { +impl From for iota_sdk::types::MoveLocation { fn from(value: MoveLocation) -> Self { Self { package: **value.package, @@ -681,27 +687,27 @@ pub enum PackageUpgradeError { }, } -impl From for PackageUpgradeError { - fn from(value: iota_types::PackageUpgradeError) -> Self { +impl From for PackageUpgradeError { + fn from(value: iota_sdk::types::PackageUpgradeError) -> Self { match value { - iota_types::PackageUpgradeError::UnableToFetchPackage { package_id } => { + iota_sdk::types::PackageUpgradeError::UnableToFetchPackage { package_id } => { Self::UnableToFetchPackage { package_id: Arc::new(package_id.into()), } } - iota_types::PackageUpgradeError::NotAPackage { object_id } => Self::NotAPackage { + iota_sdk::types::PackageUpgradeError::NotAPackage { object_id } => Self::NotAPackage { object_id: Arc::new(object_id.into()), }, - iota_types::PackageUpgradeError::IncompatibleUpgrade => Self::IncompatibleUpgrade, - iota_types::PackageUpgradeError::DigestDoesNotMatch { digest } => { + iota_sdk::types::PackageUpgradeError::IncompatibleUpgrade => Self::IncompatibleUpgrade, + iota_sdk::types::PackageUpgradeError::DigestDoesNotMatch { digest } => { Self::DigestDoesNotMatch { digest: Arc::new(digest.into()), } } - iota_types::PackageUpgradeError::UnknownUpgradePolicy { policy } => { + iota_sdk::types::PackageUpgradeError::UnknownUpgradePolicy { policy } => { Self::UnknownUpgradePolicy { policy } } - iota_types::PackageUpgradeError::PackageIdDoesNotMatch { + iota_sdk::types::PackageUpgradeError::PackageIdDoesNotMatch { package_id, ticket_id, } => Self::PackageIdDoesNotMatch { @@ -712,7 +718,7 @@ impl From for PackageUpgradeError { } } -impl From for iota_types::PackageUpgradeError { +impl From for iota_sdk::types::PackageUpgradeError { fn from(value: PackageUpgradeError) -> Self { match value { PackageUpgradeError::UnableToFetchPackage { package_id } => { diff --git a/crates/iota-sdk-ffi/src/types/gas.rs b/crates/iota-sdk-ffi/src/types/gas.rs index 889ba3b7f..cebaaef0e 100644 --- a/crates/iota-sdk-ffi/src/types/gas.rs +++ b/crates/iota-sdk-ffi/src/types/gas.rs @@ -1,7 +1,7 @@ // Copyright (c) 2025 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -use iota_types::GasCostSummary; +use iota_sdk::types::GasCostSummary; /// Summary of gas charges. /// diff --git a/crates/iota-sdk-ffi/src/types/graphql.rs b/crates/iota-sdk-ffi/src/types/graphql.rs index f6c05ea8d..9e30e7c98 100644 --- a/crates/iota-sdk-ffi/src/types/graphql.rs +++ b/crates/iota-sdk-ffi/src/types/graphql.rs @@ -4,17 +4,19 @@ use std::{str::FromStr, sync::Arc}; use base64ct::Encoding; -use iota_graphql_client::{ - pagination::{Direction, PaginationFilter}, - query_types::{ - Base64, BigInt, Feature, MoveAbility, MoveEnum, MoveEnumConnection, MoveEnumVariant, - MoveField, MoveFunctionTypeParameter, MoveObject, MoveStructConnection, MoveStructQuery, - MoveStructTypeParameter, MoveVisibility, OpenMoveType, PageInfo, ProtocolConfigAttr, - ProtocolConfigFeatureFlag, ProtocolConfigs, ServiceConfig, TransactionBlockKindInput, - ValidatorCredentials, +use iota_sdk::{ + graphql_client::{ + pagination::{Direction, PaginationFilter}, + query_types::{ + Base64, BigInt, Feature, MoveAbility, MoveEnum, MoveEnumConnection, MoveEnumVariant, + MoveField, MoveFunctionTypeParameter, MoveObject, MoveStructConnection, + MoveStructQuery, MoveStructTypeParameter, MoveVisibility, OpenMoveType, PageInfo, + ProtocolConfigAttr, ProtocolConfigFeatureFlag, ProtocolConfigs, ServiceConfig, + TransactionBlockKindInput, ValidatorCredentials, + }, }, + types::{Digest, Identifier, StructTag}, }; -use iota_types::{Digest, Identifier, StructTag}; use crate::types::{ address::Address, @@ -37,8 +39,8 @@ pub struct TransactionMetadata { pub sender: Option>, } -impl From for TransactionMetadata { - fn from(value: iota_graphql_client::query_types::TransactionMetadata) -> Self { +impl From for TransactionMetadata { + fn from(value: iota_sdk::graphql_client::query_types::TransactionMetadata) -> Self { Self { gas_budget: value.gas_budget, gas_objects: value @@ -51,7 +53,7 @@ impl From for Transaction } } -impl From for iota_graphql_client::query_types::TransactionMetadata { +impl From for iota_sdk::graphql_client::query_types::TransactionMetadata { fn from(value: TransactionMetadata) -> Self { Self { gas_budget: value.gas_budget, @@ -71,8 +73,8 @@ pub struct TransactionDataEffects { pub effects: Arc, } -impl From for TransactionDataEffects { - fn from(value: iota_graphql_client::TransactionDataEffects) -> Self { +impl From for TransactionDataEffects { + fn from(value: iota_sdk::graphql_client::TransactionDataEffects) -> Self { Self { tx: value.tx.into(), effects: Arc::new(value.effects.into()), @@ -80,7 +82,7 @@ impl From for TransactionDataEffect } } -impl From for iota_graphql_client::TransactionDataEffects { +impl From for iota_sdk::graphql_client::TransactionDataEffects { fn from(value: TransactionDataEffects) -> Self { Self { tx: value.tx.into(), @@ -115,8 +117,8 @@ pub struct TransactionsFilter { pub wrapped_or_deleted_object: Option>, } -impl From for TransactionsFilter { - fn from(value: iota_graphql_client::query_types::TransactionsFilter) -> Self { +impl From for TransactionsFilter { + fn from(value: iota_sdk::graphql_client::query_types::TransactionsFilter) -> Self { Self { function: value.function, kind: value.kind, @@ -136,7 +138,7 @@ impl From for Transactions } } -impl From for iota_graphql_client::query_types::TransactionsFilter { +impl From for iota_sdk::graphql_client::query_types::TransactionsFilter { fn from(value: TransactionsFilter) -> Self { Self { function: value.function, @@ -176,29 +178,29 @@ pub enum TransactionArgument { }, } -impl From for TransactionArgument { - fn from(value: iota_graphql_client::TransactionArgument) -> Self { +impl From for TransactionArgument { + fn from(value: iota_sdk::graphql_client::TransactionArgument) -> Self { match value { - iota_graphql_client::TransactionArgument::GasCoin => TransactionArgument::GasCoin, - iota_graphql_client::TransactionArgument::Input { ix } => { + iota_sdk::graphql_client::TransactionArgument::GasCoin => TransactionArgument::GasCoin, + iota_sdk::graphql_client::TransactionArgument::Input { ix } => { TransactionArgument::Input { ix } } - iota_graphql_client::TransactionArgument::Result { cmd, ix } => { + iota_sdk::graphql_client::TransactionArgument::Result { cmd, ix } => { TransactionArgument::Result { cmd, ix } } } } } -impl From for iota_graphql_client::TransactionArgument { +impl From for iota_sdk::graphql_client::TransactionArgument { fn from(value: TransactionArgument) -> Self { match value { - TransactionArgument::GasCoin => iota_graphql_client::TransactionArgument::GasCoin, + TransactionArgument::GasCoin => iota_sdk::graphql_client::TransactionArgument::GasCoin, TransactionArgument::Input { ix } => { - iota_graphql_client::TransactionArgument::Input { ix } + iota_sdk::graphql_client::TransactionArgument::Input { ix } } TransactionArgument::Result { cmd, ix } => { - iota_graphql_client::TransactionArgument::Result { cmd, ix } + iota_sdk::graphql_client::TransactionArgument::Result { cmd, ix } } } } @@ -213,8 +215,8 @@ pub struct DryRunReturn { pub bcs: Vec, } -impl From for DryRunReturn { - fn from(value: iota_graphql_client::DryRunReturn) -> Self { +impl From for DryRunReturn { + fn from(value: iota_sdk::graphql_client::DryRunReturn) -> Self { DryRunReturn { type_tag: Arc::new(value.type_.into()), bcs: value.bcs, @@ -222,9 +224,9 @@ impl From for DryRunReturn { } } -impl From for iota_graphql_client::DryRunReturn { +impl From for iota_sdk::graphql_client::DryRunReturn { fn from(value: DryRunReturn) -> Self { - iota_graphql_client::DryRunReturn { + iota_sdk::graphql_client::DryRunReturn { type_: value.type_tag.0.clone(), bcs: value.bcs, } @@ -242,8 +244,8 @@ pub struct DryRunMutation { pub bcs: Vec, } -impl From for DryRunMutation { - fn from(value: iota_graphql_client::DryRunMutation) -> Self { +impl From for DryRunMutation { + fn from(value: iota_sdk::graphql_client::DryRunMutation) -> Self { DryRunMutation { input: value.input.into(), type_tag: Arc::new(value.type_.into()), @@ -252,9 +254,9 @@ impl From for DryRunMutation { } } -impl From for iota_graphql_client::DryRunMutation { +impl From for iota_sdk::graphql_client::DryRunMutation { fn from(value: DryRunMutation) -> Self { - iota_graphql_client::DryRunMutation { + iota_sdk::graphql_client::DryRunMutation { input: value.input.into(), type_: value.type_tag.0.clone(), bcs: value.bcs, @@ -272,8 +274,8 @@ pub struct DryRunEffect { pub return_values: Vec, } -impl From for DryRunEffect { - fn from(value: iota_graphql_client::DryRunEffect) -> Self { +impl From for DryRunEffect { + fn from(value: iota_sdk::graphql_client::DryRunEffect) -> Self { DryRunEffect { mutated_references: value .mutated_references @@ -285,9 +287,9 @@ impl From for DryRunEffect { } } -impl From for iota_graphql_client::DryRunEffect { +impl From for iota_sdk::graphql_client::DryRunEffect { fn from(value: DryRunEffect) -> Self { - iota_graphql_client::DryRunEffect { + iota_sdk::graphql_client::DryRunEffect { mutated_references: value .mutated_references .into_iter() @@ -314,8 +316,8 @@ pub struct DryRunResult { pub effects: Option>, } -impl From for DryRunResult { - fn from(value: iota_graphql_client::DryRunResult) -> Self { +impl From for DryRunResult { + fn from(value: iota_sdk::graphql_client::DryRunResult) -> Self { DryRunResult { error: value.error, results: value.results.into_iter().map(Into::into).collect(), @@ -325,9 +327,9 @@ impl From for DryRunResult { } } -impl From for iota_graphql_client::DryRunResult { +impl From for iota_sdk::graphql_client::DryRunResult { fn from(value: DryRunResult) -> Self { - iota_graphql_client::DryRunResult { + iota_sdk::graphql_client::DryRunResult { error: value.error, results: value.results.into_iter().map(Into::into).collect(), transaction: value.transaction.map(Into::into), @@ -343,8 +345,8 @@ pub struct ObjectRef { pub version: u64, } -impl From for ObjectRef { - fn from(value: iota_graphql_client::query_types::ObjectRef) -> Self { +impl From for ObjectRef { + fn from(value: iota_sdk::graphql_client::query_types::ObjectRef) -> Self { Self { address: Arc::new(value.address.into()), digest: value.digest.to_string(), @@ -353,7 +355,7 @@ impl From for ObjectRef { } } -impl From for iota_graphql_client::query_types::ObjectRef { +impl From for iota_sdk::graphql_client::query_types::ObjectRef { fn from(value: ObjectRef) -> Self { Self { address: (**value.address), @@ -429,8 +431,8 @@ pub struct Epoch { pub validator_set: Option, } -impl From for Epoch { - fn from(value: iota_graphql_client::query_types::Epoch) -> Self { +impl From for Epoch { + fn from(value: iota_sdk::graphql_client::query_types::Epoch) -> Self { Self { epoch_id: value.epoch_id, fund_inflow: value.fund_inflow.map(|v| v.0), @@ -466,7 +468,7 @@ impl From for Epoch { } } -impl From for iota_graphql_client::query_types::Epoch { +impl From for iota_sdk::graphql_client::query_types::Epoch { fn from(value: Epoch) -> Self { Self { epoch_id: value.epoch_id, @@ -477,12 +479,12 @@ impl From for iota_graphql_client::query_types::Epoch { net_inflow: value.net_inflow.map(|v| v.into()), protocol_configs: value.protocol_configs, reference_gas_price: value.reference_gas_price.map(|v| v.into()), - start_timestamp: iota_graphql_client::query_types::DateTime( + start_timestamp: iota_sdk::graphql_client::query_types::DateTime( value.start_timestamp.to_string(), ), end_timestamp: value .end_timestamp - .map(|ts| iota_graphql_client::query_types::DateTime(ts.to_string())), + .map(|ts| iota_sdk::graphql_client::query_types::DateTime(ts.to_string())), system_state_version: value.system_state_version, total_checkpoints: value.total_checkpoints, total_gas_fees: value.total_gas_fees.map(|v| v.into()), @@ -533,8 +535,8 @@ pub struct ValidatorSet { pub validator_candidates_id: Option>, } -impl From for ValidatorSet { - fn from(value: iota_graphql_client::query_types::ValidatorSet) -> Self { +impl From for ValidatorSet { + fn from(value: iota_sdk::graphql_client::query_types::ValidatorSet) -> Self { Self { inactive_pools_id: value.inactive_pools_id.map(Into::into).map(Arc::new), inactive_pools_size: value.inactive_pools_size, @@ -553,7 +555,7 @@ impl From for ValidatorSet { } } -impl From for iota_graphql_client::query_types::ValidatorSet { +impl From for iota_sdk::graphql_client::query_types::ValidatorSet { fn from(value: ValidatorSet) -> Self { Self { inactive_pools_id: value.inactive_pools_id.map(|v| **v), @@ -582,8 +584,8 @@ pub struct EventFilter { pub transaction_digest: Option, } -impl From for EventFilter { - fn from(value: iota_graphql_client::query_types::EventFilter) -> Self { +impl From for EventFilter { + fn from(value: iota_sdk::graphql_client::query_types::EventFilter) -> Self { Self { emitting_module: value.emitting_module, event_type: value.event_type, @@ -593,7 +595,7 @@ impl From for EventFilter { } } -impl From for iota_graphql_client::query_types::EventFilter { +impl From for iota_sdk::graphql_client::query_types::EventFilter { fn from(value: EventFilter) -> Self { Self { emitting_module: value.emitting_module, @@ -614,8 +616,8 @@ pub struct ObjectFilter { pub object_ids: Option>>, } -impl From for ObjectFilter { - fn from(value: iota_graphql_client::query_types::ObjectFilter) -> Self { +impl From for ObjectFilter { + fn from(value: iota_sdk::graphql_client::query_types::ObjectFilter) -> Self { Self { type_tag: value.type_, owner: value.owner.map(Into::into).map(Arc::new), @@ -626,7 +628,7 @@ impl From for ObjectFilter { } } -impl From for iota_graphql_client::query_types::ObjectFilter { +impl From for iota_sdk::graphql_client::query_types::ObjectFilter { fn from(value: ObjectFilter) -> Self { Self { type_: value.type_tag, @@ -652,8 +654,8 @@ pub struct DynamicFieldOutput { pub value_as_json: Option, } -impl From for DynamicFieldOutput { - fn from(value: iota_graphql_client::DynamicFieldOutput) -> Self { +impl From for DynamicFieldOutput { + fn from(value: iota_sdk::graphql_client::DynamicFieldOutput) -> Self { Self { name: value.name.into(), value: value.value.map(Into::into), @@ -662,7 +664,7 @@ impl From for DynamicFieldOutput { } } -impl From for iota_graphql_client::DynamicFieldOutput { +impl From for iota_sdk::graphql_client::DynamicFieldOutput { fn from(value: DynamicFieldOutput) -> Self { Self { name: value.name.into(), @@ -685,8 +687,8 @@ pub struct DynamicFieldName { pub json: Option, } -impl From for DynamicFieldName { - fn from(value: iota_graphql_client::DynamicFieldName) -> Self { +impl From for DynamicFieldName { + fn from(value: iota_sdk::graphql_client::DynamicFieldName) -> Self { Self { type_tag: Arc::new(value.type_.into()), bcs: value.bcs, @@ -695,7 +697,7 @@ impl From for DynamicFieldName { } } -impl From for iota_graphql_client::DynamicFieldName { +impl From for iota_sdk::graphql_client::DynamicFieldName { fn from(value: DynamicFieldName) -> Self { Self { type_: value.type_tag.0.clone(), @@ -712,8 +714,8 @@ pub struct DynamicFieldValue { pub bcs: Vec, } -impl From for DynamicFieldValue { - fn from(value: iota_graphql_client::DynamicFieldValue) -> Self { +impl From for DynamicFieldValue { + fn from(value: iota_sdk::graphql_client::DynamicFieldValue) -> Self { Self { type_tag: Arc::new(value.type_.into()), bcs: value.bcs, @@ -721,7 +723,7 @@ impl From for DynamicFieldValue { } } -impl From for iota_graphql_client::DynamicFieldValue { +impl From for iota_sdk::graphql_client::DynamicFieldValue { fn from(value: DynamicFieldValue) -> Self { Self { type_: value.type_tag.0.clone(), @@ -814,8 +816,8 @@ pub struct Validator { pub voting_power: Option, } -impl From for Validator { - fn from(value: iota_graphql_client::query_types::Validator) -> Self { +impl From for Validator { + fn from(value: iota_sdk::graphql_client::query_types::Validator) -> Self { Self { apy: value.apy, address: Arc::new(value.address.address.into()), @@ -853,7 +855,7 @@ impl From for Validator { } } -impl From for iota_graphql_client::query_types::Validator { +impl From for iota_sdk::graphql_client::query_types::Validator { fn from(value: Validator) -> Self { Self { apy: value.apy, @@ -969,8 +971,8 @@ pub struct ValidatorConnection { pub nodes: Vec, } -impl From for ValidatorConnection { - fn from(value: iota_graphql_client::query_types::ValidatorConnection) -> Self { +impl From for ValidatorConnection { + fn from(value: iota_sdk::graphql_client::query_types::ValidatorConnection) -> Self { ValidatorConnection { page_info: value.page_info, nodes: value.nodes.into_iter().map(Into::into).collect(), @@ -978,9 +980,9 @@ impl From for ValidatorCo } } -impl From for iota_graphql_client::query_types::ValidatorConnection { +impl From for iota_sdk::graphql_client::query_types::ValidatorConnection { fn from(value: ValidatorConnection) -> Self { - iota_graphql_client::query_types::ValidatorConnection { + iota_sdk::graphql_client::query_types::ValidatorConnection { page_info: value.page_info, nodes: value.nodes.into_iter().map(Into::into).collect(), } @@ -992,17 +994,17 @@ pub struct GQLAddress { pub address: Arc
, } -impl From for GQLAddress { - fn from(value: iota_graphql_client::query_types::GQLAddress) -> Self { +impl From for GQLAddress { + fn from(value: iota_sdk::graphql_client::query_types::GQLAddress) -> Self { GQLAddress { address: Arc::new(value.address.into()), } } } -impl From for iota_graphql_client::query_types::GQLAddress { +impl From for iota_sdk::graphql_client::query_types::GQLAddress { fn from(value: GQLAddress) -> Self { - iota_graphql_client::query_types::GQLAddress { + iota_sdk::graphql_client::query_types::GQLAddress { address: (**value.address), } } @@ -1078,8 +1080,8 @@ pub struct CoinMetadata { pub version: u64, } -impl From for CoinMetadata { - fn from(value: iota_graphql_client::query_types::CoinMetadata) -> Self { +impl From for CoinMetadata { + fn from(value: iota_sdk::graphql_client::query_types::CoinMetadata) -> Self { Self { address: Arc::new(value.address.into()), decimals: value.decimals, @@ -1093,7 +1095,7 @@ impl From for CoinMetadata { } } -impl From for iota_graphql_client::query_types::CoinMetadata { +impl From for iota_sdk::graphql_client::query_types::CoinMetadata { fn from(value: CoinMetadata) -> Self { Self { address: **value.address, @@ -1110,7 +1112,7 @@ impl From for iota_graphql_client::query_types::CoinMetadata { #[derive(derive_more::From, derive_more::Display, uniffi::Object)] #[uniffi::export(Display)] -pub struct MoveFunction(iota_graphql_client::query_types::MoveFunction); +pub struct MoveFunction(iota_sdk::graphql_client::query_types::MoveFunction); #[uniffi::export] impl MoveFunction { @@ -1176,8 +1178,8 @@ pub struct MoveModule { pub structs: Option, } -impl From for MoveModule { - fn from(value: iota_graphql_client::query_types::MoveModule) -> Self { +impl From for MoveModule { + fn from(value: iota_sdk::graphql_client::query_types::MoveModule) -> Self { Self { file_format_version: value.file_format_version, enums: value.enums, @@ -1188,7 +1190,7 @@ impl From for MoveModule { } } -impl From for iota_graphql_client::query_types::MoveModule { +impl From for iota_sdk::graphql_client::query_types::MoveModule { fn from(value: MoveModule) -> Self { Self { file_format_version: value.file_format_version, @@ -1206,8 +1208,8 @@ pub struct MoveModuleConnection { pub page_info: PageInfo, } -impl From for MoveModuleConnection { - fn from(value: iota_graphql_client::query_types::MoveModuleConnection) -> Self { +impl From for MoveModuleConnection { + fn from(value: iota_sdk::graphql_client::query_types::MoveModuleConnection) -> Self { Self { nodes: value.nodes.into_iter().map(Into::into).collect(), page_info: value.page_info, @@ -1215,7 +1217,7 @@ impl From for MoveModule } } -impl From for iota_graphql_client::query_types::MoveModuleConnection { +impl From for iota_sdk::graphql_client::query_types::MoveModuleConnection { fn from(value: MoveModuleConnection) -> Self { Self { nodes: value.nodes.into_iter().map(Into::into).collect(), @@ -1231,8 +1233,8 @@ pub struct MovePackageQuery { pub bcs: Option, } -impl From for MovePackageQuery { - fn from(value: iota_graphql_client::query_types::MovePackageQuery) -> Self { +impl From for MovePackageQuery { + fn from(value: iota_sdk::graphql_client::query_types::MovePackageQuery) -> Self { Self { address: Arc::new(value.address.into()), bcs: value.bcs, @@ -1240,7 +1242,7 @@ impl From for MovePackageQue } } -impl From for iota_graphql_client::query_types::MovePackageQuery { +impl From for iota_sdk::graphql_client::query_types::MovePackageQuery { fn from(value: MovePackageQuery) -> Self { Self { address: (**value.address), @@ -1255,8 +1257,8 @@ pub struct MoveModuleQuery { pub name: String, } -impl From for MoveModuleQuery { - fn from(value: iota_graphql_client::query_types::MoveModuleQuery) -> Self { +impl From for MoveModuleQuery { + fn from(value: iota_sdk::graphql_client::query_types::MoveModuleQuery) -> Self { Self { package: value.package.into(), name: value.name, @@ -1264,7 +1266,7 @@ impl From for MoveModuleQuery } } -impl From for iota_graphql_client::query_types::MoveModuleQuery { +impl From for iota_sdk::graphql_client::query_types::MoveModuleQuery { fn from(value: MoveModuleQuery) -> Self { Self { package: value.package.into(), @@ -1310,8 +1312,10 @@ pub struct MoveFunctionConnection { pub page_info: PageInfo, } -impl From for MoveFunctionConnection { - fn from(value: iota_graphql_client::query_types::MoveFunctionConnection) -> Self { +impl From + for MoveFunctionConnection +{ + fn from(value: iota_sdk::graphql_client::query_types::MoveFunctionConnection) -> Self { Self { nodes: value .nodes @@ -1325,7 +1329,9 @@ impl From for MoveFunc } } -impl From for iota_graphql_client::query_types::MoveFunctionConnection { +impl From + for iota_sdk::graphql_client::query_types::MoveFunctionConnection +{ fn from(value: MoveFunctionConnection) -> Self { Self { nodes: value.nodes.iter().map(|v| v.0.clone()).collect(), diff --git a/crates/iota-sdk-ffi/src/types/iota_names.rs b/crates/iota-sdk-ffi/src/types/iota_names.rs index dd8fab1b1..869bb7c56 100644 --- a/crates/iota-sdk-ffi/src/types/iota_names.rs +++ b/crates/iota-sdk-ffi/src/types/iota_names.rs @@ -3,19 +3,19 @@ use std::{str::FromStr, sync::Arc}; -use iota_types::iota_names::{IotaNamesNft, NameFormat}; +use iota_sdk::types::iota_names::{IotaNamesNft, NameFormat}; use crate::{error::Result, types::object::ObjectId}; /// An object to manage a second-level name (SLN). #[derive(derive_more::From, uniffi::Object)] -pub struct NameRegistration(iota_types::iota_names::NameRegistration); +pub struct NameRegistration(iota_sdk::types::iota_names::NameRegistration); #[uniffi::export] impl NameRegistration { #[uniffi::constructor] pub fn new(id: &ObjectId, name: &Name, name_str: String, expiration_timestamp_ms: u64) -> Self { - Self(iota_types::iota_names::NameRegistration::new( + Self(iota_sdk::types::iota_names::NameRegistration::new( **id, name.0.clone(), name_str, @@ -36,19 +36,19 @@ impl NameRegistration { } pub fn expiration_timestamp_ms(&self) -> u64 { - iota_types::iota_names::NameRegistration::MODULE; + iota_sdk::types::iota_names::NameRegistration::MODULE; self.0.expiration_timestamp_ms() } } #[derive(derive_more::From, uniffi::Object)] -pub struct Name(iota_types::iota_names::Name); +pub struct Name(iota_sdk::types::iota_names::Name); #[uniffi::export] impl Name { #[uniffi::constructor] pub fn from_str(s: &str) -> Result { - Ok(iota_types::iota_names::Name::from_str(s)?.into()) + Ok(iota_sdk::types::iota_names::Name::from_str(s)?.into()) } // Derive the parent name for a given name. Only subnames have diff --git a/crates/iota-sdk-ffi/src/types/mod.rs b/crates/iota-sdk-ffi/src/types/mod.rs index 5f00c60e9..7bb6f5235 100644 --- a/crates/iota-sdk-ffi/src/types/mod.rs +++ b/crates/iota-sdk-ffi/src/types/mod.rs @@ -22,13 +22,13 @@ pub mod type_tag; pub mod validator; #[derive(derive_more::From, uniffi::Object)] -pub struct PersonalMessage(iota_types::PersonalMessage<'static>); +pub struct PersonalMessage(iota_sdk::types::PersonalMessage<'static>); #[uniffi::export] impl PersonalMessage { #[uniffi::constructor] pub fn new(message_bytes: &[u8]) -> Self { - Self(iota_types::PersonalMessage(Cow::Owned( + Self(iota_sdk::types::PersonalMessage(Cow::Owned( message_bytes.to_vec(), ))) } diff --git a/crates/iota-sdk-ffi/src/types/move_package.rs b/crates/iota-sdk-ffi/src/types/move_package.rs index 03b1f4d7f..e98fa1494 100644 --- a/crates/iota-sdk-ffi/src/types/move_package.rs +++ b/crates/iota-sdk-ffi/src/types/move_package.rs @@ -7,23 +7,23 @@ use crate::{error::Result, types::object::ObjectId}; /// Representation of upgrade policy constants in `iota::package`. #[derive(derive_more::From, uniffi::Object)] -pub struct UpgradePolicy(pub iota_types::UpgradePolicy); +pub struct UpgradePolicy(pub iota_sdk::types::UpgradePolicy); #[uniffi::export] impl UpgradePolicy { #[uniffi::constructor] pub fn compatible() -> Self { - Self(iota_types::UpgradePolicy::Compatible) + Self(iota_sdk::types::UpgradePolicy::Compatible) } #[uniffi::constructor] pub fn additive() -> Self { - Self(iota_types::UpgradePolicy::Additive) + Self(iota_sdk::types::UpgradePolicy::Additive) } #[uniffi::constructor] pub fn dep_only() -> Self { - Self(iota_types::UpgradePolicy::DepOnly) + Self(iota_sdk::types::UpgradePolicy::DepOnly) } pub fn as_u8(&self) -> u8 { @@ -34,13 +34,13 @@ impl UpgradePolicy { /// Type corresponding to the output of `iota move build /// --dump-bytecode-as-base64` #[derive(derive_more::From, uniffi::Object)] -pub struct MovePackageData(pub iota_types::MovePackageData); +pub struct MovePackageData(pub iota_sdk::types::MovePackageData); #[uniffi::export] impl MovePackageData { #[uniffi::constructor] pub fn new(modules: Vec>, dependencies: Vec>) -> Self { - Self(iota_types::MovePackageData::new( + Self(iota_sdk::types::MovePackageData::new( modules, dependencies.into_iter().map(|o| **o).collect(), )) @@ -52,7 +52,7 @@ impl MovePackageData { #[uniffi::constructor] pub fn from_base64(base64: &str) -> Result { - Ok(Self(iota_types::MovePackageData::from_base64(base64)?)) + Ok(Self(iota_sdk::types::MovePackageData::from_base64(base64)?)) } pub fn to_json(&self) -> String { diff --git a/crates/iota-sdk-ffi/src/types/object.rs b/crates/iota-sdk-ffi/src/types/object.rs index 105f38059..63ac2604b 100644 --- a/crates/iota-sdk-ffi/src/types/object.rs +++ b/crates/iota-sdk-ffi/src/types/object.rs @@ -6,7 +6,7 @@ use std::{ sync::Arc, }; -pub type Version = iota_types::Version; +pub type Version = iota_sdk::types::Version; use crate::{ error::Result, @@ -38,20 +38,20 @@ use crate::{ /// ``` #[derive(PartialEq, Eq, Hash, derive_more::From, derive_more::Deref, uniffi::Object)] #[uniffi::export(Hash)] -pub struct ObjectId(pub iota_types::ObjectId); +pub struct ObjectId(pub iota_sdk::types::ObjectId); #[uniffi::export] impl ObjectId { #[uniffi::constructor] pub fn from_bytes(bytes: Vec) -> Result { - Ok(Self(iota_types::ObjectId::from( - iota_types::Address::from_bytes(bytes)?, + Ok(Self(iota_sdk::types::ObjectId::from( + iota_sdk::types::Address::from_bytes(bytes)?, ))) } #[uniffi::constructor] pub fn from_hex(hex: &str) -> Result { - Ok(Self(iota_types::ObjectId::from_hex(hex)?)) + Ok(Self(iota_sdk::types::ObjectId::from_hex(hex)?)) } pub fn to_bytes(&self) -> Vec { @@ -70,7 +70,7 @@ impl ObjectId { /// that have been created during a transactions. #[uniffi::constructor] pub fn derive_id(digest: &Digest, count: u64) -> Self { - Self(iota_types::ObjectId::derive_id(**digest, count)) + Self(iota_sdk::types::ObjectId::derive_id(**digest, count)) } /// Derive an ObjectId for a Dynamic Child Object. @@ -90,7 +90,7 @@ macro_rules! named_object_id { impl ObjectId {$( #[uniffi::constructor] pub const fn [< $constant:lower >]() -> Self { - Self(iota_types::ObjectId::$constant) + Self(iota_sdk::types::ObjectId::$constant) } )+} } @@ -117,8 +117,8 @@ pub struct ObjectReference { digest: Arc, } -impl From for ObjectReference { - fn from(value: iota_types::ObjectReference) -> Self { +impl From for ObjectReference { + fn from(value: iota_sdk::types::ObjectReference) -> Self { Self { object_id: Arc::new((*value.object_id()).into()), version: value.version(), @@ -127,7 +127,7 @@ impl From for ObjectReference { } } -impl From for iota_types::ObjectReference { +impl From for iota_sdk::types::ObjectReference { fn from(value: ObjectReference) -> Self { Self::new(**value.object_id, value.version, **value.digest) } @@ -143,7 +143,7 @@ impl From for iota_types::ObjectReference { /// object = object-data owner digest u64 /// ``` #[derive(derive_more::From, uniffi::Object)] -pub struct Object(pub iota_types::Object); +pub struct Object(pub iota_sdk::types::Object); #[uniffi::export] impl Object { @@ -154,7 +154,7 @@ impl Object { previous_transaction: &Digest, storage_rebate: u64, ) -> Self { - Self(iota_types::Object::new( + Self(iota_sdk::types::Object::new( data.0.clone(), **owner, **previous_transaction, @@ -245,20 +245,20 @@ impl Object { /// object-data-package = %x01 object-move-package /// ``` #[derive(derive_more::From, uniffi::Object)] -pub struct ObjectData(pub iota_types::ObjectData); +pub struct ObjectData(pub iota_sdk::types::ObjectData); #[uniffi::export] impl ObjectData { /// Create an `ObjectData` from a `MoveStruct` #[uniffi::constructor] pub fn new_move_struct(move_struct: MoveStruct) -> Self { - Self(iota_types::ObjectData::Struct(move_struct.into())) + Self(iota_sdk::types::ObjectData::Struct(move_struct.into())) } /// Create an `ObjectData` from `MovePackage` #[uniffi::constructor] pub fn new_move_package(move_package: &MovePackage) -> Self { - Self(iota_types::ObjectData::Package(move_package.0.clone())) + Self(iota_sdk::types::ObjectData::Package(move_package.0.clone())) } /// Return whether this object is a `MoveStruct` @@ -302,8 +302,8 @@ pub struct TypeOrigin { pub package: Arc, } -impl From for TypeOrigin { - fn from(value: iota_types::TypeOrigin) -> Self { +impl From for TypeOrigin { + fn from(value: iota_sdk::types::TypeOrigin) -> Self { Self { module_name: Arc::new(value.module_name.into()), struct_name: Arc::new(value.struct_name.into()), @@ -312,7 +312,7 @@ impl From for TypeOrigin { } } -impl From for iota_types::TypeOrigin { +impl From for iota_sdk::types::TypeOrigin { fn from(value: TypeOrigin) -> Self { Self { module_name: value.module_name.0.clone(), @@ -339,8 +339,8 @@ pub struct UpgradeInfo { pub upgraded_version: Version, } -impl From for UpgradeInfo { - fn from(value: iota_types::UpgradeInfo) -> Self { +impl From for UpgradeInfo { + fn from(value: iota_sdk::types::UpgradeInfo) -> Self { Self { upgraded_id: Arc::new(value.upgraded_id.into()), upgraded_version: value.upgraded_version, @@ -348,7 +348,7 @@ impl From for UpgradeInfo { } } -impl From for iota_types::UpgradeInfo { +impl From for iota_sdk::types::UpgradeInfo { fn from(value: UpgradeInfo) -> Self { Self { upgraded_id: **value.upgraded_id, @@ -371,7 +371,7 @@ impl From for iota_types::UpgradeInfo { /// linkage-table = map (object-id upgrade-info) /// ``` #[derive(derive_more::From, uniffi::Object)] -pub struct MovePackage(pub iota_types::MovePackage); +pub struct MovePackage(pub iota_sdk::types::MovePackage); #[uniffi::export] impl MovePackage { @@ -383,7 +383,7 @@ impl MovePackage { type_origin_table: Vec, linkage_table: HashMap, UpgradeInfo>, ) -> Result { - Ok(Self(iota_types::MovePackage { + Ok(Self(iota_sdk::types::MovePackage { id: **id, version, modules: modules.into_iter().map(|(k, v)| (k.0.clone(), v)).collect(), @@ -462,8 +462,8 @@ pub struct MoveStruct { pub contents: Vec, } -impl From for MoveStruct { - fn from(value: iota_types::MoveStruct) -> Self { +impl From for MoveStruct { + fn from(value: iota_sdk::types::MoveStruct) -> Self { Self { struct_type: Arc::new(value.type_.into()), version: value.version, @@ -472,7 +472,7 @@ impl From for MoveStruct { } } -impl From for iota_types::MoveStruct { +impl From for iota_sdk::types::MoveStruct { fn from(value: MoveStruct) -> Self { Self { type_: value.struct_type.0.clone(), @@ -498,28 +498,28 @@ impl From for iota_types::MoveStruct { /// ``` #[derive(derive_more::From, derive_more::Deref, derive_more::Display, uniffi::Object)] #[uniffi::export(Display)] -pub struct Owner(pub iota_types::Owner); +pub struct Owner(pub iota_sdk::types::Owner); #[uniffi::export] impl Owner { #[uniffi::constructor] pub fn new_address(address: &Address) -> Self { - Self(iota_types::Owner::Address(address.0)) + Self(iota_sdk::types::Owner::Address(address.0)) } #[uniffi::constructor] pub fn new_object(id: &ObjectId) -> Self { - Self(iota_types::Owner::Object(id.0)) + Self(iota_sdk::types::Owner::Object(id.0)) } #[uniffi::constructor] pub fn new_shared(version: Version) -> Self { - Self(iota_types::Owner::Shared(version)) + Self(iota_sdk::types::Owner::Shared(version)) } #[uniffi::constructor] pub fn new_immutable() -> Self { - Self(iota_types::Owner::Immutable) + Self(iota_sdk::types::Owner::Immutable) } pub fn is_address(&self) -> bool { @@ -574,18 +574,18 @@ impl Owner { /// Type of an IOTA object #[derive(derive_more::From, derive_more::Display, uniffi::Object)] #[uniffi::export(Display)] -pub struct ObjectType(pub iota_types::ObjectType); +pub struct ObjectType(pub iota_sdk::types::ObjectType); #[uniffi::export] impl ObjectType { #[uniffi::constructor] pub fn new_package() -> Self { - Self(iota_types::ObjectType::Package) + Self(iota_sdk::types::ObjectType::Package) } #[uniffi::constructor] pub fn new_struct(struct_tag: &StructTag) -> Self { - Self(iota_types::ObjectType::Struct(struct_tag.0.clone())) + Self(iota_sdk::types::ObjectType::Struct(struct_tag.0.clone())) } pub fn is_package(&self) -> bool { @@ -622,13 +622,13 @@ impl ObjectType { /// genesis-object = object-data owner /// ``` #[derive(derive_more::From, uniffi::Object)] -pub struct GenesisObject(pub iota_types::GenesisObject); +pub struct GenesisObject(pub iota_sdk::types::GenesisObject); #[uniffi::export] impl GenesisObject { #[uniffi::constructor] pub fn new(data: &ObjectData, owner: &Owner) -> Self { - Self(iota_types::GenesisObject::new(data.0.clone(), owner.0)) + Self(iota_sdk::types::GenesisObject::new(data.0.clone(), owner.0)) } pub fn object_id(&self) -> ObjectId { diff --git a/crates/iota-sdk-ffi/src/types/signature.rs b/crates/iota-sdk-ffi/src/types/signature.rs index ebc5ab2ed..bf9ef6db8 100644 --- a/crates/iota-sdk-ffi/src/types/signature.rs +++ b/crates/iota-sdk-ffi/src/types/signature.rs @@ -3,7 +3,7 @@ use std::sync::Arc; -use iota_types::{SignatureScheme, ZkLoginClaim}; +use iota_sdk::types::{SignatureScheme, ZkLoginClaim}; use crate::{ error::Result, @@ -62,30 +62,34 @@ pub enum SignatureScheme { /// as `bytes` meaning it has a length prefix that defines the length of /// the completely serialized signature. #[derive(derive_more::From, uniffi::Object)] -pub struct UserSignature(pub iota_types::UserSignature); +pub struct UserSignature(pub iota_sdk::types::UserSignature); #[uniffi::export] impl UserSignature { #[uniffi::constructor] pub fn new_simple(signature: &SimpleSignature) -> Self { - Self(iota_types::UserSignature::Simple(signature.0.clone())) + Self(iota_sdk::types::UserSignature::Simple(signature.0.clone())) } #[uniffi::constructor] pub fn new_multisig(signature: &MultisigAggregatedSignature) -> Self { - Self(iota_types::UserSignature::Multisig(signature.0.clone())) + Self(iota_sdk::types::UserSignature::Multisig( + signature.0.clone(), + )) } #[uniffi::constructor] pub fn new_zklogin(authenticator: &ZkLoginAuthenticator) -> Self { - Self(iota_types::UserSignature::ZkLogin(Box::new( + Self(iota_sdk::types::UserSignature::ZkLogin(Box::new( authenticator.0.clone(), ))) } #[uniffi::constructor] pub fn new_passkey(authenticator: &PasskeyAuthenticator) -> Self { - Self(iota_types::UserSignature::Passkey(authenticator.0.clone())) + Self(iota_sdk::types::UserSignature::Passkey( + authenticator.0.clone(), + )) } /// Return the flag for this signature scheme @@ -103,12 +107,12 @@ impl UserSignature { #[uniffi::constructor] pub fn from_bytes(bytes: Vec) -> Result { - Ok(iota_types::UserSignature::from_bytes(&bytes).map(Self)?) + Ok(iota_sdk::types::UserSignature::from_bytes(&bytes).map(Self)?) } #[uniffi::constructor] pub fn from_base64(base64: String) -> Result { - Ok(iota_types::UserSignature::from_base64(&base64).map(Self)?) + Ok(iota_sdk::types::UserSignature::from_base64(&base64).map(Self)?) } pub fn is_simple(&self) -> bool { @@ -199,13 +203,13 @@ impl UserSignature { /// as `bytes` meaning it has a length prefix that defines the length of /// the completely serialized signature. #[derive(derive_more::From, uniffi::Object)] -pub struct SimpleSignature(pub iota_types::SimpleSignature); +pub struct SimpleSignature(pub iota_sdk::types::SimpleSignature); #[uniffi::export] impl SimpleSignature { #[uniffi::constructor] pub fn new_ed25519(signature: &Ed25519Signature, public_key: &Ed25519PublicKey) -> Self { - Self(iota_types::SimpleSignature::Ed25519 { + Self(iota_sdk::types::SimpleSignature::Ed25519 { signature: **signature, public_key: **public_key, }) @@ -213,7 +217,7 @@ impl SimpleSignature { #[uniffi::constructor] pub fn new_secp256k1(signature: &Secp256k1Signature, public_key: &Secp256k1PublicKey) -> Self { - Self(iota_types::SimpleSignature::Secp256k1 { + Self(iota_sdk::types::SimpleSignature::Secp256k1 { signature: **signature, public_key: **public_key, }) @@ -221,7 +225,7 @@ impl SimpleSignature { #[uniffi::constructor] pub fn new_secp256r1(signature: &Secp256r1Signature, public_key: &Secp256r1PublicKey) -> Self { - Self(iota_types::SimpleSignature::Secp256r1 { + Self(iota_sdk::types::SimpleSignature::Secp256r1 { signature: **signature, public_key: **public_key, }) diff --git a/crates/iota-sdk-ffi/src/types/struct_tag.rs b/crates/iota-sdk-ffi/src/types/struct_tag.rs index 50d071e1e..3da3110aa 100644 --- a/crates/iota-sdk-ffi/src/types/struct_tag.rs +++ b/crates/iota-sdk-ffi/src/types/struct_tag.rs @@ -23,13 +23,13 @@ use crate::{ /// ``` #[derive(PartialEq, Eq, Hash, derive_more::From, uniffi::Object)] #[uniffi::export(Hash)] -pub struct Identifier(pub iota_types::Identifier); +pub struct Identifier(pub iota_sdk::types::Identifier); #[uniffi::export] impl Identifier { #[uniffi::constructor] pub fn new(identifier: String) -> Result { - Ok(Self(iota_types::Identifier::new(identifier)?)) + Ok(Self(iota_sdk::types::Identifier::new(identifier)?)) } pub fn as_str(&self) -> String { @@ -51,7 +51,7 @@ impl Identifier { /// ``` #[derive(derive_more::From, derive_more::Display, uniffi::Object)] #[uniffi::export(Display)] -pub struct StructTag(pub iota_types::StructTag); +pub struct StructTag(pub iota_sdk::types::StructTag); #[uniffi::export] impl StructTag { @@ -62,7 +62,7 @@ impl StructTag { name: &Identifier, type_params: Vec>, ) -> Self { - Self(iota_types::StructTag { + Self(iota_sdk::types::StructTag { address: address.0, module: module.0.clone(), name: name.0.clone(), @@ -75,7 +75,7 @@ impl StructTag { #[uniffi::constructor] pub fn coin(type_tag: &TypeTag) -> Self { - Self(iota_types::StructTag::coin(type_tag.0.clone())) + Self(iota_sdk::types::StructTag::coin(type_tag.0.clone())) } /// Checks if this is a Coin type @@ -94,12 +94,12 @@ impl StructTag { #[uniffi::constructor] pub fn gas_coin() -> Self { - Self(iota_types::StructTag::gas_coin()) + Self(iota_sdk::types::StructTag::gas_coin()) } #[uniffi::constructor] pub fn staked_iota() -> Self { - Self(iota_types::StructTag::staked_iota()) + Self(iota_sdk::types::StructTag::staked_iota()) } pub fn address(&self) -> Address { diff --git a/crates/iota-sdk-ffi/src/types/transaction/mod.rs b/crates/iota-sdk-ffi/src/types/transaction/mod.rs index 8dde9b0ff..099546549 100644 --- a/crates/iota-sdk-ffi/src/types/transaction/mod.rs +++ b/crates/iota-sdk-ffi/src/types/transaction/mod.rs @@ -3,7 +3,7 @@ use std::sync::Arc; -use iota_types::{ +use iota_sdk::types::{ ActiveJwk, AuthenticatorStateExpire, AuthenticatorStateUpdateV1, GasCostSummary, Jwk, JwkId, RandomnessStateUpdate, TransactionExpiration, }; @@ -41,18 +41,18 @@ pub mod v1; /// transaction-v1 = transaction-kind address gas-payment transaction-expiration /// ``` #[derive(Clone, uniffi::Object)] -pub struct Transaction(pub iota_types::Transaction); +pub struct Transaction(pub iota_sdk::types::Transaction); #[uniffi::export] impl Transaction { #[uniffi::constructor] pub fn new_v1(transaction_v1: &TransactionV1) -> Self { - Self(iota_types::Transaction::V1(transaction_v1.0.clone())) + Self(iota_sdk::types::Transaction::V1(transaction_v1.0.clone())) } pub fn as_v1(&self) -> Arc { match &self.0 { - iota_types::Transaction::V1(tx) => Arc::new(TransactionV1(tx.clone())), + iota_sdk::types::Transaction::V1(tx) => Arc::new(TransactionV1(tx.clone())), } } @@ -94,7 +94,9 @@ impl Transaction { /// Deserialize a transaction from a base64-encoded string. #[uniffi::constructor] pub fn from_base64(base64: String) -> Result { - Ok(Transaction(iota_types::Transaction::from_base64(&base64)?)) + Ok(Transaction(iota_sdk::types::Transaction::from_base64( + &base64, + )?)) } } @@ -110,7 +112,7 @@ impl Transaction { /// transaction-v1 = transaction-kind address gas-payment transaction-expiration /// ``` #[derive(derive_more::From, uniffi::Object)] -pub struct TransactionV1(pub iota_types::TransactionV1); +pub struct TransactionV1(pub iota_sdk::types::TransactionV1); #[uniffi::export] impl TransactionV1 { @@ -121,7 +123,7 @@ impl TransactionV1 { gas_payment: GasPayment, expiration: TransactionExpiration, ) -> Self { - Self(iota_types::TransactionV1 { + Self(iota_sdk::types::TransactionV1 { kind: kind.0.clone(), sender: **sender, gas_payment: gas_payment.into(), @@ -167,7 +169,7 @@ impl TransactionV1 { /// Deserialize a transaction from a base64-encoded string. #[uniffi::constructor] pub fn from_base64(bytes: String) -> Result { - Ok(Self(iota_types::TransactionV1::from_base64(&bytes)?)) + Ok(Self(iota_sdk::types::TransactionV1::from_base64(&bytes)?)) } } @@ -177,8 +179,8 @@ pub struct SignedTransaction { pub signatures: Vec>, } -impl From for SignedTransaction { - fn from(value: iota_types::SignedTransaction) -> Self { +impl From for SignedTransaction { + fn from(value: iota_sdk::types::SignedTransaction) -> Self { Self { transaction: Arc::new(Transaction(value.transaction)), signatures: value @@ -191,7 +193,7 @@ impl From for SignedTransaction { } } -impl From for iota_types::SignedTransaction { +impl From for iota_sdk::types::SignedTransaction { fn from(value: SignedTransaction) -> Self { Self { transaction: value.transaction.0.clone(), @@ -218,46 +220,44 @@ impl From for iota_types::SignedTransaction { /// =/ %x08 consensus-commit-prologue-v3 /// ``` #[derive(derive_more::From, uniffi::Object)] -pub struct TransactionKind(pub iota_types::TransactionKind); +pub struct TransactionKind(pub iota_sdk::types::TransactionKind); #[uniffi::export] impl TransactionKind { #[uniffi::constructor] pub fn new_programmable_transaction(tx: &ProgrammableTransaction) -> Self { - Self(iota_types::TransactionKind::ProgrammableTransaction( + Self(iota_sdk::types::TransactionKind::ProgrammableTransaction( tx.0.clone(), )) } #[uniffi::constructor] pub fn new_genesis(tx: &GenesisTransaction) -> Self { - Self(iota_types::TransactionKind::Genesis(tx.0.clone())) + Self(iota_sdk::types::TransactionKind::Genesis(tx.0.clone())) } #[uniffi::constructor] pub fn new_consensus_commit_prologue_v1(tx: &ConsensusCommitPrologueV1) -> Self { - Self(iota_types::TransactionKind::ConsensusCommitPrologueV1( + Self(iota_sdk::types::TransactionKind::ConsensusCommitPrologueV1( tx.0.clone(), )) } #[uniffi::constructor] pub fn new_authenticator_state_update_v1(tx: &AuthenticatorStateUpdateV1) -> Self { - Self(iota_types::TransactionKind::AuthenticatorStateUpdateV1( - tx.clone(), - )) + Self(iota_sdk::types::TransactionKind::AuthenticatorStateUpdateV1(tx.clone())) } #[uniffi::constructor] pub fn new_end_of_epoch(tx: Vec>) -> Self { - Self(iota_types::TransactionKind::EndOfEpoch( + Self(iota_sdk::types::TransactionKind::EndOfEpoch( tx.into_iter().map(|tx| tx.0.clone()).collect(), )) } #[uniffi::constructor] pub fn new_randomness_state_update(tx: &RandomnessStateUpdate) -> Self { - Self(iota_types::TransactionKind::RandomnessStateUpdate( + Self(iota_sdk::types::TransactionKind::RandomnessStateUpdate( tx.clone(), )) } @@ -276,13 +276,13 @@ impl TransactionKind { /// ptb = (vector input) (vector command) /// ``` #[derive(derive_more::From, uniffi::Object)] -pub struct ProgrammableTransaction(pub iota_types::ProgrammableTransaction); +pub struct ProgrammableTransaction(pub iota_sdk::types::ProgrammableTransaction); #[uniffi::export] impl ProgrammableTransaction { #[uniffi::constructor] pub fn new(inputs: Vec>, commands: Vec>) -> Self { - Self(iota_types::ProgrammableTransaction { + Self(iota_sdk::types::ProgrammableTransaction { inputs: inputs.iter().map(|input| input.0.clone()).collect(), commands: commands.iter().map(|command| command.0.clone()).collect(), }) @@ -327,7 +327,7 @@ impl ProgrammableTransaction { /// input-receiving = %x04 object-ref /// ``` #[derive(derive_more::From, uniffi::Object)] -pub struct Input(pub iota_types::Input); +pub struct Input(pub iota_sdk::types::Input); #[uniffi::export] impl Input { @@ -335,19 +335,19 @@ impl Input { /// not contain structs or objects. #[uniffi::constructor] pub fn new_pure(value: Vec) -> Self { - Self(iota_types::Input::Pure { value }) + Self(iota_sdk::types::Input::Pure { value }) } /// A move object that is either immutable or address owned #[uniffi::constructor] pub fn new_immutable_or_owned(object_ref: ObjectReference) -> Self { - Self(iota_types::Input::ImmutableOrOwned(object_ref.into())) + Self(iota_sdk::types::Input::ImmutableOrOwned(object_ref.into())) } /// A move object whose owner is "Shared" #[uniffi::constructor] pub fn new_shared(object_id: &ObjectId, initial_shared_version: u64, mutable: bool) -> Self { - Self(iota_types::Input::Shared { + Self(iota_sdk::types::Input::Shared { object_id: object_id.0, initial_shared_version, mutable, @@ -356,7 +356,7 @@ impl Input { #[uniffi::constructor] pub fn new_receiving(object_ref: ObjectReference) -> Self { - Self(iota_types::Input::Receiving(object_ref.into())) + Self(iota_sdk::types::Input::Receiving(object_ref.into())) } } @@ -384,14 +384,14 @@ impl Input { /// command-upgrade = %x06 upgrade /// ``` #[derive(derive_more::From, uniffi::Object)] -pub struct Command(pub iota_types::Command); +pub struct Command(pub iota_sdk::types::Command); #[uniffi::export] impl Command { /// A call to either an entry or a public Move function #[uniffi::constructor] pub fn new_move_call(move_call: &MoveCall) -> Self { - Self(iota_types::Command::MoveCall(move_call.0.clone())) + Self(iota_sdk::types::Command::MoveCall(move_call.0.clone())) } /// It sends n-objects to the specified address. These objects must have @@ -399,7 +399,7 @@ impl Command { /// address or the object must be newly created. #[uniffi::constructor] pub fn new_transfer_objects(transfer_objects: &TransferObjects) -> Self { - Self(iota_types::Command::TransferObjects( + Self(iota_sdk::types::Command::TransferObjects( transfer_objects.0.clone(), )) } @@ -407,27 +407,27 @@ impl Command { /// It splits off some amounts into a new coins with those amounts #[uniffi::constructor] pub fn new_split_coins(split_coins: &SplitCoins) -> Self { - Self(iota_types::Command::SplitCoins(split_coins.0.clone())) + Self(iota_sdk::types::Command::SplitCoins(split_coins.0.clone())) } /// It merges n-coins into the first coin #[uniffi::constructor] pub fn new_merge_coins(merge_coins: &MergeCoins) -> Self { - Self(iota_types::Command::MergeCoins(merge_coins.0.clone())) + Self(iota_sdk::types::Command::MergeCoins(merge_coins.0.clone())) } /// Publishes a Move package. It takes the package bytes and a list of the /// package's transitive dependencies to link against on-chain. #[uniffi::constructor] pub fn new_publish(publish: &Publish) -> Self { - Self(iota_types::Command::Publish(publish.0.clone())) + Self(iota_sdk::types::Command::Publish(publish.0.clone())) } /// Given n-values of the same type, it constructs a vector. For non objects /// or an empty vector, the type tag must be specified. #[uniffi::constructor] pub fn new_make_move_vector(make_move_vector: &MakeMoveVector) -> Self { - Self(iota_types::Command::MakeMoveVector( + Self(iota_sdk::types::Command::MakeMoveVector( make_move_vector.0.clone(), )) } @@ -442,7 +442,7 @@ impl Command { /// from an earlier command in the same programmable transaction. #[uniffi::constructor] pub fn new_upgrade(upgrade: &Upgrade) -> Self { - Self(iota_types::Command::Upgrade(upgrade.0.clone())) + Self(iota_sdk::types::Command::Upgrade(upgrade.0.clone())) } } @@ -456,13 +456,13 @@ impl Command { /// transfer-objects = (vector argument) argument /// ``` #[derive(derive_more::From, uniffi::Object)] -pub struct TransferObjects(pub iota_types::TransferObjects); +pub struct TransferObjects(pub iota_sdk::types::TransferObjects); #[uniffi::export] impl TransferObjects { #[uniffi::constructor] pub fn new(objects: Vec>, address: Arc) -> Self { - Self(iota_types::TransferObjects { + Self(iota_sdk::types::TransferObjects { objects: objects.iter().map(|argument| argument.0).collect(), address: address.0, }) @@ -495,13 +495,13 @@ impl TransferObjects { /// split-coins = argument (vector argument) /// ``` #[derive(derive_more::From, uniffi::Object)] -pub struct SplitCoins(pub iota_types::SplitCoins); +pub struct SplitCoins(pub iota_sdk::types::SplitCoins); #[uniffi::export] impl SplitCoins { #[uniffi::constructor] pub fn new(coin: &Argument, amounts: Vec>) -> Self { - Self(iota_types::SplitCoins { + Self(iota_sdk::types::SplitCoins { coin: coin.0, amounts: amounts.iter().map(|amount| amount.0).collect(), }) @@ -534,13 +534,13 @@ impl SplitCoins { /// merge-coins = argument (vector argument) /// ``` #[derive(derive_more::From, uniffi::Object)] -pub struct MergeCoins(pub iota_types::MergeCoins); +pub struct MergeCoins(pub iota_sdk::types::MergeCoins); #[uniffi::export] impl MergeCoins { #[uniffi::constructor] pub fn new(coin: &Argument, coins_to_merge: Vec>) -> Self { - Self(iota_types::MergeCoins { + Self(iota_sdk::types::MergeCoins { coin: coin.0, coins_to_merge: coins_to_merge.iter().map(|coin| coin.0).collect(), }) @@ -576,13 +576,13 @@ impl MergeCoins { /// (vector object-id) ; the set of package dependencies /// ``` #[derive(derive_more::From, uniffi::Object)] -pub struct Publish(pub iota_types::Publish); +pub struct Publish(pub iota_sdk::types::Publish); #[uniffi::export] impl Publish { #[uniffi::constructor] pub fn new(modules: Vec>, dependencies: Vec>) -> Self { - Self(iota_types::Publish { + Self(iota_sdk::types::Publish { modules, dependencies: dependencies.iter().map(|object_id| object_id.0).collect(), }) @@ -615,13 +615,13 @@ impl Publish { /// make-move-vector = (option type-tag) (vector argument) /// ``` #[derive(derive_more::From, uniffi::Object)] -pub struct MakeMoveVector(pub iota_types::MakeMoveVector); +pub struct MakeMoveVector(pub iota_sdk::types::MakeMoveVector); #[uniffi::export] impl MakeMoveVector { #[uniffi::constructor] pub fn new(type_tag: Option>, elements: Vec>) -> Self { - Self(iota_types::MakeMoveVector { + Self(iota_sdk::types::MakeMoveVector { type_: type_tag.map(|type_tag| type_tag.0.clone()), elements: elements.iter().map(|element| element.0).collect(), }) @@ -660,7 +660,7 @@ impl MakeMoveVector { /// argument ; upgrade ticket /// ``` #[derive(derive_more::From, uniffi::Object)] -pub struct Upgrade(pub iota_types::Upgrade); +pub struct Upgrade(pub iota_sdk::types::Upgrade); #[uniffi::export] impl Upgrade { @@ -671,7 +671,7 @@ impl Upgrade { package: Arc, ticket: Arc, ) -> Self { - Self(iota_types::Upgrade { + Self(iota_sdk::types::Upgrade { modules, dependencies: dependencies.iter().map(|dependency| dependency.0).collect(), package: package.0, @@ -717,7 +717,7 @@ impl Upgrade { /// consensus-determined-version-assignments /// ``` #[derive(derive_more::From, uniffi::Object)] -pub struct ConsensusCommitPrologueV1(pub iota_types::ConsensusCommitPrologueV1); +pub struct ConsensusCommitPrologueV1(pub iota_sdk::types::ConsensusCommitPrologueV1); #[uniffi::export] impl ConsensusCommitPrologueV1 { @@ -730,7 +730,7 @@ impl ConsensusCommitPrologueV1 { consensus_commit_digest: &Digest, consensus_determined_version_assignments: &ConsensusDeterminedVersionAssignments, ) -> Self { - Self(iota_types::ConsensusCommitPrologueV1 { + Self(iota_sdk::types::ConsensusCommitPrologueV1 { epoch, round, sub_dag_index, @@ -781,7 +781,7 @@ impl ConsensusCommitPrologueV1 { #[derive(derive_more::From, uniffi::Object)] pub struct ConsensusDeterminedVersionAssignments( - pub iota_types::ConsensusDeterminedVersionAssignments, + pub iota_sdk::types::ConsensusDeterminedVersionAssignments, ); #[uniffi::export] @@ -791,7 +791,7 @@ impl ConsensusDeterminedVersionAssignments { cancelled_transactions: Vec>, ) -> Self { Self( - iota_types::ConsensusDeterminedVersionAssignments::CancelledTransactions { + iota_sdk::types::ConsensusDeterminedVersionAssignments::CancelledTransactions { cancelled_transactions: cancelled_transactions .into_iter() .map(|v| v.0.clone()) @@ -825,13 +825,13 @@ impl ConsensusDeterminedVersionAssignments { /// cancelled-transaction = digest (vector version-assignment) /// ``` #[derive(derive_more::From, uniffi::Object)] -pub struct CancelledTransaction(pub iota_types::CancelledTransaction); +pub struct CancelledTransaction(pub iota_sdk::types::CancelledTransaction); #[uniffi::export] impl CancelledTransaction { #[uniffi::constructor] pub fn new(digest: &Digest, version_assignments: Vec>) -> Self { - Self(iota_types::CancelledTransaction { + Self(iota_sdk::types::CancelledTransaction { digest: digest.0, version_assignments: version_assignments .into_iter() @@ -865,13 +865,13 @@ impl CancelledTransaction { /// version-assignment = object-id u64 /// ``` #[derive(derive_more::From, uniffi::Object)] -pub struct VersionAssignment(iota_types::VersionAssignment); +pub struct VersionAssignment(iota_sdk::types::VersionAssignment); #[uniffi::export] impl VersionAssignment { #[uniffi::constructor] pub fn new(object_id: &ObjectId, version: u64) -> Self { - Self(iota_types::VersionAssignment { + Self(iota_sdk::types::VersionAssignment { object_id: object_id.0, version, }) @@ -896,13 +896,13 @@ impl VersionAssignment { /// genesis-transaction = (vector genesis-object) /// ``` #[derive(derive_more::From, uniffi::Object)] -pub struct GenesisTransaction(iota_types::GenesisTransaction); +pub struct GenesisTransaction(iota_sdk::types::GenesisTransaction); #[uniffi::export] impl GenesisTransaction { #[uniffi::constructor] pub fn new(objects: Vec>, events: Vec) -> Self { - Self(iota_types::GenesisTransaction { + Self(iota_sdk::types::GenesisTransaction { objects: objects.iter().map(|object| object.0.clone()).collect(), events: events.into_iter().map(Into::into).collect(), }) @@ -940,7 +940,7 @@ impl GenesisTransaction { /// (vector system-package) /// ``` #[derive(derive_more::From, uniffi::Object)] -pub struct ChangeEpoch(pub iota_types::ChangeEpoch); +pub struct ChangeEpoch(pub iota_sdk::types::ChangeEpoch); #[uniffi::export] impl ChangeEpoch { @@ -956,7 +956,7 @@ impl ChangeEpoch { epoch_start_timestamp_ms: u64, system_packages: Vec>, ) -> Self { - Self(iota_types::ChangeEpoch { + Self(iota_sdk::types::ChangeEpoch { epoch, protocol_version, storage_charge, @@ -1031,13 +1031,13 @@ impl ChangeEpoch { /// (vector object-id) ; dependencies /// ``` #[derive(derive_more::From, uniffi::Object)] -pub struct SystemPackage(pub iota_types::SystemPackage); +pub struct SystemPackage(pub iota_sdk::types::SystemPackage); #[uniffi::export] impl SystemPackage { #[uniffi::constructor] pub fn new(version: Version, modules: Vec>, dependencies: Vec>) -> Self { - Self(iota_types::SystemPackage { + Self(iota_sdk::types::SystemPackage { version, modules, dependencies: dependencies.into_iter().map(|dep| dep.0).collect(), @@ -1081,7 +1081,7 @@ impl SystemPackage { /// (vector system-package) /// ``` #[derive(derive_more::From, uniffi::Object)] -pub struct ChangeEpochV2(pub iota_types::ChangeEpochV2); +pub struct ChangeEpochV2(pub iota_sdk::types::ChangeEpochV2); #[uniffi::export] impl ChangeEpochV2 { @@ -1098,7 +1098,7 @@ impl ChangeEpochV2 { epoch_start_timestamp_ms: u64, system_packages: Vec>, ) -> Self { - Self(iota_types::ChangeEpochV2 { + Self(iota_sdk::types::ChangeEpochV2 { epoch, protocol_version, storage_charge, @@ -1241,13 +1241,13 @@ pub struct ActiveJwk { /// ) /// ``` #[derive(derive_more::From, uniffi::Object)] -pub struct ExecutionTimeObservations(pub iota_types::ExecutionTimeObservations); +pub struct ExecutionTimeObservations(pub iota_sdk::types::ExecutionTimeObservations); #[uniffi::export] impl ExecutionTimeObservations { #[uniffi::constructor] pub fn new_v1(execution_time_observations: Vec>) -> Self { - Self(iota_types::ExecutionTimeObservations::V1( + Self(iota_sdk::types::ExecutionTimeObservations::V1( execution_time_observations .iter() .map(|obs| obs.0.clone()) @@ -1257,7 +1257,7 @@ impl ExecutionTimeObservations { } #[derive(derive_more::From, uniffi::Object)] -pub struct ExecutionTimeObservation(pub iota_types::ExecutionTimeObservation); +pub struct ExecutionTimeObservation(pub iota_sdk::types::ExecutionTimeObservation); #[uniffi::export] impl ExecutionTimeObservation { @@ -1266,7 +1266,7 @@ impl ExecutionTimeObservation { key: &ExecutionTimeObservationKey, observations: Vec>, ) -> Self { - Self(iota_types::ExecutionTimeObservation { + Self(iota_sdk::types::ExecutionTimeObservation { key: key.0.clone(), observations: observations.into_iter().map(|obs| obs.0.clone()).collect(), }) @@ -1299,13 +1299,13 @@ impl ExecutionTimeObservation { /// u32 ; subsecond nanoseconds /// ``` #[derive(derive_more::From, uniffi::Object)] -pub struct ValidatorExecutionTimeObservation(iota_types::ValidatorExecutionTimeObservation); +pub struct ValidatorExecutionTimeObservation(iota_sdk::types::ValidatorExecutionTimeObservation); #[uniffi::export] impl ValidatorExecutionTimeObservation { #[uniffi::constructor] pub fn new(validator: &Bls12381PublicKey, duration: std::time::Duration) -> Self { - Self(iota_types::ValidatorExecutionTimeObservation { + Self(iota_sdk::types::ValidatorExecutionTimeObservation { validator: validator.0, duration, }) @@ -1338,7 +1338,7 @@ impl ValidatorExecutionTimeObservation { /// move-entry-point = object-id string string (vec type-tag) /// ``` #[derive(derive_more::From, uniffi::Object)] -pub struct ExecutionTimeObservationKey(iota_types::ExecutionTimeObservationKey); +pub struct ExecutionTimeObservationKey(iota_sdk::types::ExecutionTimeObservationKey); #[uniffi::export] impl ExecutionTimeObservationKey { @@ -1349,45 +1349,47 @@ impl ExecutionTimeObservationKey { function: String, type_arguments: Vec>, ) -> Self { - Self(iota_types::ExecutionTimeObservationKey::MoveEntryPoint { - package: package.0, - module, - function, - type_arguments: type_arguments - .into_iter() - .map(|tag| tag.0.clone()) - .collect(), - }) + Self( + iota_sdk::types::ExecutionTimeObservationKey::MoveEntryPoint { + package: package.0, + module, + function, + type_arguments: type_arguments + .into_iter() + .map(|tag| tag.0.clone()) + .collect(), + }, + ) } #[uniffi::constructor] pub fn new_transfer_objects() -> Self { - Self(iota_types::ExecutionTimeObservationKey::TransferObjects) + Self(iota_sdk::types::ExecutionTimeObservationKey::TransferObjects) } #[uniffi::constructor] pub fn new_split_coins() -> Self { - Self(iota_types::ExecutionTimeObservationKey::SplitCoins) + Self(iota_sdk::types::ExecutionTimeObservationKey::SplitCoins) } #[uniffi::constructor] pub fn new_merge_coins() -> Self { - Self(iota_types::ExecutionTimeObservationKey::MergeCoins) + Self(iota_sdk::types::ExecutionTimeObservationKey::MergeCoins) } #[uniffi::constructor] pub fn new_publish() -> Self { - Self(iota_types::ExecutionTimeObservationKey::Publish) + Self(iota_sdk::types::ExecutionTimeObservationKey::Publish) } #[uniffi::constructor] pub fn new_make_move_vec() -> Self { - Self(iota_types::ExecutionTimeObservationKey::MakeMoveVec) + Self(iota_sdk::types::ExecutionTimeObservationKey::MakeMoveVec) } #[uniffi::constructor] pub fn new_upgrade() -> Self { - Self(iota_types::ExecutionTimeObservationKey::Upgrade) + Self(iota_sdk::types::ExecutionTimeObservationKey::Upgrade) } } @@ -1438,32 +1440,32 @@ pub struct RandomnessStateUpdate { /// eoe-store-execution-time-observations = %x07 stored-execution-time-observations /// ``` #[derive(derive_more::From, uniffi::Object)] -pub struct EndOfEpochTransactionKind(pub iota_types::EndOfEpochTransactionKind); +pub struct EndOfEpochTransactionKind(pub iota_sdk::types::EndOfEpochTransactionKind); #[uniffi::export] impl EndOfEpochTransactionKind { #[uniffi::constructor] pub fn new_change_epoch(tx: &ChangeEpoch) -> Self { - Self(iota_types::EndOfEpochTransactionKind::ChangeEpoch( + Self(iota_sdk::types::EndOfEpochTransactionKind::ChangeEpoch( tx.0.clone(), )) } #[uniffi::constructor] pub fn new_change_epoch_v2(tx: &ChangeEpochV2) -> Self { - Self(iota_types::EndOfEpochTransactionKind::ChangeEpochV2( + Self(iota_sdk::types::EndOfEpochTransactionKind::ChangeEpochV2( tx.0.clone(), )) } #[uniffi::constructor] pub fn new_authenticator_state_create() -> Self { - Self(iota_types::EndOfEpochTransactionKind::AuthenticatorStateCreate) + Self(iota_sdk::types::EndOfEpochTransactionKind::AuthenticatorStateCreate) } #[uniffi::constructor] pub fn new_authenticator_state_expire(tx: &AuthenticatorStateExpire) -> Self { - Self(iota_types::EndOfEpochTransactionKind::AuthenticatorStateExpire(tx.clone())) + Self(iota_sdk::types::EndOfEpochTransactionKind::AuthenticatorStateExpire(tx.clone())) } } @@ -1493,8 +1495,8 @@ pub struct GasPayment { pub budget: u64, } -impl From for GasPayment { - fn from(value: iota_types::GasPayment) -> Self { +impl From for GasPayment { + fn from(value: iota_sdk::types::GasPayment) -> Self { Self { objects: value.objects.into_iter().map(Into::into).collect(), owner: Arc::new(value.owner.into()), @@ -1504,7 +1506,7 @@ impl From for GasPayment { } } -impl From for iota_types::GasPayment { +impl From for iota_sdk::types::GasPayment { fn from(value: GasPayment) -> Self { Self { objects: value.objects.into_iter().map(Into::into).collect(), @@ -1526,13 +1528,15 @@ impl From for iota_types::GasPayment { /// =/ %x01 effects-v2 /// ``` #[derive(derive_more::From, uniffi::Object)] -pub struct TransactionEffects(pub iota_types::TransactionEffects); +pub struct TransactionEffects(pub iota_sdk::types::TransactionEffects); #[uniffi::export] impl TransactionEffects { #[uniffi::constructor] pub fn new_v1(effects: TransactionEffectsV1) -> Self { - Self(iota_types::TransactionEffects::V1(Box::new(effects.into()))) + Self(iota_sdk::types::TransactionEffects::V1(Box::new( + effects.into(), + ))) } pub fn is_v1(&self) -> bool { @@ -1585,7 +1589,7 @@ pub enum TransactionExpiration { /// argument-nested-result = %x03 u16 u16 /// ``` #[derive(derive_more::Deref, derive_more::From, uniffi::Object)] -pub struct Argument(iota_types::Argument); +pub struct Argument(iota_sdk::types::Argument); #[uniffi::export] impl Argument { @@ -1593,20 +1597,20 @@ impl Argument { /// `TransferObjects`, which can use it by-value. #[uniffi::constructor] pub fn new_gas() -> Self { - Self(iota_types::Argument::Gas) + Self(iota_sdk::types::Argument::Gas) } /// One of the input objects or primitive values (from /// `ProgrammableTransaction` inputs) #[uniffi::constructor] pub fn new_input(input: u16) -> Self { - Self(iota_types::Argument::Input(input)) + Self(iota_sdk::types::Argument::Input(input)) } /// The result of another command (from `ProgrammableTransaction` commands) #[uniffi::constructor] pub fn new_result(result: u16) -> Self { - Self(iota_types::Argument::Result(result)) + Self(iota_sdk::types::Argument::Result(result)) } /// Like a `Result` but it accesses a nested result. Currently, the only @@ -1615,7 +1619,7 @@ impl Argument { // (command index, subresult index) #[uniffi::constructor] pub fn new_nested_result(command_index: u16, subresult_index: u16) -> Self { - Self(iota_types::Argument::NestedResult( + Self(iota_sdk::types::Argument::NestedResult( command_index, subresult_index, )) @@ -1646,7 +1650,7 @@ impl Argument { /// (vector argument) ; input arguments /// ``` #[derive(derive_more::From, uniffi::Object)] -pub struct MoveCall(iota_types::MoveCall); +pub struct MoveCall(iota_sdk::types::MoveCall); #[uniffi::export] impl MoveCall { @@ -1658,7 +1662,7 @@ impl MoveCall { type_arguments: Vec>, arguments: Vec>, ) -> Self { - Self(iota_types::MoveCall { + Self(iota_sdk::types::MoveCall { package: package.0, module: module.0.clone(), function: function.0.clone(), diff --git a/crates/iota-sdk-ffi/src/types/transaction/v1.rs b/crates/iota-sdk-ffi/src/types/transaction/v1.rs index 801f62213..3da07c041 100644 --- a/crates/iota-sdk-ffi/src/types/transaction/v1.rs +++ b/crates/iota-sdk-ffi/src/types/transaction/v1.rs @@ -3,7 +3,7 @@ use std::sync::Arc; -use iota_types::{GasCostSummary, IdOperation}; +use iota_sdk::types::{GasCostSummary, IdOperation}; use crate::types::{ digest::Digest, @@ -69,8 +69,8 @@ pub struct TransactionEffectsV1 { pub auxiliary_data_digest: Option>, } -impl From for TransactionEffectsV1 { - fn from(value: iota_types::TransactionEffectsV1) -> Self { +impl From for TransactionEffectsV1 { + fn from(value: iota_sdk::types::TransactionEffectsV1) -> Self { Self { status: value.status.into(), epoch: value.epoch, @@ -96,7 +96,7 @@ impl From for TransactionEffectsV1 { } } -impl From for iota_types::TransactionEffectsV1 { +impl From for iota_sdk::types::TransactionEffectsV1 { fn from(value: TransactionEffectsV1) -> Self { Self { status: value.status.into(), @@ -141,8 +141,8 @@ pub struct ChangedObject { pub id_operation: IdOperation, } -impl From for ChangedObject { - fn from(value: iota_types::ChangedObject) -> Self { +impl From for ChangedObject { + fn from(value: iota_sdk::types::ChangedObject) -> Self { Self { object_id: Arc::new(value.object_id.into()), input_state: value.input_state.into(), @@ -152,7 +152,7 @@ impl From for ChangedObject { } } -impl From for iota_types::ChangedObject { +impl From for iota_sdk::types::ChangedObject { fn from(value: ChangedObject) -> Self { Self { object_id: **value.object_id, @@ -178,8 +178,8 @@ pub struct UnchangedSharedObject { pub kind: UnchangedSharedKind, } -impl From for UnchangedSharedObject { - fn from(value: iota_types::UnchangedSharedObject) -> Self { +impl From for UnchangedSharedObject { + fn from(value: iota_sdk::types::UnchangedSharedObject) -> Self { Self { object_id: Arc::new(value.object_id.into()), kind: value.kind.into(), @@ -187,7 +187,7 @@ impl From for UnchangedSharedObject { } } -impl From for iota_types::UnchangedSharedObject { +impl From for iota_sdk::types::UnchangedSharedObject { fn from(value: UnchangedSharedObject) -> Self { Self { object_id: **value.object_id, @@ -233,28 +233,30 @@ pub enum UnchangedSharedKind { PerEpochConfig, } -impl From for UnchangedSharedKind { - fn from(value: iota_types::UnchangedSharedKind) -> Self { +impl From for UnchangedSharedKind { + fn from(value: iota_sdk::types::UnchangedSharedKind) -> Self { match value { - iota_types::UnchangedSharedKind::ReadOnlyRoot { version, digest } => { + iota_sdk::types::UnchangedSharedKind::ReadOnlyRoot { version, digest } => { Self::ReadOnlyRoot { version, digest: Arc::new(digest.into()), } } - iota_types::UnchangedSharedKind::MutateDeleted { version } => { + iota_sdk::types::UnchangedSharedKind::MutateDeleted { version } => { Self::MutateDeleted { version } } - iota_types::UnchangedSharedKind::ReadDeleted { version } => { + iota_sdk::types::UnchangedSharedKind::ReadDeleted { version } => { Self::ReadDeleted { version } } - iota_types::UnchangedSharedKind::Cancelled { version } => Self::Cancelled { version }, - iota_types::UnchangedSharedKind::PerEpochConfig => Self::PerEpochConfig, + iota_sdk::types::UnchangedSharedKind::Cancelled { version } => { + Self::Cancelled { version } + } + iota_sdk::types::UnchangedSharedKind::PerEpochConfig => Self::PerEpochConfig, } } } -impl From for iota_types::UnchangedSharedKind { +impl From for iota_sdk::types::UnchangedSharedKind { fn from(value: UnchangedSharedKind) -> Self { match value { UnchangedSharedKind::ReadOnlyRoot { version, digest } => Self::ReadOnlyRoot { @@ -296,11 +298,11 @@ pub enum ObjectIn { }, } -impl From for ObjectIn { - fn from(value: iota_types::ObjectIn) -> Self { +impl From for ObjectIn { + fn from(value: iota_sdk::types::ObjectIn) -> Self { match value { - iota_types::ObjectIn::Missing => Self::Missing, - iota_types::ObjectIn::Data { + iota_sdk::types::ObjectIn::Missing => Self::Missing, + iota_sdk::types::ObjectIn::Data { version, digest, owner, @@ -313,7 +315,7 @@ impl From for ObjectIn { } } -impl From for iota_types::ObjectIn { +impl From for iota_sdk::types::ObjectIn { fn from(value: ObjectIn) -> Self { match value { ObjectIn::Missing => Self::Missing, @@ -360,15 +362,15 @@ pub enum ObjectOut { PackageWrite { version: u64, digest: Arc }, } -impl From for ObjectOut { - fn from(value: iota_types::ObjectOut) -> Self { +impl From for ObjectOut { + fn from(value: iota_sdk::types::ObjectOut) -> Self { match value { - iota_types::ObjectOut::Missing => Self::Missing, - iota_types::ObjectOut::ObjectWrite { digest, owner } => Self::ObjectWrite { + iota_sdk::types::ObjectOut::Missing => Self::Missing, + iota_sdk::types::ObjectOut::ObjectWrite { digest, owner } => Self::ObjectWrite { digest: Arc::new(digest.into()), owner: Arc::new(owner.into()), }, - iota_types::ObjectOut::PackageWrite { version, digest } => Self::PackageWrite { + iota_sdk::types::ObjectOut::PackageWrite { version, digest } => Self::PackageWrite { version, digest: Arc::new(digest.into()), }, @@ -376,7 +378,7 @@ impl From for ObjectOut { } } -impl From for iota_types::ObjectOut { +impl From for iota_sdk::types::ObjectOut { fn from(value: ObjectOut) -> Self { match value { ObjectOut::Missing => Self::Missing, diff --git a/crates/iota-sdk-ffi/src/types/type_tag.rs b/crates/iota-sdk-ffi/src/types/type_tag.rs index b3de66f51..1b89a56fc 100644 --- a/crates/iota-sdk-ffi/src/types/type_tag.rs +++ b/crates/iota-sdk-ffi/src/types/type_tag.rs @@ -38,7 +38,7 @@ use crate::types::struct_tag::StructTag; /// ``` #[derive(derive_more::Display, derive_more::From, uniffi::Object)] #[uniffi::export(Display)] -pub struct TypeTag(pub iota_types::TypeTag); +pub struct TypeTag(pub iota_sdk::types::TypeTag); #[uniffi::export] impl TypeTag { @@ -127,57 +127,61 @@ impl TypeTag { #[uniffi::constructor] pub fn new_u8() -> Self { - Self(iota_types::TypeTag::U8) + Self(iota_sdk::types::TypeTag::U8) } #[uniffi::constructor] pub fn new_u16() -> Self { - Self(iota_types::TypeTag::U16) + Self(iota_sdk::types::TypeTag::U16) } #[uniffi::constructor] pub fn new_u32() -> Self { - Self(iota_types::TypeTag::U32) + Self(iota_sdk::types::TypeTag::U32) } #[uniffi::constructor] pub fn new_u64() -> Self { - Self(iota_types::TypeTag::U64) + Self(iota_sdk::types::TypeTag::U64) } #[uniffi::constructor] pub fn new_u128() -> Self { - Self(iota_types::TypeTag::U128) + Self(iota_sdk::types::TypeTag::U128) } #[uniffi::constructor] pub fn new_u256() -> Self { - Self(iota_types::TypeTag::U256) + Self(iota_sdk::types::TypeTag::U256) } #[uniffi::constructor] pub fn new_bool() -> Self { - Self(iota_types::TypeTag::Bool) + Self(iota_sdk::types::TypeTag::Bool) } #[uniffi::constructor] pub fn new_address() -> Self { - Self(iota_types::TypeTag::Address) + Self(iota_sdk::types::TypeTag::Address) } #[uniffi::constructor] pub fn new_signer() -> Self { - Self(iota_types::TypeTag::Signer) + Self(iota_sdk::types::TypeTag::Signer) } #[uniffi::constructor] pub fn new_vector(type_tag: &TypeTag) -> Self { - Self(iota_types::TypeTag::Vector(Box::new(type_tag.0.clone()))) + Self(iota_sdk::types::TypeTag::Vector(Box::new( + type_tag.0.clone(), + ))) } #[uniffi::constructor] pub fn new_struct(struct_tag: &StructTag) -> Self { - Self(iota_types::TypeTag::Struct(Box::new(struct_tag.0.clone()))) + Self(iota_sdk::types::TypeTag::Struct(Box::new( + struct_tag.0.clone(), + ))) } } diff --git a/crates/iota-sdk-ffi/src/types/validator.rs b/crates/iota-sdk-ffi/src/types/validator.rs index 6d6eab0c9..9a33d84df 100644 --- a/crates/iota-sdk-ffi/src/types/validator.rs +++ b/crates/iota-sdk-ffi/src/types/validator.rs @@ -28,8 +28,8 @@ pub struct ValidatorCommittee { pub members: Vec, } -impl From for ValidatorCommittee { - fn from(value: iota_types::ValidatorCommittee) -> Self { +impl From for ValidatorCommittee { + fn from(value: iota_sdk::types::ValidatorCommittee) -> Self { Self { epoch: value.epoch, members: value.members.into_iter().map(Into::into).collect(), @@ -37,7 +37,7 @@ impl From for ValidatorCommittee { } } -impl From for iota_types::ValidatorCommittee { +impl From for iota_sdk::types::ValidatorCommittee { fn from(value: ValidatorCommittee) -> Self { Self { epoch: value.epoch, @@ -62,8 +62,8 @@ pub struct ValidatorCommitteeMember { pub stake: u64, } -impl From for ValidatorCommitteeMember { - fn from(value: iota_types::ValidatorCommitteeMember) -> Self { +impl From for ValidatorCommitteeMember { + fn from(value: iota_sdk::types::ValidatorCommitteeMember) -> Self { Self { public_key: Arc::new(value.public_key.into()), stake: value.stake, @@ -71,7 +71,7 @@ impl From for ValidatorCommitteeMember { } } -impl From for iota_types::ValidatorCommitteeMember { +impl From for iota_sdk::types::ValidatorCommitteeMember { fn from(value: ValidatorCommitteeMember) -> Self { Self { public_key: **value.public_key, @@ -92,7 +92,7 @@ impl From for iota_types::ValidatorCommitteeMember { /// bls-signature /// ``` #[derive(derive_more::From, uniffi::Object)] -pub struct ValidatorSignature(pub iota_types::ValidatorSignature); +pub struct ValidatorSignature(pub iota_sdk::types::ValidatorSignature); #[uniffi::export] impl ValidatorSignature { @@ -102,7 +102,7 @@ impl ValidatorSignature { public_key: &Bls12381PublicKey, signature: &Bls12381Signature, ) -> Self { - Self(iota_types::ValidatorSignature { + Self(iota_sdk::types::ValidatorSignature { epoch, public_key: **public_key, signature: **signature, @@ -140,13 +140,13 @@ impl ValidatorSignature { /// See for the specification for the /// serialized format of RoaringBitmaps. #[derive(derive_more::From, uniffi::Object)] -pub struct ValidatorAggregatedSignature(pub iota_types::ValidatorAggregatedSignature); +pub struct ValidatorAggregatedSignature(pub iota_sdk::types::ValidatorAggregatedSignature); #[uniffi::export] impl ValidatorAggregatedSignature { #[uniffi::constructor] pub fn new(epoch: EpochId, signature: &Bls12381Signature, bitmap_bytes: &[u8]) -> Result { - Ok(Self(iota_types::ValidatorAggregatedSignature { + Ok(Self(iota_sdk::types::ValidatorAggregatedSignature { epoch, signature: **signature, bitmap: roaring::RoaringBitmap::deserialize_from(bitmap_bytes)?, diff --git a/crates/iota-sdk-ffi/src/uniffi_helpers.rs b/crates/iota-sdk-ffi/src/uniffi_helpers.rs index b1c97b4bb..e565bcc58 100644 --- a/crates/iota-sdk-ffi/src/uniffi_helpers.rs +++ b/crates/iota-sdk-ffi/src/uniffi_helpers.rs @@ -1,7 +1,7 @@ // Copyright (c) 2025 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -use iota_graphql_client::query_types::{Base64, BigInt, PageInfo}; +use iota_sdk::graphql_client::query_types::{Base64, BigInt, PageInfo}; use serde_json::Value; use crate::types::{ @@ -26,8 +26,8 @@ macro_rules! define_paged_record { pub data: Vec<$type_>, } - impl From> for $id { - fn from(value: iota_graphql_client::pagination::Page<$type_>) -> Self { + impl From> for $id { + fn from(value: iota_sdk::graphql_client::pagination::Page<$type_>) -> Self { Self { page_info: value.page_info.into(), data: value.data, @@ -56,8 +56,8 @@ macro_rules! define_paged_object { pub data: Vec>, } - impl From> for $id { - fn from(value: iota_graphql_client::pagination::Page<$type_>) -> Self { + impl From> for $id { + fn from(value: iota_sdk::graphql_client::pagination::Page<$type_>) -> Self { Self { page_info: value.page_info.into(), data: value diff --git a/crates/iota-graphql-client-build/Cargo.toml b/crates/iota-sdk-graphql-client-build/Cargo.toml similarity index 88% rename from crates/iota-graphql-client-build/Cargo.toml rename to crates/iota-sdk-graphql-client-build/Cargo.toml index e5e7325ce..d0e84da23 100644 --- a/crates/iota-graphql-client-build/Cargo.toml +++ b/crates/iota-sdk-graphql-client-build/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "iota-graphql-client-build" +name = "iota-sdk-graphql-client-build" version = "0.0.1" authors = ["IOTA Foundation "] edition = "2021" diff --git a/crates/iota-graphql-client-build/README.md b/crates/iota-sdk-graphql-client-build/README.md similarity index 65% rename from crates/iota-graphql-client-build/README.md rename to crates/iota-sdk-graphql-client-build/README.md index c9c4f6c43..2845bfc53 100644 --- a/crates/iota-graphql-client-build/README.md +++ b/crates/iota-sdk-graphql-client-build/README.md @@ -9,7 +9,7 @@ this function in a `build.rs` file in your crate if you need to build custom que ```toml [build-dependencies] -iota-graphql-client-build = { git = "https://github.com/iotaledger/iota-rust-sdk", package = "iota-graphql-client-build", branch = "develop" } +iota-sdk-graphql-client-build = { git = "https://github.com/iotaledger/iota-rust-sdk", package = "iota-sdk-graphql-client-build", branch = "develop" } ``` 2. Add a `build.rs` file in your crate root directory and call the `register_schema` function in it. @@ -22,17 +22,17 @@ fn main() { } ``` -3. Add the `cynic` and `iota-graphql-client` dependencies in your `Cargo.toml` file. You should have something like this. +3. Add the `cynic` and `iota-sdk-graphql-client` dependencies in your `Cargo.toml` file. You should have something like this. ```toml # Cargo.toml # ... [dependencies] cynic = "3.8.0" -iota-graphql-client = { git = "https://github.com/iotaledger/iota-rust-sdk", package = "iota-graphql-client", branch = "develop" } +iota-sdk-graphql-client = { git = "https://github.com/iotaledger/iota-rust-sdk", package = "iota-sdk-graphql-client", branch = "develop" } [build-dependencies] -iota-graphql-client-build = { git = "https://github.com/iotaledger/iota-rust-sdk", package = "iota-graphql-client-build", branch = "develop" } +iota-sdk-graphql-client-build = { git = "https://github.com/iotaledger/iota-rust-sdk", package = "iota-sdk-graphql-client-build", branch = "develop" } ``` 4. If using `cynic`, use the cynic generator to generate the Rust types from the GraphQL schema.\ @@ -62,6 +62,6 @@ async fn main() { } ``` -6. For `UInt53`, you can use `u64` type directly as the `iota-graphql-client`'s schema implements the `impl_scalar`. Similarly for other types (Base64, DateTime). See more available types here: +6. For `UInt53`, you can use `u64` type directly as the `iota-sdk-graphql-client`'s schema implements the `impl_scalar`. Similarly for other types (Base64, DateTime). See more available types here: 7. Read the `cynic` [documentation](https://cynic-rs.dev/) to learn how to work with it, particularly when it comes to passing arguments to the query. diff --git a/crates/iota-graphql-client-build/schema.graphql b/crates/iota-sdk-graphql-client-build/schema.graphql similarity index 100% rename from crates/iota-graphql-client-build/schema.graphql rename to crates/iota-sdk-graphql-client-build/schema.graphql diff --git a/crates/iota-graphql-client-build/src/lib.rs b/crates/iota-sdk-graphql-client-build/src/lib.rs similarity index 100% rename from crates/iota-graphql-client-build/src/lib.rs rename to crates/iota-sdk-graphql-client-build/src/lib.rs diff --git a/crates/iota-graphql-client/Cargo.toml b/crates/iota-sdk-graphql-client/Cargo.toml similarity index 70% rename from crates/iota-graphql-client/Cargo.toml rename to crates/iota-sdk-graphql-client/Cargo.toml index b5b7af386..a899d8c63 100644 --- a/crates/iota-graphql-client/Cargo.toml +++ b/crates/iota-sdk-graphql-client/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "iota-graphql-client" +name = "iota-sdk-graphql-client" version = "0.0.1" authors = ["IOTA Foundation "] edition = "2021" @@ -24,15 +24,15 @@ tokio = { workspace = true, features = ["time"] } tracing = "0.1.37" url = "2.5.3" -iota-types = { package = "iota-sdk-types", path = "../iota-sdk-types", features = ["serde"] } +iota-types = { workspace = true, features = ["serde"] } [dev-dependencies] hex.workspace = true rand.workspace = true -iota-crypto = { path = "../iota-crypto", features = ["ed25519", "pem", "bech32"] } -iota-transaction-builder = { path = "../iota-transaction-builder" } -iota-types = { package = "iota-sdk-types", path = "../iota-sdk-types", features = ["serde", "rand", "hash"] } +iota-crypto = { workspace = true, features = ["ed25519", "pem", "bech32"] } +iota-transaction-builder.workspace = true +iota-types = { workspace = true, features = ["serde", "rand", "hash"] } [target.'cfg(target_arch = "wasm32")'.dev-dependencies] tokio = { workspace = true, features = ["macros", "rt"] } @@ -41,4 +41,4 @@ tokio = { workspace = true, features = ["macros", "rt"] } tokio = { workspace = true, features = ["full"] } [build-dependencies] -iota-graphql-client-build = { path = "../iota-graphql-client-build" } +iota-graphql-client-build.workspace = true diff --git a/crates/iota-graphql-client/Makefile b/crates/iota-sdk-graphql-client/Makefile similarity index 100% rename from crates/iota-graphql-client/Makefile rename to crates/iota-sdk-graphql-client/Makefile diff --git a/crates/iota-graphql-client/README.md b/crates/iota-sdk-graphql-client/README.md similarity index 92% rename from crates/iota-graphql-client/README.md rename to crates/iota-sdk-graphql-client/README.md index 4327ebd17..5e1636642 100644 --- a/crates/iota-graphql-client/README.md +++ b/crates/iota-sdk-graphql-client/README.md @@ -1,8 +1,8 @@ -# iota-graphql-client +# iota-sdk-graphql-client -[![iota-graphql-client on crates.io](https://img.shields.io/crates/v/iota-graphql-client)](https://crates.io/crates/iota-graphql-client) -[![Documentation (latest release)](https://img.shields.io/badge/docs-latest-brightgreen)](https://docs.rs/iota-graphql-client) -[![Documentation (develop)](https://img.shields.io/badge/docs-develop-59f)](https://github.com/iotaledger/iota-rust-sdk/iota-graphql-client/) +[![iota-sdk-graphql-client on crates.io](https://img.shields.io/crates/v/iota-sdk-graphql-client)](https://crates.io/crates/iota-sdk-graphql-client) +[![Documentation (latest release)](https://img.shields.io/badge/docs-latest-brightgreen)](https://docs.rs/iota-sdk-graphql-client) +[![Documentation (develop)](https://img.shields.io/badge/docs-develop-59f)](https://github.com/iotaledger/iota-rust-sdk/iota-sdk-graphql-client/) The IOTA GraphQL client is a client for interacting with the IOTA blockchain via GraphQL. It provides a set of APIs for querying the blockchain for information such as chain identifier, @@ -123,7 +123,7 @@ query CustomQuery($id: UInt53) { } ``` -When using `cynic` and `iota-graphql-client`, you will need to register the schema by calling `iota-graphql-client-build::register_schema` in a `build.rs` file. See [iota-graphql-client-build](https://github.com/iotaledger/iota-rust-sdk/tree/develop/crates/iota-graphql-client-build) for more information. +When using `cynic` and `iota-sdk-graphql-client`, you will need to register the schema by calling `iota-sdk-graphql-client-build::register_schema` in a `build.rs` file. See [iota-sdk-graphql-client-build](https://github.com/iotaledger/iota-rust-sdk/tree/develop/crates/iota-sdk-graphql-client-build) for more information. The generated query types are defined below. Note that the `id` variable is optional (to make it mandatory change the schema to $id: Uint53! -- note the ! character which indicates a mandatory field). That means that if the `id` variable is not provided, the query will return the data for the last known epoch. Note that instead of using `Uint53`, the scalar is mapped to `u64` in the library using `impl_scalar(u64, schema::Uint53)`, thus all references to `Uint53` in the schema are replaced with `u64` in the code below. diff --git a/crates/iota-graphql-client/build.rs b/crates/iota-sdk-graphql-client/build.rs similarity index 100% rename from crates/iota-graphql-client/build.rs rename to crates/iota-sdk-graphql-client/build.rs diff --git a/crates/iota-graphql-client/queries/coin_metadata.graphql b/crates/iota-sdk-graphql-client/queries/coin_metadata.graphql similarity index 100% rename from crates/iota-graphql-client/queries/coin_metadata.graphql rename to crates/iota-sdk-graphql-client/queries/coin_metadata.graphql diff --git a/crates/iota-graphql-client/queries/custom_query.graphql b/crates/iota-sdk-graphql-client/queries/custom_query.graphql similarity index 100% rename from crates/iota-graphql-client/queries/custom_query.graphql rename to crates/iota-sdk-graphql-client/queries/custom_query.graphql diff --git a/crates/iota-graphql-client/queries/epoch_total_checkpoints.graphql b/crates/iota-sdk-graphql-client/queries/epoch_total_checkpoints.graphql similarity index 100% rename from crates/iota-graphql-client/queries/epoch_total_checkpoints.graphql rename to crates/iota-sdk-graphql-client/queries/epoch_total_checkpoints.graphql diff --git a/crates/iota-graphql-client/queries/object.graphql b/crates/iota-sdk-graphql-client/queries/object.graphql similarity index 100% rename from crates/iota-graphql-client/queries/object.graphql rename to crates/iota-sdk-graphql-client/queries/object.graphql diff --git a/crates/iota-graphql-client/queries/objects.graphql b/crates/iota-sdk-graphql-client/queries/objects.graphql similarity index 100% rename from crates/iota-graphql-client/queries/objects.graphql rename to crates/iota-sdk-graphql-client/queries/objects.graphql diff --git a/crates/iota-graphql-client/src/error.rs b/crates/iota-sdk-graphql-client/src/error.rs similarity index 100% rename from crates/iota-graphql-client/src/error.rs rename to crates/iota-sdk-graphql-client/src/error.rs diff --git a/crates/iota-graphql-client/src/faucet.rs b/crates/iota-sdk-graphql-client/src/faucet.rs similarity index 100% rename from crates/iota-graphql-client/src/faucet.rs rename to crates/iota-sdk-graphql-client/src/faucet.rs diff --git a/crates/iota-graphql-client/src/lib.rs b/crates/iota-sdk-graphql-client/src/lib.rs similarity index 100% rename from crates/iota-graphql-client/src/lib.rs rename to crates/iota-sdk-graphql-client/src/lib.rs diff --git a/crates/iota-graphql-client/src/output_types/mod.rs b/crates/iota-sdk-graphql-client/src/output_types/mod.rs similarity index 100% rename from crates/iota-graphql-client/src/output_types/mod.rs rename to crates/iota-sdk-graphql-client/src/output_types/mod.rs diff --git a/crates/iota-graphql-client/src/pagination.rs b/crates/iota-sdk-graphql-client/src/pagination.rs similarity index 100% rename from crates/iota-graphql-client/src/pagination.rs rename to crates/iota-sdk-graphql-client/src/pagination.rs diff --git a/crates/iota-graphql-client/src/query_types/active_validators.rs b/crates/iota-sdk-graphql-client/src/query_types/active_validators.rs similarity index 100% rename from crates/iota-graphql-client/src/query_types/active_validators.rs rename to crates/iota-sdk-graphql-client/src/query_types/active_validators.rs diff --git a/crates/iota-graphql-client/src/query_types/balance.rs b/crates/iota-sdk-graphql-client/src/query_types/balance.rs similarity index 100% rename from crates/iota-graphql-client/src/query_types/balance.rs rename to crates/iota-sdk-graphql-client/src/query_types/balance.rs diff --git a/crates/iota-graphql-client/src/query_types/chain.rs b/crates/iota-sdk-graphql-client/src/query_types/chain.rs similarity index 100% rename from crates/iota-graphql-client/src/query_types/chain.rs rename to crates/iota-sdk-graphql-client/src/query_types/chain.rs diff --git a/crates/iota-graphql-client/src/query_types/checkpoint.rs b/crates/iota-sdk-graphql-client/src/query_types/checkpoint.rs similarity index 100% rename from crates/iota-graphql-client/src/query_types/checkpoint.rs rename to crates/iota-sdk-graphql-client/src/query_types/checkpoint.rs diff --git a/crates/iota-graphql-client/src/query_types/coin.rs b/crates/iota-sdk-graphql-client/src/query_types/coin.rs similarity index 100% rename from crates/iota-graphql-client/src/query_types/coin.rs rename to crates/iota-sdk-graphql-client/src/query_types/coin.rs diff --git a/crates/iota-graphql-client/src/query_types/dry_run.rs b/crates/iota-sdk-graphql-client/src/query_types/dry_run.rs similarity index 100% rename from crates/iota-graphql-client/src/query_types/dry_run.rs rename to crates/iota-sdk-graphql-client/src/query_types/dry_run.rs diff --git a/crates/iota-graphql-client/src/query_types/dynamic_fields.rs b/crates/iota-sdk-graphql-client/src/query_types/dynamic_fields.rs similarity index 100% rename from crates/iota-graphql-client/src/query_types/dynamic_fields.rs rename to crates/iota-sdk-graphql-client/src/query_types/dynamic_fields.rs diff --git a/crates/iota-graphql-client/src/query_types/epoch.rs b/crates/iota-sdk-graphql-client/src/query_types/epoch.rs similarity index 100% rename from crates/iota-graphql-client/src/query_types/epoch.rs rename to crates/iota-sdk-graphql-client/src/query_types/epoch.rs diff --git a/crates/iota-graphql-client/src/query_types/events.rs b/crates/iota-sdk-graphql-client/src/query_types/events.rs similarity index 100% rename from crates/iota-graphql-client/src/query_types/events.rs rename to crates/iota-sdk-graphql-client/src/query_types/events.rs diff --git a/crates/iota-graphql-client/src/query_types/execute_tx.rs b/crates/iota-sdk-graphql-client/src/query_types/execute_tx.rs similarity index 100% rename from crates/iota-graphql-client/src/query_types/execute_tx.rs rename to crates/iota-sdk-graphql-client/src/query_types/execute_tx.rs diff --git a/crates/iota-graphql-client/src/query_types/iota_names.rs b/crates/iota-sdk-graphql-client/src/query_types/iota_names.rs similarity index 100% rename from crates/iota-graphql-client/src/query_types/iota_names.rs rename to crates/iota-sdk-graphql-client/src/query_types/iota_names.rs diff --git a/crates/iota-graphql-client/src/query_types/mod.rs b/crates/iota-sdk-graphql-client/src/query_types/mod.rs similarity index 100% rename from crates/iota-graphql-client/src/query_types/mod.rs rename to crates/iota-sdk-graphql-client/src/query_types/mod.rs diff --git a/crates/iota-graphql-client/src/query_types/normalized_move/function.rs b/crates/iota-sdk-graphql-client/src/query_types/normalized_move/function.rs similarity index 100% rename from crates/iota-graphql-client/src/query_types/normalized_move/function.rs rename to crates/iota-sdk-graphql-client/src/query_types/normalized_move/function.rs diff --git a/crates/iota-graphql-client/src/query_types/normalized_move/mod.rs b/crates/iota-sdk-graphql-client/src/query_types/normalized_move/mod.rs similarity index 100% rename from crates/iota-graphql-client/src/query_types/normalized_move/mod.rs rename to crates/iota-sdk-graphql-client/src/query_types/normalized_move/mod.rs diff --git a/crates/iota-graphql-client/src/query_types/normalized_move/module.rs b/crates/iota-sdk-graphql-client/src/query_types/normalized_move/module.rs similarity index 100% rename from crates/iota-graphql-client/src/query_types/normalized_move/module.rs rename to crates/iota-sdk-graphql-client/src/query_types/normalized_move/module.rs diff --git a/crates/iota-graphql-client/src/query_types/object.rs b/crates/iota-sdk-graphql-client/src/query_types/object.rs similarity index 100% rename from crates/iota-graphql-client/src/query_types/object.rs rename to crates/iota-sdk-graphql-client/src/query_types/object.rs diff --git a/crates/iota-graphql-client/src/query_types/packages.rs b/crates/iota-sdk-graphql-client/src/query_types/packages.rs similarity index 100% rename from crates/iota-graphql-client/src/query_types/packages.rs rename to crates/iota-sdk-graphql-client/src/query_types/packages.rs diff --git a/crates/iota-graphql-client/src/query_types/protocol_config.rs b/crates/iota-sdk-graphql-client/src/query_types/protocol_config.rs similarity index 100% rename from crates/iota-graphql-client/src/query_types/protocol_config.rs rename to crates/iota-sdk-graphql-client/src/query_types/protocol_config.rs diff --git a/crates/iota-graphql-client/src/query_types/service_config.rs b/crates/iota-sdk-graphql-client/src/query_types/service_config.rs similarity index 100% rename from crates/iota-graphql-client/src/query_types/service_config.rs rename to crates/iota-sdk-graphql-client/src/query_types/service_config.rs diff --git a/crates/iota-graphql-client/src/query_types/transaction.rs b/crates/iota-sdk-graphql-client/src/query_types/transaction.rs similarity index 100% rename from crates/iota-graphql-client/src/query_types/transaction.rs rename to crates/iota-sdk-graphql-client/src/query_types/transaction.rs diff --git a/crates/iota-graphql-client/src/streams.rs b/crates/iota-sdk-graphql-client/src/streams.rs similarity index 100% rename from crates/iota-graphql-client/src/streams.rs rename to crates/iota-sdk-graphql-client/src/streams.rs diff --git a/crates/iota-transaction-builder/Cargo.toml b/crates/iota-sdk-transaction-builder/Cargo.toml similarity index 67% rename from crates/iota-transaction-builder/Cargo.toml rename to crates/iota-sdk-transaction-builder/Cargo.toml index 885fa4610..c7def96e9 100644 --- a/crates/iota-transaction-builder/Cargo.toml +++ b/crates/iota-sdk-transaction-builder/Cargo.toml @@ -1,9 +1,10 @@ [package] -name = "iota-transaction-builder" +name = "iota-sdk-transaction-builder" version = "0.0.1" authors = ["IOTA Foundation "] edition = "2021" license = "Apache-2.0" +repository = "https://github.com/iotaledger/iota-rust-sdk/" description = "Transaction API for the IOTA Blockchain Rust SDK" [dependencies] @@ -17,9 +18,9 @@ serde_json.workspace = true thiserror.workspace = true variadics_please = "1.1" -iota-crypto = { package = "iota-crypto", path = "../iota-crypto", features = ["ed25519"] } -iota-graphql-client = { package = "iota-graphql-client", path = "../iota-graphql-client" } -iota-types = { package = "iota-sdk-types", path = "../iota-sdk-types", features = ["serde", "hash"] } +iota-crypto = { workspace = true, features = ["ed25519"] } +iota-graphql-client.workspace = true +iota-types = { workspace = true, features = ["serde", "hash"] } [target.'cfg(target_arch = "wasm32")'.dependencies] getrandom = { version = "0.2", features = ["js"] } @@ -33,4 +34,4 @@ eyre.workspace = true rand.workspace = true serde_json.workspace = true -iota-types = { package = "iota-sdk-types", path = "../iota-sdk-types", features = ["rand"] } +iota-types = { workspace = true, features = ["rand"] } diff --git a/crates/iota-transaction-builder/Makefile b/crates/iota-sdk-transaction-builder/Makefile similarity index 100% rename from crates/iota-transaction-builder/Makefile rename to crates/iota-sdk-transaction-builder/Makefile diff --git a/crates/iota-transaction-builder/src/builder/gas_station.rs b/crates/iota-sdk-transaction-builder/src/builder/gas_station.rs similarity index 100% rename from crates/iota-transaction-builder/src/builder/gas_station.rs rename to crates/iota-sdk-transaction-builder/src/builder/gas_station.rs diff --git a/crates/iota-transaction-builder/src/builder/mod.rs b/crates/iota-sdk-transaction-builder/src/builder/mod.rs similarity index 98% rename from crates/iota-transaction-builder/src/builder/mod.rs rename to crates/iota-sdk-transaction-builder/src/builder/mod.rs index 67d7e9ba5..52296a80c 100644 --- a/crates/iota-transaction-builder/src/builder/mod.rs +++ b/crates/iota-sdk-transaction-builder/src/builder/mod.rs @@ -338,7 +338,7 @@ impl TransactionBuilder { /// ``` /// # use std::str::FromStr; /// # use iota_types::{Address, Digest, Transaction, ObjectId, ObjectReference}; - /// # use iota_transaction_builder::{TransactionBuilder, res}; + /// # use iota_sdk_transaction_builder::{TransactionBuilder, res}; /// /// # #[tokio::main(flavor = "current_thread")] /// # async fn main() -> eyre::Result<()> { @@ -406,7 +406,7 @@ impl TransactionBuilder { /// /// ```rust /// use iota_graphql_client::Client; - /// use iota_transaction_builder::TransactionBuilder; + /// use iota_sdk_transaction_builder::TransactionBuilder; /// use iota_types::Address; /// /// # #[tokio::main(flavor = "current_thread")] @@ -497,7 +497,7 @@ impl TransactionBuilder { /// /// ```rust /// use iota_graphql_client::Client; - /// use iota_transaction_builder::TransactionBuilder; + /// use iota_sdk_transaction_builder::TransactionBuilder; /// use iota_types::{Address, ObjectId}; /// /// # #[tokio::main(flavor = "current_thread")] @@ -578,7 +578,7 @@ impl TransactionBuilder { /// /// ```rust /// use iota_graphql_client::Client; - /// use iota_transaction_builder::TransactionBuilder; + /// use iota_sdk_transaction_builder::TransactionBuilder; /// use iota_types::{Address, ObjectId}; /// /// # #[tokio::main(flavor = "current_thread")] @@ -619,7 +619,7 @@ impl TransactionBuilder { /// /// ```rust /// use iota_graphql_client::Client; - /// use iota_transaction_builder::TransactionBuilder; + /// use iota_sdk_transaction_builder::TransactionBuilder; /// use iota_types::{Address, ObjectId}; /// /// # #[tokio::main(flavor = "current_thread")] @@ -657,7 +657,7 @@ impl TransactionBuilder { /// /// ``` /// # use std::str::FromStr; - /// # use iota_transaction_builder::{TransactionBuilder, res}; + /// # use iota_sdk_transaction_builder::{TransactionBuilder, res}; /// # use iota_types::{Address, Transaction}; /// /// # #[tokio::main(flavor = "current_thread")] @@ -706,7 +706,7 @@ impl TransactionBuilder<(), L> { /// ``` /// # use std::str::FromStr; /// # use iota_types::{Address, Digest, Transaction, ObjectId, ObjectReference}; - /// # use iota_transaction_builder::{TransactionBuilder, res, unresolved}; + /// # use iota_sdk_transaction_builder::{TransactionBuilder, res, unresolved}; /// /// let sender = /// Address::from_str("0x611830d3641a68f94a690dcc25d1f4b0dac948325ac18f6dd32564371735f32c")?; @@ -816,7 +816,7 @@ impl TransactionBuilder { /// ``` /// # use std::str::FromStr; /// # use iota_types::{Address, Digest, Transaction, ObjectId, ObjectReference}; - /// # use iota_transaction_builder::{TransactionBuilder, res, unresolved}; + /// # use iota_sdk_transaction_builder::{TransactionBuilder, res, unresolved}; /// /// # #[tokio::main(flavor = "current_thread")] /// # async fn main() -> eyre::Result<()> { diff --git a/crates/iota-transaction-builder/src/builder/named_results.rs b/crates/iota-sdk-transaction-builder/src/builder/named_results.rs similarity index 100% rename from crates/iota-transaction-builder/src/builder/named_results.rs rename to crates/iota-sdk-transaction-builder/src/builder/named_results.rs diff --git a/crates/iota-transaction-builder/src/builder/ptb_arguments.rs b/crates/iota-sdk-transaction-builder/src/builder/ptb_arguments.rs similarity index 100% rename from crates/iota-transaction-builder/src/builder/ptb_arguments.rs rename to crates/iota-sdk-transaction-builder/src/builder/ptb_arguments.rs diff --git a/crates/iota-transaction-builder/src/error.rs b/crates/iota-sdk-transaction-builder/src/error.rs similarity index 100% rename from crates/iota-transaction-builder/src/error.rs rename to crates/iota-sdk-transaction-builder/src/error.rs diff --git a/crates/iota-transaction-builder/src/lib.rs b/crates/iota-sdk-transaction-builder/src/lib.rs similarity index 98% rename from crates/iota-transaction-builder/src/lib.rs rename to crates/iota-sdk-transaction-builder/src/lib.rs index ae92ee6e3..d176b2d45 100644 --- a/crates/iota-transaction-builder/src/lib.rs +++ b/crates/iota-sdk-transaction-builder/src/lib.rs @@ -24,7 +24,7 @@ //! ``` //! # use std::str::FromStr; //! use iota_graphql_client::Client; -//! use iota_transaction_builder::TransactionBuilder; +//! use iota_sdk_transaction_builder::TransactionBuilder; //! use iota_types::{Address, ObjectId, Transaction}; //! //! # #[tokio::main(flavor = "current_thread")] @@ -51,7 +51,7 @@ //! //! ``` //! # use std::str::FromStr; -//! use iota_transaction_builder::TransactionBuilder; +//! use iota_sdk_transaction_builder::TransactionBuilder; //! use iota_types::{Address, Digest, ObjectId, ObjectReference, Transaction}; //! //! let sender = @@ -253,7 +253,7 @@ //! //! ``` //! # use std::str::FromStr; -//! # use iota_transaction_builder::types::{MoveArg, MoveType, PureBytes}; +//! # use iota_sdk_transaction_builder::types::{MoveArg, MoveType, PureBytes}; //! # use iota_types::TypeTag; //! #[derive(serde::Serialize)] //! struct MyStruct { @@ -312,7 +312,7 @@ mod tests { /// `test_example_v1 and test_example_v2` projects in the tests /// directory. The json files are generated automatically when running /// `make test-with-localnet` in the root of the - /// iota-transaction-builder crate. + /// iota-sdk-transaction-builder crate. fn move_package_data(file: &str) -> MovePackageData { let data = std::fs::read_to_string(file) .with_context(|| { diff --git a/crates/iota-transaction-builder/src/types/mod.rs b/crates/iota-sdk-transaction-builder/src/types/mod.rs similarity index 100% rename from crates/iota-transaction-builder/src/types/mod.rs rename to crates/iota-sdk-transaction-builder/src/types/mod.rs diff --git a/crates/iota-transaction-builder/src/types/move_arg.rs b/crates/iota-sdk-transaction-builder/src/types/move_arg.rs similarity index 100% rename from crates/iota-transaction-builder/src/types/move_arg.rs rename to crates/iota-sdk-transaction-builder/src/types/move_arg.rs diff --git a/crates/iota-transaction-builder/src/types/move_type.rs b/crates/iota-sdk-transaction-builder/src/types/move_type.rs similarity index 100% rename from crates/iota-transaction-builder/src/types/move_type.rs rename to crates/iota-sdk-transaction-builder/src/types/move_type.rs diff --git a/crates/iota-transaction-builder/src/unresolved.rs b/crates/iota-sdk-transaction-builder/src/unresolved.rs similarity index 100% rename from crates/iota-transaction-builder/src/unresolved.rs rename to crates/iota-sdk-transaction-builder/src/unresolved.rs diff --git a/crates/iota-transaction-builder/tests/test_example_v1/Move.toml b/crates/iota-sdk-transaction-builder/tests/test_example_v1/Move.toml similarity index 100% rename from crates/iota-transaction-builder/tests/test_example_v1/Move.toml rename to crates/iota-sdk-transaction-builder/tests/test_example_v1/Move.toml diff --git a/crates/iota-transaction-builder/tests/test_example_v1/sources/test_example.move b/crates/iota-sdk-transaction-builder/tests/test_example_v1/sources/test_example.move similarity index 100% rename from crates/iota-transaction-builder/tests/test_example_v1/sources/test_example.move rename to crates/iota-sdk-transaction-builder/tests/test_example_v1/sources/test_example.move diff --git a/crates/iota-transaction-builder/tests/test_example_v2/Move.toml b/crates/iota-sdk-transaction-builder/tests/test_example_v2/Move.toml similarity index 100% rename from crates/iota-transaction-builder/tests/test_example_v2/Move.toml rename to crates/iota-sdk-transaction-builder/tests/test_example_v2/Move.toml diff --git a/crates/iota-transaction-builder/tests/test_example_v2/sources/test_example.move b/crates/iota-sdk-transaction-builder/tests/test_example_v2/sources/test_example.move similarity index 100% rename from crates/iota-transaction-builder/tests/test_example_v2/sources/test_example.move rename to crates/iota-sdk-transaction-builder/tests/test_example_v2/sources/test_example.move diff --git a/crates/iota-sdk-types/Cargo.toml b/crates/iota-sdk-types/Cargo.toml index b32b3bb5e..dccfa89ad 100644 --- a/crates/iota-sdk-types/Cargo.toml +++ b/crates/iota-sdk-types/Cargo.toml @@ -4,7 +4,6 @@ version = "0.0.1" authors = ["IOTA Foundation "] edition = "2021" license = "Apache-2.0" -publish = false readme = "README.md" repository = "https://github.com/iotaledger/iota-rust-sdk/" description = "Core types for the IOTA SDK" diff --git a/crates/iota-sdk/Cargo.toml b/crates/iota-sdk/Cargo.toml index 4a955930f..6f4d9cbd5 100644 --- a/crates/iota-sdk/Cargo.toml +++ b/crates/iota-sdk/Cargo.toml @@ -4,6 +4,8 @@ version = "3.0.0" authors = ["IOTA Foundation "] edition = "2021" license = "Apache-2.0" +readme = "../../README.md" +repository = "https://github.com/iotaledger/iota-rust-sdk/" description = "The official SDK for IOTA" [features] @@ -16,6 +18,7 @@ default = [ "zklogin", "pem", "bls12381", + "bech32", "graphql", "txn-builder", "types", @@ -35,6 +38,7 @@ secp256k1 = ["crypto", "iota-crypto/secp256k1"] zklogin = ["crypto", "iota-crypto/zklogin"] pem = ["crypto", "iota-crypto/pem"] bls12381 = ["crypto", "iota-crypto/bls12381"] +bech32 = ["crypto", "iota-crypto/bech32"] # GraphQL graphql = ["dep:iota-graphql-client"] @@ -51,10 +55,10 @@ proptest = ["types", "iota-types/proptest"] schemars = ["types", "iota-types/schemars"] [dependencies] -iota-crypto = { path = "../iota-crypto", features = ["ed25519"], optional = true } -iota-graphql-client = { path = "../iota-graphql-client", optional = true } -iota-transaction-builder = { path = "../iota-transaction-builder", optional = true } -iota-types = { package = "iota-sdk-types", path = "../iota-sdk-types", features = ["rand"], optional = true } +iota-crypto = { workspace = true, features = ["ed25519"], optional = true } +iota-graphql-client = { workspace = true, optional = true } +iota-transaction-builder = { workspace = true, optional = true } +iota-types = { workspace = true, features = ["rand"], optional = true } [dev-dependencies] base64ct = { workspace = true, features = ["alloc", "std"] } @@ -68,4 +72,4 @@ serde_json.workspace = true tokio = { workspace = true, features = ["full"] } [build-dependencies] -iota-graphql-client-build = { path = "../iota-graphql-client-build" } +iota-graphql-client-build.workspace = true