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

fix: Revert breaking changes #416

Merged
merged 5 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ and this project adheres to
### Added

- Emit error if contract macro is above entry_points
- Remove support for `, custom(msg=.. ,query=..)` in entry_points
- Deprecate support for `, custom(msg=.. ,query=..)` in entry_points
jawoznia marked this conversation as resolved.
Show resolved Hide resolved
- Add CustomMsg and CustomQuery to ContractApi

### Fixed
Expand All @@ -19,7 +19,7 @@ and this project adheres to
### Other

- *(sylvia-derive)* Document inner types
- [**breaking**] Remove `InterfaceApi` in favor of `InterfaceMessagesApi` ([#413](https://github.com/CosmWasm/sylvia/pull/413))
- Deprecate `InterfaceApi` in favor of `InterfaceMessagesApi` ([#413](https://github.com/CosmWasm/sylvia/pull/413))
jawoznia marked this conversation as resolved.
Show resolved Hide resolved
- Fix duplicated instantiation error
- Refactor struct message generation
- Generic cw1-whitelist example ([#404](https://github.com/CosmWasm/sylvia/pull/404))
Expand Down
7 changes: 3 additions & 4 deletions MIGRATING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The `, custom(msg=..., query=...)` part is now not supported and can be safely r

```diff
-#[entry_points(generics<Empty, Empty>, custom(msg=Empty, query=Empty))]
+#[entry_points(generics<msg=Empty, query=Empty>)]
+#[entry_points(generics<Empty, Empty>)]
#[contract]
#[sv::custom(msg=E, query=Q)]
impl<E, Q> CounterContract<E, Q>
Expand All @@ -24,15 +24,14 @@ where

### Removed `InterfaceApi` trait

The `InterfaceApi` trait has been removed in favor of the `InterfaceMessagesApi`.
The `InterfaceApi` trait has been deprecated in favor of the `InterfaceMessagesApi`.
It will be removed in the `2.0.0` release.

```diff
-let _ = <dyn super::sv::Api as sylvia::types::InterfaceApi>::Query::query_something();
+let _ = <dyn super::MyInterface as super::sv::InterfaceMessagesApi>::Query::query_something();
```

Note: the `InterfaceMessagesApi` does not expose Querier type.

## 1.0.2 -> 1.1.0

### Generics in `sv::messages` not required
Expand Down
127 changes: 127 additions & 0 deletions examples/interfaces/custom-and-generic/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,11 @@ pub trait CustomAndGeneric {
}

#[cfg(test)]
#[allow(deprecated)]
mod tests {
use cosmwasm_std::testing::mock_dependencies;
use cosmwasm_std::{Addr, CosmosMsg, Empty, QuerierWrapper};
use sylvia::types::InterfaceApi;

use crate::sv::Querier;

Expand Down Expand Up @@ -232,5 +234,130 @@ mod tests {
CosmosMsg::Custom(SvCustomMsg {}),
CosmosMsg::Custom(SvCustomMsg {}),
);

let _ = <dyn super::CustomAndGeneric<
Error = (),
Exec1T = SvCustomMsg,
Exec2T = SvCustomMsg,
Exec3T = SvCustomMsg,
Query1T = SvCustomMsg,
Query2T = SvCustomMsg,
Query3T = SvCustomMsg,
Sudo1T = SvCustomMsg,
Sudo2T = SvCustomMsg,
Sudo3T = SvCustomMsg,
ExecC = SvCustomMsg,
QueryC = SvCustomQuery,
RetT = SvCustomMsg,
> as super::sv::InterfaceMessagesApi>::Querier::borrowed(
&contract, &querier_wrapper
);

// Construct messages with InterfaceApi
let _ = <super::sv::Api<
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomQuery,
SvCustomMsg,
> as InterfaceApi>::Query::custom_generic_query_one(
SvCustomMsg {}, SvCustomMsg {}
);

let _ = <super::sv::Api<
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomQuery,
SvCustomMsg,
> as InterfaceApi>::Query::custom_generic_query_two(
SvCustomMsg {}, SvCustomMsg {}
);

let _ = <super::sv::Api<
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomQuery,
SvCustomMsg,
> as InterfaceApi>::Exec::custom_generic_execute_one(
vec![CosmosMsg::Custom(SvCustomMsg {})],
vec![CosmosMsg::Custom(SvCustomMsg {})],
);

let _ = <super::sv::Api<
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomQuery,
SvCustomMsg,
> as InterfaceApi>::Exec::custom_generic_execute_two(
vec![CosmosMsg::Custom(SvCustomMsg {})],
vec![CosmosMsg::Custom(SvCustomMsg {})],
);

let _ = <super::sv::Api<
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomQuery,
SvCustomMsg,
> as InterfaceApi>::Sudo::custom_generic_sudo_one(
CosmosMsg::Custom(SvCustomMsg {}),
CosmosMsg::Custom(SvCustomMsg {}),
);

let _ = <super::sv::Api<
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomQuery,
SvCustomMsg,
> as InterfaceApi>::Sudo::custom_generic_sudo_two(
CosmosMsg::Custom(SvCustomMsg {}),
CosmosMsg::Custom(SvCustomMsg {}),
);
}
}
110 changes: 110 additions & 0 deletions examples/interfaces/generic/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,11 @@ pub trait Generic {
}

#[cfg(test)]
#[allow(deprecated)]
mod tests {
use cosmwasm_std::testing::mock_dependencies;
use cosmwasm_std::{Addr, CosmosMsg, Empty, QuerierWrapper};
use sylvia::types::InterfaceApi;

use crate::sv::Querier;

Expand Down Expand Up @@ -209,6 +211,7 @@ mod tests {
CosmosMsg::Custom(SvCustomMsg {}),
CosmosMsg::Custom(SvCustomMsg {}),
);

let _ = <dyn super::Generic<
Exec1T = SvCustomMsg,
Exec2T = SvCustomMsg,
Expand All @@ -225,5 +228,112 @@ mod tests {
CosmosMsg::Custom(SvCustomMsg {}),
CosmosMsg::Custom(SvCustomMsg {}),
);

let _ = <dyn super::Generic<
Exec1T = SvCustomMsg,
Exec2T = SvCustomMsg,
Exec3T = SvCustomMsg,
Query1T = SvCustomMsg,
Query2T = SvCustomMsg,
Query3T = SvCustomMsg,
Sudo1T = SvCustomMsg,
Sudo2T = SvCustomMsg,
Sudo3T = SvCustomMsg,
RetT = Empty,
Error = (),
> as super::sv::InterfaceMessagesApi>::Querier::borrowed(
&contract, &querier_wrapper
);

// Construct messages with InterfaceApi
let _ = <super::sv::Api<
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
_,
_,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
> as InterfaceApi>::Query::generic_query_one(SvCustomMsg {}, SvCustomMsg {});

let _ = <super::sv::Api<
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
_,
_,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
> as InterfaceApi>::Query::generic_query_two(SvCustomMsg {}, SvCustomMsg {});

let _ = <super::sv::Api<
_,
_,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
cosmwasm_std::Empty,
> as InterfaceApi>::Exec::generic_exec_one(
vec![CosmosMsg::Custom(SvCustomMsg {})],
vec![CosmosMsg::Custom(SvCustomMsg {})],
);

let _ = <super::sv::Api<
SvCustomMsg,
_,
_,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
cosmwasm_std::Empty,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
> as InterfaceApi>::Exec::generic_exec_two(
vec![CosmosMsg::Custom(SvCustomMsg {})],
vec![CosmosMsg::Custom(SvCustomMsg {})],
);

let _ = <super::sv::Api<
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
_,
_,
SvCustomMsg,
cosmwasm_std::Empty,
> as InterfaceApi>::Sudo::generic_sudo_one(
CosmosMsg::Custom(SvCustomMsg {}),
CosmosMsg::Custom(SvCustomMsg {}),
);

let _ = <super::sv::Api<
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
SvCustomMsg,
cosmwasm_std::Empty,
SvCustomMsg,
SvCustomMsg,
_,
_,
SvCustomMsg,
> as InterfaceApi>::Sudo::generic_sudo_two(
CosmosMsg::Custom(SvCustomMsg {}),
CosmosMsg::Custom(SvCustomMsg {}),
);
}
}
4 changes: 2 additions & 2 deletions sylvia-derive/src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl<'a> InterfaceInput<'a> {
let Self {
associated_types,
item,
..
custom,
} = self;
let messages = self.emit_messages();
let associated_names: Vec<_> = associated_types
Expand All @@ -113,7 +113,7 @@ impl<'a> InterfaceInput<'a> {
let querier =
Querier::new(&query_variants, associated_types, &item.ident).emit_querier_trait();

let interface_messages = Api::new(item, associated_types).emit();
let interface_messages = Api::new(item, custom, associated_types).emit();

let multitest_helpers = self.emit_multitest_helpers();

Expand Down
Loading
Loading