From 5792168bb5bb9c03da9402beef0c61078789764b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Pobiar=C5=BCyn?= Date: Thu, 21 Mar 2024 14:32:59 +0100 Subject: [PATCH] Update macro --- odra-macros/src/ast/schema/entry_points.rs | 54 +++++++++++++--------- odra-macros/src/test_utils.rs | 6 +-- odra-schema/src/custom_type.rs | 2 +- 3 files changed, 36 insertions(+), 26 deletions(-) diff --git a/odra-macros/src/ast/schema/entry_points.rs b/odra-macros/src/ast/schema/entry_points.rs index a70ec054..a6abb7c7 100644 --- a/odra-macros/src/ast/schema/entry_points.rs +++ b/odra-macros/src/ast/schema/entry_points.rs @@ -34,7 +34,7 @@ impl ToTokens for SchemaEntrypointsItem { #name, #desc, #is_mut, - vec![ #(#args),* ] + odra::prelude::vec![ #(#args),* ] ) } }) @@ -44,8 +44,8 @@ impl ToTokens for SchemaEntrypointsItem { #[automatically_derived] #[cfg(not(target_arch = "wasm32"))] impl odra::schema::SchemaEntrypoints for #module_ident { - fn schema_entrypoints() -> Vec { - vec![ #(#fns),* ] + fn schema_entrypoints() -> odra::prelude::vec::Vec { + odra::prelude::vec![ #(#fns),* ] } } }; @@ -89,31 +89,31 @@ mod test { #[automatically_derived] #[cfg(not(target_arch = "wasm32"))] impl odra::schema::SchemaEntrypoints for Erc20 { - fn schema_entrypoints() -> Vec { - vec![ + fn schema_entrypoints() -> odra::prelude::vec::Vec { + odra::prelude::vec![ odra::schema::entry_point::<()>( "init", "Initializes the contract with the given parameters.", true, - vec![odra::schema::argument:: >("total_supply")] + odra::prelude::vec![odra::schema::argument:: >("total_supply")] ), odra::schema::entry_point::( "total_supply", "Returns the total supply of the token.", false, - vec![] + odra::prelude::vec![] ), odra::schema::entry_point::<()>( "pay_to_mint", "Pay to mint.", true, - vec![] + odra::prelude::vec![] ), odra::schema::entry_point::<()>( "approve", "Approve.", true, - vec![ + odra::prelude::vec![ odra::schema::argument::
("to"), odra::schema::argument::("amount"), odra::schema::argument:: >("msg") @@ -123,7 +123,7 @@ mod test { "airdrop", "Airdrops the given amount to the given addresses.", false, - vec![ + odra::prelude::vec![ odra::schema::argument:: >("to"), odra::schema::argument::("amount") ] @@ -143,10 +143,10 @@ mod test { #[automatically_derived] #[cfg(not(target_arch = "wasm32"))] impl odra::schema::SchemaEntrypoints for Erc20 { - fn schema_entrypoints() -> Vec { - vec![ - odra::schema::entry_point::("total_supply", "", false, vec![]), - odra::schema::entry_point::<()>("pay_to_mint", "", true, vec![]) + fn schema_entrypoints() -> odra::prelude::vec::Vec { + odra::prelude::vec![ + odra::schema::entry_point::("total_supply", "", false, odra::prelude::vec![]), + odra::schema::entry_point::<()>("pay_to_mint", "", true, odra::prelude::vec![]) ] } } @@ -162,27 +162,37 @@ mod test { #[automatically_derived] #[cfg(not(target_arch = "wasm32"))] impl odra::schema::SchemaEntrypoints for Erc20 { - fn schema_entrypoints() -> Vec { - vec![ + fn schema_entrypoints() -> odra::prelude::vec::Vec { + odra::prelude::vec![ odra::schema::entry_point::( "total_supply", "Returns the total supply of the token.", false, - vec![] + odra::prelude::vec![] + ), + odra::schema::entry_point::
( + "get_owner", + "Returns the owner of the contract.", + false, + odra::prelude::vec![] ), - odra::schema::entry_point::
("get_owner", "A", false, vec![]), odra::schema::entry_point::<()>( "set_owner", - "C", + "Sets the owner of the contract.", true, - vec![odra::schema::argument::
("new_owner")] + odra::prelude::vec![odra::schema::argument::
("new_owner")] + ), + odra::schema::entry_point::( + "name", + "Returns the name of the token.", + false, + odra::prelude::vec![] ), - odra::schema::entry_point::("name", "W", false, vec![]), odra::schema::entry_point::( "symbol", "Delegated. See `self.metadata.symbol()` for details.", false, - vec![] + odra::prelude::vec![] ) ] } diff --git a/odra-macros/src/test_utils.rs b/odra-macros/src/test_utils.rs index 7c78b74e..8b3d1d21 100644 --- a/odra-macros/src/test_utils.rs +++ b/odra-macros/src/test_utils.rs @@ -82,14 +82,14 @@ pub mod mock { delegate! { to self.ownable { - /// A + /// Returns the owner of the contract. fn get_owner(&self) -> Address; - /// C + /// Sets the owner of the contract. fn set_owner(&mut self, new_owner: Address); } to self.metadata { - /// W + /// Returns the name of the token. fn name(&self) -> String; fn symbol(&self) -> String; } diff --git a/odra-schema/src/custom_type.rs b/odra-schema/src/custom_type.rs index 5123d523..1b460fce 100644 --- a/odra-schema/src/custom_type.rs +++ b/odra-schema/src/custom_type.rs @@ -165,7 +165,7 @@ impl SchemaEvents for SubModule { fn schema_events() -> Vec { M::schema_events() } - + fn custom_types() -> Vec> { M::custom_types() }