sui_jsonrpc/msgs/
sui_protocol.rs

1// Copyright (c) Mysten Labs, Inc.
2// SPDX-License-Identifier: Apache-2.0
3
4use std::collections::BTreeMap;
5
6use af_sui_types::ProtocolVersion;
7use serde::{Deserialize, Serialize};
8use serde_with::{DisplayFromStr, IfIsHumanReadable, serde_as};
9
10use crate::serde::BigInt;
11
12#[serde_as]
13#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
14#[serde(rename_all = "camelCase", rename = "ProtocolConfig")]
15pub struct ProtocolConfigResponse {
16    #[serde_as(as = "IfIsHumanReadable<DisplayFromStr, _>")]
17    pub min_supported_protocol_version: ProtocolVersion,
18    #[serde_as(as = "IfIsHumanReadable<DisplayFromStr, _>")]
19    pub max_supported_protocol_version: ProtocolVersion,
20    #[serde_as(as = "IfIsHumanReadable<DisplayFromStr, _>")]
21    pub protocol_version: ProtocolVersion,
22    pub feature_flags: BTreeMap<String, bool>,
23    pub attributes: BTreeMap<String, Option<SuiProtocolConfigValue>>,
24}
25
26#[serde_as]
27#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
28#[serde(rename_all = "camelCase", rename = "ProtocolConfigValue")]
29pub enum SuiProtocolConfigValue {
30    U16(#[serde_as(as = "BigInt<u16>")] u16),
31    U32(#[serde_as(as = "BigInt<u32>")] u32),
32    U64(#[serde_as(as = "BigInt<u64>")] u64),
33    F64(#[serde_as(as = "DisplayFromStr")] f64),
34    Bool(#[serde_as(as = "DisplayFromStr")] bool),
35}