@@ -38,6 +38,28 @@ use std::{
38
38
fmt:: Display ,
39
39
} ;
40
40
41
+ pub mod local_state;
42
+ pub mod protocol_state;
43
+ pub mod signed_command;
44
+ pub mod transaction_applied;
45
+ pub mod transaction_partially_applied;
46
+ pub mod transaction_union_payload;
47
+ pub mod transaction_witness;
48
+ pub mod valid;
49
+ pub mod verifiable;
50
+ pub mod zkapp_command;
51
+ pub mod zkapp_statement;
52
+ pub use transaction_partially_applied:: {
53
+ apply_transaction_first_pass, apply_transaction_second_pass, apply_transactions,
54
+ apply_user_command, set_with_location, AccountState ,
55
+ } ;
56
+ pub use transaction_union_payload:: {
57
+ account_check_timing, add_amount, checked_cons_signed_command_payload,
58
+ cons_signed_command_payload, cons_zkapp_command_commitment, get_with_location, sub_amount,
59
+ timing_error_to_user_command_status, validate_nonces, validate_timing, Body , Common ,
60
+ ExistingOrNew , Tag , TimingValidation , TransactionUnion , TransactionUnionPayload ,
61
+ } ;
62
+
41
63
/// <https://github.com/MinaProtocol/mina/blob/2ee6e004ba8c6a0541056076aab22ea162f7eb3a/src/lib/mina_base/transaction_status.ml#L9>
42
64
#[ derive( serde:: Serialize , serde:: Deserialize , Debug , Clone , PartialEq , Eq ) ]
43
65
pub enum TransactionFailure {
@@ -237,8 +259,6 @@ where
237
259
}
238
260
}
239
261
240
- pub mod valid;
241
-
242
262
/// <https://github.com/MinaProtocol/mina/blob/2ee6e004ba8c6a0541056076aab22ea162f7eb3a/src/lib/mina_base/fee_transfer.ml#L19>
243
263
#[ derive( Debug , Clone , PartialEq ) ]
244
264
pub struct SingleFeeTransfer {
@@ -589,13 +609,6 @@ impl Memo {
589
609
}
590
610
}
591
611
592
- pub mod signed_command;
593
-
594
- pub mod zkapp_command;
595
- pub mod zkapp_statement;
596
-
597
- pub mod verifiable;
598
-
599
612
#[ derive( Clone , Debug , PartialEq ) ]
600
613
pub enum UserCommand {
601
614
SignedCommand ( Box < signed_command:: SignedCommand > ) ,
@@ -1017,24 +1030,6 @@ impl From<&Transaction> for MinaTransactionTransactionStableV2 {
1017
1030
}
1018
1031
}
1019
1032
1020
- pub mod local_state;
1021
- pub mod protocol_state;
1022
- pub mod transaction_applied;
1023
- pub mod transaction_partially_applied;
1024
- pub mod transaction_witness;
1025
- pub use transaction_partially_applied:: {
1026
- apply_transaction_first_pass, apply_transaction_second_pass, apply_transactions,
1027
- apply_user_command, set_with_location, AccountState ,
1028
- } ;
1029
-
1030
- pub mod transaction_union_payload;
1031
- pub use transaction_union_payload:: {
1032
- account_check_timing, add_amount, checked_cons_signed_command_payload,
1033
- cons_signed_command_payload, cons_zkapp_command_commitment, get_with_location, sub_amount,
1034
- timing_error_to_user_command_status, validate_nonces, validate_timing, Body , Common ,
1035
- ExistingOrNew , Tag , TimingValidation , TransactionUnion , TransactionUnionPayload ,
1036
- } ;
1037
-
1038
1033
#[ cfg( any( test, feature = "fuzzing" ) ) ]
1039
1034
pub mod for_tests {
1040
1035
use mina_signer:: Keypair ;
@@ -1319,107 +1314,3 @@ pub mod for_tests {
1319
1314
}
1320
1315
}
1321
1316
1322
- #[ cfg( test) ]
1323
- mod tests {
1324
- use std:: str:: FromStr ;
1325
-
1326
- use o1_utils:: FieldHelpers ;
1327
-
1328
- #[ cfg( target_family = "wasm" ) ]
1329
- use wasm_bindgen_test:: wasm_bindgen_test as test;
1330
-
1331
- use super :: {
1332
- signed_command:: { Body , Common , PaymentPayload } ,
1333
- * ,
1334
- } ;
1335
-
1336
- fn pub_key ( address : & str ) -> CompressedPubKey {
1337
- mina_signer:: PubKey :: from_address ( address)
1338
- . unwrap ( )
1339
- . into_compressed ( )
1340
- }
1341
-
1342
- #[ test]
1343
- fn test_hash_empty_event ( ) {
1344
- // Same value than OCaml
1345
- const EXPECTED : & str =
1346
- "6963060754718463299978089777716994949151371320681588566338620419071140958308" ;
1347
-
1348
- let event = zkapp_command:: Event :: empty ( ) ;
1349
- assert_eq ! ( event. hash( ) , Fp :: from_str( EXPECTED ) . unwrap( ) ) ;
1350
- }
1351
-
1352
- /// Test using same values as here:
1353
- /// <https://github.com/MinaProtocol/mina/blob/3a78f0e0c1343d14e2729c8b00205baa2ec70c93/src/lib/mina_base/receipt.ml#L136>
1354
- #[ test]
1355
- fn test_cons_receipt_hash_ocaml ( ) {
1356
- let from = pub_key ( "B62qr71UxuyKpkSKYceCPsjw14nuaeLwWKZdMqaBMPber5AAF6nkowS" ) ;
1357
- let to = pub_key ( "B62qnvGVnU7FXdy8GdkxL7yciZ8KattyCdq5J6mzo5NCxjgQPjL7BTH" ) ;
1358
-
1359
- let common = Common {
1360
- fee : Fee :: from_u64 ( 9758327274353182341 ) ,
1361
- fee_payer_pk : from,
1362
- nonce : Nonce :: from_u32 ( 1609569868 ) ,
1363
- valid_until : Slot :: from_u32 ( 2127252111 ) ,
1364
- memo : Memo ( [
1365
- 1 , 32 , 101 , 26 , 225 , 104 , 115 , 118 , 55 , 102 , 76 , 118 , 108 , 78 , 114 , 50 , 0 , 115 ,
1366
- 110 , 108 , 53 , 75 , 109 , 112 , 50 , 110 , 88 , 97 , 76 , 66 , 76 , 81 , 235 , 79 ,
1367
- ] ) ,
1368
- } ;
1369
-
1370
- let body = Body :: Payment ( PaymentPayload {
1371
- receiver_pk : to,
1372
- amount : Amount :: from_u64 ( 1155659205107036493 ) ,
1373
- } ) ;
1374
-
1375
- let tx = SignedCommandPayload { common, body } ;
1376
-
1377
- let prev = "4918218371695029984164006552208340844155171097348169027410983585063546229555" ;
1378
- let prev_receipt_chain_hash = ReceiptChainHash ( Fp :: from_str ( prev) . unwrap ( ) ) ;
1379
-
1380
- let next = "19078048535981853335308913493724081578728104896524544653528728307378106007337" ;
1381
- let next_receipt_chain_hash = ReceiptChainHash ( Fp :: from_str ( next) . unwrap ( ) ) ;
1382
-
1383
- let result = cons_signed_command_payload ( & tx, prev_receipt_chain_hash) ;
1384
- assert_eq ! ( result, next_receipt_chain_hash) ;
1385
- }
1386
-
1387
- #[ test]
1388
- fn test_receipt_hash_update ( ) {
1389
- let from = pub_key ( "B62qmnY6m4c6bdgSPnQGZriSaj9vuSjsfh6qkveGTsFX3yGA5ywRaja" ) ;
1390
- let to = pub_key ( "B62qjVQLxt9nYMWGn45mkgwYfcz8e8jvjNCBo11VKJb7vxDNwv5QLPS" ) ;
1391
-
1392
- let common = Common {
1393
- fee : Fee :: from_u64 ( 14500000 ) ,
1394
- fee_payer_pk : from,
1395
- nonce : Nonce :: from_u32 ( 15 ) ,
1396
- valid_until : Slot :: from_u32 ( -1i32 as u32 ) ,
1397
- memo : Memo ( [
1398
- 1 , 7 , 84 , 104 , 101 , 32 , 49 , 48 , 49 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
1399
- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
1400
- ] ) ,
1401
- } ;
1402
-
1403
- let body = Body :: Payment ( PaymentPayload {
1404
- receiver_pk : to,
1405
- amount : Amount :: from_u64 ( 2354000000 ) ,
1406
- } ) ;
1407
-
1408
- let tx = SignedCommandPayload { common, body } ;
1409
-
1410
- let mut prev =
1411
- hex:: decode ( "09ac04c9965b885acfc9c54141dbecfc63b2394a4532ea2c598d086b894bfb14" )
1412
- . unwrap ( ) ;
1413
- prev. reverse ( ) ;
1414
- let prev_receipt_chain_hash = ReceiptChainHash ( Fp :: from_bytes ( & prev) . unwrap ( ) ) ;
1415
-
1416
- let mut next =
1417
- hex:: decode ( "3ecaa73739df77549a2f92f7decf822562d0593373cff1e480bb24b4c87dc8f0" )
1418
- . unwrap ( ) ;
1419
- next. reverse ( ) ;
1420
- let next_receipt_chain_hash = ReceiptChainHash ( Fp :: from_bytes ( & next) . unwrap ( ) ) ;
1421
-
1422
- let result = cons_signed_command_payload ( & tx, prev_receipt_chain_hash) ;
1423
- assert_eq ! ( result, next_receipt_chain_hash) ;
1424
- }
1425
- }
0 commit comments