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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
use super::errors::Result;
use safe_nd::{Coins, MDataSeqValue, SeqMutableData, Transaction, TransactionId, XorName};
use std::collections::BTreeMap;
use threshold_crypto::{PublicKey, SecretKey};
pub type AppendOnlyDataRawData = (Vec<u8>, Vec<u8>);
pub trait SafeApp {
fn new() -> Self;
fn connect(&mut self, app_id: &str, auth_credentials: Option<&str>) -> Result<()>;
fn create_balance(
&mut self,
from_sk: Option<SecretKey>,
new_balance_owner: PublicKey,
amount: Coins,
) -> Result<XorName>;
fn allocate_test_coins(&mut self, owner_sk: SecretKey, amount: Coins) -> Result<XorName>;
fn get_balance_from_sk(&self, sk: SecretKey) -> Result<Coins>;
fn safecoin_transfer_to_xorname(
&mut self,
from_sk: Option<SecretKey>,
to_xorname: XorName,
tx_id: TransactionId,
amount: Coins,
) -> Result<Transaction>;
fn safecoin_transfer_to_pk(
&mut self,
from_sk: Option<SecretKey>,
to_pk: PublicKey,
tx_id: TransactionId,
amount: Coins,
) -> Result<Transaction>;
fn get_transaction(&self, tx_id: u64, pk: PublicKey, sk: SecretKey) -> Result<String>;
fn files_put_published_immutable(&mut self, data: &[u8], dry_run: bool) -> Result<XorName>;
fn files_get_published_immutable(&self, xorname: XorName) -> Result<Vec<u8>>;
fn put_seq_append_only_data(
&mut self,
data: Vec<(Vec<u8>, Vec<u8>)>,
name: Option<XorName>,
tag: u64,
permissions: Option<String>,
) -> Result<XorName>;
fn append_seq_append_only_data(
&mut self,
data: Vec<(Vec<u8>, Vec<u8>)>,
new_version: u64,
name: XorName,
tag: u64,
) -> Result<u64>;
fn get_latest_seq_append_only_data(
&self,
name: XorName,
tag: u64,
) -> Result<(u64, AppendOnlyDataRawData)>;
fn get_current_seq_append_only_data_version(&self, name: XorName, tag: u64) -> Result<u64>;
fn get_seq_append_only_data(
&self,
name: XorName,
tag: u64,
version: u64,
) -> Result<AppendOnlyDataRawData>;
fn put_seq_mutable_data(
&mut self,
name: Option<XorName>,
tag: u64,
permissions: Option<String>,
) -> Result<XorName>;
fn get_seq_mdata(&self, name: XorName, tag: u64) -> Result<SeqMutableData>;
fn seq_mutable_data_insert(
&mut self,
name: XorName,
tag: u64,
key: &[u8],
value: &[u8],
) -> Result<()>;
fn seq_mutable_data_get_value(
&self,
name: XorName,
tag: u64,
key: &[u8],
) -> Result<MDataSeqValue>;
fn list_seq_mdata_entries(
&self,
name: XorName,
tag: u64,
) -> Result<BTreeMap<Vec<u8>, MDataSeqValue>>;
fn seq_mutable_data_update(
&mut self,
name: XorName,
tag: u64,
key: &[u8],
value: &[u8],
version: u64,
) -> Result<()>;
}