-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Add trybuild check for two instantiate methods (#392)
- Loading branch information
1 parent
0cec90b
commit 3ab2a01
Showing
4 changed files
with
95 additions
and
3 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#![allow(unused_imports)] | ||
use sylvia::cw_std::{Response, StdResult}; | ||
use sylvia::types::InstantiateCtx; | ||
|
||
pub struct Contract; | ||
|
||
|
||
mod interface { | ||
use sylvia::cw_std::{Response, StdResult, StdError}; | ||
use sylvia::types::{InstantiateCtx, MigrateCtx}; | ||
|
||
#[sylvia::interface] | ||
trait Interface { | ||
type Error: From<StdError>; | ||
|
||
#[sv::msg(instantiate)] | ||
fn instantiate(&self, ctx: InstantiateCtx) -> StdResult<Response>; | ||
|
||
#[sv::msg(migrate)] | ||
fn migrate(&self, ctx: MigrateCtx) -> StdResult<Response>; | ||
} | ||
} | ||
|
||
#[sylvia::contract] | ||
impl Contract { | ||
pub const fn new() -> Self { | ||
Contract | ||
} | ||
|
||
#[sv::msg(instantiate)] | ||
pub fn instantiate(&self, ctx: InstantiateCtx) -> StdResult<Response> { | ||
Ok(Response::new()) | ||
} | ||
|
||
#[sv::msg(instantiate)] | ||
pub fn instantiate2(&self, ctx: InstantiateCtx) -> StdResult<Response> { | ||
Ok(Response::new()) | ||
} | ||
} | ||
|
||
fn main() {} |
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,26 @@ | ||
error: The message attribute `instantiate` is not supported in interfaces. | ||
|
||
= note: Contracts need to implement `instantiate` method within their `impl` block. | ||
|
||
--> tests/ui/missing_method/msgs_misused.rs:17:12 | ||
| | ||
17 | fn instantiate(&self, ctx: InstantiateCtx) -> StdResult<Response>; | ||
| ^^^^^^^^^^^ | ||
|
||
error: The message attribute `migrate` is not supported in interfaces | ||
|
||
= note: Contracts need to implement `migrate` method within their `impl` block. | ||
|
||
--> tests/ui/missing_method/msgs_misused.rs:20:12 | ||
| | ||
20 | fn migrate(&self, ctx: MigrateCtx) -> StdResult<Response>; | ||
| ^^^^^^^ | ||
|
||
error: More than one instantiation or migration message | ||
|
||
= note: Instantiation/Migration message previously defined here | ||
|
||
--> tests/ui/missing_method/msgs_misused.rs:35:5 | ||
| | ||
35 | #[sv::msg(instantiate)] | ||
| ^ |