-
Notifications
You must be signed in to change notification settings - Fork 477
Implement seal_is_contract and seal_caller_is_origin
#1129
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
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
b817ff8
[env][lang] add support for new `is_contract` API
agryaznov 9c39937
added `is_contract()` to ink_lang::EnvAccess to use from within contr…
agryaznov 2a58c38
added `is-contract` example
agryaznov 5e1bc60
add support for `caller_is_origin()` API
agryaznov ff08823
updated is-contract example to use `caller_is_origin()` as well
agryaznov 623b044
Merge branch 'master' of github.com:agryaznov/ink into is_contract
agryaznov b1310fb
Corrections in response to @HCastrano review
agryaznov 81ec866
Merge branch 'master' of https://github.com/paritytech/ink into is_co…
agryaznov 444c497
removed `examples/is-contract`
agryaznov 5617aeb
turned back whitespaces in `env_access.rs` not to mess up with the ch…
agryaznov 0bfcd80
Merge branch 'master' of https://github.com/paritytech/ink into is_co…
agryaznov 4f76c30
added new functions to `experimental_offchain_engine`
agryaznov a40fab1
fixed `wrong_self_convention` clippy warning for `is_` functions
agryaznov 123474e
supressed `wrong_self_convention` clippy warning for `is_` functions
agryaznov 6ac81a7
Update crates/env/src/api.rs
agryaznov f5d9384
Merge branch 'master' of https://github.com/paritytech/ink into is_co…
agryaznov 68d7cc4
set `is_contract` and `caller_is_origin` as `unimplemented` in experi…
agryaznov b00e7e4
Apply suggestions from code review
agryaznov 2061940
message cant take ref as a param: revert suggested change
agryaznov 7d463d6
Merge branch 'master' of https://github.com/paritytech/ink into is_co…
agryaznov 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -839,4 +839,68 @@ where | |||||||||||||
| .map(|_| output.into()) | ||||||||||||||
| .map_err(|_| Error::EcdsaRecoveryFailed) | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| /// Checks whether a specified account belongs to a contract. | ||||||||||||||
| /// | ||||||||||||||
|
agryaznov marked this conversation as resolved.
|
||||||||||||||
| /// # Example | ||||||||||||||
| /// | ||||||||||||||
| /// ``` | ||||||||||||||
| /// # use ink_lang as ink; | ||||||||||||||
| /// # #[ink::contract] | ||||||||||||||
| /// # pub mod my_contract { | ||||||||||||||
| /// # #[ink(storage)] | ||||||||||||||
| /// # pub struct MyContract { } | ||||||||||||||
| /// # | ||||||||||||||
| /// # impl MyContract { | ||||||||||||||
| /// # #[ink(constructor)] | ||||||||||||||
| /// # pub fn new() -> Self { | ||||||||||||||
| /// # Self {} | ||||||||||||||
| /// # } | ||||||||||||||
| /// # | ||||||||||||||
| /// #[ink(message)] | ||||||||||||||
| /// pub fn is_contract(&mut self, account_id: AccountId) -> bool { | ||||||||||||||
| /// self.env().is_contract(&account_id) | ||||||||||||||
| /// } | ||||||||||||||
|
Comment on lines
+861
to
+863
Contributor
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.
Suggested change
Contributor
Author
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. Hm, no, this won't work as Ink messages can't take references as params. |
||||||||||||||
| /// # } | ||||||||||||||
| /// # } | ||||||||||||||
| /// ``` | ||||||||||||||
| /// | ||||||||||||||
| /// # Note | ||||||||||||||
| /// | ||||||||||||||
| /// For more details visit: [`ink_env::is_contract`] | ||||||||||||||
| pub fn is_contract(self, account_id: &T::AccountId) -> bool { | ||||||||||||||
| ink_env::is_contract::<T>(account_id) | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| /// Checks whether the caller of the current contract is the origin of the whole call stack. | ||||||||||||||
| /// | ||||||||||||||
|
agryaznov marked this conversation as resolved.
|
||||||||||||||
| /// # Example | ||||||||||||||
| /// | ||||||||||||||
| /// ``` | ||||||||||||||
| /// # use ink_lang as ink; | ||||||||||||||
| /// # #[ink::contract] | ||||||||||||||
| /// # pub mod my_contract { | ||||||||||||||
| /// # #[ink(storage)] | ||||||||||||||
| /// # pub struct MyContract { } | ||||||||||||||
| /// # | ||||||||||||||
| /// # impl MyContract { | ||||||||||||||
| /// # #[ink(constructor)] | ||||||||||||||
| /// # pub fn new() -> Self { | ||||||||||||||
| /// # Self {} | ||||||||||||||
| /// # } | ||||||||||||||
| /// # | ||||||||||||||
| /// #[ink(message)] | ||||||||||||||
| /// pub fn caller_is_origin(&mut self) -> bool { | ||||||||||||||
| /// self.env().caller_is_origin() | ||||||||||||||
| /// } | ||||||||||||||
| /// # } | ||||||||||||||
| /// # } | ||||||||||||||
| /// ``` | ||||||||||||||
| /// | ||||||||||||||
| /// # Note | ||||||||||||||
| /// | ||||||||||||||
| /// For more details visit: [`ink_env::caller_is_origin`] | ||||||||||||||
| pub fn caller_is_origin(self) -> bool { | ||||||||||||||
| ink_env::caller_is_origin::<T>() | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
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.
Uh oh!
There was an error while loading. Please reload this page.