Unverified Commit fd541250 authored by Michael Müller's avatar Michael Müller Committed by GitHub
Browse files

Some minor fixes (#587)

* Fix typo

* Fn does not need to take mutable self

* Fix naming: #[ink(implemenetation)] ➜ #[ink(impl)]

* #[ink(storage)] can not be applied to enum

* Fix typo: accesses ➜ accessed

* Fix typo: sturctures ➜ structures
parent 3803a266
Pipeline #114739 canceled with stages
in 5 minutes and 14 seconds
......@@ -203,7 +203,7 @@ In a module annotated with `#[ink::contract]` these attributes are available:
| `#[ink(payable)]` | Applicable to ink! messages. | Allows receiving value as part of the call of the ink! message. ink! constructors are implicitly payable. |
| `#[ink(selector = "..")]` | Applicable to ink! messages and ink! constructors. | Specifies a concrete dispatch selector for the flagged entity. This allows a contract author to precisely control the selectors of their APIs making it possible to rename their API without breakage. |
| `#[ink(namespace = "..")]` | Applicable to ink! trait implementation blocks. | Changes the resulting selectors of all the ink! messages and ink! constructors within the trait implementation. Allows to disambiguate between trait implementations with overlapping message or constructor names. Use only with great care and consideration! |
| `#[ink(implementation)]` | Applicable to ink! implementation blocks. | Tells the ink! codegen that some implementation block shall be granted access to ink! internals even without it containing any ink! messages or ink! constructors. |
| `#[ink(impl)]` | Applicable to ink! implementation blocks. | Tells the ink! codegen that some implementation block shall be granted access to ink! internals even without it containing any ink! messages or ink! constructors. |
See [here](https://paritytech.github.io/ink/ink_lang/attr.contract.html) for a more detailed description of those and also for details on the `#[ink::contract]` macro.
......
......@@ -260,7 +260,7 @@ pub struct OptedOut {
```
The the above example `a` and `b` are normal storage entities, however, `c` on the other hand side will never load from or store to contract storage and will always be reset to the default value of its `i32` type for every contract call.
It can be accesses from all ink! messages or methods via `self.c` but will never manipulate the contract storage and thus acts wonderfully as some shared local information.
It can be accessed from all ink! messages or methods via `self.c` but will never manipulate the contract storage and thus acts wonderfully as some shared local information.
### Dynamic Storage Allocator
......@@ -278,7 +278,7 @@ pub struct Matrix {
}
```
However, this will fail compilation with an error indicating that `StorageVec<T>` requires for its `T` to be packed (`T: PackedLayout`) which `StorageVec<T>` itself does not since it always stores all of its elements into different cells. The same applies to many other storage data sturctures provided by `ink_storage` and is a trade-off the ink! team decided for the case of efficiency of the overall system.
However, this will fail compilation with an error indicating that `StorageVec<T>` requires for its `T` to be packed (`T: PackedLayout`) which `StorageVec<T>` itself does not since it always stores all of its elements into different cells. The same applies to many other storage data structures provided by `ink_storage` and is a trade-off the ink! team decided for the case of efficiency of the overall system.
Instead what a user can do in order to get their vector-of-vector to be working is to make use of ink!'s dynamic storage allocator capabilities.
For this the contract author has to first enable the feature via:
......@@ -360,7 +360,7 @@ We won't be going into the details for any of those but will briefly present the
| `#[ink(payable)]` **new** | Applicable to ink! messages. | Allows receiving value as part of the call of the ink! message. ink! constructors are implicitly payable. |
| `#[ink(selector = "..")]` **new** | Applicable to ink! messages and ink! constructors. | Specifies a concrete dispatch selector for the flagged entity. This allows a contract author to precisely control the selectors of their APIs making it possible to rename their API without breakage. |
| `#[ink(namespace = "..")]` **new** | Applicable to ink! trait implementation blocks. | Changes the resulting selectors of all the ink! messages and ink! constructors within the trait implementation. Allows to disambiguate between trait implementations with overlapping message or constructor names. Use only with great care and consideration! |
| `#[ink(implementation)]` **new** | Applicable to ink! implementation blocks. | Tells the ink! codegen that some implementation block shall be granted access to ink! internals even without it containing any ink! messages or ink! constructors. |
| `#[ink(impl)]` **new** | Applicable to ink! implementation blocks. | Tells the ink! codegen that some implementation block shall be granted access to ink! internals even without it containing any ink! messages or ink! constructors. |
## Merging of ink! Attributes
......
......@@ -268,8 +268,8 @@ impl Spanned for AttributeArg {
pub enum AttributeArgKind {
/// `#[ink(storage)]`
///
/// Applied on `struct` or `enum` types in order to flag them for being
/// the contract's storage definition.
/// Applied on `struct` types in order to flag them for being the
/// contract's storage definition.
Storage,
/// `#[ink(event)]`
///
......
......@@ -289,7 +289,7 @@ pub trait Callable {
///
/// These recommendation mainly apply to trait implementation blocks:
///
/// - The recommandation by the ink! team is to use the full-path approach
/// - The recommendation by the ink! team is to use the full-path approach
/// wherever possible; OR import the trait and use only its identifier with
/// an additional namespace if required to disambiguate selectors.
/// - Try not to intermix the above recommendations.
......
......@@ -84,7 +84,7 @@ pub mod give_me {
/// The method needs to be annotated with `payable`; only then it is
/// allowed to receive value as part of the call.
#[ink(message, payable, selector = "0xCAFEBABE")]
pub fn was_it_ten(&mut self) -> bool {
pub fn was_it_ten(&self) -> bool {
self.env().transferred_balance() == 10
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment