-
Notifications
You must be signed in to change notification settings - Fork 202
program: let anotehr signer deposit on user behalf #1891
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -653,6 +653,11 @@ pub fn handle_deposit<'c: 'info, 'info>( | |
| } else { | ||
| DepositExplanation::None | ||
| }; | ||
| let signer = if ctx.accounts.authority.key() == user.authority { | ||
| Some(ctx.accounts.authority.key()) | ||
| } else { | ||
| None | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should this just always be ctx.accounts.authority? i guess that would make all events larger
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. prefer keeping it |
||
| }; | ||
| let deposit_record = DepositRecord { | ||
| ts: now, | ||
| deposit_record_id, | ||
|
|
@@ -670,6 +675,7 @@ pub fn handle_deposit<'c: 'info, 'info>( | |
| market_index, | ||
| explanation, | ||
| transfer_user: None, | ||
| signer, | ||
| }; | ||
| emit!(deposit_record); | ||
|
|
||
|
|
@@ -825,6 +831,7 @@ pub fn handle_withdraw<'c: 'info, 'info>( | |
| total_withdraws_after: user.total_withdraws, | ||
| explanation: deposit_explanation, | ||
| transfer_user: None, | ||
| signer: None, | ||
| }; | ||
| emit!(deposit_record); | ||
|
|
||
|
|
@@ -995,6 +1002,7 @@ pub fn handle_transfer_deposit<'c: 'info, 'info>( | |
| total_withdraws_after: from_user.total_withdraws, | ||
| explanation: DepositExplanation::Transfer, | ||
| transfer_user: Some(to_user_key), | ||
| signer: None, | ||
| }; | ||
| emit!(deposit_record); | ||
| } | ||
|
|
@@ -1059,6 +1067,7 @@ pub fn handle_transfer_deposit<'c: 'info, 'info>( | |
| total_withdraws_after, | ||
| explanation: DepositExplanation::Transfer, | ||
| transfer_user: Some(from_user_key), | ||
| signer: None, | ||
| }; | ||
| emit!(deposit_record); | ||
| } | ||
|
|
@@ -1271,6 +1280,7 @@ pub fn handle_transfer_pools<'c: 'info, 'info>( | |
| total_withdraws_after: from_user.total_withdraws, | ||
| explanation: DepositExplanation::Transfer, | ||
| transfer_user: Some(to_user_key), | ||
| signer: None, | ||
| }; | ||
| emit!(deposit_record); | ||
|
|
||
|
|
@@ -1305,6 +1315,7 @@ pub fn handle_transfer_pools<'c: 'info, 'info>( | |
| total_withdraws_after: to_user.total_withdraws, | ||
| explanation: DepositExplanation::Transfer, | ||
| transfer_user: Some(from_user_key), | ||
| signer: None, | ||
| }; | ||
| emit!(deposit_record); | ||
| } | ||
|
|
@@ -1371,6 +1382,7 @@ pub fn handle_transfer_pools<'c: 'info, 'info>( | |
| total_withdraws_after: from_user.total_withdraws, | ||
| explanation: DepositExplanation::Transfer, | ||
| transfer_user: Some(to_user_key), | ||
| signer: None, | ||
| }; | ||
| emit!(deposit_record); | ||
|
|
||
|
|
@@ -1405,6 +1417,7 @@ pub fn handle_transfer_pools<'c: 'info, 'info>( | |
| total_withdraws_after: to_user.total_withdraws, | ||
| explanation: DepositExplanation::Transfer, | ||
| transfer_user: Some(from_user_key), | ||
| signer: None, | ||
| }; | ||
| emit!(deposit_record); | ||
| } | ||
|
|
@@ -4140,8 +4153,7 @@ pub struct InitializeReferrerName<'info> { | |
| pub struct Deposit<'info> { | ||
| pub state: Box<Account<'info, State>>, | ||
| #[account( | ||
| mut, | ||
| constraint = can_sign_for_user(&user, &authority)? | ||
| mut | ||
| )] | ||
| pub user: AccountLoader<'info, User>, | ||
| #[account( | ||
|
|
||
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 think you want to flip this and log if it's a third party making the deposit?
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.
should this be a newly named instruction to lower chance of accidental deposit into wrong account?