File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -85,3 +85,4 @@ packages/wasm-sdk/extracted_definitions.json
8585
8686# gRPC coverage report
8787grpc-coverage-report.txt
88+ worktrees /
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ arc-swap = { version = "1.7.1" }
99chrono = { version = " 0.4.38" }
1010dpp = { path = " ../rs-dpp" , default-features = false , features = [
1111 " dash-sdk-features" ,
12+ " validation" ,
1213] }
1314dapi-grpc = { path = " ../dapi-grpc" , default-features = false }
1415rs-dapi-client = { path = " ../rs-dapi-client" , default-features = false }
Original file line number Diff line number Diff line change @@ -167,6 +167,22 @@ impl DocumentCreateTransitionBuilder {
167167 self . state_transition_creation_options ,
168168 ) ?;
169169
170+ // Validate the transition structure before returning
171+ let validation_result = match & state_transition {
172+ StateTransition :: Batch ( batch_transition) => {
173+ batch_transition. validate_base_structure ( platform_version) ?
174+ }
175+ _ => {
176+ return Err ( Error :: Protocol ( dpp:: ProtocolError :: InvalidStateTransitionType (
177+ "expected Batch transition" . to_string ( ) ,
178+ ) ) ) ;
179+ }
180+ } ;
181+ if !validation_result. is_valid ( ) {
182+ let first_error = validation_result. errors . into_iter ( ) . next ( ) . unwrap ( ) ;
183+ return Err ( Error :: Protocol ( dpp:: ProtocolError :: ConsensusError ( Box :: new ( first_error) ) ) ) ;
184+ }
185+
170186 Ok ( state_transition)
171187 }
172188}
Original file line number Diff line number Diff line change @@ -207,6 +207,22 @@ impl DocumentDeleteTransitionBuilder {
207207 self . state_transition_creation_options ,
208208 ) ?;
209209
210+ // Validate the transition structure before returning
211+ let validation_result = match & state_transition {
212+ StateTransition :: Batch ( batch_transition) => {
213+ batch_transition. validate_base_structure ( platform_version) ?
214+ }
215+ _ => {
216+ return Err ( Error :: Protocol ( dpp:: ProtocolError :: InvalidStateTransitionType (
217+ "expected Batch transition" . to_string ( ) ,
218+ ) ) ) ;
219+ }
220+ } ;
221+ if !validation_result. is_valid ( ) {
222+ let first_error = validation_result. errors . into_iter ( ) . next ( ) . unwrap ( ) ;
223+ return Err ( Error :: Protocol ( dpp:: ProtocolError :: ConsensusError ( Box :: new ( first_error) ) ) ) ;
224+ }
225+
210226 Ok ( state_transition)
211227 }
212228}
Original file line number Diff line number Diff line change @@ -221,6 +221,22 @@ impl DocumentPurchaseTransitionBuilder {
221221 self . state_transition_creation_options ,
222222 ) ?;
223223
224+ // Validate the transition structure before returning
225+ let validation_result = match & state_transition {
226+ StateTransition :: Batch ( batch_transition) => {
227+ batch_transition. validate_base_structure ( platform_version) ?
228+ }
229+ _ => {
230+ return Err ( Error :: Protocol ( dpp:: ProtocolError :: InvalidStateTransitionType (
231+ "expected Batch transition" . to_string ( ) ,
232+ ) ) ) ;
233+ }
234+ } ;
235+ if !validation_result. is_valid ( ) {
236+ let first_error = validation_result. errors . into_iter ( ) . next ( ) . unwrap ( ) ;
237+ return Err ( Error :: Protocol ( dpp:: ProtocolError :: ConsensusError ( Box :: new ( first_error) ) ) ) ;
238+ }
239+
224240 Ok ( state_transition)
225241 }
226242}
Original file line number Diff line number Diff line change @@ -160,6 +160,22 @@ impl DocumentReplaceTransitionBuilder {
160160 self . state_transition_creation_options ,
161161 ) ?;
162162
163+ // Validate the transition structure before returning
164+ let validation_result = match & state_transition {
165+ StateTransition :: Batch ( batch_transition) => {
166+ batch_transition. validate_base_structure ( platform_version) ?
167+ }
168+ _ => {
169+ return Err ( Error :: Protocol ( dpp:: ProtocolError :: InvalidStateTransitionType (
170+ "expected Batch transition" . to_string ( ) ,
171+ ) ) ) ;
172+ }
173+ } ;
174+ if !validation_result. is_valid ( ) {
175+ let first_error = validation_result. errors . into_iter ( ) . next ( ) . unwrap ( ) ;
176+ return Err ( Error :: Protocol ( dpp:: ProtocolError :: ConsensusError ( Box :: new ( first_error) ) ) ) ;
177+ }
178+
163179 Ok ( state_transition)
164180 }
165181}
Original file line number Diff line number Diff line change @@ -208,6 +208,22 @@ impl DocumentSetPriceTransitionBuilder {
208208 self . state_transition_creation_options ,
209209 ) ?;
210210
211+ // Validate the transition structure before returning
212+ let validation_result = match & state_transition {
213+ StateTransition :: Batch ( batch_transition) => {
214+ batch_transition. validate_base_structure ( platform_version) ?
215+ }
216+ _ => {
217+ return Err ( Error :: Protocol ( dpp:: ProtocolError :: InvalidStateTransitionType (
218+ "expected Batch transition" . to_string ( ) ,
219+ ) ) ) ;
220+ }
221+ } ;
222+ if !validation_result. is_valid ( ) {
223+ let first_error = validation_result. errors . into_iter ( ) . next ( ) . unwrap ( ) ;
224+ return Err ( Error :: Protocol ( dpp:: ProtocolError :: ConsensusError ( Box :: new ( first_error) ) ) ) ;
225+ }
226+
211227 Ok ( state_transition)
212228 }
213229}
Original file line number Diff line number Diff line change @@ -207,6 +207,22 @@ impl DocumentTransferTransitionBuilder {
207207 self . state_transition_creation_options ,
208208 ) ?;
209209
210+ // Validate the transition structure before returning
211+ let validation_result = match & state_transition {
212+ StateTransition :: Batch ( batch_transition) => {
213+ batch_transition. validate_base_structure ( platform_version) ?
214+ }
215+ _ => {
216+ return Err ( Error :: Protocol ( dpp:: ProtocolError :: InvalidStateTransitionType (
217+ "expected Batch transition" . to_string ( ) ,
218+ ) ) ) ;
219+ }
220+ } ;
221+ if !validation_result. is_valid ( ) {
222+ let first_error = validation_result. errors . into_iter ( ) . next ( ) . unwrap ( ) ;
223+ return Err ( Error :: Protocol ( dpp:: ProtocolError :: ConsensusError ( Box :: new ( first_error) ) ) ) ;
224+ }
225+
210226 Ok ( state_transition)
211227 }
212228}
Original file line number Diff line number Diff line change @@ -179,6 +179,22 @@ impl TokenBurnTransitionBuilder {
179179 self . state_transition_creation_options ,
180180 ) ?;
181181
182+ // Validate the transition structure before returning
183+ let validation_result = match & state_transition {
184+ StateTransition :: Batch ( batch_transition) => {
185+ batch_transition. validate_base_structure ( platform_version) ?
186+ }
187+ _ => {
188+ return Err ( Error :: Protocol ( dpp:: ProtocolError :: InvalidStateTransitionType (
189+ "expected Batch transition" . to_string ( ) ,
190+ ) ) ) ;
191+ }
192+ } ;
193+ if !validation_result. is_valid ( ) {
194+ let first_error = validation_result. errors . into_iter ( ) . next ( ) . unwrap ( ) ;
195+ return Err ( Error :: Protocol ( dpp:: ProtocolError :: ConsensusError ( Box :: new ( first_error) ) ) ) ;
196+ }
197+
182198 Ok ( state_transition)
183199 }
184200}
Original file line number Diff line number Diff line change @@ -165,6 +165,22 @@ impl TokenClaimTransitionBuilder {
165165 self . state_transition_creation_options ,
166166 ) ?;
167167
168+ // Validate the transition structure before returning
169+ let validation_result = match & state_transition {
170+ StateTransition :: Batch ( batch_transition) => {
171+ batch_transition. validate_base_structure ( platform_version) ?
172+ }
173+ _ => {
174+ return Err ( Error :: Protocol ( dpp:: ProtocolError :: InvalidStateTransitionType (
175+ "expected Batch transition" . to_string ( ) ,
176+ ) ) ) ;
177+ }
178+ } ;
179+ if !validation_result. is_valid ( ) {
180+ let first_error = validation_result. errors . into_iter ( ) . next ( ) . unwrap ( ) ;
181+ return Err ( Error :: Protocol ( dpp:: ProtocolError :: ConsensusError ( Box :: new ( first_error) ) ) ) ;
182+ }
183+
168184 Ok ( state_transition)
169185 }
170186}
You can’t perform that action at this time.
0 commit comments