Add credit-only info to AccountMetadata (#4405)
* Add credit-only flag to AccountMeta, default to false * Sort keys by is_credit_only within signed/unsigned groupings * Process and de-dupe program keys along with other account keys * Add message helper functions * Fix test * Improve comment * s/is_credit_only/is_debitable * Add InstructionKeys helper struct, and simplify program_position method
This commit is contained in:
@@ -96,11 +96,25 @@ pub struct AccountMeta {
|
||||
pub pubkey: Pubkey,
|
||||
/// True if an Instruciton requires a Transaction signature matching `pubkey`.
|
||||
pub is_signer: bool,
|
||||
/// True if the `pubkey` can be loaded as a credit-debit account.
|
||||
pub is_debitable: bool,
|
||||
}
|
||||
|
||||
impl AccountMeta {
|
||||
pub fn new(pubkey: Pubkey, is_signer: bool) -> Self {
|
||||
Self { pubkey, is_signer }
|
||||
Self {
|
||||
pubkey,
|
||||
is_signer,
|
||||
is_debitable: true,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_credit_only(pubkey: Pubkey, is_signer: bool) -> Self {
|
||||
Self {
|
||||
pubkey,
|
||||
is_signer,
|
||||
is_debitable: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user