Skip to content

Commit

Permalink
Renaming StoredValue::LegacyTransfer to StoredValue::Transfer
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakub Zajkowski committed Dec 17, 2024
1 parent ffb8064 commit 2ad34b5
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 40 deletions.
2 changes: 1 addition & 1 deletion execution_engine/src/runtime_context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ where
| StoredValue::Contract(_)
| StoredValue::AddressableEntity(_)
| StoredValue::SmartContract(_)
| StoredValue::LegacyTransfer(_)
| StoredValue::Transfer(_)
| StoredValue::DeployInfo(_)
| StoredValue::EraInfo(_)
| StoredValue::Bid(_)
Expand Down
2 changes: 1 addition & 1 deletion storage/src/tracking_copy/byte_size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl ByteSize for StoredValue {
}
StoredValue::SmartContract(package) => package.serialized_length(),
StoredValue::DeployInfo(deploy_info) => deploy_info.serialized_length(),
StoredValue::LegacyTransfer(transfer_v1) => transfer_v1.serialized_length(),
StoredValue::Transfer(transfer_v1) => transfer_v1.serialized_length(),
StoredValue::EraInfo(era_info) => era_info.serialized_length(),
StoredValue::Bid(bid) => bid.serialized_length(),
StoredValue::BidKind(bid_kind) => bid_kind.serialized_length(),
Expand Down
2 changes: 1 addition & 1 deletion storage/src/tracking_copy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ where
StoredValue::ByteCode(_) => {
return Ok(query.into_not_found_result("ByteCode value found."));
}
StoredValue::LegacyTransfer(_) => {
StoredValue::Transfer(_) => {
return Ok(query.into_not_found_result("Legacy Transfer value found."));
}
StoredValue::DeployInfo(_) => {
Expand Down
2 changes: 1 addition & 1 deletion types/src/execution/transform_kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ impl TransformKindV2 {
let found = "ByteCode".to_string();
Err(StoredValueTypeMismatch::new(expected, found).into())
}
StoredValue::LegacyTransfer(_) => {
StoredValue::Transfer(_) => {
let expected = "Contract or Account".to_string();
let found = "Transfer".to_string();
Err(StoredValueTypeMismatch::new(expected, found).into())
Expand Down
4 changes: 2 additions & 2 deletions types/src/gens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,7 @@ pub fn stored_value_arb() -> impl Strategy<Value = StoredValue> {
contract_package_arb().prop_map(StoredValue::ContractPackage),
addressable_entity_arb().prop_map(StoredValue::AddressableEntity),
package_arb().prop_map(StoredValue::SmartContract),
transfer_v1_arb().prop_map(StoredValue::LegacyTransfer),
transfer_v1_arb().prop_map(StoredValue::Transfer),
deploy_info_arb().prop_map(StoredValue::DeployInfo),
era_info_arb(1..10).prop_map(StoredValue::EraInfo),
unified_bid_arb(0..3).prop_map(StoredValue::BidKind),
Expand All @@ -1002,7 +1002,7 @@ pub fn stored_value_arb() -> impl Strategy<Value = StoredValue> {
StoredValue::ContractWasm(_) => stored_value,
StoredValue::Contract(_) => stored_value,
StoredValue::ContractPackage(_) => stored_value,
StoredValue::LegacyTransfer(_) => stored_value,
StoredValue::Transfer(_) => stored_value,
StoredValue::DeployInfo(_) => stored_value,
StoredValue::EraInfo(_) => stored_value,
StoredValue::Bid(_) => stored_value,
Expand Down
2 changes: 1 addition & 1 deletion types/src/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ pub enum FromStrError {
Hash(String),
/// URef parse error.
URef(uref::FromStrError),
/// Legacy Transfer parse error.
/// Transfer parse error.
Transfer(TransferFromStrError),
/// DeployInfo parse error.
DeployInfo(String),
Expand Down
49 changes: 20 additions & 29 deletions types/src/stored_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ pub enum StoredValueTag {
Contract = 3,
/// A contract package.
ContractPackage = 4,
/// A version 1 (legacy) transfer.
LegacyTransfer = 5,
/// A version 1 transfer.
Transfer = 5,
/// Info about a deploy.
DeployInfo = 6,
/// Info about an era.
Expand Down Expand Up @@ -101,7 +101,7 @@ pub enum StoredValue {
/// A contract package.
ContractPackage(ContractPackage),
/// A version 1 transfer.
LegacyTransfer(TransferV1),
Transfer(TransferV1),
/// Info about a deploy.
DeployInfo(DeployInfo),
/// Info about an era.
Expand Down Expand Up @@ -191,10 +191,10 @@ impl StoredValue {
}
}

/// Returns a reference to the wrapped `TransferV1` if this is a `LegacyTransfer` variant.
pub fn as_legacy_transfer(&self) -> Option<&TransferV1> {
/// Returns a reference to the wrapped `TransferV1` if this is a `Transfer` variant.
pub fn as_transfer(&self) -> Option<&TransferV1> {
match self {
StoredValue::LegacyTransfer(transfer_v1) => Some(transfer_v1),
StoredValue::Transfer(transfer_v1) => Some(transfer_v1),
_ => None,
}
}
Expand Down Expand Up @@ -348,10 +348,10 @@ impl StoredValue {
}
}

/// Returns the `TransferV1` if this is a `LegacyTransfer` variant.
/// Returns the `TransferV1` if this is a `Transfer` variant.
pub fn into_legacy_transfer(self) -> Option<TransferV1> {
match self {
StoredValue::LegacyTransfer(transfer_v1) => Some(transfer_v1),
StoredValue::Transfer(transfer_v1) => Some(transfer_v1),
_ => None,
}
}
Expand Down Expand Up @@ -430,7 +430,7 @@ impl StoredValue {
StoredValue::ContractWasm(_) => "ContractWasm".to_string(),
StoredValue::Contract(_) => "Contract".to_string(),
StoredValue::ContractPackage(_) => "ContractPackage".to_string(),
StoredValue::LegacyTransfer(_) => "LegacyTransfer".to_string(),
StoredValue::Transfer(_) => "Transfer".to_string(),
StoredValue::DeployInfo(_) => "DeployInfo".to_string(),
StoredValue::EraInfo(_) => "EraInfo".to_string(),
StoredValue::Bid(_) => "Bid".to_string(),
Expand All @@ -457,7 +457,7 @@ impl StoredValue {
StoredValue::ContractWasm(_) => StoredValueTag::ContractWasm,
StoredValue::ContractPackage(_) => StoredValueTag::ContractPackage,
StoredValue::Contract(_) => StoredValueTag::Contract,
StoredValue::LegacyTransfer(_) => StoredValueTag::LegacyTransfer,
StoredValue::Transfer(_) => StoredValueTag::Transfer,
StoredValue::DeployInfo(_) => StoredValueTag::DeployInfo,
StoredValue::EraInfo(_) => StoredValueTag::EraInfo,
StoredValue::Bid(_) => StoredValueTag::Bid,
Expand Down Expand Up @@ -679,11 +679,8 @@ impl TryFrom<StoredValue> for TransferV1 {

fn try_from(value: StoredValue) -> Result<Self, Self::Error> {
match value {
StoredValue::LegacyTransfer(transfer_v1) => Ok(transfer_v1),
_ => Err(TypeMismatch::new(
"LegacyTransfer".to_string(),
value.type_name(),
)),
StoredValue::Transfer(transfer_v1) => Ok(transfer_v1),
_ => Err(TypeMismatch::new("Transfer".to_string(), value.type_name())),
}
}
}
Expand Down Expand Up @@ -766,7 +763,7 @@ impl ToBytes for StoredValue {
StoredValue::ContractPackage(contract_package) => {
contract_package.serialized_length()
}
StoredValue::LegacyTransfer(transfer_v1) => transfer_v1.serialized_length(),
StoredValue::Transfer(transfer_v1) => transfer_v1.serialized_length(),
StoredValue::DeployInfo(deploy_info) => deploy_info.serialized_length(),
StoredValue::EraInfo(era_info) => era_info.serialized_length(),
StoredValue::Bid(bid) => bid.serialized_length(),
Expand Down Expand Up @@ -795,7 +792,7 @@ impl ToBytes for StoredValue {
StoredValue::ContractWasm(contract_wasm) => contract_wasm.write_bytes(writer),
StoredValue::Contract(contract_header) => contract_header.write_bytes(writer),
StoredValue::ContractPackage(contract_package) => contract_package.write_bytes(writer),
StoredValue::LegacyTransfer(transfer_v1) => transfer_v1.write_bytes(writer),
StoredValue::Transfer(transfer_v1) => transfer_v1.write_bytes(writer),
StoredValue::DeployInfo(deploy_info) => deploy_info.write_bytes(writer),
StoredValue::EraInfo(era_info) => era_info.write_bytes(writer),
StoredValue::Bid(bid) => bid.write_bytes(writer),
Expand Down Expand Up @@ -836,10 +833,8 @@ impl FromBytes for StoredValue {
}
tag if tag == StoredValueTag::Contract as u8 => Contract::from_bytes(remainder)
.map(|(contract, remainder)| (StoredValue::Contract(contract), remainder)),
tag if tag == StoredValueTag::LegacyTransfer as u8 => TransferV1::from_bytes(remainder)
.map(|(transfer_v1, remainder)| {
(StoredValue::LegacyTransfer(transfer_v1), remainder)
}),
tag if tag == StoredValueTag::Transfer as u8 => TransferV1::from_bytes(remainder)
.map(|(transfer_v1, remainder)| (StoredValue::Transfer(transfer_v1), remainder)),
tag if tag == StoredValueTag::DeployInfo as u8 => DeployInfo::from_bytes(remainder)
.map(|(deploy_info, remainder)| (StoredValue::DeployInfo(deploy_info), remainder)),
tag if tag == StoredValueTag::EraInfo as u8 => EraInfo::from_bytes(remainder)
Expand Down Expand Up @@ -901,7 +896,7 @@ mod serde_helpers {
ContractWasm(&'a ContractWasm),
Contract(&'a Contract),
ContractPackage(&'a ContractPackage),
LegacyTransfer(&'a TransferV1),
Transfer(&'a TransferV1),
DeployInfo(&'a DeployInfo),
EraInfo(&'a EraInfo),
Bid(&'a Bid),
Expand All @@ -927,7 +922,7 @@ mod serde_helpers {
ContractWasm(ContractWasm),
Contract(Contract),
ContractPackage(ContractPackage),
LegacyTransfer(TransferV1),
Transfer(TransferV1),
DeployInfo(DeployInfo),
EraInfo(EraInfo),
Bid(Box<Bid>),
Expand Down Expand Up @@ -955,9 +950,7 @@ mod serde_helpers {
StoredValue::ContractPackage(payload) => {
HumanReadableSerHelper::ContractPackage(payload)
}
StoredValue::LegacyTransfer(payload) => {
HumanReadableSerHelper::LegacyTransfer(payload)
}
StoredValue::Transfer(payload) => HumanReadableSerHelper::Transfer(payload),
StoredValue::DeployInfo(payload) => HumanReadableSerHelper::DeployInfo(payload),
StoredValue::EraInfo(payload) => HumanReadableSerHelper::EraInfo(payload),
StoredValue::Bid(payload) => HumanReadableSerHelper::Bid(payload),
Expand Down Expand Up @@ -997,9 +990,7 @@ mod serde_helpers {
HumanReadableDeserHelper::ContractPackage(payload) => {
StoredValue::ContractPackage(payload)
}
HumanReadableDeserHelper::LegacyTransfer(payload) => {
StoredValue::LegacyTransfer(payload)
}
HumanReadableDeserHelper::Transfer(payload) => StoredValue::Transfer(payload),
HumanReadableDeserHelper::DeployInfo(payload) => StoredValue::DeployInfo(payload),
HumanReadableDeserHelper::EraInfo(payload) => StoredValue::EraInfo(payload),
HumanReadableDeserHelper::Bid(bid) => StoredValue::Bid(bid),
Expand Down
2 changes: 1 addition & 1 deletion types/src/transaction/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub use crate::transaction::transaction_v1::InvalidTransactionV1;
#[cfg_attr(feature = "datasize", derive(DataSize))]
#[non_exhaustive]
pub enum InvalidTransaction {
/// Legacy deploys.
/// Deploys.
Deploy(InvalidDeploy),
/// V1 transactions.
V1(InvalidTransactionV1),
Expand Down
6 changes: 3 additions & 3 deletions utils/validation/src/generators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ pub fn make_abi_test_fixtures() -> Result<TestFixtures, Error> {
ABITestCase::from_inputs(vec![UREF_KEY.into()])?,
);
keys.insert(
"LegacyTransfer".to_string(),
"Transfer".to_string(),
ABITestCase::from_inputs(vec![TRANSFER_KEY.into()])?,
);
keys.insert(
Expand Down Expand Up @@ -433,8 +433,8 @@ pub fn make_abi_test_fixtures() -> Result<TestFixtures, Error> {
);

stored_value.insert(
"LegacyTransfer".to_string(),
ABITestCase::from_inputs(vec![StoredValue::LegacyTransfer(legacy_transfer).into()])?,
"Transfer".to_string(),
ABITestCase::from_inputs(vec![StoredValue::Transfer(legacy_transfer).into()])?,
);
stored_value.insert(
"DeployInfo".to_string(),
Expand Down

0 comments on commit 2ad34b5

Please sign in to comment.