-
Notifications
You must be signed in to change notification settings - Fork 16
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
chore: Review fixes #458
chore: Review fixes #458
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#![allow(unused_imports, unused_variables)] | ||
use sylvia::ctx::{InstantiateCtx, ReplyCtx}; | ||
use sylvia::cw_std::{Addr, Binary, Response, StdResult}; | ||
|
||
pub mod attributes_swapped { | ||
use super::*; | ||
|
||
pub struct Contract {} | ||
|
||
#[sylvia::contract] | ||
#[sv::features(replies)] | ||
impl Contract { | ||
pub const fn new() -> Self { | ||
Self {} | ||
} | ||
|
||
#[sv::msg(instantiate)] | ||
fn instantiate(&self, _ctx: InstantiateCtx) -> StdResult<Response> { | ||
Ok(Response::new()) | ||
} | ||
|
||
#[sv::msg(reply, reply_on=success)] | ||
fn reply( | ||
&self, | ||
_ctx: ReplyCtx, | ||
#[sv::payload(raw)] param: Binary, | ||
#[sv::data(opt, raw)] _data: Option<Binary>, | ||
) -> StdResult<Response> { | ||
Ok(Response::new()) | ||
} | ||
} | ||
} | ||
|
||
pub mod error_handler { | ||
use super::*; | ||
|
||
pub struct Contract {} | ||
|
||
#[sylvia::contract] | ||
#[sv::features(replies)] | ||
impl Contract { | ||
pub const fn new() -> Self { | ||
Self {} | ||
} | ||
|
||
#[sv::msg(instantiate)] | ||
fn instantiate(&self, _ctx: InstantiateCtx) -> StdResult<Response> { | ||
Ok(Response::new()) | ||
} | ||
|
||
#[sv::msg(reply, reply_on=error)] | ||
fn reply( | ||
&self, | ||
_ctx: ReplyCtx, | ||
#[sv::data(opt, raw)] _data: Option<Binary>, | ||
#[sv::payload(raw)] param: Binary, | ||
) -> StdResult<Response> { | ||
Ok(Response::new()) | ||
} | ||
} | ||
} | ||
|
||
fn main() {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
error: Wrong usage of `#[sv::data]` attribute. | ||
|
||
= note: The `#[sv::data]` attribute can only be used on the first parameter after the `ReplyCtx`. | ||
|
||
--> tests/ui/attributes/data/invalid_usage.rs:27:35 | ||
| | ||
27 | #[sv::data(opt, raw)] _data: Option<Binary>, | ||
| ^^^^^ | ||
|
||
error: Redundant payload parameter. | ||
|
||
= note: Expected no parameters after the parameter marked with `#[sv::payload(raw)]`. | ||
|
||
--> tests/ui/attributes/data/invalid_usage.rs:27:35 | ||
| | ||
27 | #[sv::data(opt, raw)] _data: Option<Binary>, | ||
| ^^^^^ | ||
|
||
error: Wrong usage of `#[sv::data]` attribute. | ||
|
||
= note: The `#[sv::data]` attribute can only be used in `success` scenario. | ||
= note: Found usage in `error` scenario. | ||
|
||
--> tests/ui/attributes/data/invalid_usage.rs:55:35 | ||
| | ||
55 | #[sv::data(opt, raw)] _data: Option<Binary>, | ||
| ^^^^^ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#![allow(unused_imports, unused_variables)] | ||
use sylvia::ctx::{InstantiateCtx, ReplyCtx}; | ||
use sylvia::cw_std::{Addr, Binary, Response, StdResult}; | ||
|
||
pub mod used_on_context { | ||
use super::*; | ||
|
||
pub struct Contract {} | ||
|
||
#[sylvia::contract] | ||
#[sv::features(replies)] | ||
impl Contract { | ||
pub const fn new() -> Self { | ||
Self {} | ||
} | ||
|
||
#[sv::msg(instantiate)] | ||
fn instantiate(&self, _ctx: InstantiateCtx) -> StdResult<Response> { | ||
Ok(Response::new()) | ||
} | ||
|
||
#[sv::msg(reply, reply_on=success)] | ||
fn reply(&self, #[sv::payload(raw)] _ctx: ReplyCtx) -> StdResult<Response> { | ||
Ok(Response::new()) | ||
} | ||
} | ||
} | ||
|
||
fn main() {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
error: Missing payload parameter. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's not 100% accurate - there is a payload parameter There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually there is a payload attribute, not parameter ^^ |
||
|
||
= note: Expected at least one payload parameter at the end of parameter list. | ||
|
||
--> tests/ui/attributes/payload/invalid_usage.rs:23:12 | ||
| | ||
23 | fn reply(&self, #[sv::payload(raw)] _ctx: ReplyCtx) -> StdResult<Response> { | ||
| ^^^^^ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NO
stands for number here? If so it's quite misleading in this contextThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ye, number of. It is a bit if you don't check the type. I will revert this change.