-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use ConstructorArgs trait for args on deploy with constructor (#1349)
### What Use ConstructorArgs trait for args on deploy with constructor, and rename deploy with constructor to deploy_v2. ### Why So that types can be passed directly to the deploy function like they can now be passed to the register function since #1343. I renamed the function to deploy_v2 for consistency with what we did when we added a second register for stellar asset contract function. I considered merging with the deploy function which would have been a breaking change, that I think we agreed would be worthwhile, but breaking is just such a bad experience and I think a _v2 is almost as good. We can consider merging the deploy functions at a later date. Close #1347
- Loading branch information
1 parent
9b7ac44
commit 01f27c1
Showing
5 changed files
with
59 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use crate::{Env, IntoVal, Val, Vec}; | ||
|
||
pub trait ConstructorArgs: IntoVal<Env, Vec<Val>> {} | ||
|
||
impl<T> ConstructorArgs for Vec<T> {} | ||
|
||
macro_rules! impl_constructor_args_for_tuple { | ||
( $($typ:ident $idx:tt)* ) => { | ||
impl<$($typ),*> ConstructorArgs for ($($typ,)*) | ||
where | ||
$($typ: IntoVal<Env, Val>),* | ||
{ | ||
} | ||
}; | ||
} | ||
|
||
// 0 topics | ||
impl ConstructorArgs for () {} | ||
// 1-13 topics | ||
impl_constructor_args_for_tuple! { T0 0 } | ||
impl_constructor_args_for_tuple! { T0 0 T1 1 } | ||
impl_constructor_args_for_tuple! { T0 0 T1 1 T2 2 } | ||
impl_constructor_args_for_tuple! { T0 0 T1 1 T2 2 T3 3 } | ||
impl_constructor_args_for_tuple! { T0 0 T1 1 T2 2 T3 3 T4 4 } | ||
impl_constructor_args_for_tuple! { T0 0 T1 1 T2 2 T3 3 T4 4 T5 5 } | ||
impl_constructor_args_for_tuple! { T0 0 T1 1 T2 2 T3 3 T4 4 T5 5 T6 6 } | ||
impl_constructor_args_for_tuple! { T0 0 T1 1 T2 2 T3 3 T4 4 T5 5 T6 6 T7 7 } | ||
impl_constructor_args_for_tuple! { T0 0 T1 1 T2 2 T3 3 T4 4 T5 5 T6 6 T7 7 T8 8 } | ||
impl_constructor_args_for_tuple! { T0 0 T1 1 T2 2 T3 3 T4 4 T5 5 T6 6 T7 7 T8 8 T9 9 } | ||
impl_constructor_args_for_tuple! { T0 0 T1 1 T2 2 T3 3 T4 4 T5 5 T6 6 T7 7 T8 8 T9 9 T10 10 } | ||
impl_constructor_args_for_tuple! { T0 0 T1 1 T2 2 T3 3 T4 4 T5 5 T6 6 T7 7 T8 8 T9 9 T10 10 T11 11 } | ||
impl_constructor_args_for_tuple! { T0 0 T1 1 T2 2 T3 3 T4 4 T5 5 T6 6 T7 7 T8 8 T9 9 T10 10 T11 11 T12 12 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters