-
Notifications
You must be signed in to change notification settings - Fork 46
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
Multisig support on invoke helpers #233
Conversation
mint_info.key, | ||
destination_info.key, | ||
authority_info.key, | ||
&[], // add them later, to avoid unnecessary clones |
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.
The source of the bug. Signer status is added depending if the accounts are added here. See:
token-2022/program/src/instruction.rs
Lines 1689 to 1692 in d52d1cd
accounts.push(AccountMeta::new_readonly( | |
*authority_pubkey, | |
signer_pubkeys.is_empty(), | |
)); |
1e0c162
to
5f0af83
Compare
Talked to @buffalojoec offline about stubbing the sys calls versus the manual dependency injection pattern. Will re-request when ready 👍 |
5f0af83
to
4b8d38b
Compare
1fedcbb
to
44d9478
Compare
program/src/onchain.rs
Outdated
#[test] | ||
fn test_single_signer() { | ||
test_parameterized_invoke_fns(false, false, false); | ||
} | ||
|
||
#[test] | ||
fn test_single_signer_with_fee() { | ||
test_parameterized_invoke_fns(false, true, false); | ||
} | ||
|
||
#[test] | ||
fn test_single_signer_with_transfer_hook() { | ||
test_parameterized_invoke_fns(false, false, true); | ||
} | ||
|
||
#[test] | ||
fn test_single_signer_with_fee_and_transfer_hook() { | ||
test_parameterized_invoke_fns(false, true, true); |
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.
You should consider test_case
!
Sorry for the late review, but this looks good! I've been working on using the split-up crates in token-2022, which unfortunately means that we can't use the program stubs, so I refactored the code a little bit to make it testable without the program stubs |
== Bug fix ==
At the moment, these helpers are passing in an empty signers slice to
transfer_checked()
andtransfer_checked_with_fee()
to avoid clones. Unfortunately, for multisigs, this improperly adds signer status to theauthority_info
which causes an permissions escalation error for consumers.This PR does:
_invoke_transfer_internal()
to reduce redundancy between functions & allow dependency injection