feat(wasm-dpp): add extra methods for state transitions #4949
Annotations
10 warnings and 1 notice
Run clechasseur/rs-clippy-check@v3:
packages/rs-platform-value/src/inner_value.rs#L364
warning: elided lifetime has a name
--> packages/rs-platform-value/src/inner_value.rs:364:66
|
364 | pub fn get_array_slice<'a>(&'a self, key: &'a str) -> Result<&[Value], Error> {
| -- lifetime `'a` declared here ^ this elided lifetime gets resolved as `'a`
|
= note: `#[warn(elided_named_lifetimes)]` on by default
|
Run clechasseur/rs-clippy-check@v3:
packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/mod.rs#L174
warning: unused variable: `t`
--> packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/mod.rs:174:41
|
174 | DocumentTransition::Replace(t) => None,
| ^ help: if this is intentional, prefix it with an underscore: `_t`
|
= note: `#[warn(unused_variables)]` on by default
|
Run clechasseur/rs-clippy-check@v3:
packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/mod.rs#L175
warning: unused variable: `t`
--> packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/mod.rs:175:40
|
175 | DocumentTransition::Delete(t) => None,
| ^ help: if this is intentional, prefix it with an underscore: `_t`
|
Run clechasseur/rs-clippy-check@v3:
packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/mod.rs#L176
warning: unused variable: `t`
--> packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/mod.rs:176:42
|
176 | DocumentTransition::Transfer(t) => None,
| ^ help: if this is intentional, prefix it with an underscore: `_t`
|
Run clechasseur/rs-clippy-check@v3:
packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/mod.rs#L177
warning: unused variable: `t`
--> packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/mod.rs:177:45
|
177 | DocumentTransition::UpdatePrice(t) => None,
| ^ help: if this is intentional, prefix it with an underscore: `_t`
|
Run clechasseur/rs-clippy-check@v3:
packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/mod.rs#L178
warning: unused variable: `t`
--> packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/mod.rs:178:42
|
178 | DocumentTransition::Purchase(t) => None,
| ^ help: if this is intentional, prefix it with an underscore: `_t`
|
Run clechasseur/rs-clippy-check@v3:
packages/rs-dpp/src/data_contract/document_type/accessors/mod.rs#L153
warning: the following explicit lifetimes could be elided: 'a
--> packages/rs-dpp/src/data_contract/document_type/accessors/mod.rs:153:6
|
153 | impl<'a> DocumentTypeV0Getters for DocumentTypeRef<'a> {
| ^^ ^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes
= note: `#[warn(clippy::needless_lifetimes)]` on by default
help: elide the lifetimes
|
153 - impl<'a> DocumentTypeV0Getters for DocumentTypeRef<'a> {
153 + impl DocumentTypeV0Getters for DocumentTypeRef<'_> {
|
|
Run clechasseur/rs-clippy-check@v3:
packages/rs-dpp/src/data_contract/document_type/accessors/mod.rs#L287
warning: the following explicit lifetimes could be elided: 'a
--> packages/rs-dpp/src/data_contract/document_type/accessors/mod.rs:287:6
|
287 | impl<'a> DocumentTypeV0Getters for DocumentTypeMutRef<'a> {
| ^^ ^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes
help: elide the lifetimes
|
287 - impl<'a> DocumentTypeV0Getters for DocumentTypeMutRef<'a> {
287 + impl DocumentTypeV0Getters for DocumentTypeMutRef<'_> {
|
|
Run clechasseur/rs-clippy-check@v3:
packages/rs-dpp/src/data_contract/document_type/property/array.rs#L73
warning: unneeded `return` statement
--> packages/rs-dpp/src/data_contract/document_type/property/array.rs:73:9
|
73 | / return match self {
74 | | ArrayItemType::String(_, _) => {
75 | | let value_as_text = value.as_text().ok_or_else(get_field_type_matching_error)?;
76 | | let vec = value_as_text.as_bytes().to_vec();
... |
118 | | }
119 | | };
| |_________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
= note: `#[warn(clippy::needless_return)]` on by default
help: remove `return`
|
73 ~ match self {
74 + ArrayItemType::String(_, _) => {
75 + let value_as_text = value.as_text().ok_or_else(get_field_type_matching_error)?;
76 + let vec = value_as_text.as_bytes().to_vec();
77 + let mut r_vec = vec.len().encode_var_vec();
78 + r_vec.extend(vec);
79 + Ok(r_vec)
80 + }
81 + ArrayItemType::Date => {
82 + let value_as_f64 = value.to_float().map_err(ProtocolError::ValueError)?;
83 + let value_bytes = value_as_f64.to_be_bytes().to_vec();
84 + Ok(value_bytes)
85 + }
86 + ArrayItemType::Integer => {
87 + let value_as_i64: i64 = value.to_integer().map_err(ProtocolError::ValueError)?;
88 + let value_bytes = value_as_i64.to_be_bytes().to_vec();
89 + Ok(value_bytes)
90 + }
91 + ArrayItemType::Number => {
92 + let value_as_f64 = value.to_float().map_err(ProtocolError::ValueError)?;
93 + let value_bytes = value_as_f64.to_be_bytes().to_vec();
94 + Ok(value_bytes)
95 + }
96 + ArrayItemType::ByteArray(_, _) => {
97 + let mut bytes = value.to_binary_bytes()?;
98 +
99 + let mut r_vec = bytes.len().encode_var_vec();
100 + r_vec.append(&mut bytes);
101 + Ok(r_vec)
102 + }
103 + ArrayItemType::Identifier => {
104 + let mut bytes = value.to_identifier_bytes()?;
105 +
106 + let mut r_vec = bytes.len().encode_var_vec();
107 + r_vec.append(&mut bytes);
108 + Ok(r_vec)
109 + }
110 + ArrayItemType::Boolean => {
111 + let value_as_boolean = value.as_bool().ok_or_else(get_field_type_matching_error)?;
112 + // 0 means does not exist
113 + if value_as_boolean {
114 + Ok(vec![1]) // 1 is true
115 + } else {
116 + Ok(vec![0]) // 2 is false
117 + }
118 + }
119 ~ }
|
|
Run clechasseur/rs-clippy-check@v3:
packages/rs-dpp/src/data_contract/document_type/property/mod.rs#L955
warning: unneeded `return` statement
--> packages/rs-dpp/src/data_contract/document_type/property/mod.rs:955:9
|
955 | / return match self {
956 | | DocumentPropertyType::String(_) => {
957 | | let value_as_text = value
958 | | .as_text()
... |
1097 | | )),
1098 | | };
| |_________^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
help: remove `return`
|
955 ~ match self {
956 + DocumentPropertyType::String(_) => {
957 + let value_as_text = value
958 + .as_text()
959 + .ok_or_else(|| get_field_type_matching_error(value))?;
960 + let vec = value_as_text.as_bytes().to_vec();
961 + let mut r_vec = vec.len().encode_var_vec();
962 + r_vec.extend(vec);
963 + Ok(r_vec)
964 + }
965 + // TODO: Make the same as in https://github.com/dashpay/platform/blob/8d2a9e54d62b77581c44a15a09a2c61864af37d3/packages/rs-dpp/src/document/v0/serialize.rs#L161
966 + // it must be u64 BE. Markers are wrong here as well
967 + DocumentPropertyType::Date => {
968 + let value_as_f64 = value.to_float().map_err(ProtocolError::ValueError)?;
969 + let mut value_bytes = value_as_f64.to_be_bytes().to_vec();
970 + if required {
971 + Ok(value_bytes)
972 + } else {
973 + // if the value wasn't required we need to add a byte to prove it existed
974 + let mut r_vec = vec![255u8];
975 + r_vec.append(&mut value_bytes);
976 + Ok(r_vec)
977 + }
978 + }
979 + DocumentPropertyType::U128 => {
980 + let value_as_u128: u128 = value.to_integer().map_err(ProtocolError::ValueError)?;
981 + Ok(value_as_u128.to_be_bytes().to_vec())
982 + }
983 + DocumentPropertyType::I128 => {
984 + let value_as_i128: i128 = value.to_integer().map_err(ProtocolError::ValueError)?;
985 + Ok(value_as_i128.to_be_bytes().to_vec())
986 + }
987 + DocumentPropertyType::U64 => {
988 + let value_as_u64: u64 = value.to_integer().map_err(ProtocolError::ValueError)?;
989 + Ok(value_as_u64.to_be_bytes().to_vec())
990 + }
991 + DocumentPropertyType::I64 => {
992 + let value_as_i64: i64 = value.to_integer().map_err(ProtocolError::ValueError)?;
993 + Ok(value_as_i64.to_be_bytes().to_vec())
994 + }
995 + DocumentPropertyType::U32 => {
996 + let value_as_u32: u32 = value.to_integer().map_err(ProtocolError::ValueError)?;
997 + Ok(value_as_u32.to_be_bytes().to_vec())
998 + }
999 + DocumentPropertyType::I32 => {
1000 + let value_as_i32: i32 = value.to_integer().map_err(ProtocolError::ValueError)?;
1001 + Ok(value_as_i32.to_be_bytes().to_vec())
1002 + }
1003 + DocumentPropertyType::U16 => {
1004 + let value_as_u16: u16 = value.to_integer().map_err(ProtocolError::ValueError)?;
1005 + Ok(value_as_u16.to_be_bytes().to_vec())
1006 + }
1007 + DocumentPropertyType::I16 => {
1008 + let value_as_i16: i16 = value.to_integer().map_err(ProtocolError::ValueError)?;
1009 + Ok(value_as_i16.to_be_bytes().to_vec())
1010 + }
1011 + DocumentPropertyType::U8 => {
1012 + let value_as_u8: u8 = value.to_integer().map_err(ProtocolError::ValueError)?;
1013 + Ok(value_as_u8.to_be_bytes().to_vec())
1014 + }
1015 + DocumentPropertyType::I8 => {
|
Post Setup sccache
100% - 196 hits, 0 misses, 0 errors
|
Loading