git.delta.rocks / unique-network / refs/commits / 64d0cdb0c53e

difftreelog

refac: rename bytes -> Bytes

Trubnikov Sergey2023-01-18parent: #7d542e4.patch.diff
in: master

9 files changed

modifiedcrates/evm-coder/src/abi/impls.rsdiffbeforeafterboth
--- a/crates/evm-coder/src/abi/impls.rs
+++ b/crates/evm-coder/src/abi/impls.rs
@@ -67,15 +67,15 @@
 
 impl_abi_writeable!(&str, string);
 
-impl_abi_type!(bytes, bytes, true);
+impl_abi_type!(Bytes, bytes, true);
 
-impl AbiRead for bytes {
-	fn abi_read(reader: &mut AbiReader) -> Result<bytes> {
-		Ok(bytes(reader.bytes()?))
+impl AbiRead for Bytes {
+	fn abi_read(reader: &mut AbiReader) -> Result<Bytes> {
+		Ok(Bytes(reader.bytes()?))
 	}
 }
 
-impl AbiWrite for bytes {
+impl AbiWrite for Bytes {
 	fn abi_write(&self, writer: &mut AbiWriter) {
 		writer.bytes(self.0.as_slice())
 	}
modifiedcrates/evm-coder/src/abi/test.rsdiffbeforeafterboth
--- a/crates/evm-coder/src/abi/test.rs
+++ b/crates/evm-coder/src/abi/test.rs
@@ -273,12 +273,12 @@
 
 #[test]
 fn encode_decode_vec_tuple_string_bytes() {
-	test_impl::<Vec<(String, bytes)>>(
+	test_impl::<Vec<(String, Bytes)>>(
 		0xdeadbeef,
 		vec![
 			(
 				"Test URI 0".to_string(),
-				bytes(vec![
+				Bytes(vec![
 					0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
 					0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
 					0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
@@ -287,14 +287,14 @@
 			),
 			(
 				"Test URI 1".to_string(),
-				bytes(vec![
+				Bytes(vec![
 					0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
 					0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
 					0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
 					0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
 				]),
 			),
-			("Test URI 2".to_string(), bytes(vec![0x33, 0x33])),
+			("Test URI 2".to_string(), Bytes(vec![0x33, 0x33])),
 		],
 		&hex!(
 			"
@@ -337,10 +337,10 @@
 // #[ignore = "reason"]
 fn encode_decode_tuple0_tuple1_uint8_tuple1_string_bytes_tuple1_uint8_bytes() {
 	let int = 0xff;
-	let by = bytes(vec![0x11, 0x22, 0x33]);
+	let by = Bytes(vec![0x11, 0x22, 0x33]);
 	let string = "some string".to_string();
 
-	test_impl::<((u8,), (String, bytes), (u8, bytes))>(
+	test_impl::<((u8,), (String, Bytes), (u8, Bytes))>(
 		0xdeadbeef,
 		((int,), (string.clone(), by.clone()), (int, by)),
 		&hex!(
@@ -485,9 +485,9 @@
 
 #[test]
 fn encode_decode_tuple0_tuple1_string_bytes() {
-	test_impl::<((String, bytes),)>(
+	test_impl::<((String, Bytes),)>(
 		0xdeadbeef,
-		(("some string".to_string(), bytes(vec![1, 2, 3])),),
+		(("some string".to_string(), Bytes(vec![1, 2, 3])),),
 		&hex!(
 			"
                 deadbeef
modifiedcrates/evm-coder/src/lib.rsdiffbeforeafterboth
--- a/crates/evm-coder/src/lib.rs
+++ b/crates/evm-coder/src/lib.rs
@@ -141,7 +141,7 @@
 	pub type String = ::std::string::String;
 
 	#[derive(Default, Debug, PartialEq, Eq, Clone)]
-	pub struct bytes(pub Vec<u8>);
+	pub struct Bytes(pub Vec<u8>);
 
 	//#region Special types
 	/// Makes function payable
@@ -162,20 +162,20 @@
 		pub value: U256,
 	}
 
-	impl From<Vec<u8>> for bytes {
+	impl From<Vec<u8>> for Bytes {
 		fn from(src: Vec<u8>) -> Self {
 			Self(src)
 		}
 	}
 
 	#[allow(clippy::from_over_into)]
-	impl Into<Vec<u8>> for bytes {
+	impl Into<Vec<u8>> for Bytes {
 		fn into(self) -> Vec<u8> {
 			self.0
 		}
 	}
 
-	impl bytes {
+	impl Bytes {
 		#[must_use]
 		pub fn len(&self) -> usize {
 			self.0.len()
modifiedcrates/evm-coder/src/solidity/impls.rsdiffbeforeafterboth
--- a/crates/evm-coder/src/solidity/impls.rs
+++ b/crates/evm-coder/src/solidity/impls.rs
@@ -30,7 +30,7 @@
 	Bytes4 => "bytes4" true = "bytes4(0)",
 	H160 => "address" true = "0x0000000000000000000000000000000000000000",
 	String => "string" false = "\"\"",
-	bytes => "bytes" false = "hex\"\"",
+	Bytes => "bytes" false = "hex\"\"",
 	bool => "bool" true = "false",
 }
 
modifiedcrates/evm-coder/tests/abi_derive_generation.rsdiffbeforeafterboth
1mod test_struct {1mod test_struct {
2 use evm_coder_procedural::AbiCoder;2 use evm_coder_procedural::AbiCoder;
3 use evm_coder::types::bytes;3 use evm_coder::types::Bytes;
44
5 #[test]5 #[test]
6 fn empty_struct() {6 fn empty_struct() {
27 #[derive(AbiCoder, PartialEq, Debug)]27 #[derive(AbiCoder, PartialEq, Debug)]
28 struct TypeStruct2DynamicParam {28 struct TypeStruct2DynamicParam {
29 _a: String,29 _a: String,
30 _b: bytes,30 _b: Bytes,
31 }31 }
3232
33 #[derive(AbiCoder, PartialEq, Debug)]33 #[derive(AbiCoder, PartialEq, Debug)]
34 struct TypeStruct2MixedParam {34 struct TypeStruct2MixedParam {
35 _a: u8,35 _a: u8,
36 _b: bytes,36 _b: Bytes,
37 }37 }
3838
39 #[derive(AbiCoder, PartialEq, Debug)]39 #[derive(AbiCoder, PartialEq, Debug)]
236 struct TupleStruct2SimpleParam(u8, u32);236 struct TupleStruct2SimpleParam(u8, u32);
237237
238 #[derive(AbiCoder, PartialEq, Debug)]238 #[derive(AbiCoder, PartialEq, Debug)]
239 struct TupleStruct2DynamicParam(String, bytes);239 struct TupleStruct2DynamicParam(String, Bytes);
240240
241 #[derive(AbiCoder, PartialEq, Debug)]241 #[derive(AbiCoder, PartialEq, Debug)]
242 struct TupleStruct2MixedParam(u8, bytes);242 struct TupleStruct2MixedParam(u8, Bytes);
243243
244 #[derive(AbiCoder, PartialEq, Debug)]244 #[derive(AbiCoder, PartialEq, Debug)]
245 struct TupleStruct1DerivedSimpleParam(TupleStruct1SimpleParam);245 struct TupleStruct1DerivedSimpleParam(TupleStruct1SimpleParam);
562 #[test]562 #[test]
563 fn codec_struct_2_dynamic() {563 fn codec_struct_2_dynamic() {
564 let _a: String = "some string".into();564 let _a: String = "some string".into();
565 let _b: bytes = bytes(vec![0x11, 0x22, 0x33]);565 let _b: Bytes = Bytes(vec![0x11, 0x22, 0x33]);
566 test_impl::<(String, bytes), TupleStruct2DynamicParam, TypeStruct2DynamicParam>(566 test_impl::<(String, Bytes), TupleStruct2DynamicParam, TypeStruct2DynamicParam>(
567 (_a.clone(), _b.clone()),567 (_a.clone(), _b.clone()),
568 TupleStruct2DynamicParam(_a.clone(), _b.clone()),568 TupleStruct2DynamicParam(_a.clone(), _b.clone()),
569 TypeStruct2DynamicParam { _a, _b },569 TypeStruct2DynamicParam { _a, _b },
573 #[test]573 #[test]
574 fn codec_struct_2_mixed() {574 fn codec_struct_2_mixed() {
575 let _a: u8 = 0xff;575 let _a: u8 = 0xff;
576 let _b: bytes = bytes(vec![0x11, 0x22, 0x33]);576 let _b: Bytes = Bytes(vec![0x11, 0x22, 0x33]);
577 test_impl::<(u8, bytes), TupleStruct2MixedParam, TypeStruct2MixedParam>(577 test_impl::<(u8, Bytes), TupleStruct2MixedParam, TypeStruct2MixedParam>(
578 (_a.clone(), _b.clone()),578 (_a.clone(), _b.clone()),
579 TupleStruct2MixedParam(_a.clone(), _b.clone()),579 TupleStruct2MixedParam(_a.clone(), _b.clone()),
580 TypeStruct2MixedParam { _a, _b },580 TypeStruct2MixedParam { _a, _b },
605 #[test]605 #[test]
606 fn codec_struct_2_derived_dynamic() {606 fn codec_struct_2_derived_dynamic() {
607 let _a = "some string".to_string();607 let _a = "some string".to_string();
608 let _b = bytes(vec![0x11, 0x22, 0x33]);608 let _b = Bytes(vec![0x11, 0x22, 0x33]);
609 test_impl::<609 test_impl::<
610 ((String,), (String, bytes)),610 ((String,), (String, Bytes)),
611 TupleStruct2DerivedDynamicParam,611 TupleStruct2DerivedDynamicParam,
612 TypeStruct2DerivedDynamicParam,612 TypeStruct2DerivedDynamicParam,
613 >(613 >(
626 #[test]626 #[test]
627 fn codec_struct_3_derived_mixed() {627 fn codec_struct_3_derived_mixed() {
628 let int = 0xff;628 let int = 0xff;
629 let by = bytes(vec![0x11, 0x22, 0x33]);629 let by = Bytes(vec![0x11, 0x22, 0x33]);
630 let string = "some string".to_string();630 let string = "some string".to_string();
631 test_impl::<631 test_impl::<
632 ((u8,), (String, bytes), (u8, bytes)),632 ((u8,), (String, Bytes), (u8, Bytes)),
633 TupleStruct3DerivedMixedParam,633 TupleStruct3DerivedMixedParam,
634 TypeStruct3DerivedMixedParam,634 TypeStruct3DerivedMixedParam,
635 >(635 >(
modifiedpallets/common/src/erc.rsdiffbeforeafterboth
--- a/pallets/common/src/erc.rs
+++ b/pallets/common/src/erc.rs
@@ -94,7 +94,7 @@
 	/// @param value Propery value.
 	#[solidity(hide)]
 	#[weight(<SelfWeightOf<T>>::set_collection_properties(1))]
-	fn set_collection_property(&mut self, caller: caller, key: String, value: bytes) -> Result<()> {
+	fn set_collection_property(&mut self, caller: caller, key: String, value: Bytes) -> Result<()> {
 		let caller = T::CrossAccountId::from_eth(caller);
 		let key = <Vec<u8>>::from(key)
 			.try_into()
@@ -164,7 +164,7 @@
 	///
 	/// @param key Property key.
 	/// @return bytes The property corresponding to the key.
-	fn collection_property(&self, key: String) -> Result<bytes> {
+	fn collection_property(&self, key: String) -> Result<Bytes> {
 		let key = <Vec<u8>>::from(key)
 			.try_into()
 			.map_err(|_| "key too large")?;
@@ -172,7 +172,7 @@
 		let props = CollectionProperties::<T>::get(self.id);
 		let prop = props.get(&key).ok_or("key not found")?;
 
-		Ok(bytes(prop.to_vec()))
+		Ok(Bytes(prop.to_vec()))
 	}
 
 	/// Get collection properties.
modifiedpallets/common/src/eth.rsdiffbeforeafterboth
--- a/pallets/common/src/eth.rs
+++ b/pallets/common/src/eth.rs
@@ -119,7 +119,7 @@
 #[derive(Debug, Default, AbiCoder)]
 pub struct Property {
 	key: evm_coder::types::String,
-	value: evm_coder::types::bytes,
+	value: evm_coder::types::Bytes,
 }
 
 impl TryFrom<up_data_structs::Property> for Property {
@@ -128,7 +128,7 @@
 	fn try_from(from: up_data_structs::Property) -> Result<Self, Self::Error> {
 		let key = evm_coder::types::String::from_utf8(from.key.into())
 			.map_err(|e| Self::Error::Revert(format!("utf8 conversion error: {}", e)))?;
-		let value = evm_coder::types::bytes(from.value.to_vec());
+		let value = evm_coder::types::Bytes(from.value.to_vec());
 		Ok(Property { key, value })
 	}
 }
modifiedpallets/nonfungible/src/erc.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/erc.rs
+++ b/pallets/nonfungible/src/erc.rs
@@ -124,7 +124,7 @@
 		caller: caller,
 		token_id: U256,
 		key: String,
-		value: bytes,
+		value: Bytes,
 	) -> Result<()> {
 		let caller = T::CrossAccountId::from_eth(caller);
 		let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;
@@ -239,7 +239,7 @@
 	/// @param tokenId ID of the token.
 	/// @param key Property key.
 	/// @return Property value bytes
-	fn property(&self, token_id: U256, key: String) -> Result<bytes> {
+	fn property(&self, token_id: U256, key: String) -> Result<Bytes> {
 		let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;
 		let key = <Vec<u8>>::from(key)
 			.try_into()
@@ -422,7 +422,7 @@
 		_from: Address,
 		_to: Address,
 		_token_id: U256,
-		_data: bytes,
+		_data: Bytes,
 	) -> Result<()> {
 		// TODO: Not implemetable
 		Err("not implemented".into())
modifiedpallets/refungible/src/erc.rsdiffbeforeafterboth
--- a/pallets/refungible/src/erc.rs
+++ b/pallets/refungible/src/erc.rs
@@ -127,7 +127,7 @@
 		caller: caller,
 		token_id: U256,
 		key: String,
-		value: bytes,
+		value: Bytes,
 	) -> Result<()> {
 		let caller = T::CrossAccountId::from_eth(caller);
 		let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;
@@ -242,7 +242,7 @@
 	/// @param tokenId ID of the token.
 	/// @param key Property key.
 	/// @return Property value bytes
-	fn property(&self, token_id: U256, key: String) -> Result<bytes> {
+	fn property(&self, token_id: U256, key: String) -> Result<Bytes> {
 		let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;
 		let key = <Vec<u8>>::from(key)
 			.try_into()
@@ -423,7 +423,7 @@
 		_from: Address,
 		_to: Address,
 		_token_id: U256,
-		_data: bytes,
+		_data: Bytes,
 	) -> Result<()> {
 		// TODO: Not implemetable
 		Err("not implemented".into())