diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0714ad3bb..bf8488373 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -17,7 +17,7 @@ $ cargo run --package polywrap_tests_utils --bin generate ``` Now you will be able to run tests of all crates: ```shell -$ cargo test +$ cargo test --release ``` ## Feedback and discussions diff --git a/examples/src/ens.rs b/examples/src/ens.rs index 3e2d1bef9..6ab0080e2 100644 --- a/examples/src/ens.rs +++ b/examples/src/ens.rs @@ -22,12 +22,12 @@ fn main() { let domain = "vitalik.eth".to_string(); let ens_uri = uri!("wrapscan.io/polywrap/ens@1.0.0"); - let mut config = PolywrapClientConfig::new(); + let mut config = ClientConfig::new(); config .add(SystemClientConfig::default().into()) .add(Web3ClientConfig::default().into()); - let client = PolywrapClient::new(config.build()); + let client = Client::new(config.build()); let resolver_address = client.invoke::( &ens_uri, diff --git a/examples/src/ethers.rs b/examples/src/ethers.rs index 2e0f2e7d4..fb2f20352 100644 --- a/examples/src/ethers.rs +++ b/examples/src/ethers.rs @@ -28,7 +28,7 @@ struct ToEthArgs { fn main() { let ethers_core_uri = uri!("wrapscan.io/polywrap/ethers@1.0.0"); let ethers_util_uri = uri!("wrapscan.io/polywrap/ethers-utils@1.0.0"); - let mut config = PolywrapClientConfig::new(); + let mut config = ClientConfig::new(); config.add(SystemClientConfig::default().into()); let mainnet_connection = Connection::new( @@ -50,7 +50,7 @@ fn main() { config.add_package(uri!("wrapscan.io/polywrap/ethereum-wallet@1.0"), package); - let client = PolywrapClient::new(config.build()); + let client = Client::new(config.build()); let balance = client.invoke::( ðers_core_uri, diff --git a/examples/src/filesystem.rs b/examples/src/filesystem.rs index 011d433fc..77035ee56 100644 --- a/examples/src/filesystem.rs +++ b/examples/src/filesystem.rs @@ -21,7 +21,7 @@ struct FileArgs { fn main() { let uri = uri!("wrapscan.io/polywrap/file-system@1.0"); - let mut config = PolywrapClientConfig::new(); + let mut config = ClientConfig::new(); let fs_package = PluginPackage::from(FileSystemPlugin {}); config.add_package(uri.clone(), Arc::new(fs_package)); @@ -29,7 +29,7 @@ fn main() { let file_path = "./fs-example.txt".to_string(); let data = "Hello world!"; - let client = PolywrapClient::new(config.build()); + let client = Client::new(config.build()); let write_file_result = client.invoke::( &uri, "writeFile", diff --git a/examples/src/http.rs b/examples/src/http.rs index f7dfa0370..419402b84 100644 --- a/examples/src/http.rs +++ b/examples/src/http.rs @@ -37,12 +37,12 @@ struct PostArgs { fn main() { let uri = uri!("wrapscan.io/polywrap/http@1.0"); - let mut config = PolywrapClientConfig::new(); + let mut config = ClientConfig::new(); let http_package = PluginPackage::from(HttpPlugin {}); config.add_package(uri.clone(), Arc::new(http_package)); - let client = PolywrapClient::new(config.build()); + let client = Client::new(config.build()); let get_result = client.invoke::( &uri, "get", diff --git a/examples/src/ipfs.rs b/examples/src/ipfs.rs index aec9fc84b..a75078eff 100644 --- a/examples/src/ipfs.rs +++ b/examples/src/ipfs.rs @@ -34,12 +34,12 @@ fn main() { let ipfs_provider = "http://localhost:5001"; let uri = uri!("wrapscan.io/polywrap/ipfs-http-client@1.0"); - let mut config = PolywrapClientConfig::new(); + let mut config = ClientConfig::new(); config.add(SystemClientConfig::default().into()); let config = config.build(); - let client = PolywrapClient::new(config); + let client = Client::new(config); let file_name = "hello-world.txt"; let file_data = "Hello World!!!"; diff --git a/examples/src/logger.rs b/examples/src/logger.rs index 02a831747..69268d54e 100644 --- a/examples/src/logger.rs +++ b/examples/src/logger.rs @@ -12,10 +12,10 @@ struct LogMessageArgs { fn main() { let wrap_uri = uri!("wrapscan.io/polywrap/logging@1.0.0"); - let mut config = PolywrapClientConfig::new(); + let mut config = ClientConfig::new(); config.add(SystemClientConfig::default().into()); - let client = PolywrapClient::new(config.build()); + let client = Client::new(config.build()); let result = client.invoke::( &wrap_uri, "info", diff --git a/packages/builder/src/lib.rs b/packages/builder/src/lib.rs index 33824349c..bbe27bb40 100644 --- a/packages/builder/src/lib.rs +++ b/packages/builder/src/lib.rs @@ -3,5 +3,5 @@ pub mod polywrap_client_config; pub mod polywrap_client_config_builder; pub use polywrap_base_resolver::{PolywrapBaseResolver, PolywrapBaseResolverOptions}; -pub use polywrap_client_config::PolywrapClientConfig; -pub use polywrap_client_config_builder::PolywrapClientConfigBuilder; +pub use polywrap_client_config::ClientConfig; +pub use polywrap_client_config_builder::ClientConfigBuilder; diff --git a/packages/builder/src/polywrap_client_config.rs b/packages/builder/src/polywrap_client_config.rs index c0f418881..4601522a9 100644 --- a/packages/builder/src/polywrap_client_config.rs +++ b/packages/builder/src/polywrap_client_config.rs @@ -1,7 +1,7 @@ use std::{collections::HashMap, sync::Arc}; use polywrap_core::{ - client::{ClientConfig, ClientConfigBuilder}, + client::{CoreClientConfig, CoreClientConfigBuilder}, interface_implementation::InterfaceImplementations, package::WrapPackage, resolution::uri_resolver::UriResolver, @@ -10,10 +10,10 @@ use polywrap_core::{ }; use polywrap_resolvers::static_resolver::{StaticResolver, StaticResolverLike}; -use crate::{PolywrapBaseResolver, PolywrapBaseResolverOptions, PolywrapClientConfigBuilder}; +use crate::{PolywrapBaseResolver, PolywrapBaseResolverOptions, ClientConfigBuilder}; #[derive(Default, Clone)] -pub struct PolywrapClientConfig { +pub struct ClientConfig { pub interfaces: Option, pub envs: Option>>, pub wrappers: Option)>>, @@ -22,7 +22,7 @@ pub struct PolywrapClientConfig { pub resolvers: Option>>, } -impl PolywrapClientConfig { +impl ClientConfig { pub fn new() -> Self { // We don't want to use the default constructor here because it may change // and then `new` would no longer create an empty config. @@ -65,8 +65,8 @@ impl PolywrapClientConfig { } } -impl PolywrapClientConfigBuilder for PolywrapClientConfig { - fn add(&mut self, config: PolywrapClientConfig) -> &mut Self { +impl ClientConfigBuilder for ClientConfig { + fn add(&mut self, config: ClientConfig) -> &mut Self { if let Some(e) = config.envs { self.add_envs(e); }; @@ -323,11 +323,11 @@ impl PolywrapClientConfigBuilder for PolywrapClientConfig { } } -impl ClientConfigBuilder for PolywrapClientConfig { - fn build(self) -> ClientConfig { +impl CoreClientConfigBuilder for ClientConfig { + fn build(self) -> CoreClientConfig { // We first build the resolver because it needs a reference to self // this way we don't need to clone `envs`, and `interfaces`. - ClientConfig { + CoreClientConfig { resolver: PolywrapBaseResolver::new(PolywrapBaseResolverOptions { static_resolver: self.build_static_resolver(), dynamic_resolvers: self.resolvers, @@ -339,8 +339,8 @@ impl ClientConfigBuilder for PolywrapClientConfig { } } -impl Into for PolywrapClientConfig { - fn into(self) -> ClientConfig { +impl Into for ClientConfig { + fn into(self) -> CoreClientConfig { self.build() } } diff --git a/packages/builder/src/polywrap_client_config_builder.rs b/packages/builder/src/polywrap_client_config_builder.rs index 1981bb6d3..6ff5dda70 100644 --- a/packages/builder/src/polywrap_client_config_builder.rs +++ b/packages/builder/src/polywrap_client_config_builder.rs @@ -1,14 +1,14 @@ use std::{collections::HashMap, sync::Arc}; use polywrap_core::{ - client::ClientConfigBuilder, package::WrapPackage, resolution::uri_resolver::UriResolver, + client::CoreClientConfigBuilder, package::WrapPackage, resolution::uri_resolver::UriResolver, uri::Uri, wrapper::Wrapper, }; -use crate::PolywrapClientConfig; +use crate::ClientConfig; -pub trait PolywrapClientConfigBuilder: ClientConfigBuilder { - fn add(&mut self, config: PolywrapClientConfig) -> &mut Self; +pub trait ClientConfigBuilder: CoreClientConfigBuilder { + fn add(&mut self, config: ClientConfig) -> &mut Self; fn add_env(&mut self, uri: Uri, env: Vec) -> &mut Self; fn add_envs(&mut self, env: HashMap>) -> &mut Self; fn remove_env(&mut self, uri: &Uri) -> &mut Self; diff --git a/packages/builder/tests/test_builder.rs b/packages/builder/tests/test_builder.rs index 9ea7780eb..d83b82315 100644 --- a/packages/builder/tests/test_builder.rs +++ b/packages/builder/tests/test_builder.rs @@ -1,6 +1,6 @@ use std::{collections::HashMap, sync::Arc}; -use polywrap_client_builder::{PolywrapClientConfig, PolywrapClientConfigBuilder}; +use polywrap_client_builder::{ClientConfig, ClientConfigBuilder}; use polywrap_core::{macros::uri, package::WrapPackage, uri::Uri, wrapper::Wrapper}; use polywrap_msgpack_serde::to_vec; use polywrap_tests_utils::mocks::{ @@ -22,7 +22,7 @@ struct EnvTwo { #[test] fn test_env_methods() { - let mut builder = PolywrapClientConfig::new(); + let mut builder = ClientConfig::new(); let uri = uri!("wrap://mock/wrapper"); assert!(builder.envs.is_none()); @@ -74,7 +74,7 @@ fn test_interface_implementation_methods() { let another_interface_uri = uri!("wrap://mock/another-interface"); - let mut builder = PolywrapClientConfig::new(); + let mut builder = ClientConfig::new(); assert!(builder.interfaces.is_none()); builder.add_interface_implementation(interface_uri.clone(), implementation_a_uri.clone()); builder.add_interface_implementation(another_interface_uri, implementation_b_uri.clone()); @@ -83,7 +83,7 @@ fn test_interface_implementation_methods() { assert!(builder.interfaces.unwrap().len() == 2); // Recreate builder again to test add interfaces implementations - let mut builder = PolywrapClientConfig::new(); + let mut builder = ClientConfig::new(); assert!(builder.interfaces.is_none()); @@ -125,7 +125,7 @@ fn test_interface_implementation_methods() { #[test] fn test_redirects() { - let mut builder = PolywrapClientConfig::new(); + let mut builder = ClientConfig::new(); assert!(builder.redirects.is_none()); let a_uri = uri!("mock/a"); @@ -146,7 +146,7 @@ fn test_redirects() { let builder_redirects = builder.redirects.unwrap(); assert_eq!(builder_redirects, redirects); - let mut builder = PolywrapClientConfig::new(); + let mut builder = ClientConfig::new(); assert!(builder.redirects.is_none()); builder.add_redirect(a_uri.clone(), b_uri.clone()); @@ -163,7 +163,7 @@ fn test_redirects() { #[test] fn test_packages() { - let mut builder = PolywrapClientConfig::new(); + let mut builder = ClientConfig::new(); assert!(builder.packages.is_none()); let uri_a: Uri = String::from("wrap://package/a").try_into().unwrap(); @@ -192,7 +192,7 @@ fn test_packages() { // We need to recreate the builder because when we do builder.packages.unwrap // the ownership is given, not allowing us to call the builder again - let mut builder = PolywrapClientConfig::new(); + let mut builder = ClientConfig::new(); let modified_uri_package_b = (uri_b.clone(), get_different_mock_package()); @@ -213,7 +213,7 @@ fn test_packages() { #[test] fn test_wrappers() { - let mut builder = PolywrapClientConfig::new(); + let mut builder = ClientConfig::new(); assert!(builder.wrappers.is_none()); let uri_wrapper_a = ( @@ -242,7 +242,7 @@ fn test_wrappers() { // We need to recreate the builder because when we do builder.wrappers.unwrap // the ownership is given, not allowing us to call the builder again - let mut builder = PolywrapClientConfig::new(); + let mut builder = ClientConfig::new(); let modified_uri_wrapper_b = ( String::from("wrap://wrapper/b").try_into().unwrap(), @@ -268,7 +268,7 @@ fn test_wrappers() { #[test] fn test_resolvers() { - let mut builder = PolywrapClientConfig::new(); + let mut builder = ClientConfig::new(); assert!(builder.resolvers.is_none()); builder.add_resolvers(vec![Arc::new(MockResolver {})]); assert!(builder.resolvers.is_some()); diff --git a/packages/client/src/client.rs b/packages/client/src/client.rs index cdd76774e..1b8d30fe0 100644 --- a/packages/client/src/client.rs +++ b/packages/client/src/client.rs @@ -1,5 +1,5 @@ use polywrap_core::{ - client::{Client, ClientConfig}, + client::{CoreClient, CoreClientConfig}, error::Error, interface_implementation::InterfaceImplementations, invoker::Invoker, @@ -26,14 +26,14 @@ use std::{ use crate::subinvoker::Subinvoker; #[derive(Clone, Debug)] -pub struct PolywrapClient { +pub struct Client { pub resolver: Arc, pub envs: Option>>, pub interfaces: Option, } -impl PolywrapClient { - pub fn new(config: ClientConfig) -> Self { +impl Client { + pub fn new(config: CoreClientConfig) -> Self { let resolver = config.resolver; let envs = config.envs; let interfaces = config.interfaces; @@ -73,7 +73,7 @@ impl PolywrapClient { } } -impl Invoker for PolywrapClient { +impl Invoker for Client { fn invoke_raw( &self, uri: &Uri, @@ -175,7 +175,7 @@ impl Invoker for PolywrapClient { } } -impl WrapLoader for PolywrapClient { +impl WrapLoader for Client { fn load_wrapper( &self, uri: &Uri, @@ -203,7 +203,7 @@ impl WrapLoader for PolywrapClient { } } -impl WrapInvoker for PolywrapClient { +impl WrapInvoker for Client { fn invoke_wrapper_raw( &self, wrapper: &dyn Wrapper, @@ -248,7 +248,7 @@ impl WrapInvoker for PolywrapClient { } } -impl UriResolverHandler for PolywrapClient { +impl UriResolverHandler for Client { fn try_resolve_uri( &self, uri: &Uri, @@ -264,23 +264,23 @@ impl UriResolverHandler for PolywrapClient { } } -impl Client for PolywrapClient {} +impl CoreClient for Client {} #[cfg(test)] mod client_tests { use polywrap_core::{ - client::ClientConfig, resolution::uri_resolution_context::UriPackageOrWrapper, uri::Uri, + client::CoreClientConfig, resolution::uri_resolution_context::UriPackageOrWrapper, uri::Uri, uri_resolver_handler::UriResolverHandler, wrap_loader::WrapLoader, }; use polywrap_msgpack_serde::from_slice; use polywrap_tests_utils::mocks::{get_mock_resolver, MockWrapper}; use std::sync::Arc; - use super::PolywrapClient; + use super::Client; #[test] fn invoke() { - let client = PolywrapClient::new(ClientConfig { + let client = Client::new(CoreClientConfig { resolver: get_mock_resolver(), envs: None, interfaces: None, @@ -295,7 +295,7 @@ mod client_tests { #[test] fn invoke_wrapper() { - let client = PolywrapClient::new(ClientConfig { + let client = Client::new(CoreClientConfig { resolver: get_mock_resolver(), envs: None, interfaces: None, @@ -319,7 +319,7 @@ mod client_tests { #[test] fn load_wrapper() { - let client = PolywrapClient::new(ClientConfig { + let client = Client::new(CoreClientConfig { resolver: get_mock_resolver(), envs: None, interfaces: None, @@ -336,7 +336,7 @@ mod client_tests { #[test] fn try_resolve_uri() { - let client = PolywrapClient::new(ClientConfig { + let client = Client::new(CoreClientConfig { resolver: get_mock_resolver(), envs: None, interfaces: None, diff --git a/packages/client/tests/it/wrap_features/env_with_invoke.rs b/packages/client/tests/it/wrap_features/env_with_invoke.rs index cfeb15f85..ced920821 100644 --- a/packages/client/tests/it/wrap_features/env_with_invoke.rs +++ b/packages/client/tests/it/wrap_features/env_with_invoke.rs @@ -1,7 +1,7 @@ -use polywrap_client::client::PolywrapClient; +use polywrap_client::client::Client; use polywrap_client::core::uri::Uri; -use polywrap_core::client::ClientConfig; +use polywrap_core::client::CoreClientConfig; use polywrap_core::file_reader::SimpleFileReader; use polywrap_core::macros::uri; use polywrap_core::resolution::uri_resolution_context::UriPackageOrWrapper; @@ -70,7 +70,7 @@ fn get_default_serialized_env() -> Vec { polywrap_msgpack_serde::to_vec(&get_default_env()).unwrap() } -fn build_client(uri: &Uri, env: Option<&[u8]>) -> PolywrapClient { +fn build_client(uri: &Uri, env: Option<&[u8]>) -> Client { let mut envs = HashMap::new(); if let Some(env) = env { @@ -86,13 +86,13 @@ fn build_client(uri: &Uri, env: Option<&[u8]>) -> PolywrapClient { Box::new(fs_resolver), Box::new(StaticResolver::new(resolvers)), ); - let config = ClientConfig { + let config = CoreClientConfig { envs: Some(envs), resolver: Arc::new(base_resolver), interfaces: None, }; - PolywrapClient::new(config) + Client::new(config) } #[derive(Serialize)] @@ -224,7 +224,7 @@ fn env_can_be_registered_for_any_uri_in_resolution_path() { let file_reader = SimpleFileReader::new(); let fs_resolver = FilesystemResolver::new(Arc::new(file_reader)); - let config = ClientConfig { + let config = CoreClientConfig { envs: Some(envs), // Use the RecursiveResolver because it tracks resolution path (unlike BaseResolver) resolver: Arc::new(RecursiveResolver::from(resolver_vec![ @@ -234,7 +234,7 @@ fn env_can_be_registered_for_any_uri_in_resolution_path() { interfaces: None, }; - PolywrapClient::new(config) + Client::new(config) }; let result = client @@ -262,7 +262,7 @@ fn env_can_be_registered_for_any_uri_in_resolution_path() { let file_reader = SimpleFileReader::new(); let fs_resolver = FilesystemResolver::new(Arc::new(file_reader)); - let config = ClientConfig { + let config = CoreClientConfig { envs: Some(envs), // Use the RecursiveResolver because it tracks resolution path (unlike BaseResolver) resolver: Arc::new(RecursiveResolver::from(resolver_vec![ @@ -272,7 +272,7 @@ fn env_can_be_registered_for_any_uri_in_resolution_path() { interfaces: None, }; - PolywrapClient::new(config) + Client::new(config) }; let result = client diff --git a/packages/client/tests/it/wrap_features/env_with_subinvoke.rs b/packages/client/tests/it/wrap_features/env_with_subinvoke.rs index 71209c764..129e6e3cd 100644 --- a/packages/client/tests/it/wrap_features/env_with_subinvoke.rs +++ b/packages/client/tests/it/wrap_features/env_with_subinvoke.rs @@ -1,7 +1,7 @@ -use polywrap_client::client::PolywrapClient; +use polywrap_client::client::Client; use polywrap_client::core::uri::Uri; -use polywrap_core::client::ClientConfig; +use polywrap_core::client::CoreClientConfig; use polywrap_core::file_reader::SimpleFileReader; use polywrap_core::macros::uri; use polywrap_core::resolution::uri_resolution_context::UriPackageOrWrapper; @@ -82,7 +82,7 @@ struct Env { array: Vec, } -fn build_client(subinvoker_env: Option<&[u8]>, subinvoked_env: Option<&[u8]>) -> PolywrapClient { +fn build_client(subinvoker_env: Option<&[u8]>, subinvoked_env: Option<&[u8]>) -> Client { let subinvoker_uri = get_subinvoker_uri(); let subinvoked_uri = get_subinvoked_uri(); @@ -106,13 +106,13 @@ fn build_client(subinvoker_env: Option<&[u8]>, subinvoked_env: Option<&[u8]>) -> Box::new(fs_resolver), Box::new(StaticResolver::new(resolvers)), ); - let config = ClientConfig { + let config = CoreClientConfig { envs: Some(envs), resolver: Arc::new(base_resolver), interfaces: None, }; - PolywrapClient::new(config) + Client::new(config) } #[derive(Serialize)] @@ -313,13 +313,13 @@ fn subinvoker_env_does_not_override_subinvoked_env() { Box::new(fs_resolver), Box::new(StaticResolver::new(resolvers)), ); - let config = ClientConfig { + let config = CoreClientConfig { envs: Some(envs), resolver: Arc::new(base_resolver), interfaces: None, }; - PolywrapClient::new(config) + Client::new(config) }; let result = client diff --git a/packages/client/tests/it/wrap_features/interface_implementation.rs b/packages/client/tests/it/wrap_features/interface_implementation.rs index 1151f0ceb..815197b80 100644 --- a/packages/client/tests/it/wrap_features/interface_implementation.rs +++ b/packages/client/tests/it/wrap_features/interface_implementation.rs @@ -1,7 +1,7 @@ -use polywrap_client::client::PolywrapClient; +use polywrap_client::client::Client; use polywrap_client::core::interface_implementation::InterfaceImplementations; -use polywrap_core::client::ClientConfig; +use polywrap_core::client::CoreClientConfig; use polywrap_core::file_reader::SimpleFileReader; use polywrap_core::macros::uri; use polywrap_core::uri::Uri; @@ -56,7 +56,7 @@ fn test_interface_implementation() { Box::new(fs_resolver), Box::new(StaticResolver::new(HashMap::new())), ); - let client = PolywrapClient::new(ClientConfig { + let client = Client::new(CoreClientConfig { envs: None, interfaces: Some(interfaces), resolver: Arc::new(base_resolver), diff --git a/packages/client/tests/it/wrap_features/plugin_invocation.rs b/packages/client/tests/it/wrap_features/plugin_invocation.rs index 3ecb06119..d265434cb 100644 --- a/packages/client/tests/it/wrap_features/plugin_invocation.rs +++ b/packages/client/tests/it/wrap_features/plugin_invocation.rs @@ -1,7 +1,7 @@ -use polywrap_client::client::PolywrapClient; -use polywrap_client_builder::{PolywrapClientConfig, PolywrapClientConfigBuilder}; +use polywrap_client::client::Client; +use polywrap_client_builder::{ClientConfig, ClientConfigBuilder}; use polywrap_core::{ - client::ClientConfig, error::Error, macros::uri, package::WrapPackage, uri::Uri, + client::CoreClientConfig, error::Error, macros::uri, package::WrapPackage, uri::Uri, }; use polywrap_msgpack_serde::to_vec; use polywrap_resolvers::static_resolver::{StaticResolver, StaticResolverLike}; @@ -35,7 +35,7 @@ fn invoke_with_env() { }) .unwrap(); let envs = HashMap::from([(uri!("plugin/env"), env_val)]); - let client = PolywrapClient::new(ClientConfig { + let client = Client::new(CoreClientConfig { envs: Some(envs), interfaces: None, resolver: Arc::new(static_resolver), @@ -62,13 +62,13 @@ fn invoke_with_env() { fn invoke_methods() { let plugin_uri = uri!("mock/plugin"); - let mut config = PolywrapClientConfig::new(); + let mut config = ClientConfig::new(); config.add_package( plugin_uri.clone(), Arc::new(PluginPackage::from(MemoryStoragePlugin { value: 1 })), ); - let client = PolywrapClient::new(config.into()); + let client = Client::new(config.into()); let result = client .invoke::(&plugin_uri, "getData", Some(&to_vec(&ArgsGetData {}).unwrap()), None, None) @@ -97,13 +97,13 @@ fn invoke_non_existent_method_should_err() { let plugin_uri = uri!("mock/plugin"); let method = String::from("iDontExist"); - let mut config = PolywrapClientConfig::new(); + let mut config = ClientConfig::new(); config.add_package( plugin_uri.clone(), Arc::new(PluginPackage::from(MemoryStoragePlugin { value: 1 })), ); - let client = PolywrapClient::new(config.into()); + let client = Client::new(config.into()); let result = client.invoke::(&plugin_uri, &method, None, None, None); diff --git a/packages/client/tests/it/wrap_features/plugin_state.rs b/packages/client/tests/it/wrap_features/plugin_state.rs index 125eb55a8..01ba85955 100644 --- a/packages/client/tests/it/wrap_features/plugin_state.rs +++ b/packages/client/tests/it/wrap_features/plugin_state.rs @@ -2,7 +2,7 @@ mod plugin_state_tests { use std::sync::{Arc, Mutex}; - use polywrap_client_builder::{PolywrapClientConfig, PolywrapClientConfigBuilder}; + use polywrap_client_builder::{ClientConfig, ClientConfigBuilder}; use polywrap_core::wrapper::Wrapper; use polywrap_plugin::{module::PluginModule, error::PluginError, wrapper::PluginWrapper}; @@ -27,7 +27,7 @@ mod plugin_state_tests { #[test] pub fn it_adds_concrete_plugin_without_losing_state_access() { - let mut config = PolywrapClientConfig::new(); + let mut config = ClientConfig::new(); let plugin = Arc::new(Mutex::new(CounterPlugin { counter: 7 })); let plugin_wrapper = Arc::new(PluginWrapper::new(plugin.clone())); config.add_wrapper("foo/bar".try_into().unwrap(), plugin_wrapper.clone() as Arc); diff --git a/packages/client/tests/it/wrap_features/subinvoke.rs b/packages/client/tests/it/wrap_features/subinvoke.rs index 5eeddcb31..aeda6227b 100644 --- a/packages/client/tests/it/wrap_features/subinvoke.rs +++ b/packages/client/tests/it/wrap_features/subinvoke.rs @@ -1,9 +1,9 @@ use std::collections::HashMap; use std::sync::Arc; -use polywrap_client::client::PolywrapClient; +use polywrap_client::client::Client; use polywrap_client::core::uri::Uri; -use polywrap_core::client::ClientConfig; +use polywrap_core::client::CoreClientConfig; use polywrap_core::file_reader::SimpleFileReader; use polywrap_core::macros::uri; use polywrap_core::resolution::uri_resolution_context::UriPackageOrWrapper; @@ -45,12 +45,12 @@ fn subinvoke_test() { Box::new(StaticResolver::new(resolvers)), ); - let config = ClientConfig { + let config = CoreClientConfig { resolver: Arc::new(base_resolver), envs: None, interfaces: None, }; - let client = PolywrapClient::new(config); + let client = Client::new(config); let invoke_result = client .invoke::( diff --git a/packages/client/tests/it/wrap_types/asyncify.rs b/packages/client/tests/it/wrap_types/asyncify.rs index 725f8bf54..38a6cd1ab 100644 --- a/packages/client/tests/it/wrap_types/asyncify.rs +++ b/packages/client/tests/it/wrap_types/asyncify.rs @@ -1,4 +1,4 @@ -use polywrap_client::client::PolywrapClient; +use polywrap_client::client::Client; use polywrap_client::core::macros::uri; use polywrap_client::core::uri::Uri; use polywrap_core::resolution::uri_resolution_context::UriPackageOrWrapper; @@ -62,7 +62,7 @@ struct SetDataWithManyArgsArgs { valueL: String, } -fn get_client_and_uri() -> (PolywrapClient, Uri) { +fn get_client_and_uri() -> (Client, Uri) { let test_path = get_tests_path().unwrap(); let path = test_path.into_os_string().into_string().unwrap(); let uri = format!("fs/{}/asyncify/implementations/rs", path) diff --git a/packages/client/tests/it/wrap_types/bigint.rs b/packages/client/tests/it/wrap_types/bigint.rs index 238b226a4..718694228 100644 --- a/packages/client/tests/it/wrap_types/bigint.rs +++ b/packages/client/tests/it/wrap_types/bigint.rs @@ -1,5 +1,5 @@ use num_bigint::BigInt; -use polywrap_client::client::PolywrapClient; +use polywrap_client::client::Client; use polywrap_client::core::uri::Uri; use polywrap_msgpack_serde::to_vec; use polywrap_tests_utils::helpers::get_tests_path; @@ -7,7 +7,7 @@ use serde::Serialize; use crate::wrap_types::get_client; -fn get_client_and_uri() -> (PolywrapClient, Uri) { +fn get_client_and_uri() -> (Client, Uri) { let test_path = get_tests_path().unwrap(); let path = test_path.into_os_string().into_string().unwrap(); let uri = format!("fs/{}/bigint-type/implementations/rs", path) diff --git a/packages/client/tests/it/wrap_types/bignumber.rs b/packages/client/tests/it/wrap_types/bignumber.rs index 832943a28..4d5a1cb52 100644 --- a/packages/client/tests/it/wrap_types/bignumber.rs +++ b/packages/client/tests/it/wrap_types/bignumber.rs @@ -1,5 +1,5 @@ use bigdecimal::BigDecimal as BigNumber; -use polywrap_client::client::PolywrapClient; +use polywrap_client::client::Client; use polywrap_client::core::uri::Uri; use polywrap_msgpack_serde::to_vec; use polywrap_tests_utils::helpers::get_tests_path; @@ -20,7 +20,7 @@ struct ArgsObject { prop2: Option, } -fn get_client_and_uri() -> (PolywrapClient, Uri) { +fn get_client_and_uri() -> (Client, Uri) { let test_path = get_tests_path().unwrap(); let path = test_path.into_os_string().into_string().unwrap(); let uri = format!("fs/{}/bignumber-type/implementations/rs", path) diff --git a/packages/client/tests/it/wrap_types/enum.rs b/packages/client/tests/it/wrap_types/enum.rs index 3e288442b..d41252978 100644 --- a/packages/client/tests/it/wrap_types/enum.rs +++ b/packages/client/tests/it/wrap_types/enum.rs @@ -1,4 +1,4 @@ -use polywrap_client::client::PolywrapClient; +use polywrap_client::client::Client; use polywrap_client::core::uri::Uri; use polywrap_msgpack_serde::to_vec; use polywrap_tests_utils::helpers::get_tests_path; @@ -6,7 +6,7 @@ use serde::Serialize; use super::get_client; -fn get_client_and_uri() -> (PolywrapClient, Uri) { +fn get_client_and_uri() -> (Client, Uri) { let test_path = get_tests_path().unwrap(); let path = test_path.into_os_string().into_string().unwrap(); let uri = format!("fs/{}/enum-type/implementations/rs", path) diff --git a/packages/client/tests/it/wrap_types/json.rs b/packages/client/tests/it/wrap_types/json.rs index ad13b61ce..bfcc61366 100644 --- a/packages/client/tests/it/wrap_types/json.rs +++ b/packages/client/tests/it/wrap_types/json.rs @@ -1,4 +1,4 @@ -use polywrap_client::client::PolywrapClient; +use polywrap_client::client::Client; use polywrap_client::core::uri::Uri; use polywrap_msgpack_serde::{to_vec, wrappers::polywrap_json}; use polywrap_tests_utils::helpers::get_tests_path; @@ -13,7 +13,7 @@ struct StringifyArgs { values: Vec, } -fn get_client_and_uri() -> (PolywrapClient, Uri) { +fn get_client_and_uri() -> (Client, Uri) { let test_path = get_tests_path().unwrap(); let path = test_path.into_os_string().into_string().unwrap(); let uri = format!("fs/{}/json-type/implementations/rs", path) diff --git a/packages/client/tests/it/wrap_types/map.rs b/packages/client/tests/it/wrap_types/map.rs index bad3aa324..e17177a77 100644 --- a/packages/client/tests/it/wrap_types/map.rs +++ b/packages/client/tests/it/wrap_types/map.rs @@ -1,4 +1,4 @@ -use polywrap_client::client::PolywrapClient; +use polywrap_client::client::Client; use polywrap_client::core::uri::Uri; use polywrap_client::plugin::Map; @@ -35,7 +35,7 @@ pub struct CustomMap { pub nestedMap: Map>, } -fn get_client_and_uri() -> (PolywrapClient, Uri) { +fn get_client_and_uri() -> (Client, Uri) { let test_path = get_tests_path().unwrap(); let path = test_path.into_os_string().into_string().unwrap(); let uri = format!("fs/{path}/map-type/implementations/rs") diff --git a/packages/client/tests/it/wrap_types/mod.rs b/packages/client/tests/it/wrap_types/mod.rs index 9858b280e..ab61a05da 100644 --- a/packages/client/tests/it/wrap_types/mod.rs +++ b/packages/client/tests/it/wrap_types/mod.rs @@ -1,8 +1,8 @@ use std::{collections::HashMap, sync::Arc}; -use polywrap_client::client::PolywrapClient; +use polywrap_client::client::Client; use polywrap_core::{ - client::ClientConfig, file_reader::SimpleFileReader, + client::CoreClientConfig, file_reader::SimpleFileReader, resolution::uri_resolution_context::UriPackageOrWrapper, uri::Uri, }; use polywrap_resolvers::{ @@ -21,7 +21,7 @@ pub mod map; pub mod numbers; pub mod object; -pub fn get_client(static_resolvers: Option>) -> PolywrapClient { +pub fn get_client(static_resolvers: Option>) -> Client { let file_reader = SimpleFileReader::new(); let fs_resolver = FilesystemResolver::new(Arc::new(file_reader)); @@ -36,10 +36,10 @@ pub fn get_client(static_resolvers: Option>) - Box::new(StaticResolver::new(static_resolver)), ); - let config = ClientConfig { + let config = CoreClientConfig { resolver: Arc::new(base_resolver), envs: None, interfaces: None, }; - PolywrapClient::new(config) + Client::new(config) } diff --git a/packages/client/tests/it/wrap_types/object.rs b/packages/client/tests/it/wrap_types/object.rs index 88f05498d..409ef81f4 100644 --- a/packages/client/tests/it/wrap_types/object.rs +++ b/packages/client/tests/it/wrap_types/object.rs @@ -1,4 +1,4 @@ -use polywrap_client::client::PolywrapClient; +use polywrap_client::client::Client; use polywrap_client::core::uri::Uri; use polywrap_msgpack_serde::to_vec; use polywrap_tests_utils::helpers::get_tests_path; @@ -6,7 +6,7 @@ use serde::{Deserialize, Serialize}; use super::get_client; -fn get_client_and_uri() -> (PolywrapClient, Uri) { +fn get_client_and_uri() -> (Client, Uri) { let test_path = get_tests_path().unwrap(); let path = test_path.into_os_string().into_string().unwrap(); let uri = format!("fs/{}/object-type/implementations/rs", path) diff --git a/packages/core/src/client.rs b/packages/core/src/client.rs index 81e54e41c..83f25ef01 100644 --- a/packages/core/src/client.rs +++ b/packages/core/src/client.rs @@ -34,14 +34,14 @@ impl From<(&Uri, &Uri)> for UriRedirect { } #[derive(Debug)] -pub struct ClientConfig { +pub struct CoreClientConfig { pub resolver: Arc, pub envs: Option>>, pub interfaces: Option, } -pub trait ClientConfigBuilder { - fn build(self) -> ClientConfig; +pub trait CoreClientConfigBuilder { + fn build(self) -> CoreClientConfig; } -pub trait Client: Invoker + WrapLoader + WrapInvoker + UriResolverHandler {} +pub trait CoreClient: Invoker + WrapLoader + WrapInvoker + UriResolverHandler {} diff --git a/packages/core/src/resolution/helpers.rs b/packages/core/src/resolution/helpers.rs index 00d24b012..f14bd898a 100644 --- a/packages/core/src/resolution/helpers.rs +++ b/packages/core/src/resolution/helpers.rs @@ -1,7 +1,7 @@ use std::sync::Arc; use crate::{ - client::Client, error::Error, file_reader::FileReader, + client::CoreClient, error::Error, file_reader::FileReader, interface_implementation::InterfaceImplementations, invoker::Invoker, uri::Uri, }; use polywrap_msgpack_serde::to_vec; @@ -71,7 +71,7 @@ impl FileReader for UriResolverExtensionFileReader { pub fn get_implementations( wrapper_uri: &Uri, interfaces: Option, - _: &dyn Client, + _: &dyn CoreClient, ) -> Result, Error> { let mut implementation_uris: Vec = vec![]; @@ -92,7 +92,7 @@ pub fn get_implementations( pub fn get_env_from_resolution_path( resolution_path: &[Uri], - client: &dyn Client, + client: &dyn CoreClient, ) -> Option> { for uri in resolution_path.iter() { let env = client.get_env_by_uri(uri); diff --git a/packages/default-config/src/system_config.rs b/packages/default-config/src/system_config.rs index 0624bec00..938d0896d 100644 --- a/packages/default-config/src/system_config.rs +++ b/packages/default-config/src/system_config.rs @@ -1,9 +1,9 @@ -use polywrap_client_builder::PolywrapClientConfig; +use polywrap_client_builder::ClientConfig; use polywrap_fs_plugin::FileSystemPlugin; use polywrap_http_plugin::HttpPlugin; use polywrap_logger_plugin::LoggerPlugin; -use polywrap_core::{client::ClientConfig, macros::uri, uri::Uri, package::WrapPackage}; +use polywrap_core::{client::CoreClientConfig, macros::uri, uri::Uri, package::WrapPackage}; use polywrap_msgpack_serde::to_vec; use polywrap_plugin::package::PluginPackage; use serde::Serialize; @@ -11,7 +11,7 @@ use std::{collections::HashMap, sync::Arc}; use crate::embeds::{fs_resolver, http_resolver, ipfs_http_client, ipfs_resolver}; -pub struct SystemClientConfig(PolywrapClientConfig); +pub struct SystemClientConfig(ClientConfig); impl SystemClientConfig { pub fn precompiled() -> Self { @@ -79,14 +79,14 @@ impl Default for SystemClientConfig { } } -impl Into for SystemClientConfig { - fn into(self) -> PolywrapClientConfig { +impl Into for SystemClientConfig { + fn into(self) -> ClientConfig { self.0 } } -impl Into for SystemClientConfig { - fn into(self) -> ClientConfig { +impl Into for SystemClientConfig { + fn into(self) -> CoreClientConfig { self.0.into() } } @@ -113,7 +113,7 @@ fn build_config(packages: Option)>>) -> SystemCli }; SystemClientConfig({ - PolywrapClientConfig { + ClientConfig { redirects: Some(HashMap::from([ ( uri!("wrapscan.io/polywrap/http@1.0"), diff --git a/packages/default-config/src/web3_config.rs b/packages/default-config/src/web3_config.rs index 2497ae04b..713801e16 100644 --- a/packages/default-config/src/web3_config.rs +++ b/packages/default-config/src/web3_config.rs @@ -1,12 +1,12 @@ -use polywrap_client_builder::PolywrapClientConfig; -use polywrap_core::{client::ClientConfig, macros::uri, uri::Uri}; +use polywrap_client_builder::ClientConfig; +use polywrap_core::{client::CoreClientConfig, macros::uri, uri::Uri}; use polywrap_ethereum_wallet_plugin::{ connection::Connection, connections::Connections, EthereumWalletPlugin, }; use polywrap_plugin::package::PluginPackage; use std::{collections::HashMap, sync::Arc}; -pub struct Web3ClientConfig(PolywrapClientConfig); +pub struct Web3ClientConfig(ClientConfig); impl Web3ClientConfig { fn get_ethereum_plugin() -> PluginPackage { @@ -35,7 +35,7 @@ impl Web3ClientConfig { impl Default for Web3ClientConfig { fn default() -> Self { - Self(PolywrapClientConfig { + Self(ClientConfig { interfaces: Some(HashMap::from([( uri!("wrapscan.io/polywrap/uri-resolver@1.0"), vec![ @@ -63,14 +63,14 @@ impl Default for Web3ClientConfig { } } -impl Into for Web3ClientConfig { - fn into(self) -> PolywrapClientConfig { +impl Into for Web3ClientConfig { + fn into(self) -> ClientConfig { self.0 } } -impl Into for Web3ClientConfig { - fn into(self) -> ClientConfig { +impl Into for Web3ClientConfig { + fn into(self) -> CoreClientConfig { self.0.into() } } diff --git a/packages/default-config/tests/it/ens.rs b/packages/default-config/tests/it/ens.rs index c63c50819..14c66ef62 100644 --- a/packages/default-config/tests/it/ens.rs +++ b/packages/default-config/tests/it/ens.rs @@ -1,5 +1,5 @@ -use polywrap_client::client::PolywrapClient; -use polywrap_client_builder::{PolywrapClientConfig, PolywrapClientConfigBuilder}; +use polywrap_client::client::Client; +use polywrap_client_builder::{ClientConfig, ClientConfigBuilder}; use polywrap_client_default_config::{SystemClientConfig, Web3ClientConfig}; use polywrap_msgpack_serde::to_vec; use serde::Serialize; @@ -12,12 +12,12 @@ pub struct ToWeiArgs { #[test] fn text_record_uri_resolver() { let wrap_uri = format!("ens/ethers.wraps.eth:utils@0.1.1"); - let mut config = PolywrapClientConfig::new(); + let mut config = ClientConfig::new(); config .add(SystemClientConfig::precompiled().into()) .add(Web3ClientConfig::default().into()); - let client = PolywrapClient::new(config.into()); + let client = Client::new(config.into()); let result = client.invoke::( &wrap_uri.parse().unwrap(), "toWei", @@ -36,12 +36,12 @@ fn text_record_uri_resolver() { #[test] fn content_hash_uri_resolver() { let wrap_uri = format!("ens/goerli/test-wraps.eth"); - let mut config = PolywrapClientConfig::new(); + let mut config = ClientConfig::new(); config .add(SystemClientConfig::default().into()) .add(Web3ClientConfig::default().into()); - let client = PolywrapClient::new(config.into()); + let client = Client::new(config.into()); let result = client.invoke::( &wrap_uri.parse().unwrap(), "toWei", diff --git a/packages/default-config/tests/it/fs.rs b/packages/default-config/tests/it/fs.rs index 129aca3e5..6196f065f 100644 --- a/packages/default-config/tests/it/fs.rs +++ b/packages/default-config/tests/it/fs.rs @@ -1,4 +1,4 @@ -use polywrap_client::client::PolywrapClient; +use polywrap_client::client::Client; use polywrap_client_default_config::SystemClientConfig; use polywrap_msgpack_serde::to_vec; use polywrap_tests_utils::helpers::get_tests_path; @@ -16,7 +16,7 @@ fn sanity() { let path = test_path.into_os_string().into_string().unwrap(); let subinvoke_wrap_uri = format!("fs/{path}/subinvoke/00-subinvoke/implementations/rs"); - let client = PolywrapClient::new(SystemClientConfig::precompiled().into()); + let client = Client::new(SystemClientConfig::precompiled().into()); let result = client .invoke::( diff --git a/packages/default-config/tests/it/http.rs b/packages/default-config/tests/it/http.rs index 4755ed540..e813c7507 100644 --- a/packages/default-config/tests/it/http.rs +++ b/packages/default-config/tests/it/http.rs @@ -1,6 +1,6 @@ use core::panic; -use polywrap_client::client::PolywrapClient; +use polywrap_client::client::Client; use polywrap_client_default_config::SystemClientConfig; use polywrap_msgpack_serde::to_vec; use serde::Serialize; @@ -16,7 +16,7 @@ struct Args { #[test] fn sanity() { - let client = PolywrapClient::new(SystemClientConfig::default().into()); + let client = Client::new(SystemClientConfig::default().into()); let result = client .invoke::( @@ -36,7 +36,7 @@ fn sanity() { assert_eq!(result, 42); - let client = PolywrapClient::new(SystemClientConfig::precompiled().into()); + let client = Client::new(SystemClientConfig::precompiled().into()); let result = client .invoke::( diff --git a/packages/default-config/tests/it/ipfs.rs b/packages/default-config/tests/it/ipfs.rs index 94f78c1bc..10b2f8efc 100644 --- a/packages/default-config/tests/it/ipfs.rs +++ b/packages/default-config/tests/it/ipfs.rs @@ -1,5 +1,5 @@ -use polywrap_client::client::PolywrapClient; -use polywrap_client_builder::{PolywrapClientConfig, PolywrapClientConfigBuilder}; +use polywrap_client::client::Client; +use polywrap_client_builder::{ClientConfig, ClientConfigBuilder}; use polywrap_client_default_config::SystemClientConfig; use polywrap_msgpack_serde::to_vec; @@ -9,10 +9,10 @@ const SUBINVOKE_WRAP_URI: &str = "wrap://ipfs/Qmf7jukQhTQekdSgKfdnFtB6ERTN6V7aT4 #[test] fn sanity() { - let mut config = PolywrapClientConfig::new(); + let mut config = ClientConfig::new(); config.add(SystemClientConfig::precompiled().into()); - let client = PolywrapClient::new(config.into()); + let client = Client::new(config.into()); let result = client .invoke::( &SUBINVOKE_WRAP_URI.parse().unwrap(), diff --git a/packages/default-config/tests/it/wrapscan.rs b/packages/default-config/tests/it/wrapscan.rs index 6cf0af753..f150d9ede 100644 --- a/packages/default-config/tests/it/wrapscan.rs +++ b/packages/default-config/tests/it/wrapscan.rs @@ -1,15 +1,15 @@ -use polywrap_client::client::PolywrapClient; -use polywrap_client_builder::{PolywrapClientConfig, PolywrapClientConfigBuilder}; +use polywrap_client::client::Client; +use polywrap_client_builder::{ClientConfig, ClientConfigBuilder}; use polywrap_client_default_config::SystemClientConfig; use polywrap_core::{wrap_loader::WrapLoader, uri::Uri, macros::uri}; #[test] fn sanity() { - let mut config = PolywrapClientConfig::new(); + let mut config = ClientConfig::new(); config .add(SystemClientConfig::precompiled().into()); - let client = PolywrapClient::new(config.into()); + let client = Client::new(config.into()); client .load_wrapper( &uri!("wrapscan.io/polywrap/wrapscan-uri-resolver@1.0.0"), diff --git a/packages/native/src/builder.rs b/packages/native/src/builder.rs index c4051110e..da57838cd 100644 --- a/packages/native/src/builder.rs +++ b/packages/native/src/builder.rs @@ -4,8 +4,8 @@ use std::{ }; use polywrap_client::{ - builder::{PolywrapClientConfig, PolywrapClientConfigBuilder}, - client::PolywrapClient, + builder::{ClientConfig, ClientConfigBuilder}, + client::Client, core::uri::Uri, }; use polywrap_client_default_config::{SystemClientConfig, Web3ClientConfig}; @@ -21,11 +21,11 @@ use crate::{ wrapper::FFIWrapper, }; -pub struct FFIBuilderConfig(Mutex); +pub struct FFIBuilderConfig(Mutex); impl FFIBuilderConfig { pub fn new() -> FFIBuilderConfig { - FFIBuilderConfig(Mutex::new(PolywrapClientConfig::new())) + FFIBuilderConfig(Mutex::new(ClientConfig::new())) } pub fn get_interfaces(&self) -> Option>>> { @@ -193,7 +193,7 @@ impl FFIBuilderConfig { pub fn build(&self) -> Arc { let config = self.0.lock().unwrap().clone(); - let client = Arc::new(PolywrapClient::new(config.into())); + let client = Arc::new(Client::new(config.into())); Arc::new(FFIClient::new(client)) } } diff --git a/packages/native/src/client.rs b/packages/native/src/client.rs index d5dc1d6f0..bb2d4866f 100644 --- a/packages/native/src/client.rs +++ b/packages/native/src/client.rs @@ -1,6 +1,6 @@ use std::{collections::HashMap, ops::{DerefMut, Deref}, sync::Arc}; -use polywrap_client::core::{client::Client, invoker::Invoker}; +use polywrap_client::core::{client::CoreClient, invoker::Invoker}; use crate::{ error::FFIError, @@ -12,11 +12,11 @@ use crate::{ #[derive(Clone)] pub struct FFIClient { - inner_client: Arc, + inner_client: Arc, } impl FFIClient { - pub fn new(client: Arc) -> FFIClient { + pub fn new(client: Arc) -> FFIClient { Self { inner_client: client, } @@ -178,10 +178,10 @@ impl Invoker for FFIClient { #[cfg(test)] mod test { - use polywrap_client::builder::PolywrapClientConfigBuilder; + use polywrap_client::builder::ClientConfigBuilder; use polywrap_client::core::macros::uri; use polywrap_client::core::uri::Uri; - use polywrap_client::{builder::PolywrapClientConfig, client::PolywrapClient}; + use polywrap_client::{builder::ClientConfig, client::Client}; use std::{collections::HashMap, sync::Arc}; use polywrap_client_default_config::{SystemClientConfig, Web3ClientConfig}; @@ -261,12 +261,12 @@ mod test { #[test] fn ffi_invoke_raw_real() { - let mut config = PolywrapClientConfig::new(); + let mut config = ClientConfig::new(); config .add(SystemClientConfig::precompiled().into()) .add(Web3ClientConfig::default().into()); - let client = Arc::from(PolywrapClient::new(config.into())); + let client = Arc::from(Client::new(config.into())); let ffi_client = FFIClient::new(client.clone()); const SUBINVOKE_WRAP_URI: &str = @@ -291,10 +291,10 @@ mod test { let from_uri: Uri = uri!("wrap://mock/from"); let to_uri: Uri = uri!("wrap://mock/to"); - let mut config: PolywrapClientConfig = PolywrapClientConfig::new(); + let mut config: ClientConfig = ClientConfig::new(); config.add_redirect(from_uri.clone(), to_uri.clone()); - let client = Arc::from(PolywrapClient::new(config.into())); + let client = Arc::from(Client::new(config.into())); let ffi_client = FFIClient::new(client.clone()); let uri = ffi_uri_from_string(&from_uri.to_string()).unwrap(); @@ -319,12 +319,12 @@ mod test { #[test] fn ffi_try_resolve_uri_to_package() { - let mut config = PolywrapClientConfig::new(); + let mut config = ClientConfig::new(); config .add(SystemClientConfig::precompiled().into()) .add(Web3ClientConfig::default().into()); - let client = Arc::from(PolywrapClient::new(config.into())); + let client = Arc::from(Client::new(config.into())); let ffi_client = FFIClient::new(client.clone()); const SUBINVOKE_WRAP_URI: &str = @@ -364,11 +364,11 @@ mod test { #[test] fn ffi_try_resolve_uri_to_wrapper() { - let mut config = PolywrapClientConfig::new(); + let mut config = ClientConfig::new(); config .add_wrapper("wrap://mock/uri".parse().unwrap(), Arc::new(MockWrapper)); - let client = Arc::from(PolywrapClient::new(config.into())); + let client = Arc::from(Client::new(config.into())); let ffi_client = FFIClient::new(client.clone()); const SUBINVOKE_WRAP_URI: &str = diff --git a/packages/plugins/ethereum-wallet/tests/it/main.rs b/packages/plugins/ethereum-wallet/tests/it/main.rs index 55ce27365..6aa0298cb 100644 --- a/packages/plugins/ethereum-wallet/tests/it/main.rs +++ b/packages/plugins/ethereum-wallet/tests/it/main.rs @@ -1,5 +1,5 @@ use polywrap_client::{ - client::PolywrapClient, + client::Client, resolvers::static_resolver::{StaticResolver, StaticResolverLike}, }; use polywrap_ethereum_wallet_plugin::{ @@ -18,7 +18,7 @@ pub struct ConnectionArgs { node: Option, } -fn get_client() -> PolywrapClient { +fn get_client() -> Client { let bsc_connection = Connection::new( "https://bsc-dataseed1.binance.org/".to_string(), Some(String::from( @@ -53,7 +53,7 @@ fn get_client() -> PolywrapClient { package, )]); - PolywrapClient::new(ClientConfig { + Client::new(CoreClientConfig { resolver: Arc::new(resolver), interfaces: None, envs: None, diff --git a/packages/plugins/fs/tests/it/main.rs b/packages/plugins/fs/tests/it/main.rs index ec348987a..a0d586656 100644 --- a/packages/plugins/fs/tests/it/main.rs +++ b/packages/plugins/fs/tests/it/main.rs @@ -1,5 +1,5 @@ use polywrap_client::{ - client::PolywrapClient, + client::Client, resolvers::static_resolver::{StaticResolver, StaticResolverLike}, }; use polywrap_fs_plugin::FileSystemPlugin; @@ -39,7 +39,7 @@ fn clean_up_temp_files() -> std::io::Result<()> { Ok(()) } -fn get_client() -> PolywrapClient { +fn get_client() -> Client { let fs_plugin = FileSystemPlugin {}; let plugin_pkg: PluginPackage = fs_plugin.into(); let package = Arc::new(plugin_pkg); @@ -49,7 +49,7 @@ fn get_client() -> PolywrapClient { package, )]); - PolywrapClient::new(ClientConfig { + Client::new(CoreClientConfig { resolver: Arc::new(resolver), interfaces: None, envs: None, diff --git a/packages/plugins/http/tests/it/main.rs b/packages/plugins/http/tests/it/main.rs index 39f03b807..16519c922 100644 --- a/packages/plugins/http/tests/it/main.rs +++ b/packages/plugins/http/tests/it/main.rs @@ -1,5 +1,5 @@ use polywrap_client::{ - client::PolywrapClient, + client::Client, resolvers::static_resolver::{StaticResolver, StaticResolverLike}, }; use polywrap_http_plugin::HttpPlugin; @@ -9,7 +9,7 @@ use std::sync::Arc; mod get; mod post; -pub fn get_client() -> PolywrapClient { +pub fn get_client() -> Client { let http_plugin = HttpPlugin {}; let package = Arc::new(PluginPackage::from(http_plugin)); @@ -18,7 +18,7 @@ pub fn get_client() -> PolywrapClient { package, )]); - PolywrapClient::new(ClientConfig { + Client::new(CoreClientConfig { resolver: Arc::new(resolver), interfaces: None, envs: None, diff --git a/packages/plugins/logger/src/lib.rs b/packages/plugins/logger/src/lib.rs index e24c8a448..0ad048288 100644 --- a/packages/plugins/logger/src/lib.rs +++ b/packages/plugins/logger/src/lib.rs @@ -60,10 +60,10 @@ impl Module for LoggerPlugin { mod tests { use super::*; use polywrap_client::{ - builder::{PolywrapClientConfig, PolywrapClientConfigBuilder}, - client::PolywrapClient, + builder::{ClientConfig, ClientConfigBuilder}, + client::Client, }; - use polywrap_core::{client::ClientConfigBuilder, macros::uri, uri::Uri}; + use polywrap_core::{client::CoreClientConfigBuilder, macros::uri, uri::Uri}; use polywrap_msgpack_serde::to_vec; use polywrap_plugin::package::PluginPackage; @@ -74,11 +74,11 @@ mod tests { message: String::from("Info message"), }; - let mut builder = PolywrapClientConfig::new(); + let mut builder = ClientConfig::new(); let logger_plugin = LoggerPlugin::new(None); let logger_package: PluginPackage = PluginPackage::from(logger_plugin); builder.add_package(uri!("plugin/logger"), Arc::new(logger_package)); - let client = PolywrapClient::new(builder.build()); + let client = Client::new(builder.build()); let result = client.invoke::( &uri!("plugin/logger"), "log", diff --git a/packages/tests-utils/src/mocks/client.rs b/packages/tests-utils/src/mocks/client.rs index 832eb89ef..98c99146d 100644 --- a/packages/tests-utils/src/mocks/client.rs +++ b/packages/tests-utils/src/mocks/client.rs @@ -4,7 +4,7 @@ use std::{ }; use polywrap_core::{ - client::Client, + client::CoreClient, invoker::Invoker, macros::uri, resolution::uri_resolution_context::{UriPackageOrWrapper, UriResolutionContext}, @@ -83,8 +83,8 @@ impl UriResolverHandler for MockClient { } } -impl Client for MockClient {} +impl CoreClient for MockClient {} -pub fn get_mock_client() -> Arc { +pub fn get_mock_client() -> Arc { Arc::new(MockClient {}) }