diff --git a/sui_core/Cargo.toml b/sui_core/Cargo.toml index fd917b7b4eebd..c88aa5cb7c32c 100644 --- a/sui_core/Cargo.toml +++ b/sui_core/Cargo.toml @@ -36,7 +36,7 @@ move-core-types = { git = "https://github.com/diem/move", rev = "584bfc8c5f8e582 move-package = { git = "https://github.com/diem/move", rev = "584bfc8c5f8e582223581975106ffa2545677e2a" } move-vm-runtime = { git = "https://github.com/diem/move", rev = "584bfc8c5f8e582223581975106ffa2545677e2a" } -typed-store = { git = "https://github.com/MystenLabs/mysten-infra", rev = "a36c852c30729a16ee3c8a6a863f654887f0c30e"} +typed-store = { git = "https://github.com/MystenLabs/mysten-infra", rev = "97a056f85555fa2afe497d6abb7cf6bf8faa63cf"} [dev-dependencies] fdlimit = "0.2.1" diff --git a/sui_types/Cargo.toml b/sui_types/Cargo.toml index bb354459a4a0d..40015805f35b9 100644 --- a/sui_types/Cargo.toml +++ b/sui_types/Cargo.toml @@ -24,10 +24,9 @@ serde_json = "1.0.79" serde_with = "1.12.0" signature = "1.5.0" static_assertions = "1.1.0" -strum = "0.24.0" -strum_macros = "0.24.0" -typed-store = { git = "https://github.com/MystenLabs/mysten-infra", rev ="a36c852c30729a16ee3c8a6a863f654887f0c30e"} +name_variant = { git = "https://github.com/MystenLabs/mysten-infra", rev ="97a056f85555fa2afe497d6abb7cf6bf8faa63cf"} +typed-store = { git = "https://github.com/MystenLabs/mysten-infra", rev ="97a056f85555fa2afe497d6abb7cf6bf8faa63cf"} move-binary-format = { git = "https://github.com/diem/move", rev = "584bfc8c5f8e582223581975106ffa2545677e2a" } move-bytecode-utils = { git = "https://github.com/diem/move", rev = "584bfc8c5f8e582223581975106ffa2545677e2a" } diff --git a/sui_types/src/messages.rs b/sui_types/src/messages.rs index c3d3c4b0f3b4c..d17400cede0b1 100644 --- a/sui_types/src/messages.rs +++ b/sui_types/src/messages.rs @@ -13,6 +13,7 @@ mod messages_tests; use move_binary_format::{access::ModuleAccess, CompiledModule}; use move_core_types::{identifier::Identifier, language_storage::TypeTag, value::MoveStructLayout}; +use name_variant::NamedVariant; use serde::{Deserialize, Serialize}; use static_assertions::const_assert_eq; use std::fmt::Write; @@ -22,7 +23,6 @@ use std::{ collections::{BTreeSet, HashSet}, hash::{Hash, Hasher}, }; -use strum::VariantNames; #[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize, Deserialize)] pub struct Transfer { @@ -53,9 +53,7 @@ pub struct MoveModulePublish { pub gas_budget: u64, } -#[derive( - Debug, PartialEq, Eq, Hash, Clone, Serialize, Deserialize, strum_macros::EnumVariantNames, -)] +#[derive(Debug, PartialEq, Eq, Hash, Clone, Serialize, Deserialize, NamedVariant)] pub enum TransactionKind { /// Initiate an object transfer between addresses Transfer(Transfer), @@ -135,16 +133,7 @@ impl TransactionData { /// Returns the transaction kind as a &str (variant name, no fields) pub fn kind_as_str(&self) -> &'static str { - // NOTE: Ideally we could have used something like https://docs.rs/strum/latest/strum/derive.AsRefStr.html - // The problem is that it doesn't actually return &'static ref due to &self above - // and we really want 'static for common situations, such as authority_server dispatch where - // by the time we instrument the transaction kind, the message or Transaction might have been moved - // and so the lifetime and Kind is out of scope and we cannot borrow it. - match self.kind { - TransactionKind::Transfer(_) => TransactionKind::VARIANTS[0], - TransactionKind::Publish(_) => TransactionKind::VARIANTS[1], - TransactionKind::Call(_) => TransactionKind::VARIANTS[2], - } + self.kind.variant_name() } }