Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
64901a9
Implement wildcard selector, add `proxy` example
cmichi Nov 9, 2021
2eaf655
Minor code and text improvements
cmichi Nov 17, 2021
bd7eea1
Remove code
cmichi Nov 17, 2021
7b7c43b
Fix function name
cmichi Nov 17, 2021
4677a59
Add unit tests for lang parsing
cmichi Nov 17, 2021
fbe82d2
Clarify where state resides
cmichi Nov 17, 2021
2e633e3
Apply suggestions from code review
Nov 17, 2021
23e2baf
Implement comments
cmichi Nov 17, 2021
75886af
Apply suggestions from code review
Nov 22, 2021
0299f4d
Pre-process `_` to `"_"`
cmichi Nov 18, 2021
1d102b0
Update String error message
cmichi Nov 22, 2021
7f1a7ea
Merge branch 'master' into cmichi-implement-wildcard-selector
cmichi Nov 22, 2021
7dba798
Rename `is_wildcard_selector` to `has_wildcard_selector`
cmichi Nov 22, 2021
66a3455
Move `_` to `"_"` transformation to lower layer
cmichi Nov 22, 2021
f643a30
Update test fixtures
cmichi Nov 22, 2021
1b0c396
Update error message
cmichi Nov 22, 2021
5cb1f3c
Update test fixtures
cmichi Nov 22, 2021
ee3d140
Migrate to enum `SelectorOrWildcard`
cmichi Nov 23, 2021
3ed386c
Allow wildcard selectors for constructors
cmichi Nov 23, 2021
724ff9f
Fix tests
cmichi Nov 23, 2021
f4a2765
Include clippy suggestion
cmichi Nov 23, 2021
dc2a9fd
Fix error output matching
cmichi Nov 23, 2021
17067e7
Apply suggestions from code review
Nov 23, 2021
a7e624a
Fix suggestions
cmichi Nov 23, 2021
f1429cf
Implement reviewer suggestions
cmichi Nov 23, 2021
0b7cf6e
Merge branch 'master' into cmichi-implement-wildcard-selector
cmichi Nov 23, 2021
cc078ea
Improve matching
cmichi Nov 23, 2021
c2a2697
Include clippy suggestion
cmichi Nov 23, 2021
99a4ff8
Update test fixture
cmichi Nov 23, 2021
a2ba30a
Detect multiple wildcard selectors in constructors
cmichi Nov 23, 2021
9f58738
Apply suggestions from code review
Nov 23, 2021
1a7b33c
Rename enum variant `Selector` to `UserProvided`
cmichi Nov 23, 2021
00f360d
Return `Result:Err` instead of asserting
cmichi Nov 23, 2021
1bc3bb6
Implement suggestions
cmichi Nov 23, 2021
98da359
Revert "Return `Result:Err` instead of asserting"
cmichi Nov 23, 2021
b498308
Apply `cargo fmt`
cmichi Nov 23, 2021
36a374c
Disable overflow checks for `proxy` example
cmichi Nov 23, 2021
d55c84b
Return `Result:Err` instead of asserting
cmichi Nov 24, 2021
fbc6097
Fix import path
cmichi Nov 24, 2021
7698ad5
Fix import path
cmichi Nov 24, 2021
c297f50
Fix import path
cmichi Nov 24, 2021
21bb558
Revert "Return `Result:Err` instead of asserting"
cmichi Nov 24, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Minor code and text improvements
  • Loading branch information
cmichi committed Nov 17, 2021
commit 2eaf655d622417592c68e6561d3100d76edab3e6
2 changes: 1 addition & 1 deletion RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This is the 7th release candidate for ink! 3.0.
- Added basic support for wildcard selectors ‒ [#1020](https://github.com/paritytech/ink/pull/1020).
- This enables writing upgradable smart contracts using the proxy pattern.
We added a new example illustrating this ‒ the [proxy](https://github.com/paritytech/ink/tree/master/examples/delegator) example.
- The wildcard selector is not yet supported to be annotated in a trait.
- Annotating a wildcard selector in traits is not yet supported.

## Changed
- Upgraded to the unstable `seal_call` API ‒ [#960](https://github.com/paritytech/ink/pull/960).
Expand Down
11 changes: 5 additions & 6 deletions crates/lang/codegen/src/generator/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -649,13 +649,12 @@ impl Dispatch<'_> {
}
)
});
let wildcard_index = self.query_wildcard_message();
let possibly_wildcard_selector_message = match wildcard_index {
Some(index) => {
let message_span = message_spans[index];
let message_ident = message_variant_ident(index);
let possibly_wildcard_selector_message = match self.query_wildcard_message() {
Some(wildcard_index) => {
let message_span = message_spans[wildcard_index];
let message_ident = message_variant_ident(wildcard_index);
let message_input =
expand_message_input(message_span, storage_ident, index);
expand_message_input(message_span, storage_ident, wildcard_index);
quote! {
::core::result::Result::Ok(Self::#message_ident(
<#message_input as ::scale::Decode>::decode(input)
Expand Down
4 changes: 2 additions & 2 deletions examples/proxy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ In order to test it out you need to do the following:
1. Now you are able to run the operations provided by the `flipper` smart contract via
the `proxy` contract.

To upgrade the address of the smart contract where calls are forwarded to you would
To change the address of the smart contract where calls are forwarded to you would
switch the metadata (i.e. the `Contract ABI`) back to the `proxy` contract
and then invoke the `upgrade` message.
and then invoke the `change_forward_address` message.
13 changes: 9 additions & 4 deletions examples/proxy/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,16 @@ pub mod proxy {
}
}

/// Forward everything to the next contract
/// Changes the `AccountId` of the contract where any call that does
/// not match a selector of this contract is forwarded to.
#[ink(message)]
pub fn upgrade(&mut self, new_forward_addr: AccountId) {
assert_eq!(self.env().caller(), self.admin);
self.forward_to = new_forward_addr;
pub fn change_forward_address(&mut self, new_address: AccountId) {
assert_eq!(
self.env().caller(),
self.admin,
"caller does not have sufficient permissions"
);
self.forward_to = new_address;
}

/// Fallback message for a contract call that doesn't match any
Expand Down