Inline payment_plan

This module predates Accounts. That was a separate module because
it used to be part of Bank and those types could be sent to any
smart contract. Now each instruction processor defines for itself
what instructions it accepts.
This commit is contained in:
Greg Fitzgerald 2019-03-23 06:18:10 -06:00
parent 33972ef89e
commit 6286947697
5 changed files with 21 additions and 32 deletions

View File

@ -3,12 +3,31 @@
//! which it uses to reduce the payment plan. When the budget is reduced to a
//! `Payment`, the payment is executed.
use crate::payment_plan::{Payment, Witness};
use chrono::prelude::*;
use serde_derive::{Deserialize, Serialize};
use solana_sdk::pubkey::Pubkey;
use std::mem;
/// The types of events a payment plan can process.
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
pub enum Witness {
/// The current time.
Timestamp(DateTime<Utc>),
/// A signature from Pubkey.
Signature,
}
/// Some amount of lamports that should be sent to the `to` `Pubkey`.
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
pub struct Payment {
/// Amount to be paid.
pub lamports: u64,
/// The `Pubkey` that `lamports` should be paid to.
pub to: Pubkey,
}
/// A data type representing a `Witness` that the payment plan is waiting on.
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
pub enum Condition {

View File

@ -1,7 +1,7 @@
//! budget program
use crate::budget_expr::Witness;
use crate::budget_instruction::BudgetInstruction;
use crate::budget_state::{BudgetError, BudgetState};
use crate::payment_plan::Witness;
use bincode::{deserialize, serialize};
use chrono::prelude::{DateTime, Utc};
use log::*;

View File

@ -2,7 +2,6 @@ pub mod budget_expr;
pub mod budget_instruction;
pub mod budget_processor;
pub mod budget_state;
pub mod payment_plan;
use solana_sdk::pubkey::Pubkey;

View File

@ -1,28 +0,0 @@
//! The `plan` module provides a domain-specific language for payment plans. Users create BudgetExpr objects that
//! are given to an interpreter. The interpreter listens for `Witness` transactions,
//! which it uses to reduce the payment plan. When the plan is reduced to a
//! `Payment`, the payment is executed.
use chrono::prelude::*;
use serde_derive::{Deserialize, Serialize};
use solana_sdk::pubkey::Pubkey;
/// The types of events a payment plan can process.
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
pub enum Witness {
/// The current time.
Timestamp(DateTime<Utc>),
/// A signature from Pubkey.
Signature,
}
/// Some amount of lamports that should be sent to the `to` `Pubkey`.
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
pub struct Payment {
/// Amount to be paid.
pub lamports: u64,
/// The `Pubkey` that `lamports` should be paid to.
pub to: Pubkey,
}

View File

@ -4,7 +4,6 @@ use serde_derive::{Deserialize, Serialize};
use solana_sdk::instruction::{AccountMeta, Instruction};
use solana_sdk::pubkey::Pubkey;
use solana_sdk::system_instruction::SystemInstruction;
use solana_sdk::transaction::{AccountMeta, Instruction};
#[derive(Serialize, Default, Deserialize, Debug, PartialEq, Eq, Clone)]
pub struct Vote {