-
Notifications
You must be signed in to change notification settings - Fork 304
Conversation
….InitSpace.html) to calculate space needed for accounts. Delete Unnecessary parameters found in the test typescript. Consistently use "rpc()" as sending transactions in the test typescript.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is another great, PR, we can get it in with a few small tweaks. Please also rebase on top of current main
.
@@ -3,45 +3,44 @@ title: Owner Checks | |||
objectives: | |||
- Explain the security risks associated with not performing appropriate owner | |||
checks | |||
- Use Anchor's `Account<'info, T>` wrapper and an account type to automate | |||
- Implement owner checks using long-form Rust |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use 'native Rust' to mean without Anchor.
owner checks | ||
- Use Anchor's `#[account(owner = <expr>)]` constraint to explicitly define an | ||
- Use Anchor’s `#[account(owner = <expr>)]` constraint to explicitly define an |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just use '
rather than smart quotes. Do a find/replace.
represents the **program** that owns the account. Owner checks ensure that this | ||
`owner` field in the `AccountInfo` matches the expected program ID. | ||
As a refresher, the `AccountInfo` struct contains the following fields. An owner | ||
check refers to checking that the `owner` field in the `AccountInfo` matches an |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check refers to checking that the `owner` field in the `AccountInfo` matches an | |
check refers to checking that the `owner` field matches an |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems clear we're already talking about AccountInfo
here.
@@ -81,7 +95,7 @@ declare_id!("Cft4eTTrt4sJU4Ar35rUQHx6PSXfJju3dixmvApzhWws"); | |||
#[program] | |||
pub mod owner_check { | |||
use super::*; | |||
... | |||
... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check indentation, this may be a tab characters, use four spaces.
```typescript | ||
describe("owner-check", () => { | ||
... | ||
it("Insecure withdraw should be successful", async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See 'BDD' in CONTRIBUTING.md, and do that for all tests.
This pull request has been automatically marked as stale because it has not had recent activity. Remove stale label or comment or this will be closed in 7 days. |
Problem
Magic number found on space calculation.
Unnecessary parameters are found in the test typescript.
Two Different ways to send transactions are found.
Summary of Changes
Use InitSpace to calculate space needed for accounts.
Delete Unnecessary parameters found in the test typescript.
Consistently use "rpc()" as sending transactions in the test typescript.
Also, I made a PR for solana-owner-checks starter branch and a PR for solana-owner-checks solution branch
which must be synced with this PR.