Skip to content

Commit ca61af3

Browse files
author
Igor Markin
authored
feat: handle operator payout address change in get_protx_listdiff (#43)
* feat: add operator_payout_address * fix: double Option on operator payout address
1 parent 7309f3a commit ca61af3

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

json/src/lib.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2106,7 +2106,7 @@ pub struct DMNStateDiff {
21062106
pub voting_address: Option<[u8; 20]>,
21072107
pub payout_address: Option<[u8; 20]>,
21082108
pub pub_key_operator: Option<Vec<u8>>,
2109-
pub operator_payout_address: Option<Option<[u8; 20]>>,
2109+
pub operator_payout_address: Option<[u8; 20]>,
21102110
pub platform_node_id: Option<[u8; 20]>,
21112111
pub platform_p2p_port: Option<u32>,
21122112
pub platform_http_port: Option<u32>,
@@ -2131,6 +2131,7 @@ impl TryFrom<DMNStateDiffIntermediate> for DMNStateDiff {
21312131
platform_p2p_port,
21322132
platform_http_port,
21332133
payout_address,
2134+
operator_payout_address,
21342135
pub_key_operator,
21352136
} = value;
21362137

@@ -2161,7 +2162,15 @@ impl TryFrom<DMNStateDiffIntermediate> for DMNStateDiff {
21612162
})
21622163
})
21632164
.transpose()?;
2164-
let operator_payout_address = None; //todo
2165+
let operator_payout_address = operator_payout_address
2166+
.map(|address| {
2167+
let address = Address::from_str(address.as_str())?;
2168+
address.payload_to_vec().try_into().map_err(|_| encode::Error::InvalidVectorSize {
2169+
expected: 20,
2170+
actual: address.payload_to_vec().len(),
2171+
})
2172+
})
2173+
.transpose()?;
21652174

21662175
let platform_node_id = platform_node_id
21672176
.map(|address| {
@@ -2264,7 +2273,7 @@ impl DMNState {
22642273
!= newer.operator_payout_address
22652274
{
22662275
has_diff = true;
2267-
Some(newer.operator_payout_address)
2276+
newer.operator_payout_address
22682277
} else {
22692278
None
22702279
},
@@ -2333,9 +2342,7 @@ impl DMNState {
23332342
if let Some(payout_address) = payout_address {
23342343
self.payout_address = payout_address;
23352344
}
2336-
if let Some(operator_payout_address) = operator_payout_address {
2337-
self.operator_payout_address = operator_payout_address;
2338-
}
2345+
self.operator_payout_address = operator_payout_address;
23392346
if let Some(platform_node_id) = platform_node_id {
23402347
self.platform_node_id = Some(platform_node_id);
23412348
}
@@ -2887,6 +2894,8 @@ pub struct DMNStateDiffIntermediate {
28872894
pub platform_http_port: Option<u32>,
28882895
#[serde(default)]
28892896
pub payout_address: Option<String>,
2897+
#[serde(default)]
2898+
pub operator_payout_address: Option<String>,
28902899
#[serde(default, deserialize_with = "deserialize_hex_opt")]
28912900
pub pub_key_operator: Option<Vec<u8>>,
28922901
}

0 commit comments

Comments
 (0)