1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#[crate::service(name = "staged-tx", dispatch = false, psibase_mod = "crate")]
#[allow(non_snake_case, unused_variables)]
mod service {
use crate::{AccountNumber, Action, Checksum256, Fracpack, TimePointUSec};
use async_graphql::SimpleObject;
use fracpack::ToSchema;
use serde::{Deserialize, Serialize};
#[derive(Fracpack, Serialize, Deserialize, ToSchema, SimpleObject)]
#[fracpack(fracpack_mod = "fracpack")]
pub struct ActionList {
pub actions: Vec<Action>,
}
#[derive(Fracpack, Serialize, Deserialize, ToSchema, SimpleObject)]
#[fracpack(fracpack_mod = "fracpack")]
pub struct StagedTx {
pub id: u32,
pub txid: Checksum256,
pub propose_block: u32,
pub propose_date: TimePointUSec,
pub proposer: AccountNumber,
pub action_list: ActionList,
pub auto_exec: bool,
}
/// Initialize the service
#[action]
fn init() {
unimplemented!()
}
/// Proposes a new staged transaction containing the specified actions.
/// Returns the ID of the database record containing the staged transaction.
///
/// * `actions`: The actions to be staged
/// * `auto_exec`: Enables automatic execution as soon as the transaction has enough approvals
#[action]
fn propose(actions: Vec<Action>, auto_exec: bool) -> u32 {
unimplemented!()
}
/// Removes (deletes) a staged transaction
///
/// A staged transaction can only be removed by its proposer.
///
/// * `id`: The ID of the database record containing the staged transaction
/// * `txid`: The unique txid of the staged transaction
#[action]
fn remove(id: u32, txid: Checksum256) {
unimplemented!()
}
/// Indicates that the caller accepts the specified staged transaction
///
/// Depending on the staging rules enforced by the auth service of the sender
/// of the staged transaction, this could result in the execution of the transaction.
///
/// * `id`: The ID of the database record containing the staged transaction
/// * `txid`: The unique txid of the staged transaction
#[action]
fn accept(id: u32, txid: Checksum256) {
unimplemented!()
}
/// Indicates that the caller rejects the staged transaction
///
/// * `id`: The ID of the database record containing the staged transaction
/// * `txid`: The unique txid of the staged transaction
#[action]
fn reject(id: u32, txid: Checksum256) {
unimplemented!()
}
/// Executes a transaction
///
/// This is only needed when automatic execution is disabled
///
/// * `id`: The ID of the database record containing the staged transaction
/// * `txid`: The unique txid of the staged transaction
#[action]
fn execute(id: u32, txid: Checksum256) {
unimplemented!()
}
/// Gets a staged transaction by id.
#[action]
fn get_staged_tx(id: u32) -> StagedTx {
unimplemented!()
}
#[event(history)]
pub fn updated(
txid: Checksum256, // The txid of the staged transaction
actor: AccountNumber, // The sender of the action causing the event
datetime: TimePointUSec, // The time of the event emission
event_type: String, // The type of event
) {
unimplemented!()
}
}
#[test]
fn verify_schema() {
crate::assert_schema_matches_package::<Wrapper>();
}