Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove async_trait import #397

Open
dj8yfo opened this issue Dec 24, 2024 · 0 comments
Open

remove async_trait import #397

dj8yfo opened this issue Dec 24, 2024 · 0 comments

Comments

@dj8yfo
Copy link
Collaborator

dj8yfo commented Dec 24, 2024

it was noticed during review of #369 that async_trait import and annotations can be potentially removed,

more details on blog post

crate compiles with following diff and tests pass:

diff --git a/workspaces/Cargo.toml b/workspaces/Cargo.toml
index d4b1c45..0ed2f29 100644
--- a/workspaces/Cargo.toml
+++ b/workspaces/Cargo.toml
@@ -42,2 +42,3 @@ near-sandbox-utils = "0.13"
 near-chain-configs = { version = "0.28", optional = true }
+trait-variant = "0.1.2"
 
diff --git a/workspaces/src/network/betanet.rs b/workspaces/src/network/betanet.rs
index 872a01d..f6add88 100644
--- a/workspaces/src/network/betanet.rs
+++ b/workspaces/src/network/betanet.rs
@@ -28,3 +28,3 @@ pub struct Betanet {
 
-#[async_trait::async_trait]
+// #[async_trait::async_trait]
 impl FromNetworkBuilder for Betanet {
diff --git a/workspaces/src/network/builder.rs b/workspaces/src/network/builder.rs
index 2e48e44..3d7b524 100644
--- a/workspaces/src/network/builder.rs
+++ b/workspaces/src/network/builder.rs
@@ -18,4 +18,6 @@ pub(crate) type BoxFuture<'a, T> = std::pin::Pin<Box<dyn Future<Output = T> + Se
 /// ```
-#[async_trait::async_trait]
-pub(crate) trait FromNetworkBuilder: Sized {
+// #[async_trait::async_trait]
+
+#[trait_variant::make(FromNetworkBuilder: Send)]
+pub(crate) trait LocalFromNetworkBuilder: Sized {
     async fn from_builder<'a>(build: NetworkBuilder<'a, Self>) -> crate::result::Result<Self>;
diff --git a/workspaces/src/network/custom.rs b/workspaces/src/network/custom.rs
index c47296a..3a67992 100644
--- a/workspaces/src/network/custom.rs
+++ b/workspaces/src/network/custom.rs
@@ -13,3 +13,3 @@ pub struct Custom {
 
-#[async_trait::async_trait]
+// #[async_trait::async_trait]
 impl FromNetworkBuilder for Custom {
diff --git a/workspaces/src/network/mainnet.rs b/workspaces/src/network/mainnet.rs
index 65ab757..a94e044 100644
--- a/workspaces/src/network/mainnet.rs
+++ b/workspaces/src/network/mainnet.rs
@@ -29,3 +29,3 @@ pub struct Mainnet {
 
-#[async_trait::async_trait]
+// #[async_trait::async_trait]
 impl FromNetworkBuilder for Mainnet {
diff --git a/workspaces/src/network/sandbox.rs b/workspaces/src/network/sandbox.rs
index 9c97526..e7a328d 100644
--- a/workspaces/src/network/sandbox.rs
+++ b/workspaces/src/network/sandbox.rs
@@ -125,3 +125,3 @@ impl std::fmt::Debug for Sandbox {
 
-#[async_trait]
+// #[async_trait]
 impl FromNetworkBuilder for Sandbox {
@@ -132,3 +132,3 @@ impl FromNetworkBuilder for Sandbox {
 
-#[async_trait]
+// #[async_trait]
 impl TopLevelAccountCreator for Sandbox {
@@ -178,3 +178,3 @@ impl TopLevelAccountCreator for Sandbox {
 
-#[async_trait]
+// #[async_trait]
 impl SponsoredAccountCreator for Sandbox {
diff --git a/workspaces/src/network/testnet.rs b/workspaces/src/network/testnet.rs
index 7f6efd2..8721675 100644
--- a/workspaces/src/network/testnet.rs
+++ b/workspaces/src/network/testnet.rs
@@ -40,3 +40,3 @@ pub struct Testnet {
 
-#[async_trait]
+// #[async_trait]
 impl FromNetworkBuilder for Testnet {
@@ -68,3 +68,3 @@ impl std::fmt::Debug for Testnet {
 
-#[async_trait]
+// #[async_trait]
 impl SponsoredAccountCreator for Testnet {
diff --git a/workspaces/src/network/variants.rs b/workspaces/src/network/variants.rs
index e12c749..96e4952 100644
--- a/workspaces/src/network/variants.rs
+++ b/workspaces/src/network/variants.rs
@@ -25,3 +25,3 @@ pub trait NetworkInfo {
 /// It is expected that the `subaccount_prefix` does not contain a `.`.
-#[async_trait]
+// #[async_trait]
 pub trait SponsoredAccountCreator {
@@ -43,3 +43,3 @@ pub trait SponsoredAccountCreator {
 
-#[async_trait]
+// #[async_trait]
 pub trait TopLevelAccountCreator {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: NEW❗
Development

No branches or pull requests

1 participant