Skip to content

Commit

Permalink
Update macro
Browse files Browse the repository at this point in the history
  • Loading branch information
kpob committed Mar 21, 2024
1 parent 76e6ee9 commit 5792168
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 26 deletions.
54 changes: 32 additions & 22 deletions odra-macros/src/ast/schema/entry_points.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl ToTokens for SchemaEntrypointsItem {
#name,
#desc,
#is_mut,
vec![ #(#args),* ]
odra::prelude::vec![ #(#args),* ]
)
}
})
Expand All @@ -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<odra::schema::casper_contract_schema::Entrypoint> {
vec![ #(#fns),* ]
fn schema_entrypoints() -> odra::prelude::vec::Vec<odra::schema::casper_contract_schema::Entrypoint> {
odra::prelude::vec![ #(#fns),* ]
}
}
};
Expand Down Expand Up @@ -89,31 +89,31 @@ mod test {
#[automatically_derived]
#[cfg(not(target_arch = "wasm32"))]
impl odra::schema::SchemaEntrypoints for Erc20 {
fn schema_entrypoints() -> Vec<odra::schema::casper_contract_schema::Entrypoint> {
vec![
fn schema_entrypoints() -> odra::prelude::vec::Vec<odra::schema::casper_contract_schema::Entrypoint> {
odra::prelude::vec![
odra::schema::entry_point::<()>(
"init",
"Initializes the contract with the given parameters.",
true,
vec![odra::schema::argument::<Option<U256> >("total_supply")]
odra::prelude::vec![odra::schema::argument::<Option<U256> >("total_supply")]
),
odra::schema::entry_point::<U256>(
"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::<Address>("to"),
odra::schema::argument::<U256>("amount"),
odra::schema::argument::<Maybe<String> >("msg")
Expand All @@ -123,7 +123,7 @@ mod test {
"airdrop",
"Airdrops the given amount to the given addresses.",
false,
vec![
odra::prelude::vec![
odra::schema::argument::<odra::prelude::vec::Vec<Address> >("to"),
odra::schema::argument::<U256>("amount")
]
Expand All @@ -143,10 +143,10 @@ mod test {
#[automatically_derived]
#[cfg(not(target_arch = "wasm32"))]
impl odra::schema::SchemaEntrypoints for Erc20 {
fn schema_entrypoints() -> Vec<odra::schema::casper_contract_schema::Entrypoint> {
vec![
odra::schema::entry_point::<U256>("total_supply", "", false, vec![]),
odra::schema::entry_point::<()>("pay_to_mint", "", true, vec![])
fn schema_entrypoints() -> odra::prelude::vec::Vec<odra::schema::casper_contract_schema::Entrypoint> {
odra::prelude::vec![
odra::schema::entry_point::<U256>("total_supply", "", false, odra::prelude::vec![]),
odra::schema::entry_point::<()>("pay_to_mint", "", true, odra::prelude::vec![])
]
}
}
Expand All @@ -162,27 +162,37 @@ mod test {
#[automatically_derived]
#[cfg(not(target_arch = "wasm32"))]
impl odra::schema::SchemaEntrypoints for Erc20 {
fn schema_entrypoints() -> Vec<odra::schema::casper_contract_schema::Entrypoint> {
vec![
fn schema_entrypoints() -> odra::prelude::vec::Vec<odra::schema::casper_contract_schema::Entrypoint> {
odra::prelude::vec![
odra::schema::entry_point::<U256>(
"total_supply",
"Returns the total supply of the token.",
false,
vec![]
odra::prelude::vec![]
),
odra::schema::entry_point::<Address>(
"get_owner",
"Returns the owner of the contract.",
false,
odra::prelude::vec![]
),
odra::schema::entry_point::<Address>("get_owner", "A", false, vec![]),
odra::schema::entry_point::<()>(
"set_owner",
"C",
"Sets the owner of the contract.",
true,
vec![odra::schema::argument::<Address>("new_owner")]
odra::prelude::vec![odra::schema::argument::<Address>("new_owner")]
),
odra::schema::entry_point::<String>(
"name",
"Returns the name of the token.",
false,
odra::prelude::vec![]
),
odra::schema::entry_point::<String>("name", "W", false, vec![]),
odra::schema::entry_point::<String>(
"symbol",
"Delegated. See `self.metadata.symbol()` for details.",
false,
vec![]
odra::prelude::vec![]
)
]
}
Expand Down
6 changes: 3 additions & 3 deletions odra-macros/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion odra-schema/src/custom_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ impl<M: SchemaEvents> SchemaEvents for SubModule<M> {
fn schema_events() -> Vec<casper_contract_schema::Event> {
M::schema_events()
}

fn custom_types() -> Vec<Option<CustomType>> {
M::custom_types()
}
Expand Down

0 comments on commit 5792168

Please sign in to comment.