-
Notifications
You must be signed in to change notification settings - Fork 428
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
Allow specifying payable
constructors
#1065
Merged
Merged
Changes from 11 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
f49184e
Add `payable` constructor support to IR
HCastano 325f1dc
Add payable associated type to `DispatchableConstructorInfo`
HCastano c42e371
Allow constructors to be payable in dispatcher codegen
HCastano 2acf3c5
Add UI tests
HCastano 8313263
Remove test related to constructors being implicitly payable
HCastano fb4f136
Add some failing UI tests
HCastano ebbff47
Deny payments on `deploy` if there are no payable constructors
HCastano e07772d
Appease Clippy
HCastano aeaf383
Deny payments when executing constructors
HCastano cb7188f
`s/message/constructor/g`
HCastano 206bdac
RustFmt
HCastano d14cbd2
Merge branch 'master' into hc-make-constructors-non-payable
HCastano d081127
Address `unnecessary_to_owned` lint
HCastano 1de66b4
Address `needless_borrow` lint
HCastano 9f0a8b8
Make a note about this PR in the RELEASES doc
HCastano 4c648d0
Merge branch 'master' into hc-make-constructors-non-payable
HCastano c72a352
Merge branch 'master' into hc-make-constructors-non-payable
HCastano aebeb39
Allow `clippy::nonminimal_bool` for `deploy()`
HCastano d70973d
Remove `any_payable_*` checks from individual Config creation
HCastano d915ec0
Add UI test for multiple non-payable constructors
HCastano File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
5 changes: 5 additions & 0 deletions
5
crates/lang/tests/ui/contract/fail/constructor-payable-invalid-1.stderr
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,5 @@ | ||
error: unknown ink! attribute argument (name = value) | ||
--> tests/ui/contract/fail/constructor-payable-invalid-1.rs:9:28 | ||
| | ||
9 | #[ink(constructor, payable = true)] | ||
| ^^^^^^^^^^^^^^ |
19 changes: 19 additions & 0 deletions
19
crates/lang/tests/ui/contract/fail/constructor-payable-invalid-2.rs
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,19 @@ | ||
use ink_lang as ink; | ||
|
||
#[ink::contract] | ||
mod contract { | ||
#[ink(storage)] | ||
pub struct Contract {} | ||
|
||
impl Contract { | ||
#[ink(constructor, payable = false)] | ||
pub fn constructor() -> Self { | ||
Self {} | ||
} | ||
|
||
#[ink(message)] | ||
pub fn message(&self) {} | ||
} | ||
} | ||
|
||
fn main() {} |
5 changes: 5 additions & 0 deletions
5
crates/lang/tests/ui/contract/fail/constructor-payable-invalid-2.stderr
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,5 @@ | ||
error: unknown ink! attribute argument (name = value) | ||
--> tests/ui/contract/fail/constructor-payable-invalid-2.rs:9:28 | ||
| | ||
9 | #[ink(constructor, payable = false)] | ||
| ^^^^^^^^^^^^^^^ |
11 changes: 0 additions & 11 deletions
11
crates/lang/tests/ui/contract/fail/constructor-payable.stderr
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Hmm, not happy about this. This possibility of
payable
being set totrue
despite no payable constructor seems to be destined for a bug. How about we reflect this information e.g. with an enum here as a wrapper around thebool
?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.
I think there was already a small bug here actually. If there were indeed no payable messages for example, we'd never hit this check. Although to be fair, payment would have been denied in call() (maybe this was the optimization alluded to in the comment?).
Either way, this was confusing and I think it's unnecessary so I removed it.