-
Notifications
You must be signed in to change notification settings - Fork 443
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow specifying
payable
constructors (#1065)
* Add `payable` constructor support to IR * Add payable associated type to `DispatchableConstructorInfo` * Allow constructors to be payable in dispatcher codegen * Add UI tests * Remove test related to constructors being implicitly payable * Add some failing UI tests * Deny payments on `deploy` if there are no payable constructors * Appease Clippy * Deny payments when executing constructors * `s/message/constructor/g` * RustFmt * Address `unnecessary_to_owned` lint Reference: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_to_owned * Address `needless_borrow` lint Reference: https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow * Make a note about this PR in the RELEASES doc * Allow `clippy::nonminimal_bool` for `deploy()` * Remove `any_payable_*` checks from individual Config creation It looks like this was meant to be part of an optimization, however it doesn't look like this is necessary anymore. If no constructor or message is payable we already do early deny payment checks in `deploy()` and `call()` respectively. * Add UI test for multiple non-payable constructors
- Loading branch information
Showing
14 changed files
with
261 additions
and
43 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
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() {} |
Oops, something went wrong.