Skip to content

Commit

Permalink
fix: minor typos in the docs (#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
tudorpintea999 authored Dec 6, 2023
1 parent 4d4d985 commit 8796a05
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/anchor_bts/discriminator.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ However, a user mistakenly passes Account B as an argument to the `foo` instruct

This is where the discriminator comes into play. It uniquely identifies the type of an account. Even though Account A and Account B are structurally identical and share the same owner, they have different discriminators.

When the `foo` instruction gets executed, the Anchor framework checks the discriminator of the account passed as argument. If you have declared `foo` as `foo: Account<'info, A>`, Anchor will make sure that the passed account's discriminator matches that of Account A. If the discriminators don't match (as would be the case if Account B was passed), Anchor raises an error, preventing any unintended effects on Account B.
When the `foo` instruction gets executed, the Anchor framework checks the discriminator of the account passed as an argument. If you have declared `foo` as `foo: Account<'info, A>`, Anchor will make sure that the passed account's discriminator matches that of Account A. If the discriminators don't match (as would be the case if Account B was passed), Anchor raises an error, preventing any unintended effects on Account B.

The discriminator helps Anchor to ensure that the account being processed is indeed the one expected, preventing type-related errors at runtime. This mechanism is automatically handled when you use the `Account` type in Anchor, adding an extra layer of security to your program.

Expand Down
2 changes: 1 addition & 1 deletion src/anchor_in_depth/anchor_programs_in-depth.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ This section explains how you can use Anchor to build Solana programs. Each sect
anchor init hello-anchor
```

This sections begins with the essentials and then explains more intermediate content afterwards.
This section begins with the essentials and then explains more intermediate content afterwards.
4 changes: 2 additions & 2 deletions src/anchor_in_depth/the_accounts_struct.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ You can find information about all constraints in the reference. We will cover s

## Safety checks

Two of the Anchor account types, [AccountInfo](https://docs.rs/anchor-lang/latest/anchor_lang/accounts/account_info/index.html) and [UncheckedAccount](https://docs.rs/anchor-lang/latest/anchor_lang/accounts/unchecked_account/index.html) do not implement any checks on the account being passed. Anchor implements safety checks that encourage additional documentation describing why additional checks are not necesssary.
Two of the Anchor account types, [AccountInfo](https://docs.rs/anchor-lang/latest/anchor_lang/accounts/account_info/index.html) and [UncheckedAccount](https://docs.rs/anchor-lang/latest/anchor_lang/accounts/unchecked_account/index.html) do not implement any checks on the account being passed. Anchor implements safety checks that encourage additional documentation describing why additional checks are not necessary.

Attempting to build a program containing the following excerpt with `anchor build`:

Expand Down Expand Up @@ -164,4 +164,4 @@ pub struct Initialize<'info> {
}
```

Note the doc comment needs to be a [line or block doc comment](https://doc.rust-lang.org/reference/comments.html#doc-comments) (/// or /\*\*) to be interepreted as doc attribute by Rust. Double slash comments (//) are not interpreted as such.
Note the doc comment needs to be a [line or block doc comment](https://doc.rust-lang.org/reference/comments.html#doc-comments) (/// or /\*\*) to be interpreted as doc attribute by Rust. Double slash comments (//) are not interpreted as such.

0 comments on commit 8796a05

Please sign in to comment.