docs: Update tutorial 2 with Signer changes (#917)

This commit is contained in:
Camden Clark 2021-10-23 16:40:36 -07:00 committed by GitHub
parent 95d46976d4
commit 1ba6db0afe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -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