Skip to content

Commit 72bef2c

Browse files
authored
sui-rpc: updating vendored proto with CoinRegistry changes (#127)
1 parent d971950 commit 72bef2c

File tree

5 files changed

+193
-4
lines changed

5 files changed

+193
-4
lines changed
218 Bytes
Binary file not shown.

crates/sui-rpc/src/proto/generated/sui.rpc.v2beta2.field_info.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1639,6 +1639,12 @@ mod _field_impls {
16391639
number: 6i32,
16401640
message_fields: None,
16411641
};
1642+
pub const METADATA_CAP_ID_FIELD: &'static MessageField = &MessageField {
1643+
name: "metadata_cap_id",
1644+
json_name: "metadataCapId",
1645+
number: 7i32,
1646+
message_fields: None,
1647+
};
16421648
}
16431649
impl MessageFields for CoinMetadata {
16441650
const FIELDS: &'static [&'static MessageField] = &[
@@ -1648,6 +1654,7 @@ mod _field_impls {
16481654
Self::SYMBOL_FIELD,
16491655
Self::DESCRIPTION_FIELD,
16501656
Self::ICON_URL_FIELD,
1657+
Self::METADATA_CAP_ID_FIELD,
16511658
];
16521659
}
16531660
impl CoinTreasury {
@@ -1663,11 +1670,18 @@ mod _field_impls {
16631670
number: 2i32,
16641671
message_fields: None,
16651672
};
1673+
pub const SUPPLY_STATE_FIELD: &'static MessageField = &MessageField {
1674+
name: "supply_state",
1675+
json_name: "supplyState",
1676+
number: 3i32,
1677+
message_fields: None,
1678+
};
16661679
}
16671680
impl MessageFields for CoinTreasury {
16681681
const FIELDS: &'static [&'static MessageField] = &[
16691682
Self::ID_FIELD,
16701683
Self::TOTAL_SUPPLY_FIELD,
1684+
Self::SUPPLY_STATE_FIELD,
16711685
];
16721686
}
16731687
impl RegulatedCoinMetadata {

crates/sui-rpc/src/proto/generated/sui.rpc.v2beta2.rs

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2417,7 +2417,8 @@ pub struct GetCoinInfoResponse {
24172417
/// Metadata for a coin type
24182418
#[derive(Clone, PartialEq, ::prost::Message)]
24192419
pub struct CoinMetadata {
2420-
/// ObjectId of the `0x2::coin::CoinMetadata` object.
2420+
/// ObjectId of the `0x2::coin::CoinMetadata` object or
2421+
/// 0x2::sui::coin_registry::CoinData object (when registered with CoinRegistry).
24212422
#[prost(string, optional, tag = "1")]
24222423
pub id: ::core::option::Option<::prost::alloc::string::String>,
24232424
/// Number of decimal places to coin uses.
@@ -2435,6 +2436,11 @@ pub struct CoinMetadata {
24352436
/// URL for the token logo
24362437
#[prost(string, optional, tag = "6")]
24372438
pub icon_url: ::core::option::Option<::prost::alloc::string::String>,
2439+
/// The MetadataCap ID if it has been claimed for this coin type.
2440+
/// This capability allows updating the coin's metadata fields.
2441+
/// Only populated when metadata is from CoinRegistry.
2442+
#[prost(string, optional, tag = "7")]
2443+
pub metadata_cap_id: ::core::option::Option<::prost::alloc::string::String>,
24382444
}
24392445
/// Information about a coin type's `0x2::coin::TreasuryCap` and its total available supply
24402446
#[derive(Clone, PartialEq, ::prost::Message)]
@@ -2445,14 +2451,59 @@ pub struct CoinTreasury {
24452451
/// Total available supply for this coin type.
24462452
#[prost(uint64, optional, tag = "2")]
24472453
pub total_supply: ::core::option::Option<u64>,
2454+
/// Supply state indicating if the supply is fixed or can still be minted
2455+
#[prost(enumeration = "coin_treasury::SupplyState", optional, tag = "3")]
2456+
pub supply_state: ::core::option::Option<i32>,
2457+
}
2458+
/// Nested message and enum types in `CoinTreasury`.
2459+
pub mod coin_treasury {
2460+
/// Supply state of a coin, matching the Move SupplyState enum
2461+
#[derive(
2462+
Clone,
2463+
Copy,
2464+
Debug,
2465+
PartialEq,
2466+
Eq,
2467+
Hash,
2468+
PartialOrd,
2469+
Ord,
2470+
::prost::Enumeration
2471+
)]
2472+
#[repr(i32)]
2473+
pub enum SupplyState {
2474+
/// Supply is unknown or TreasuryCap still exists (minting still possible)
2475+
Unknown = 0,
2476+
/// Supply is fixed (TreasuryCap consumed, no more minting possible)
2477+
Fixed = 1,
2478+
}
2479+
impl SupplyState {
2480+
/// String value of the enum field names used in the ProtoBuf definition.
2481+
///
2482+
/// The values are not transformed in any way and thus are considered stable
2483+
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
2484+
pub fn as_str_name(&self) -> &'static str {
2485+
match self {
2486+
Self::Unknown => "SUPPLY_STATE_UNKNOWN",
2487+
Self::Fixed => "FIXED",
2488+
}
2489+
}
2490+
/// Creates an enum from field names used in the ProtoBuf definition.
2491+
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
2492+
match value {
2493+
"SUPPLY_STATE_UNKNOWN" => Some(Self::Unknown),
2494+
"FIXED" => Some(Self::Fixed),
2495+
_ => None,
2496+
}
2497+
}
2498+
}
24482499
}
24492500
/// Information about a regulated coin, which indicates that it makes use of the transfer deny list.
24502501
#[derive(Clone, PartialEq, ::prost::Message)]
24512502
pub struct RegulatedCoinMetadata {
24522503
/// ObjectId of the `0x2::coin::RegulatedCoinMetadata` object.
24532504
#[prost(string, optional, tag = "1")]
24542505
pub id: ::core::option::Option<::prost::alloc::string::String>,
2455-
/// The ID of the coin's `CoinMetadata` object.
2506+
/// The ID of the coin's `CoinMetadata` or `CoinData` object.
24562507
#[prost(string, optional, tag = "2")]
24572508
pub coin_metadata_object: ::core::option::Option<::prost::alloc::string::String>,
24582509
/// The ID of the coin's `DenyCap` object.

crates/sui-rpc/src/proto/generated/sui.rpc.v2beta2.serde.rs

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4018,6 +4018,9 @@ impl serde::Serialize for CoinMetadata {
40184018
if self.icon_url.is_some() {
40194019
len += 1;
40204020
}
4021+
if self.metadata_cap_id.is_some() {
4022+
len += 1;
4023+
}
40214024
let mut struct_ser = serializer.serialize_struct("sui.rpc.v2beta2.CoinMetadata", len)?;
40224025
if let Some(v) = self.id.as_ref() {
40234026
struct_ser.serialize_field("id", v)?;
@@ -4037,6 +4040,9 @@ impl serde::Serialize for CoinMetadata {
40374040
if let Some(v) = self.icon_url.as_ref() {
40384041
struct_ser.serialize_field("iconUrl", v)?;
40394042
}
4043+
if let Some(v) = self.metadata_cap_id.as_ref() {
4044+
struct_ser.serialize_field("metadataCapId", v)?;
4045+
}
40404046
struct_ser.end()
40414047
}
40424048
}
@@ -4054,6 +4060,8 @@ impl<'de> serde::Deserialize<'de> for CoinMetadata {
40544060
"description",
40554061
"icon_url",
40564062
"iconUrl",
4063+
"metadata_cap_id",
4064+
"metadataCapId",
40574065
];
40584066

40594067
#[allow(clippy::enum_variant_names)]
@@ -4064,6 +4072,7 @@ impl<'de> serde::Deserialize<'de> for CoinMetadata {
40644072
Symbol,
40654073
Description,
40664074
IconUrl,
4075+
MetadataCapId,
40674076
__SkipField__,
40684077
}
40694078
impl<'de> serde::Deserialize<'de> for GeneratedField {
@@ -4092,6 +4101,7 @@ impl<'de> serde::Deserialize<'de> for CoinMetadata {
40924101
"symbol" => Ok(GeneratedField::Symbol),
40934102
"description" => Ok(GeneratedField::Description),
40944103
"iconUrl" | "icon_url" => Ok(GeneratedField::IconUrl),
4104+
"metadataCapId" | "metadata_cap_id" => Ok(GeneratedField::MetadataCapId),
40954105
_ => Ok(GeneratedField::__SkipField__),
40964106
}
40974107
}
@@ -4119,6 +4129,7 @@ impl<'de> serde::Deserialize<'de> for CoinMetadata {
41194129
let mut symbol__ = None;
41204130
let mut description__ = None;
41214131
let mut icon_url__ = None;
4132+
let mut metadata_cap_id__ = None;
41224133
while let Some(k) = map_.next_key()? {
41234134
match k {
41244135
GeneratedField::Id => {
@@ -4159,6 +4170,12 @@ impl<'de> serde::Deserialize<'de> for CoinMetadata {
41594170
}
41604171
icon_url__ = map_.next_value()?;
41614172
}
4173+
GeneratedField::MetadataCapId => {
4174+
if metadata_cap_id__.is_some() {
4175+
return Err(serde::de::Error::duplicate_field("metadataCapId"));
4176+
}
4177+
metadata_cap_id__ = map_.next_value()?;
4178+
}
41624179
GeneratedField::__SkipField__ => {
41634180
let _ = map_.next_value::<serde::de::IgnoredAny>()?;
41644181
}
@@ -4171,6 +4188,7 @@ impl<'de> serde::Deserialize<'de> for CoinMetadata {
41714188
symbol: symbol__,
41724189
description: description__,
41734190
icon_url: icon_url__,
4191+
metadata_cap_id: metadata_cap_id__,
41744192
})
41754193
}
41764194
}
@@ -4191,6 +4209,9 @@ impl serde::Serialize for CoinTreasury {
41914209
if self.total_supply.is_some() {
41924210
len += 1;
41934211
}
4212+
if self.supply_state.is_some() {
4213+
len += 1;
4214+
}
41944215
let mut struct_ser = serializer.serialize_struct("sui.rpc.v2beta2.CoinTreasury", len)?;
41954216
if let Some(v) = self.id.as_ref() {
41964217
struct_ser.serialize_field("id", v)?;
@@ -4200,6 +4221,11 @@ impl serde::Serialize for CoinTreasury {
42004221
#[allow(clippy::needless_borrows_for_generic_args)]
42014222
struct_ser.serialize_field("totalSupply", ToString::to_string(&v).as_str())?;
42024223
}
4224+
if let Some(v) = self.supply_state.as_ref() {
4225+
let v = coin_treasury::SupplyState::try_from(*v)
4226+
.map_err(|_| serde::ser::Error::custom(format!("Invalid variant {}", *v)))?;
4227+
struct_ser.serialize_field("supplyState", &v)?;
4228+
}
42034229
struct_ser.end()
42044230
}
42054231
}
@@ -4213,12 +4239,15 @@ impl<'de> serde::Deserialize<'de> for CoinTreasury {
42134239
"id",
42144240
"total_supply",
42154241
"totalSupply",
4242+
"supply_state",
4243+
"supplyState",
42164244
];
42174245

42184246
#[allow(clippy::enum_variant_names)]
42194247
enum GeneratedField {
42204248
Id,
42214249
TotalSupply,
4250+
SupplyState,
42224251
__SkipField__,
42234252
}
42244253
impl<'de> serde::Deserialize<'de> for GeneratedField {
@@ -4243,6 +4272,7 @@ impl<'de> serde::Deserialize<'de> for CoinTreasury {
42434272
match value {
42444273
"id" => Ok(GeneratedField::Id),
42454274
"totalSupply" | "total_supply" => Ok(GeneratedField::TotalSupply),
4275+
"supplyState" | "supply_state" => Ok(GeneratedField::SupplyState),
42464276
_ => Ok(GeneratedField::__SkipField__),
42474277
}
42484278
}
@@ -4266,6 +4296,7 @@ impl<'de> serde::Deserialize<'de> for CoinTreasury {
42664296
{
42674297
let mut id__ = None;
42684298
let mut total_supply__ = None;
4299+
let mut supply_state__ = None;
42694300
while let Some(k) = map_.next_key()? {
42704301
match k {
42714302
GeneratedField::Id => {
@@ -4282,6 +4313,12 @@ impl<'de> serde::Deserialize<'de> for CoinTreasury {
42824313
map_.next_value::<::std::option::Option<crate::_serde::NumberDeserialize<_>>>()?.map(|x| x.0)
42834314
;
42844315
}
4316+
GeneratedField::SupplyState => {
4317+
if supply_state__.is_some() {
4318+
return Err(serde::de::Error::duplicate_field("supplyState"));
4319+
}
4320+
supply_state__ = map_.next_value::<::std::option::Option<coin_treasury::SupplyState>>()?.map(|x| x as i32);
4321+
}
42854322
GeneratedField::__SkipField__ => {
42864323
let _ = map_.next_value::<serde::de::IgnoredAny>()?;
42874324
}
@@ -4290,12 +4327,84 @@ impl<'de> serde::Deserialize<'de> for CoinTreasury {
42904327
Ok(CoinTreasury {
42914328
id: id__,
42924329
total_supply: total_supply__,
4330+
supply_state: supply_state__,
42934331
})
42944332
}
42954333
}
42964334
deserializer.deserialize_struct("sui.rpc.v2beta2.CoinTreasury", FIELDS, GeneratedVisitor)
42974335
}
42984336
}
4337+
impl serde::Serialize for coin_treasury::SupplyState {
4338+
#[allow(deprecated)]
4339+
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4340+
where
4341+
S: serde::Serializer,
4342+
{
4343+
let variant = match self {
4344+
Self::Unknown => "SUPPLY_STATE_UNKNOWN",
4345+
Self::Fixed => "FIXED",
4346+
};
4347+
serializer.serialize_str(variant)
4348+
}
4349+
}
4350+
impl<'de> serde::Deserialize<'de> for coin_treasury::SupplyState {
4351+
#[allow(deprecated)]
4352+
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4353+
where
4354+
D: serde::Deserializer<'de>,
4355+
{
4356+
const FIELDS: &[&str] = &[
4357+
"SUPPLY_STATE_UNKNOWN",
4358+
"FIXED",
4359+
];
4360+
4361+
struct GeneratedVisitor;
4362+
4363+
impl<'de> serde::de::Visitor<'de> for GeneratedVisitor {
4364+
type Value = coin_treasury::SupplyState;
4365+
4366+
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4367+
write!(formatter, "expected one of: {:?}", &FIELDS)
4368+
}
4369+
4370+
fn visit_i64<E>(self, v: i64) -> std::result::Result<Self::Value, E>
4371+
where
4372+
E: serde::de::Error,
4373+
{
4374+
i32::try_from(v)
4375+
.ok()
4376+
.and_then(|x| x.try_into().ok())
4377+
.ok_or_else(|| {
4378+
serde::de::Error::invalid_value(serde::de::Unexpected::Signed(v), &self)
4379+
})
4380+
}
4381+
4382+
fn visit_u64<E>(self, v: u64) -> std::result::Result<Self::Value, E>
4383+
where
4384+
E: serde::de::Error,
4385+
{
4386+
i32::try_from(v)
4387+
.ok()
4388+
.and_then(|x| x.try_into().ok())
4389+
.ok_or_else(|| {
4390+
serde::de::Error::invalid_value(serde::de::Unexpected::Unsigned(v), &self)
4391+
})
4392+
}
4393+
4394+
fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
4395+
where
4396+
E: serde::de::Error,
4397+
{
4398+
match value {
4399+
"SUPPLY_STATE_UNKNOWN" => Ok(coin_treasury::SupplyState::Unknown),
4400+
"FIXED" => Ok(coin_treasury::SupplyState::Fixed),
4401+
_ => Err(serde::de::Error::unknown_variant(value, FIELDS)),
4402+
}
4403+
}
4404+
}
4405+
deserializer.deserialize_any(GeneratedVisitor)
4406+
}
4407+
}
42994408
impl serde::Serialize for Command {
43004409
#[allow(deprecated)]
43014410
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>

crates/sui-rpc/vendored/proto/sui/rpc/v2beta2/live_data_service.proto

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ message GetCoinInfoResponse {
5050

5151
// Metadata for a coin type
5252
message CoinMetadata {
53-
// ObjectId of the `0x2::coin::CoinMetadata` object.
53+
// ObjectId of the `0x2::coin::CoinMetadata` object or
54+
// 0x2::sui::coin_registry::CoinData object (when registered with CoinRegistry).
5455
optional string id = 1;
5556
// Number of decimal places to coin uses.
5657
optional uint32 decimals = 2;
@@ -62,21 +63,35 @@ message CoinMetadata {
6263
optional string description = 5;
6364
// URL for the token logo
6465
optional string icon_url = 6;
66+
67+
// The MetadataCap ID if it has been claimed for this coin type.
68+
// This capability allows updating the coin's metadata fields.
69+
// Only populated when metadata is from CoinRegistry.
70+
optional string metadata_cap_id = 7;
6571
}
6672

6773
// Information about a coin type's `0x2::coin::TreasuryCap` and its total available supply
6874
message CoinTreasury {
75+
// Supply state of a coin, matching the Move SupplyState enum
76+
enum SupplyState {
77+
// Supply is unknown or TreasuryCap still exists (minting still possible)
78+
SUPPLY_STATE_UNKNOWN = 0;
79+
// Supply is fixed (TreasuryCap consumed, no more minting possible)
80+
FIXED = 1;
81+
}
6982
// ObjectId of the `0x2::coin::TreasuryCap` object.
7083
optional string id = 1;
7184
// Total available supply for this coin type.
7285
optional uint64 total_supply = 2;
86+
// Supply state indicating if the supply is fixed or can still be minted
87+
optional SupplyState supply_state = 3;
7388
}
7489

7590
// Information about a regulated coin, which indicates that it makes use of the transfer deny list.
7691
message RegulatedCoinMetadata {
7792
// ObjectId of the `0x2::coin::RegulatedCoinMetadata` object.
7893
optional string id = 1;
79-
// The ID of the coin's `CoinMetadata` object.
94+
// The ID of the coin's `CoinMetadata` or `CoinData` object.
8095
optional string coin_metadata_object = 2;
8196
// The ID of the coin's `DenyCap` object.
8297
optional string deny_cap_object = 3;

0 commit comments

Comments
 (0)