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
use crate::avm::parser::Context;
use crate::pvm::parser::atomic_block_parser::Transaction;
use crate::pvm::parser::base_tx_parser::BaseTx;
use crate::utils::cb58::encode;
use rust_base58::ToBase58;
use std::error::Error;
use tracing::{instrument, trace};
#[derive(Serialize, Deserialize, Debug)]
pub struct RewardValidatorTx {
pub tx_id: String,
}
#[instrument(fields(block_id = % _context.tx_id, tx_type = "reward_validator"))]
pub fn reward_validator_parser(
_raw_msg: &[u8],
_tx_id: String,
_context: &mut Context,
) -> Result<Transaction, Box<dyn Error>> {
*_context.offset += 2;
*_context.offset += 4;
let tx_id = encode(&_raw_msg[*_context.offset..=(*_context.offset + 31)]).to_base58();
trace!("Tx Id : {:?}", tx_id);
*_context.offset += 32;
let reward_validator = RewardValidatorTx { tx_id };
Ok(Transaction {
base_tx: BaseTx {
type_id: 20,
network_id: 1,
blockchain_id: "".to_string(),
transferable_outputs: vec![],
transferable_inputs: vec![],
memo: vec![],
},
tx_id: _tx_id,
add_validator_tx: None,
import_tx: None,
export_tx: None,
add_subnet_validator_tx: None,
add_delegator_tx: None,
create_blockchain_tx: None,
create_subnet_tx: None,
advance_time_tx: None,
reward_validator_tx: Some(reward_validator),
credentials: vec![],
})
}