Impl credit-only accounts in Budget (#4862)

This commit is contained in:
Tyera Eulberg
2019-06-27 19:22:21 -04:00
committed by GitHub
parent baca35ef4d
commit 278614fc7c

View File

@ -37,7 +37,7 @@ pub enum BudgetInstruction {
fn initialize_account(contract: &Pubkey, expr: BudgetExpr) -> Instruction { fn initialize_account(contract: &Pubkey, expr: BudgetExpr) -> Instruction {
let mut keys = vec![]; let mut keys = vec![];
if let BudgetExpr::Pay(payment) = &expr { if let BudgetExpr::Pay(payment) = &expr {
keys.push(AccountMeta::new(payment.to, false)); keys.push(AccountMeta::new_credit_only(payment.to, false));
} }
keys.push(AccountMeta::new(*contract, false)); keys.push(AccountMeta::new(*contract, false));
Instruction::new( Instruction::new(
@ -128,7 +128,7 @@ pub fn apply_timestamp(
AccountMeta::new(*contract, false), AccountMeta::new(*contract, false),
]; ];
if from != to { if from != to {
account_metas.push(AccountMeta::new(*to, false)); account_metas.push(AccountMeta::new_credit_only(*to, false));
} }
Instruction::new(id(), &BudgetInstruction::ApplyTimestamp(dt), account_metas) Instruction::new(id(), &BudgetInstruction::ApplyTimestamp(dt), account_metas)
} }
@ -139,7 +139,7 @@ pub fn apply_signature(from: &Pubkey, contract: &Pubkey, to: &Pubkey) -> Instruc
AccountMeta::new(*contract, false), AccountMeta::new(*contract, false),
]; ];
if from != to { if from != to {
account_metas.push(AccountMeta::new(*to, false)); account_metas.push(AccountMeta::new_credit_only(*to, false));
} }
Instruction::new(id(), &BudgetInstruction::ApplySignature, account_metas) Instruction::new(id(), &BudgetInstruction::ApplySignature, account_metas)
} }
@ -147,9 +147,9 @@ pub fn apply_signature(from: &Pubkey, contract: &Pubkey, to: &Pubkey) -> Instruc
/// Apply account data to a contract waiting on an AccountData witness. /// Apply account data to a contract waiting on an AccountData witness.
pub fn apply_account_data(witness_pubkey: &Pubkey, contract: &Pubkey, to: &Pubkey) -> Instruction { pub fn apply_account_data(witness_pubkey: &Pubkey, contract: &Pubkey, to: &Pubkey) -> Instruction {
let account_metas = vec![ let account_metas = vec![
AccountMeta::new(*witness_pubkey, false), AccountMeta::new_credit_only(*witness_pubkey, false),
AccountMeta::new(*contract, false), AccountMeta::new(*contract, false),
AccountMeta::new(*to, false), AccountMeta::new_credit_only(*to, false),
]; ];
Instruction::new(id(), &BudgetInstruction::ApplyAccountData, account_metas) Instruction::new(id(), &BudgetInstruction::ApplyAccountData, account_metas)
} }