solana-with-rpc-optimizations/sdk/src/payment_plan.rs

28 lines
880 B
Rust
Raw Normal View History

2018-11-02 19:13:33 -07:00
//! The `plan` module provides a domain-specific language for payment plans. Users create BudgetExpr objects that
2018-05-25 14:51:41 -07:00
//! are given to an interpreter. The interpreter listens for `Witness` transactions,
2018-03-20 14:52:46 -07:00
//! which it uses to reduce the payment plan. When the plan is reduced to a
//! `Payment`, the payment is executed.
2018-03-17 13:42:43 -07:00
use chrono::prelude::*;
2018-12-04 14:38:19 -08:00
use pubkey::Pubkey;
2018-03-17 13:42:43 -07:00
2018-06-06 16:16:12 -07:00
/// The types of events a payment plan can process.
2018-05-22 20:42:04 -07:00
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
2018-03-20 14:31:28 -07:00
pub enum Witness {
2018-06-06 16:16:12 -07:00
/// The current time.
2018-03-17 13:42:43 -07:00
Timestamp(DateTime<Utc>),
2018-06-06 16:16:12 -07:00
2018-09-10 19:58:18 -07:00
/// A signature from Pubkey.
Signature,
2018-03-17 13:42:43 -07:00
}
/// Some amount of tokens that should be sent to the `to` `Pubkey`.
2018-03-17 13:42:43 -07:00
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
pub struct Payment {
2018-06-06 16:16:12 -07:00
/// Amount to be paid.
pub tokens: u64,
2018-06-06 16:16:12 -07:00
/// The `Pubkey` that `tokens` should be paid to.
pub to: Pubkey,
2018-03-17 13:42:43 -07:00
}