-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add: allow withdraw SOL to PDA #37
Merged
+3
−11
Merged
Changes from 11 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
5abfbaf
remove memo from deposit_spl_token
brewmaster012 6f4eccd
refactor deposit*_and_call instructions to reuse deposit*
brewmaster012 acbd25c
format
brewmaster012 b0318bb
update comment in code that is inaccurate
brewmaster012 0e18af4
address some CI complaints
brewmaster012 f352dc3
add some light comments to instructions
brewmaster012 f9151ac
silence intentional unused variable warnings
brewmaster012 0d81e93
add some test
brewmaster012 d1497af
Merge branch 'main' into withdraw-to-pda
brewmaster012 605b695
allow withdraw to PDA (other than system account)
brewmaster012 30e11cd
add a test to withdraw SOL to a ATA address (PDA)
brewmaster012 7ca038b
Update tests/protocol-contracts-solana.ts
brewmaster012 0b0027e
substantiated comment regarding UncheckedAccount
brewmaster012 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
is there a way to expand this comment a bit? account is still marked as mutable, and writing to unchecked accounts (which doesnt check owner of account) seems more dangerous than reading
maybe we can add explanation why writing to it is not dangerous, but up to you if it makes sense
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.
i'll keep it simple in the comment, but expand here:
Account<'info, T>
is an Anchor convenient struct that automatically does "ownership" check, whichUncheckedAccount
explicitly does not.Ownership is usually critical because these accounts are completely supplied by user (tx builder) and
could be anything. The onwership validation makes sure the user supplied the correct account.
For example, in the above
pub pda: Account<'info, Pda>
, Anchor does ownership checkAccount. info. owner == T::owner()
, which checks whether the supplied PDA account is in factowned by the current program (i.e. created by the current program). This is crucial otherwise
the program would be directed to read any user supplied potential malicious PDA account.
For the
to
field, obviously we don't care who its owner is because we don't read it. Whatevertx builder tells us to send to, we happily send to. In this case Anchor requires program to explicit
exempt ownership checking by the
UncheckedAccount
struct and also the comment///CHECK
.