docs: Update tutorial 2 with Signer changes (#917)
This commit is contained in:
parent
95d46976d4
commit
1ba6db0afe
|
@ -52,11 +52,13 @@ pub struct Increment<'info> {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Here, several `#[account(..)]` attributes are used.
|
Here, a couple `#[account(..)]` attributes are used.
|
||||||
|
|
||||||
- `mut`: tells the program to persist all changes to the account.
|
- `mut`: tells the program to persist all changes to the account.
|
||||||
- `has_one`: enforces the constraint that `Increment.counter.authority == Increment.authority.key`.
|
- `has_one`: enforces the constraint that `Increment.counter.authority == Increment.authority.key`.
|
||||||
- `signer`: enforces the constraint that the `authority` account **signed** the transaction.
|
|
||||||
|
Another new concept here is the `Signer` type. This enforces the constraint that the `authority`
|
||||||
|
account **signed** the transaction. However, anchor doesn't fetch the data on that account.
|
||||||
|
|
||||||
If any of these constraints do not hold, then the `increment` instruction will never be executed.
|
If any of these constraints do not hold, then the `increment` instruction will never be executed.
|
||||||
This allows us to completely separate account validation from our program's business logic, allowing us
|
This allows us to completely separate account validation from our program's business logic, allowing us
|
||||||
|
|
Loading…
Reference in New Issue