From c0a3f97e77aadceacdf11671d2089bd1cd5760e1 Mon Sep 17 00:00:00 2001 From: Filippo Neysofu Costa Date: Mon, 24 Jul 2023 17:32:03 +0200 Subject: [PATCH] Hide `sov-modules-macros` for all public APIs; re-export from `sov-modules-api` (#542) * Re-export macros for `sov-modules-api` * Remove direct use of `sov-modules-macros` * Update all docs * Fix intradoc links * Fix macros module doc comment & import * Fix all tests * Fix default features * Fix README code example --- examples/demo-nft-module/Cargo.toml | 3 +- examples/demo-nft-module/README.md | 19 +++++------- examples/demo-nft-module/src/lib.rs | 3 +- examples/demo-prover/Cargo.lock | 7 +---- examples/demo-prover/methods/guest/Cargo.lock | 8 +---- examples/demo-stf/Cargo.toml | 14 ++++----- examples/demo-stf/src/batch_builder.rs | 4 +-- examples/demo-stf/src/runtime.rs | 6 ++-- module-system/README.md | 2 +- module-system/RPC_WALKTHROUGH.md | 2 +- .../examples/sov-election/Cargo.toml | 3 +- .../examples/sov-election/src/lib.rs | 5 ++- .../examples/sov-election/src/query.rs | 2 +- .../examples/sov-value-setter/Cargo.toml | 3 +- .../examples/sov-value-setter/src/lib.rs | 5 ++- .../examples/sov-value-setter/src/query.rs | 2 +- .../integration-tests/Cargo.toml | 2 -- .../tests/nested_modules_tests.rs | 3 +- .../module-template/Cargo.toml | 3 +- .../module-template/src/lib.rs | 5 ++- .../sov-accounts/Cargo.toml | 3 +- .../sov-accounts/src/lib.rs | 5 ++- .../sov-accounts/src/query.rs | 2 +- .../sov-bank/Cargo.toml | 4 +-- .../sov-bank/src/lib.rs | 5 ++- .../sov-bank/src/query.rs | 2 +- .../sov-blob-storage/Cargo.toml | 2 +- .../sov-blob-storage/src/lib.rs | 3 +- .../module-implementations/sov-evm/Cargo.toml | 11 +++---- .../module-implementations/sov-evm/src/lib.rs | 5 ++- .../sov-evm/src/query.rs | 2 +- .../sov-prover-incentives/Cargo.toml | 5 ++- .../sov-prover-incentives/src/lib.rs | 5 ++- .../sov-sequencer-registry/Cargo.toml | 3 +- .../sov-sequencer-registry/src/lib.rs | 5 ++- .../sov-sequencer-registry/src/query.rs | 2 +- module-system/sov-modules-api/Cargo.toml | 4 ++- module-system/sov-modules-api/src/lib.rs | 14 +++++++++ module-system/sov-modules-macros/src/lib.rs | 31 +++++++++---------- .../sov-modules-macros/tests/derive_rpc.rs | 5 ++- .../tests/dispatch/derive_dispatch.rs | 8 ++--- .../tests/dispatch/derive_genesis.rs | 6 ++-- .../tests/dispatch/missing_serialization.rs | 2 +- .../tests/dispatch/modules.rs | 3 +- .../derive_on_enum_not_supported.rs | 2 +- .../module_info/field_missing_attribute.rs | 3 +- .../field_missing_attribute.stderr | 8 ++--- .../tests/module_info/missing_address.rs | 2 +- .../tests/module_info/mod_and_state.rs | 3 +- .../tests/module_info/no_generics.rs | 2 +- .../module_info/not_supported_attribute.rs | 3 +- .../not_supported_attribute.stderr | 12 +++---- .../tests/module_info/not_supported_type.rs | 3 +- .../module_info/not_supported_type.stderr | 4 +-- .../tests/module_info/parse.rs | 1 - .../module_info/second_addr_not_supported.rs | 3 +- .../second_addr_not_supported.stderr | 4 +-- 57 files changed, 126 insertions(+), 162 deletions(-) diff --git a/examples/demo-nft-module/Cargo.toml b/examples/demo-nft-module/Cargo.toml index 2b6269f64d..077ed8298b 100644 --- a/examples/demo-nft-module/Cargo.toml +++ b/examples/demo-nft-module/Cargo.toml @@ -14,8 +14,7 @@ anyhow = { workspace = true } borsh = { workspace = true, features = ["rc"] } serde = { workspace = true, optional = true } -sov-modules-api = { path = "../../module-system/sov-modules-api", default-features = false } -sov-modules-macros = { path = "../../module-system/sov-modules-macros" } +sov-modules-api = { path = "../../module-system/sov-modules-api", default-features = false, features = ["macros"] } sov-state = { path = "../../module-system/sov-state", default-features = false } [dev-dependencies] diff --git a/examples/demo-nft-module/README.md b/examples/demo-nft-module/README.md index f44b55efca..2594ea079e 100644 --- a/examples/demo-nft-module/README.md +++ b/examples/demo-nft-module/README.md @@ -41,8 +41,7 @@ Here are defining basic dependencies in `Cargo.toml` that module needs to get st ```toml [dependencies] anyhow = { anyhow = "1.0.62" } -sov-modules-api = { git = "https://github.com/Sovereign-Labs/sovereign-sdk.git", branch = "stable", default-features = false } -sov-modules-macros = { git = "https://github.com/Sovereign-Labs/sovereign-sdk.git", branch = "stable" } +sov-modules-api = { git = "https://github.com/Sovereign-Labs/sovereign-sdk.git", branch = "stable", features = ["macros"] } ``` ### Establishing the Root Module Structure @@ -55,8 +54,7 @@ has private state, which it updates in response to input messages. NFT module is defined as the following: ```rust -use sov_modules_api::Context; -use sov_modules_macros::ModuleInfo; +use sov_modules_api::{Context, ModuleInfo}; #[derive(ModuleInfo, Clone)] pub struct NonFungibleToken { @@ -121,14 +119,13 @@ Before we start implementing the `Module` trait, there are several preparatory s serde = { version = "1", features = ["derive"] } serde_json = "1" - sov-modules-api = { git = "https://github.com/Sovereign-Labs/sovereign-sdk.git", branch = "stable", default-features = false } - sov-modules-macros = { git = "https://github.com/Sovereign-Labs/sovereign-sdk.git", branch = "stable" } - sov-state = { git = "https://github.com/Sovereign-Labs/sovereign-sdk.git", branch = "stable", default-features = false } + sov-modules-api = { git = "https://github.com/Sovereign-Labs/sovereign-sdk.git", branch = "stable", default-features = false, features = ["macros"] } + sov-state = { git = "https://github.com/Sovereign-Labs/sovereign-sdk.git", branch = "stable", default-features = false } - [features] - default = ["native"] - serde = ["dep:serde", "dep:serde_json"] - native = ["serde", "sov-state/native", "sov-modules-api/native"] + [features] + default = ["native"] + serde = ["dep:serde", "dep:serde_json"] + native = ["serde", "sov-state/native", "sov-modules-api/native"] ``` This step is necessary to optimize the module for execution in ZK mode, where none of the RPC-related logic is diff --git a/examples/demo-nft-module/src/lib.rs b/examples/demo-nft-module/src/lib.rs index 3627b842d5..9b1f680ca4 100644 --- a/examples/demo-nft-module/src/lib.rs +++ b/examples/demo-nft-module/src/lib.rs @@ -3,8 +3,7 @@ pub mod genesis; #[cfg(feature = "native")] pub mod query; -use sov_modules_api::{CallResponse, Context, Error, Module}; -use sov_modules_macros::ModuleInfo; +use sov_modules_api::{CallResponse, Context, Error, Module, ModuleInfo}; use sov_state::WorkingSet; #[derive(ModuleInfo, Clone)] diff --git a/examples/demo-prover/Cargo.lock b/examples/demo-prover/Cargo.lock index 827e740edd..2de662c46b 100644 --- a/examples/demo-prover/Cargo.lock +++ b/examples/demo-prover/Cargo.lock @@ -680,7 +680,6 @@ dependencies = [ "sov-bank", "sov-election", "sov-modules-api", - "sov-modules-macros", "sov-modules-stf-template", "sov-rollup-interface", "sov-sequencer", @@ -3085,7 +3084,6 @@ dependencies = [ "serde", "serde_json", "sov-modules-api", - "sov-modules-macros", "sov-state", ] @@ -3100,7 +3098,6 @@ dependencies = [ "serde", "serde_json", "sov-modules-api", - "sov-modules-macros", "sov-state", ] @@ -3155,7 +3152,6 @@ dependencies = [ "serde", "serde_json", "sov-modules-api", - "sov-modules-macros", "sov-state", ] @@ -3181,6 +3177,7 @@ dependencies = [ "serde", "serde_json", "sha2 0.10.7", + "sov-modules-macros", "sov-rollup-interface", "sov-state", "thiserror", @@ -3265,7 +3262,6 @@ dependencies = [ "serde_json", "sov-bank", "sov-modules-api", - "sov-modules-macros", "sov-rollup-interface", "sov-state", ] @@ -3297,7 +3293,6 @@ dependencies = [ "serde", "serde_json", "sov-modules-api", - "sov-modules-macros", "sov-rollup-interface", "sov-state", "thiserror", diff --git a/examples/demo-prover/methods/guest/Cargo.lock b/examples/demo-prover/methods/guest/Cargo.lock index 1f8b97d81b..2823663a9d 100644 --- a/examples/demo-prover/methods/guest/Cargo.lock +++ b/examples/demo-prover/methods/guest/Cargo.lock @@ -424,7 +424,6 @@ dependencies = [ "sov-bank", "sov-election", "sov-modules-api", - "sov-modules-macros", "sov-modules-stf-template", "sov-rollup-interface", "sov-sequencer-registry", @@ -2297,7 +2296,6 @@ dependencies = [ "anyhow", "borsh", "sov-modules-api", - "sov-modules-macros", "sov-state", ] @@ -2308,7 +2306,6 @@ dependencies = [ "anyhow", "borsh", "sov-modules-api", - "sov-modules-macros", "sov-state", ] @@ -2342,7 +2339,6 @@ dependencies = [ "anyhow", "borsh", "sov-modules-api", - "sov-modules-macros", "sov-state", ] @@ -2365,6 +2361,7 @@ dependencies = [ "serde", "serde_json", "sha2 0.10.7", + "sov-modules-macros", "sov-rollup-interface", "sov-state", "thiserror", @@ -2380,7 +2377,6 @@ dependencies = [ "proc-macro2", "quote", "schemars", - "sov-modules-api", "syn 1.0.109", ] @@ -2420,7 +2416,6 @@ dependencies = [ "borsh", "sov-bank", "sov-modules-api", - "sov-modules-macros", "sov-rollup-interface", "sov-state", ] @@ -2447,7 +2442,6 @@ dependencies = [ "anyhow", "borsh", "sov-modules-api", - "sov-modules-macros", "sov-rollup-interface", "sov-state", "thiserror", diff --git a/examples/demo-stf/Cargo.toml b/examples/demo-stf/Cargo.toml index 9a8ca0dd8a..7ddd29ec50 100644 --- a/examples/demo-stf/Cargo.toml +++ b/examples/demo-stf/Cargo.toml @@ -33,15 +33,13 @@ sov-sequencer-registry = { path = "../../module-system/module-implementations/so sov-bank = { path = "../../module-system/module-implementations/sov-bank", default-features = false } sov-modules-stf-template = { path = "../../module-system/sov-modules-stf-template" } # no features available sov-value-setter = { path = "../../module-system/module-implementations/examples/sov-value-setter", default-features = false } -sov-accounts = { path = "../../module-system/module-implementations/sov-accounts", default-features = false} +sov-accounts = { path = "../../module-system/module-implementations/sov-accounts", default-features = false } sov-state = { path = "../../module-system/sov-state", default-features = false } -sov-modules-api = { path = "../../module-system/sov-modules-api", default-features = false } -sov-modules-macros = { path = "../../module-system/sov-modules-macros" } -# Only enable the sequencer on "native" feature +sov-modules-api = { path = "../../module-system/sov-modules-api", default-features = false, features = ["macros"] } sov-sequencer = { path = "../../full-node/sov-sequencer", optional = true } # Only enable the evm on "experimental" feature -sov-evm = { path = "../../module-system/module-implementations/sov-evm", default-features = false, optional = true} +sov-evm = { path = "../../module-system/module-implementations/sov-evm", default-features = false, optional = true } [dev-dependencies] sov-rollup-interface = { path = "../../rollup-interface", features = ["mocks"] } @@ -50,8 +48,7 @@ rand = "0.8" [features] default = ["native"] -experimental =["sov-evm/experimental"] - +experimental = ["sov-evm/experimental"] native = [ "sov-bank/native", @@ -66,5 +63,6 @@ native = [ "serde_json", "jsonrpsee", "tokio", - "toml"] + "toml", +] verifier = [] diff --git a/examples/demo-stf/src/batch_builder.rs b/examples/demo-stf/src/batch_builder.rs index 68ed563690..d946ab586c 100644 --- a/examples/demo-stf/src/batch_builder.rs +++ b/examples/demo-stf/src/batch_builder.rs @@ -138,9 +138,9 @@ mod tests { use sov_modules_api::default_context::DefaultContext; use sov_modules_api::default_signature::private_key::DefaultPrivateKey; use sov_modules_api::default_signature::DefaultPublicKey; + use sov_modules_api::macros::DefaultRuntime; use sov_modules_api::transaction::Transaction; - use sov_modules_api::{Context, Genesis}; - use sov_modules_macros::{DefaultRuntime, DispatchCall, Genesis, MessageCodec}; + use sov_modules_api::{Context, DispatchCall, Genesis, MessageCodec}; use sov_rollup_interface::services::batch_builder::BatchBuilder; use sov_state::{DefaultStorageSpec, ProverStorage, Storage}; use sov_value_setter::{CallMessage, ValueSetterConfig}; diff --git a/examples/demo-stf/src/runtime.rs b/examples/demo-stf/src/runtime.rs index cbaf57aef8..af7609a075 100644 --- a/examples/demo-stf/src/runtime.rs +++ b/examples/demo-stf/src/runtime.rs @@ -9,10 +9,10 @@ use sov_election::{ElectionRpcImpl, ElectionRpcServer}; use sov_evm::query::{EvmRpcImpl, EvmRpcServer}; #[cfg(feature = "native")] pub use sov_modules_api::default_context::DefaultContext; -use sov_modules_api::Context; +use sov_modules_api::macros::DefaultRuntime; #[cfg(feature = "native")] -use sov_modules_macros::{cli_parser, expose_rpc}; -use sov_modules_macros::{DefaultRuntime, DispatchCall, Genesis, MessageCodec}; +use sov_modules_api::macros::{cli_parser, expose_rpc}; +use sov_modules_api::{Context, DispatchCall, Genesis, MessageCodec}; #[cfg(feature = "native")] use sov_sequencer_registry::{SequencerRegistryRpcImpl, SequencerRegistryRpcServer}; #[cfg(feature = "native")] diff --git a/module-system/README.md b/module-system/README.md index e5979c4d53..0e3c90fb94 100644 --- a/module-system/README.md +++ b/module-system/README.md @@ -91,7 +91,7 @@ impl sov_modules_api::Module for Bank { ### The `RPC` Macro: The Node-to-User Interface The third interface that modules expose is an rpc implementation. To generate an RPC implementation, simply annotate your `impl` block -with the `#[rpc_gen]` macro from `sov_modules_macros`. +with the `#[rpc_gen]` macro from `sov_modules_api::macros`. ```rust #[rpc_gen(client, server, namespace = "bank")] diff --git a/module-system/RPC_WALKTHROUGH.md b/module-system/RPC_WALKTHROUGH.md index 3b656e805e..384de4714b 100644 --- a/module-system/RPC_WALKTHROUGH.md +++ b/module-system/RPC_WALKTHROUGH.md @@ -21,7 +21,7 @@ except that the `method` annotation has been renamed to `rpc_method` to clarify ```rust // This code goes in your module's query.rs file -use sov_modules_macros::rpc_gen; +use sov_modules_api::macros::rpc_gen; #[rpc_gen(client, server, namespace = "bank")] impl Bank { diff --git a/module-system/module-implementations/examples/sov-election/Cargo.toml b/module-system/module-implementations/examples/sov-election/Cargo.toml index c7dfc27f30..1c8eef6bab 100644 --- a/module-system/module-implementations/examples/sov-election/Cargo.toml +++ b/module-system/module-implementations/examples/sov-election/Cargo.toml @@ -20,8 +20,7 @@ schemars = { workspace = true, optional = true } serde = { workspace = true, optional = true } serde_json = { workspace = true, optional = true } -sov-modules-api = { path = "../../../sov-modules-api", default-features = false } -sov-modules-macros = { path = "../../../sov-modules-macros" } +sov-modules-api = { path = "../../../sov-modules-api", default-features = false, features = ["macros"] } sov-state = { path = "../../../sov-state", default-features = false } [dev-dependencies] diff --git a/module-system/module-implementations/examples/sov-election/src/lib.rs b/module-system/module-implementations/examples/sov-election/src/lib.rs index 621a163cf2..f9033dab1a 100644 --- a/module-system/module-implementations/examples/sov-election/src/lib.rs +++ b/module-system/module-implementations/examples/sov-election/src/lib.rs @@ -11,8 +11,7 @@ mod types; pub use call::CallMessage; #[cfg(feature = "native")] pub use query::{ElectionRpcImpl, ElectionRpcServer, GetNbOfVotesResponse, GetResultResponse}; -use sov_modules_api::Error; -use sov_modules_macros::ModuleInfo; +use sov_modules_api::{Error, ModuleInfo}; use sov_state::WorkingSet; pub use types::Candidate; use types::Voter; @@ -21,7 +20,7 @@ pub struct ElectionConfig { pub admin: C::Address, } -#[cfg_attr(feature = "native", derive(sov_modules_macros::ModuleCallJsonSchema))] +#[cfg_attr(feature = "native", derive(sov_modules_api::ModuleCallJsonSchema))] #[derive(ModuleInfo, Clone)] pub struct Election { #[address] diff --git a/module-system/module-implementations/examples/sov-election/src/query.rs b/module-system/module-implementations/examples/sov-election/src/query.rs index da8331f5e3..a5642984c5 100644 --- a/module-system/module-implementations/examples/sov-election/src/query.rs +++ b/module-system/module-implementations/examples/sov-election/src/query.rs @@ -1,4 +1,4 @@ -use sov_modules_macros::rpc_gen; +use sov_modules_api::macros::rpc_gen; use sov_state::WorkingSet; use super::types::Candidate; diff --git a/module-system/module-implementations/examples/sov-value-setter/Cargo.toml b/module-system/module-implementations/examples/sov-value-setter/Cargo.toml index e1c161c47c..b193462f95 100644 --- a/module-system/module-implementations/examples/sov-value-setter/Cargo.toml +++ b/module-system/module-implementations/examples/sov-value-setter/Cargo.toml @@ -18,8 +18,7 @@ tempfile = { workspace = true } [dependencies] anyhow = { workspace = true } -sov-modules-api = { path = "../../../sov-modules-api", default-features = false } -sov-modules-macros = { path = "../../../sov-modules-macros" } +sov-modules-api = { path = "../../../sov-modules-api", default-features = false, features = ["macros"] } sov-state = { path = "../../../sov-state", default-features = false } sov-rollup-interface = { path = "../../../../rollup-interface" } schemars = { workspace = true, optional = true } diff --git a/module-system/module-implementations/examples/sov-value-setter/src/lib.rs b/module-system/module-implementations/examples/sov-value-setter/src/lib.rs index e114cc48eb..dc207c6065 100644 --- a/module-system/module-implementations/examples/sov-value-setter/src/lib.rs +++ b/module-system/module-implementations/examples/sov-value-setter/src/lib.rs @@ -10,8 +10,7 @@ mod query; pub use call::CallMessage; #[cfg(feature = "native")] pub use query::{Response, ValueSetterRpcImpl, ValueSetterRpcServer}; -use sov_modules_api::Error; -use sov_modules_macros::ModuleInfo; +use sov_modules_api::{Error, ModuleInfo}; use sov_state::WorkingSet; pub struct ValueSetterConfig { @@ -22,7 +21,7 @@ pub struct ValueSetterConfig { /// - Must derive `ModuleInfo` /// - Must contain `[address]` field /// - Can contain any number of ` #[state]` or `[module]` fields -#[cfg_attr(feature = "native", derive(sov_modules_macros::ModuleCallJsonSchema))] +#[cfg_attr(feature = "native", derive(sov_modules_api::ModuleCallJsonSchema))] #[derive(ModuleInfo)] pub struct ValueSetter { /// Address of the module. diff --git a/module-system/module-implementations/examples/sov-value-setter/src/query.rs b/module-system/module-implementations/examples/sov-value-setter/src/query.rs index 51a45b27d6..9d9679a1c0 100644 --- a/module-system/module-implementations/examples/sov-value-setter/src/query.rs +++ b/module-system/module-implementations/examples/sov-value-setter/src/query.rs @@ -1,4 +1,4 @@ -use sov_modules_macros::rpc_gen; +use sov_modules_api::macros::rpc_gen; use sov_state::WorkingSet; use super::ValueSetter; diff --git a/module-system/module-implementations/integration-tests/Cargo.toml b/module-system/module-implementations/integration-tests/Cargo.toml index d38b36a10d..7c92d1b9c9 100644 --- a/module-system/module-implementations/integration-tests/Cargo.toml +++ b/module-system/module-implementations/integration-tests/Cargo.toml @@ -17,8 +17,6 @@ borsh = { workspace = true, features = ["rc"] } tempfile = { workspace = true } sov-modules-api = { path = "../../sov-modules-api" } -sov-modules-macros = { path = "../../sov-modules-macros" } sov-state = { path = "../../sov-state" } sov-rollup-interface = { path = "../../../rollup-interface" } sov-schema-db = { path = "../../../full-node/db/sov-schema-db" } - diff --git a/module-system/module-implementations/integration-tests/tests/nested_modules_tests.rs b/module-system/module-implementations/integration-tests/tests/nested_modules_tests.rs index 6356b7f44e..f8774ed03a 100644 --- a/module-system/module-implementations/integration-tests/tests/nested_modules_tests.rs +++ b/module-system/module-implementations/integration-tests/tests/nested_modules_tests.rs @@ -1,6 +1,5 @@ use sov_modules_api::default_context::{DefaultContext, ZkDefaultContext}; -use sov_modules_api::{Context, Prefix}; -use sov_modules_macros::ModuleInfo; +use sov_modules_api::{Context, ModuleInfo, Prefix}; use sov_rollup_interface::stf::Event; use sov_state::{ProverStorage, StateMap, StateValue, Storage, WorkingSet, ZkStorage}; diff --git a/module-system/module-implementations/module-template/Cargo.toml b/module-system/module-implementations/module-template/Cargo.toml index cb6c8962f4..ce00b27338 100644 --- a/module-system/module-implementations/module-template/Cargo.toml +++ b/module-system/module-implementations/module-template/Cargo.toml @@ -14,8 +14,7 @@ resolver = "2" [dependencies] anyhow = { workspace = true } sov-bank = { path = "../sov-bank", default-features = false } -sov-modules-api = { path = "../../sov-modules-api", default-features = false } -sov-modules-macros = { path = "../../sov-modules-macros" } +sov-modules-api = { path = "../../sov-modules-api", default-features = false, features = ["macros"] } sov-state = { path = "../../sov-state", default-features = false } sov-rollup-interface = { path = "../../../rollup-interface" } schemars = { workspace = true, optional = true } diff --git a/module-system/module-implementations/module-template/src/lib.rs b/module-system/module-implementations/module-template/src/lib.rs index 3d44697e59..ede00b2794 100644 --- a/module-system/module-implementations/module-template/src/lib.rs +++ b/module-system/module-implementations/module-template/src/lib.rs @@ -10,8 +10,7 @@ mod query; pub use call::CallMessage; #[cfg(feature = "native")] pub use query::Response; -use sov_modules_api::Error; -use sov_modules_macros::ModuleInfo; +use sov_modules_api::{Error, ModuleInfo}; use sov_state::WorkingSet; pub struct ExampleModuleConfig {} @@ -24,7 +23,7 @@ pub struct ExampleModuleConfig {} /// This is optional, and is only used to generate a JSON Schema for your /// module's call messages (which is useful to develop clients, CLI tooling /// etc.). -#[cfg_attr(feature = "native", derive(sov_modules_macros::ModuleCallJsonSchema))] +#[cfg_attr(feature = "native", derive(sov_modules_api::ModuleCallJsonSchema))] #[derive(ModuleInfo)] pub struct ExampleModule { /// Address of the module. diff --git a/module-system/module-implementations/sov-accounts/Cargo.toml b/module-system/module-implementations/sov-accounts/Cargo.toml index e886c12c7d..1c572081c8 100644 --- a/module-system/module-implementations/sov-accounts/Cargo.toml +++ b/module-system/module-implementations/sov-accounts/Cargo.toml @@ -19,8 +19,7 @@ serde = { workspace = true, optional = true } serde_json = { workspace = true, optional = true } jsonrpsee = { workspace = true, features = ["macros", "client-core", "server"], optional = true } -sov-modules-api = { path = "../../sov-modules-api", version = "0.1", default-features = false } -sov-modules-macros = { path = "../../sov-modules-macros", version = "0.1" } +sov-modules-api = { path = "../../sov-modules-api", version = "0.1", default-features = false, features = ["macros"] } sov-state = { path = "../../sov-state", version = "0.1", default-features = false } diff --git a/module-system/module-implementations/sov-accounts/src/lib.rs b/module-system/module-implementations/sov-accounts/src/lib.rs index f4ad5c728f..8385a86937 100644 --- a/module-system/module-implementations/sov-accounts/src/lib.rs +++ b/module-system/module-implementations/sov-accounts/src/lib.rs @@ -12,8 +12,7 @@ mod tests; pub use call::{CallMessage, UPDATE_ACCOUNT_MSG}; #[cfg(feature = "native")] pub use query::{AccountsRpcImpl, AccountsRpcServer, Response}; -use sov_modules_api::Error; -use sov_modules_macros::ModuleInfo; +use sov_modules_api::{Error, ModuleInfo}; use sov_state::WorkingSet; /// Initial configuration for sov-accounts module. @@ -32,7 +31,7 @@ pub struct Account { } /// A module responsible for managing accounts on the rollup. -#[cfg_attr(feature = "native", derive(sov_modules_macros::ModuleCallJsonSchema))] +#[cfg_attr(feature = "native", derive(sov_modules_api::ModuleCallJsonSchema))] #[derive(ModuleInfo, Clone)] pub struct Accounts { /// The address of the sov-accounts module. diff --git a/module-system/module-implementations/sov-accounts/src/query.rs b/module-system/module-implementations/sov-accounts/src/query.rs index 19ca8667ee..0b7fe9afcc 100644 --- a/module-system/module-implementations/sov-accounts/src/query.rs +++ b/module-system/module-implementations/sov-accounts/src/query.rs @@ -1,6 +1,6 @@ #![allow(missing_docs)] +use sov_modules_api::macros::rpc_gen; use sov_modules_api::AddressBech32; -use sov_modules_macros::rpc_gen; use sov_state::WorkingSet; use crate::{Account, Accounts}; diff --git a/module-system/module-implementations/sov-bank/Cargo.toml b/module-system/module-implementations/sov-bank/Cargo.toml index 9331299e35..6dc80f5ce6 100644 --- a/module-system/module-implementations/sov-bank/Cargo.toml +++ b/module-system/module-implementations/sov-bank/Cargo.toml @@ -19,12 +19,10 @@ schemars = { workspace = true, optional = true } serde = { workspace = true, optional = true } serde_json = { workspace = true, optional = true } -sov-modules-api = { path = "../../sov-modules-api", version = "0.1", default-features = false } -sov-modules-macros = { path = "../../sov-modules-macros", version = "0.1" } +sov-modules-api = { path = "../../sov-modules-api", version = "0.1", default-features = false, features = ["macros"] } sov-state = { path = "../../sov-state", version = "0.1", default-features = false } - [dev-dependencies] sov-modules-api = { path = "../../sov-modules-api", version = "0.1" } tempfile = { workspace = true } diff --git a/module-system/module-implementations/sov-bank/src/lib.rs b/module-system/module-implementations/sov-bank/src/lib.rs index d4d1f0ce3f..a90d052b9f 100644 --- a/module-system/module-implementations/sov-bank/src/lib.rs +++ b/module-system/module-implementations/sov-bank/src/lib.rs @@ -8,8 +8,7 @@ mod utils; pub use call::CallMessage; #[cfg(feature = "native")] pub use query::{BalanceResponse, BankRpcImpl, BankRpcServer, TotalSupplyResponse}; -use sov_modules_api::Error; -use sov_modules_macros::ModuleInfo; +use sov_modules_api::{Error, ModuleInfo}; use sov_state::WorkingSet; use token::Token; pub use token::{Amount, Coins}; @@ -31,7 +30,7 @@ pub struct BankConfig { /// - Token creation. /// - Token transfers. /// - Token burn. -#[cfg_attr(feature = "native", derive(sov_modules_macros::ModuleCallJsonSchema))] +#[cfg_attr(feature = "native", derive(sov_modules_api::ModuleCallJsonSchema))] #[derive(ModuleInfo, Clone)] pub struct Bank { /// The address of the sov-bank module. diff --git a/module-system/module-implementations/sov-bank/src/query.rs b/module-system/module-implementations/sov-bank/src/query.rs index 9f2edb57a0..f62bdb6a69 100644 --- a/module-system/module-implementations/sov-bank/src/query.rs +++ b/module-system/module-implementations/sov-bank/src/query.rs @@ -1,4 +1,4 @@ -use sov_modules_macros::rpc_gen; +use sov_modules_api::macros::rpc_gen; use sov_state::WorkingSet; use crate::{Amount, Bank}; diff --git a/module-system/module-implementations/sov-blob-storage/Cargo.toml b/module-system/module-implementations/sov-blob-storage/Cargo.toml index bf998174e9..8ba5a0dc80 100644 --- a/module-system/module-implementations/sov-blob-storage/Cargo.toml +++ b/module-system/module-implementations/sov-blob-storage/Cargo.toml @@ -16,7 +16,7 @@ resolver = "2" [dependencies] anyhow = { workspace = true } bincode = { workspace = true } -sov-modules-api = { path = "../../sov-modules-api", version = "0.1", default-features = false } +sov-modules-api = { path = "../../sov-modules-api", version = "0.1", default-features = false, features = ["macros"] } sov-modules-macros = { path = "../../sov-modules-macros", version = "0.1" } sov-state = { path = "../../sov-state", version = "0.1", default-features = false } sov-rollup-interface = { path = "../../../rollup-interface", version = "0.1" } diff --git a/module-system/module-implementations/sov-blob-storage/src/lib.rs b/module-system/module-implementations/sov-blob-storage/src/lib.rs index 71fd61ebb1..8e20df4990 100644 --- a/module-system/module-implementations/sov-blob-storage/src/lib.rs +++ b/module-system/module-implementations/sov-blob-storage/src/lib.rs @@ -2,8 +2,7 @@ //! Blob storage module allows to save DA blobs in the state -use sov_modules_api::Module; -use sov_modules_macros::ModuleInfo; +use sov_modules_api::{Module, ModuleInfo}; use sov_rollup_interface::da::BlobTransactionTrait; use sov_state::{StateMap, WorkingSet}; diff --git a/module-system/module-implementations/sov-evm/Cargo.toml b/module-system/module-implementations/sov-evm/Cargo.toml index 18cb17ed70..1872d7b657 100644 --- a/module-system/module-implementations/sov-evm/Cargo.toml +++ b/module-system/module-implementations/sov-evm/Cargo.toml @@ -14,8 +14,7 @@ resolver = "2" [dependencies] revm = "3.3.0" -sov-modules-api = { path = "../../sov-modules-api", version = "0.1", default-features = false } -sov-modules-macros = { path = "../../sov-modules-macros", version = "0.1" } +sov-modules-api = { path = "../../sov-modules-api", version = "0.1", default-features = false, features = ["macros"] } sov-state = { path = "../../sov-state", version = "0.1", default-features = false } anyhow = { workspace = true } @@ -37,18 +36,18 @@ ethers-providers = { workspace = true } ethers-signers = { workspace = true } -anvil = { workspace = true } -anvil-core = { workspace = true } +anvil = { workspace = true } +anvil-core = { workspace = true } ethers = { workspace = true } [dev-dependencies] -anvil = { workspace = true } +anvil = { workspace = true } primitive-types = "0.12.1" tokio = { workspace = true } tempfile = { workspace = true } bytes = { workspace = true } -sov-modules-api = { path = "../../sov-modules-api", version = "0.1" } +sov-modules-api = { path = "../../sov-modules-api", version = "0.1", features = ["macros"] } [features] default = ["native"] diff --git a/module-system/module-implementations/sov-evm/src/lib.rs b/module-system/module-implementations/sov-evm/src/lib.rs index 82ae40fb37..72631a0d76 100644 --- a/module-system/module-implementations/sov-evm/src/lib.rs +++ b/module-system/module-implementations/sov-evm/src/lib.rs @@ -20,8 +20,7 @@ pub use receipt::TransactionReceipt; #[cfg(feature = "experimental")] mod experimental { use revm::primitives::{KECCAK_EMPTY, U256}; - use sov_modules_api::Error; - use sov_modules_macros::ModuleInfo; + use sov_modules_api::{Error, ModuleInfo}; use sov_state::WorkingSet; use super::evm::db::EvmDb; @@ -55,7 +54,7 @@ mod experimental { } #[allow(dead_code)] - #[cfg_attr(feature = "native", derive(sov_modules_macros::ModuleCallJsonSchema))] + #[cfg_attr(feature = "native", derive(sov_modules_api::ModuleCallJsonSchema))] #[derive(ModuleInfo, Clone)] pub struct Evm { #[address] diff --git a/module-system/module-implementations/sov-evm/src/query.rs b/module-system/module-implementations/sov-evm/src/query.rs index 8d514f1cb3..498299a225 100644 --- a/module-system/module-implementations/sov-evm/src/query.rs +++ b/module-system/module-implementations/sov-evm/src/query.rs @@ -4,7 +4,7 @@ use ethereum_types::{Address, H256, U256, U64}; use ethers::types::Bytes; use ethers_core::types::{Block, BlockId, FeeHistory, Transaction, TransactionReceipt, TxHash}; use revm::primitives::{CfgEnv, ExecutionResult, U256 as EVM_U256}; -use sov_modules_macros::rpc_gen; +use sov_modules_api::macros::rpc_gen; use sov_state::WorkingSet; use tracing::info; diff --git a/module-system/module-implementations/sov-prover-incentives/Cargo.toml b/module-system/module-implementations/sov-prover-incentives/Cargo.toml index 08331aea2e..ce19507421 100644 --- a/module-system/module-implementations/sov-prover-incentives/Cargo.toml +++ b/module-system/module-implementations/sov-prover-incentives/Cargo.toml @@ -13,14 +13,13 @@ resolver = "2" [dev-dependencies] sov-rollup-interface = { path = "../../../rollup-interface", version = "0.1", features = ["mocks"] } -sov-modules-api = { path = "../../sov-modules-api", version = "0.1" } +sov-modules-api = { path = "../../sov-modules-api", version = "0.1", features = ["macros"] } tempfile = { workspace = true } [dependencies] anyhow = { workspace = true } sov-bank = { path = "../sov-bank", version = "0.1", default-features = false } -sov-modules-api = { path = "../../sov-modules-api", version = "0.1", default-features = false } -sov-modules-macros = { path = "../../sov-modules-macros", version = "0.1" } +sov-modules-api = { path = "../../sov-modules-api", version = "0.1", default-features = false, features = ["macros"] } sov-state = { path = "../../sov-state", version = "0.1", default-features = false } sov-rollup-interface = { path = "../../../rollup-interface", version = "0.1" } schemars = { workspace = true, optional = true } diff --git a/module-system/module-implementations/sov-prover-incentives/src/lib.rs b/module-system/module-implementations/sov-prover-incentives/src/lib.rs index f55b2b8677..d1898f9f3c 100644 --- a/module-system/module-implementations/sov-prover-incentives/src/lib.rs +++ b/module-system/module-implementations/sov-prover-incentives/src/lib.rs @@ -11,8 +11,7 @@ use borsh::{BorshDeserialize, BorshSerialize}; pub use call::CallMessage; #[cfg(feature = "native")] pub use query::Response; -use sov_modules_api::{Context, Error}; -use sov_modules_macros::ModuleInfo; +use sov_modules_api::{Context, Error, ModuleInfo}; use sov_rollup_interface::zk::Zkvm; use sov_state::WorkingSet; @@ -53,7 +52,7 @@ impl BorshDeserialize for StoredCodeCommitment { /// - Must derive `ModuleInfo` /// - Must contain `[address]` field /// - Can contain any number of ` #[state]` or `[module]` fields -#[cfg_attr(feature = "native", derive(sov_modules_macros::ModuleCallJsonSchema))] +#[cfg_attr(feature = "native", derive(sov_modules_api::ModuleCallJsonSchema))] #[derive(ModuleInfo)] pub struct ProverIncentives { /// Address of the module. diff --git a/module-system/module-implementations/sov-sequencer-registry/Cargo.toml b/module-system/module-implementations/sov-sequencer-registry/Cargo.toml index 564dd353e1..4f4ea774eb 100644 --- a/module-system/module-implementations/sov-sequencer-registry/Cargo.toml +++ b/module-system/module-implementations/sov-sequencer-registry/Cargo.toml @@ -20,8 +20,7 @@ tempfile = { workspace = true } [dependencies] anyhow = { workspace = true } sov-bank = { path = "../sov-bank", version = "0.1", default-features = false } -sov-modules-api = { path = "../../sov-modules-api", version = "0.1", default-features = false } -sov-modules-macros = { path = "../../sov-modules-macros", version = "0.1" } +sov-modules-api = { path = "../../sov-modules-api", version = "0.1", default-features = false, features = ["macros"] } sov-state = { path = "../../sov-state", version = "0.1", default-features = false } sov-rollup-interface = { path = "../../../rollup-interface", version = "0.1" } schemars = { workspace = true, optional = true } diff --git a/module-system/module-implementations/sov-sequencer-registry/src/lib.rs b/module-system/module-implementations/sov-sequencer-registry/src/lib.rs index ef4d5a6d32..eeda0eb77f 100644 --- a/module-system/module-implementations/sov-sequencer-registry/src/lib.rs +++ b/module-system/module-implementations/sov-sequencer-registry/src/lib.rs @@ -7,8 +7,7 @@ mod query; pub use call::CallMessage; #[cfg(feature = "native")] pub use query::{SequencerAddressResponse, SequencerRegistryRpcImpl, SequencerRegistryRpcServer}; -use sov_modules_api::{CallResponse, Error, Spec}; -use sov_modules_macros::ModuleInfo; +use sov_modules_api::{CallResponse, Error, ModuleInfo, Spec}; use sov_state::{StateMap, StateValue, WorkingSet}; /// Initial configuration for the sov_sequencer_registry module. @@ -22,7 +21,7 @@ pub struct SequencerConfig { pub preferred_sequencer: Option>, } -#[cfg_attr(feature = "native", derive(sov_modules_macros::ModuleCallJsonSchema))] +#[cfg_attr(feature = "native", derive(sov_modules_api::ModuleCallJsonSchema))] #[derive(ModuleInfo)] pub struct SequencerRegistry { /// The address of the sov_sequencer_registry module diff --git a/module-system/module-implementations/sov-sequencer-registry/src/query.rs b/module-system/module-implementations/sov-sequencer-registry/src/query.rs index e97626a9f6..eb538ef4f8 100644 --- a/module-system/module-implementations/sov-sequencer-registry/src/query.rs +++ b/module-system/module-implementations/sov-sequencer-registry/src/query.rs @@ -1,5 +1,5 @@ +use sov_modules_api::macros::rpc_gen; use sov_modules_api::Context; -use sov_modules_macros::rpc_gen; use sov_state::WorkingSet; use crate::SequencerRegistry; diff --git a/module-system/sov-modules-api/Cargo.toml b/module-system/sov-modules-api/Cargo.toml index 38072836f0..0b351f8ecb 100644 --- a/module-system/sov-modules-api/Cargo.toml +++ b/module-system/sov-modules-api/Cargo.toml @@ -15,6 +15,7 @@ resolver = "2" anyhow = { workspace = true } sov-state = { path = "../sov-state", version = "0.1", default-features = false } sov-rollup-interface = { path = "../../rollup-interface", version = "0.1" } +sov-modules-macros = { path = "../sov-modules-macros", version = "0.1", optional = true } serde = { workspace = true } borsh = { workspace = true } thiserror = { workspace = true } @@ -32,5 +33,6 @@ hex = { workspace = true, optional = true } serde_json = { workspace = true } [features] -default = ["native"] +default = ["native", "macros"] native = ["sov-state/native", "rand", "hex", "schemars", "ed25519-dalek/default"] +macros = ["sov-modules-macros"] diff --git a/module-system/sov-modules-api/src/lib.rs b/module-system/sov-modules-api/src/lib.rs index fc10c14224..85c075b857 100644 --- a/module-system/sov-modules-api/src/lib.rs +++ b/module-system/sov-modules-api/src/lib.rs @@ -14,6 +14,20 @@ mod serde_address; mod tests; pub mod transaction; +#[cfg(feature = "macros")] +extern crate sov_modules_macros; + +#[cfg(feature = "macros")] +pub use sov_modules_macros::{ + DispatchCall, Genesis, MessageCodec, ModuleCallJsonSchema, ModuleInfo, +}; + +/// Procedural macros to assist with creating new modules. +#[cfg(feature = "macros")] +pub mod macros { + pub use sov_modules_macros::{cli_parser, expose_rpc, rpc_gen, DefaultRuntime, MessageCodec}; +} + use core::fmt::{self, Debug, Display}; use borsh::{BorshDeserialize, BorshSerialize}; diff --git a/module-system/sov-modules-macros/src/lib.rs b/module-system/sov-modules-macros/src/lib.rs index 2495a06f85..cf5d42100d 100644 --- a/module-system/sov-modules-macros/src/lib.rs +++ b/module-system/sov-modules-macros/src/lib.rs @@ -21,7 +21,7 @@ use proc_macro::TokenStream; use rpc::ExposeRpcMacro; use syn::parse_macro_input; -/// Derives the [`sov_modules_api::ModuleInfo`] trait for the underlying `struct`. +/// Derives the [`ModuleInfo`](trait.ModuleInfo.html) trait for the underlying `struct`. /// /// The underlying type must respect the following conditions, or compilation /// will fail: @@ -33,14 +33,12 @@ use syn::parse_macro_input; /// - `#[state]` is used for state members. /// - `#[module]` is used for module members. /// -/// In addition to implementing [`sov_modules_api::ModuleInfo`], this macro will -/// also generate so-called "prefix" methods. See the [`sov_modules_api`] docs -/// for more information about prefix methods. +/// In addition to implementing [`ModuleInfo`](trait.ModuleInfo.html), this macro will +/// also generate so-called "prefix" methods. /// /// ## Example /// /// ``` -/// use sov_modules_macros::ModuleInfo; /// use sov_modules_api::{Context, ModuleInfo}; /// use sov_state::StateMap; /// @@ -66,7 +64,7 @@ pub fn module_info(input: TokenStream) -> TokenStream { handle_macro_error(module_info::derive_module_info(input)) } -/// Derives the `sov-modules-api::Default` implementation for the underlying type. +/// Derives a custom [`Default`] implementation for the underlying type. /// We decided to implement a custom macro DefaultRuntime that would implement a custom Default /// trait for the Runtime because the stdlib implementation of the default trait imposes the generic /// arguments to have the Default trait, which is not needed in our case. @@ -78,7 +76,7 @@ pub fn default_runtime(input: TokenStream) -> TokenStream { handle_macro_error(default_config_macro.derive_default_runtime(input)) } -/// Derives the [`sov_modules_api::Genesis`] trait for the underlying runtime +/// Derives the [`Genesis`](trait.Genesis.html) trait for the underlying runtime /// `struct`. #[proc_macro_derive(Genesis)] pub fn genesis(input: TokenStream) -> TokenStream { @@ -88,7 +86,8 @@ pub fn genesis(input: TokenStream) -> TokenStream { handle_macro_error(genesis_macro.derive_genesis(input)) } -/// Derives the [`sov_modules_api::DispatchCall`] trait for the underlying type. +/// Derives the [`DispatchCall`](trait.DispatchCall.html) trait for the underlying +/// type. #[proc_macro_derive(DispatchCall, attributes(serialization))] pub fn dispatch_call(input: TokenStream) -> TokenStream { let input = parse_macro_input!(input); @@ -97,7 +96,8 @@ pub fn dispatch_call(input: TokenStream) -> TokenStream { handle_macro_error(call_macro.derive_dispatch_call(input)) } -/// Derives the [`sov_modules_api::ModuleCallJsonSchema`] trait for the underlying type. +/// Derives the [`ModuleCallJsonSchema`](trait.ModuleCallJsonSchema.html) trait for +/// the underlying type. /// /// ## Example /// @@ -106,7 +106,6 @@ pub fn dispatch_call(input: TokenStream) -> TokenStream { /// /// use sov_modules_api::{Context, Module, ModuleInfo, ModuleCallJsonSchema}; /// use sov_modules_api::default_context::ZkDefaultContext; -/// use sov_modules_macros::{ModuleInfo, ModuleCallJsonSchema}; /// use sov_state::StateMap; /// use sov_bank::CallMessage; /// @@ -152,8 +151,8 @@ pub fn codec(input: TokenStream) -> TokenStream { /// /// ## Example /// ``` -/// use sov_modules_macros::{rpc_gen, ModuleInfo}; -/// use sov_modules_api::Context; +/// use sov_modules_api::{Context, ModuleInfo}; +/// use sov_modules_api::macros::rpc_gen; /// /// #[derive(ModuleInfo)] /// struct MyModule { @@ -174,8 +173,8 @@ pub fn codec(input: TokenStream) -> TokenStream { /// This is exactly equivalent to hand-writing /// /// ``` -/// use sov_modules_macros::{rpc_gen, ModuleInfo}; -/// use sov_modules_api::Context; +/// use sov_modules_api::{Context, ModuleInfo}; +/// use sov_modules_api::macros::rpc_gen; /// use sov_state::WorkingSet; /// /// #[derive(ModuleInfo)] @@ -245,9 +244,9 @@ pub fn expose_rpc(attr: TokenStream, input: TokenStream) -> TokenStream { /// /// ## Examples /// ``` -/// use sov_modules_api::Context; +/// use sov_modules_api::{Context, DispatchCall}; /// use sov_modules_api::default_context::DefaultContext; -/// use sov_modules_macros::{DispatchCall, MessageCodec, cli_parser}; +/// use sov_modules_api::macros::{MessageCodec, cli_parser}; /// /// #[derive(DispatchCall, MessageCodec)] /// #[serialization(borsh::BorshDeserialize, borsh::BorshSerialize)] diff --git a/module-system/sov-modules-macros/tests/derive_rpc.rs b/module-system/sov-modules-macros/tests/derive_rpc.rs index 8d93160317..274e0ffa0b 100644 --- a/module-system/sov-modules-macros/tests/derive_rpc.rs +++ b/module-system/sov-modules-macros/tests/derive_rpc.rs @@ -1,7 +1,6 @@ use sov_modules_api::default_context::ZkDefaultContext; -use sov_modules_api::Context; -use sov_modules_macros::rpc_gen; -use sov_modules_macros::ModuleInfo; +use sov_modules_api::macros::rpc_gen; +use sov_modules_api::{Context, ModuleInfo}; use sov_state::{WorkingSet, ZkStorage}; #[derive(ModuleInfo)] diff --git a/module-system/sov-modules-macros/tests/dispatch/derive_dispatch.rs b/module-system/sov-modules-macros/tests/dispatch/derive_dispatch.rs index 98c83d0dfa..62f23a7aec 100644 --- a/module-system/sov-modules-macros/tests/dispatch/derive_dispatch.rs +++ b/module-system/sov-modules-macros/tests/dispatch/derive_dispatch.rs @@ -1,9 +1,8 @@ mod modules; use modules::{first_test_module, second_test_module}; -use sov_modules_api::Address; -use sov_modules_api::ModuleInfo; -use sov_modules_api::{default_context::ZkDefaultContext, Context, Genesis}; -use sov_modules_macros::{DefaultRuntime, DispatchCall, Genesis, MessageCodec}; +use sov_modules_api::default_context::ZkDefaultContext; +use sov_modules_api::macros::{DefaultRuntime, MessageCodec}; +use sov_modules_api::{Address, Context, DispatchCall, Genesis, ModuleInfo}; use sov_state::ZkStorage; #[derive(Genesis, DispatchCall, MessageCodec, DefaultRuntime)] @@ -14,7 +13,6 @@ struct Runtime { } fn main() { - use sov_modules_api::DispatchCall; type RT = Runtime; let runtime = &mut RT::default(); diff --git a/module-system/sov-modules-macros/tests/dispatch/derive_genesis.rs b/module-system/sov-modules-macros/tests/dispatch/derive_genesis.rs index 42c3cba8a2..15306d7a14 100644 --- a/module-system/sov-modules-macros/tests/dispatch/derive_genesis.rs +++ b/module-system/sov-modules-macros/tests/dispatch/derive_genesis.rs @@ -2,8 +2,8 @@ mod modules; use modules::{first_test_module, second_test_module}; use sov_modules_api::default_context::ZkDefaultContext; -use sov_modules_api::Context; -use sov_modules_macros::{DefaultRuntime, DispatchCall, Genesis, MessageCodec}; +use sov_modules_api::macros::{DefaultRuntime, MessageCodec}; +use sov_modules_api::{Context, DispatchCall, Genesis}; use sov_state::ZkStorage; // Debugging hint: To expand the macro in tests run: `cargo expand --test tests` @@ -18,8 +18,6 @@ where } fn main() { - use sov_modules_api::Genesis; - type C = ZkDefaultContext; let storage = ZkStorage::new([1u8; 32]); let mut working_set = &mut sov_state::WorkingSet::new(storage); diff --git a/module-system/sov-modules-macros/tests/dispatch/missing_serialization.rs b/module-system/sov-modules-macros/tests/dispatch/missing_serialization.rs index 654f59b0d9..806536d88c 100644 --- a/module-system/sov-modules-macros/tests/dispatch/missing_serialization.rs +++ b/module-system/sov-modules-macros/tests/dispatch/missing_serialization.rs @@ -1,4 +1,4 @@ -use sov_modules_macros::DispatchCall; +use sov_modules_api::DispatchCall; #[derive(DispatchCall)] struct TestStruct {} diff --git a/module-system/sov-modules-macros/tests/dispatch/modules.rs b/module-system/sov-modules-macros/tests/dispatch/modules.rs index 834704a2c2..7a12e4a180 100644 --- a/module-system/sov-modules-macros/tests/dispatch/modules.rs +++ b/module-system/sov-modules-macros/tests/dispatch/modules.rs @@ -1,5 +1,4 @@ -use sov_modules_api::{CallResponse, Context, Error, Module}; -use sov_modules_macros::ModuleInfo; +use sov_modules_api::{CallResponse, Context, Error, Module, ModuleInfo}; use sov_state::{StateValue, WorkingSet}; pub mod first_test_module { diff --git a/module-system/sov-modules-macros/tests/module_info/derive_on_enum_not_supported.rs b/module-system/sov-modules-macros/tests/module_info/derive_on_enum_not_supported.rs index ec2ceff68a..99fe240945 100644 --- a/module-system/sov-modules-macros/tests/module_info/derive_on_enum_not_supported.rs +++ b/module-system/sov-modules-macros/tests/module_info/derive_on_enum_not_supported.rs @@ -1,4 +1,4 @@ -use sov_modules_macros::ModuleInfo; +use sov_modules_api::ModuleInfo; use sov_state::StateMap; #[derive(ModuleInfo)] diff --git a/module-system/sov-modules-macros/tests/module_info/field_missing_attribute.rs b/module-system/sov-modules-macros/tests/module_info/field_missing_attribute.rs index 764a916814..622b75ada6 100644 --- a/module-system/sov-modules-macros/tests/module_info/field_missing_attribute.rs +++ b/module-system/sov-modules-macros/tests/module_info/field_missing_attribute.rs @@ -1,5 +1,4 @@ -use sov_modules_api::Context; -use sov_modules_macros::ModuleInfo; +use sov_modules_api::{Context, ModuleInfo}; use sov_state::StateMap; #[derive(ModuleInfo)] diff --git a/module-system/sov-modules-macros/tests/module_info/field_missing_attribute.stderr b/module-system/sov-modules-macros/tests/module_info/field_missing_attribute.stderr index 5dae682973..a2751deb85 100644 --- a/module-system/sov-modules-macros/tests/module_info/field_missing_attribute.stderr +++ b/module-system/sov-modules-macros/tests/module_info/field_missing_attribute.stderr @@ -1,5 +1,5 @@ error: This field is missing an attribute: add `#[module]`, `#[state]` or `#[address]`. - --> tests/module_info/field_missing_attribute.rs:10:5 - | -10 | test_state1: StateMap, - | ^^^^^^^^^^^ + --> tests/module_info/field_missing_attribute.rs:9:5 + | +9 | test_state1: StateMap, + | ^^^^^^^^^^^ diff --git a/module-system/sov-modules-macros/tests/module_info/missing_address.rs b/module-system/sov-modules-macros/tests/module_info/missing_address.rs index f43891188b..93d2176b98 100644 --- a/module-system/sov-modules-macros/tests/module_info/missing_address.rs +++ b/module-system/sov-modules-macros/tests/module_info/missing_address.rs @@ -1,4 +1,4 @@ -use sov_modules_macros::ModuleInfo; +use sov_modules_api::ModuleInfo; use sov_state::StateMap; #[derive(ModuleInfo)] diff --git a/module-system/sov-modules-macros/tests/module_info/mod_and_state.rs b/module-system/sov-modules-macros/tests/module_info/mod_and_state.rs index ddf9e5691d..d837c8e884 100644 --- a/module-system/sov-modules-macros/tests/module_info/mod_and_state.rs +++ b/module-system/sov-modules-macros/tests/module_info/mod_and_state.rs @@ -1,6 +1,5 @@ use sov_modules_api::default_context::ZkDefaultContext; -use sov_modules_api::Context; -use sov_modules_macros::ModuleInfo; +use sov_modules_api::{Context, ModuleInfo}; use sov_state::StateMap; pub mod first_test_module { diff --git a/module-system/sov-modules-macros/tests/module_info/no_generics.rs b/module-system/sov-modules-macros/tests/module_info/no_generics.rs index 853addfe29..0ebcf121f6 100644 --- a/module-system/sov-modules-macros/tests/module_info/no_generics.rs +++ b/module-system/sov-modules-macros/tests/module_info/no_generics.rs @@ -1,4 +1,4 @@ -use sov_modules_macros::ModuleInfo; +use sov_modules_api::ModuleInfo; #[derive(ModuleInfo)] struct TestStruct {} diff --git a/module-system/sov-modules-macros/tests/module_info/not_supported_attribute.rs b/module-system/sov-modules-macros/tests/module_info/not_supported_attribute.rs index 285b7f4af1..1f01783ffa 100644 --- a/module-system/sov-modules-macros/tests/module_info/not_supported_attribute.rs +++ b/module-system/sov-modules-macros/tests/module_info/not_supported_attribute.rs @@ -1,5 +1,4 @@ -use sov_modules_api::Context; -use sov_modules_macros::ModuleInfo; +use sov_modules_api::{Context, ModuleInfo}; use sov_state::StateMap; #[derive(ModuleInfo)] diff --git a/module-system/sov-modules-macros/tests/module_info/not_supported_attribute.stderr b/module-system/sov-modules-macros/tests/module_info/not_supported_attribute.stderr index 4063f89a75..a36937a55c 100644 --- a/module-system/sov-modules-macros/tests/module_info/not_supported_attribute.stderr +++ b/module-system/sov-modules-macros/tests/module_info/not_supported_attribute.stderr @@ -1,11 +1,11 @@ error: Only `#[module]`, `#[state]` or `#[address]` attributes are supported. - --> tests/module_info/not_supported_attribute.rs:11:5 + --> tests/module_info/not_supported_attribute.rs:10:5 | -11 | test_state1: StateMap, +10 | test_state1: StateMap, | ^^^^^^^^^^^ error: cannot find attribute `other` in this scope - --> tests/module_info/not_supported_attribute.rs:10:7 - | -10 | #[other] - | ^^^^^ + --> tests/module_info/not_supported_attribute.rs:9:7 + | +9 | #[other] + | ^^^^^ diff --git a/module-system/sov-modules-macros/tests/module_info/not_supported_type.rs b/module-system/sov-modules-macros/tests/module_info/not_supported_type.rs index 86025989cd..ff1e1ba140 100644 --- a/module-system/sov-modules-macros/tests/module_info/not_supported_type.rs +++ b/module-system/sov-modules-macros/tests/module_info/not_supported_type.rs @@ -1,5 +1,4 @@ -use sov_modules_api::Context; -use sov_modules_macros::ModuleInfo; +use sov_modules_api::{Context, ModuleInfo}; use sov_state::StateMap; #[derive(ModuleInfo)] diff --git a/module-system/sov-modules-macros/tests/module_info/not_supported_type.stderr b/module-system/sov-modules-macros/tests/module_info/not_supported_type.stderr index 1ffcc4bd07..ddaa61fc6b 100644 --- a/module-system/sov-modules-macros/tests/module_info/not_supported_type.stderr +++ b/module-system/sov-modules-macros/tests/module_info/not_supported_type.stderr @@ -1,5 +1,5 @@ error: Type not supported by the `ModuleInfo` macro - --> tests/module_info/not_supported_type.rs:11:18 + --> tests/module_info/not_supported_type.rs:10:18 | -11 | test_state1: [usize; 22], +10 | test_state1: [usize; 22], | ^^^^^^^^^^^ diff --git a/module-system/sov-modules-macros/tests/module_info/parse.rs b/module-system/sov-modules-macros/tests/module_info/parse.rs index f271916a7c..1292a2fe0f 100644 --- a/module-system/sov-modules-macros/tests/module_info/parse.rs +++ b/module-system/sov-modules-macros/tests/module_info/parse.rs @@ -1,6 +1,5 @@ use sov_modules_api::default_context::ZkDefaultContext; use sov_modules_api::{Context, ModuleInfo}; -use sov_modules_macros::ModuleInfo; use sov_state::{StateMap, StateValue}; mod test_module { diff --git a/module-system/sov-modules-macros/tests/module_info/second_addr_not_supported.rs b/module-system/sov-modules-macros/tests/module_info/second_addr_not_supported.rs index 053b3f4f68..0fd17c6dff 100644 --- a/module-system/sov-modules-macros/tests/module_info/second_addr_not_supported.rs +++ b/module-system/sov-modules-macros/tests/module_info/second_addr_not_supported.rs @@ -1,5 +1,4 @@ -use sov_modules_api::Context; -use sov_modules_macros::ModuleInfo; +use sov_modules_api::{Context, ModuleInfo}; use sov_state::StateMap; #[derive(ModuleInfo)] diff --git a/module-system/sov-modules-macros/tests/module_info/second_addr_not_supported.stderr b/module-system/sov-modules-macros/tests/module_info/second_addr_not_supported.stderr index 28be72e29c..ed877e3bea 100644 --- a/module-system/sov-modules-macros/tests/module_info/second_addr_not_supported.stderr +++ b/module-system/sov-modules-macros/tests/module_info/second_addr_not_supported.stderr @@ -1,5 +1,5 @@ error: The `address` attribute is defined more than once, revisit field: address_1 - --> tests/module_info/second_addr_not_supported.rs:8:5 + --> tests/module_info/second_addr_not_supported.rs:7:5 | -8 | address_1: C::Address, +7 | address_1: C::Address, | ^^^^^^^^^