antelope/api/system/
structs.rs

1use crate::chain::asset::{Asset, Symbol};
2use crate::chain::authority::Authority;
3use crate::chain::binary_extension::BinaryExtension;
4use crate::chain::name::Name;
5use crate::chain::public_key::PublicKey;
6use crate::chain::{Decoder, Encoder, Packer};
7use antelope_client_macros::StructPacker;
8
9pub struct CreateAccountParams {
10    pub name: Name,
11    pub creator: Name,
12    pub owner: Authority,
13    pub active: Authority,
14    pub ram_bytes: u32,
15    pub stake_net: Asset,
16    pub stake_cpu: Asset,
17    pub transfer: bool,
18}
19
20impl CreateAccountParams {
21    pub fn testing(name: Name, creator: Name, public_key: PublicKey) -> Self {
22        let owner = Authority::new_single_key(public_key);
23        let active = owner.clone();
24        CreateAccountParams {
25            name,
26            creator,
27            owner,
28            active,
29            ram_bytes: 10_048_576,
30            stake_net: Asset::new(10_000, Symbol::new("TLOS", 4)),
31            stake_cpu: Asset::new(10_000, Symbol::new("TLOS", 4)),
32            transfer: true,
33        }
34    }
35}
36
37#[derive(Debug, Clone, StructPacker)]
38pub struct TransferAction {
39    pub from: Name,
40    pub to: Name,
41    pub quantity: Asset,
42    pub memo: String,
43}
44
45#[derive(Debug, Clone, StructPacker)]
46pub struct NewAccountAction {
47    pub creator: Name,
48    pub name: Name,
49    pub owner: Authority,
50    pub active: Authority,
51}
52
53#[derive(Debug, Clone, StructPacker)]
54pub struct BuyRamBytesAction {
55    pub payer: Name,
56    pub receiver: Name,
57    pub bytes: u32,
58}
59
60#[derive(Debug, Clone, StructPacker)]
61pub struct DelegateBandwidthAction {
62    pub from: Name,
63    pub receiver: Name,
64    pub stake_net_quantity: Asset,
65    pub stake_cpu_quantity: Asset,
66    pub transfer: bool,
67}
68
69#[derive(Debug, Clone, StructPacker)]
70pub struct SetCodeAction {
71    pub account: Name,
72    pub vmtype: u8,
73    pub vmversion: u8,
74    pub code: Vec<u8>,
75    pub memo: BinaryExtension<String>,
76}
77
78#[derive(Debug, Clone, StructPacker)]
79pub struct SetAbiAction {
80    pub account: Name,
81    pub abi: Vec<u8>,
82    pub memo: BinaryExtension<String>,
83}