@@ -1830,24 +1830,27 @@ impl From<&zkapp_command::ZkAppCommand> for MinaBaseZkappCommandTStableV1WireSta
18301830 }
18311831}
18321832
1833- impl From < & MinaTransactionLogicTransactionAppliedVaryingStableV2 > for transaction_applied:: Varying {
1834- fn from ( value : & MinaTransactionLogicTransactionAppliedVaryingStableV2 ) -> Self {
1833+ impl TryFrom < & MinaTransactionLogicTransactionAppliedVaryingStableV2 >
1834+ for transaction_applied:: Varying
1835+ {
1836+ type Error = InvalidBigInt ;
1837+
1838+ fn try_from (
1839+ value : & MinaTransactionLogicTransactionAppliedVaryingStableV2 ,
1840+ ) -> Result < Self , Self :: Error > {
18351841 use mina_p2p_messages:: v2:: MinaTransactionLogicTransactionAppliedVaryingStableV2 :: * ;
18361842 use mina_p2p_messages:: v2:: MinaTransactionLogicTransactionAppliedCommandAppliedStableV2 :: * ;
18371843 use mina_p2p_messages:: v2:: MinaTransactionLogicTransactionAppliedSignedCommandAppliedBodyStableV2 :: * ;
1838- // use mina_p2p_messages::v2::TransactionSnarkPendingCoinbaseStackStateInitStackStableV1::{Base, Merge};
1839- use mina_p2p_messages:: v2:: MinaStateSnarkedLedgerStatePendingCoinbaseStackStateInitStackStableV1 :: { Base , Merge } ;
1840- use crate :: scan_state:: scan_state:: transaction_snark:: InitStack ;
18411844 use transaction_applied:: signed_command_applied;
18421845
1843- match value {
1846+ let result = match value {
18441847 Command ( cmd) => match cmd {
18451848 SignedCommand ( cmd) => transaction_applied:: Varying :: Command (
18461849 transaction_applied:: CommandApplied :: SignedCommand ( Box :: new (
18471850 transaction_applied:: SignedCommandApplied {
18481851 common : transaction_applied:: signed_command_applied:: Common {
18491852 user_command : WithStatus {
1850- data : ( & cmd. common . user_command . data ) . into ( ) ,
1853+ data : ( & cmd. common . user_command . data ) . try_into ( ) ? ,
18511854 status : ( & cmd. common . user_command . status ) . into ( ) ,
18521855 } ,
18531856 } ,
@@ -1857,15 +1860,16 @@ impl From<&MinaTransactionLogicTransactionAppliedVaryingStableV2> for transactio
18571860 new_accounts : new_accounts
18581861 . iter ( )
18591862 . cloned ( )
1860- . map ( Into :: into )
1861- . collect ( ) ,
1863+ . map ( TryInto :: try_into )
1864+ . collect :: < Result < _ , _ > > ( ) ? ,
18621865 }
18631866 }
18641867 StakeDelegation { previous_delegate } => {
18651868 signed_command_applied:: Body :: StakeDelegation {
1866- previous_delegate : previous_delegate
1867- . as_ref ( )
1868- . map ( |d| d. into ( ) ) ,
1869+ previous_delegate : match previous_delegate. as_ref ( ) {
1870+ Some ( prev) => Some ( prev. try_into ( ) ?) ,
1871+ None => None ,
1872+ } ,
18691873 }
18701874 }
18711875 Failed => signed_command_applied:: Body :: Failed ,
@@ -1880,104 +1884,89 @@ impl From<&MinaTransactionLogicTransactionAppliedVaryingStableV2> for transactio
18801884 . accounts
18811885 . iter ( )
18821886 . map ( |( id, account_opt) | {
1883- let id: AccountId = id. into ( ) ;
1884- let account: Option < Account > = account_opt. as_ref ( ) . map ( Into :: into) ;
1887+ let id: AccountId = id. try_into ( ) ?;
1888+ let account: Option < Account > = match account_opt. as_ref ( ) {
1889+ Some ( account) => Some ( account. try_into ( ) ?) ,
1890+ None => None ,
1891+ } ;
18851892 let account = account. map ( Box :: new) ;
18861893
1887- Ok ( ( id, account) )
1888- } )
1889- . collect :: < Result < _ , _ > > ( ) ?,
1890- command : WithStatus {
1891- data : ( & cmd. command . data ) . try_into ( ) ?,
1892- status : ( & cmd. command . status ) . into ( ) ,
1893- } ,
1894- new_accounts : cmd. new_accounts . iter ( ) . map ( TryInto :: try_into) . collect :: < Result < _ , _ > > ( ) ?,
1895- } ,
1896- ) ) ,
1897- ) ,
1898- } ,
1899- FeeTransfer ( ft) => transaction_applied:: Varying :: FeeTransfer (
1900- transaction_applied:: FeeTransferApplied {
1901- fee_transfer : WithStatus {
1902- data : ( & ft. fee_transfer . data ) . try_into ( ) ?,
1903- status : ( & ft. fee_transfer . status ) . into ( ) ,
1904- } ,
1905- new_accounts : ft. new_accounts . iter ( ) . map ( TryInto :: try_into) . collect :: < Result < _ , _ > > ( ) ?,
1906- burned_tokens : ft. burned_tokens . clone ( ) . into ( ) ,
1907- } ,
1908- ) ,
1909- Coinbase ( cb) => transaction_applied:: Varying :: Coinbase ( transaction_applied:: CoinbaseApplied {
1910- coinbase : WithStatus {
1911- data : crate :: scan_state:: transaction_logic:: Coinbase {
1912- receiver : ( & cb. coinbase . data . receiver ) . try_into ( ) ?,
1913- amount : cb. coinbase . data . amount . clone ( ) . into ( ) ,
1914- fee_transfer : match cb. coinbase . data . fee_transfer . as_ref ( ) {
1915- Some ( ft) => Some ( crate :: scan_state:: transaction_logic:: CoinbaseFeeTransfer {
1916- receiver_pk : ( & ft. receiver_pk ) . try_into ( ) ?,
1917- fee : Fee :: from_u64 ( ft. fee . as_u64 ( ) ) ,
1918- } ) ,
1919- None => None ,
1920- }
1921- } ,
1922- status : ( & cb. coinbase . status ) . into ( ) ,
1923- } ,
1924- new_accounts : cb. new_accounts . iter ( ) . map ( TryInto :: try_into) . collect :: < Result < _ , _ > > ( ) ?,
1925- burned_tokens : cb. burned_tokens . clone ( ) . into ( ) ,
1926- } ) ,
1927- } ,
1928- ( id, account)
1894+ Ok ( ( id, account) )
19291895 } )
1930- . collect ( ) ,
1896+ . collect :: < Result < _ , _ > > ( ) ? ,
19311897 command : WithStatus {
1932- data : ( & cmd. command . data ) . into ( ) ,
1898+ data : ( & cmd. command . data ) . try_into ( ) ? ,
19331899 status : ( & cmd. command . status ) . into ( ) ,
19341900 } ,
1935- new_accounts: cmd. new_accounts . iter ( ) . map ( Into :: into) . collect ( ) ,
1901+ new_accounts : cmd
1902+ . new_accounts
1903+ . iter ( )
1904+ . map ( TryInto :: try_into)
1905+ . collect :: < Result < _ , _ > > ( ) ?,
19361906 } ,
19371907 ) ) ,
19381908 ) ,
19391909 } ,
1940- FeeTransfer ( ft) => transaction_applied :: Varying :: FeeTransfer (
1941- transaction_applied:: FeeTransferApplied {
1910+ FeeTransfer ( ft) => {
1911+ transaction_applied:: Varying :: FeeTransfer ( transaction_applied :: FeeTransferApplied {
19421912 fee_transfer : WithStatus {
1943- data : ( & ft. fee_transfer . data ) . into ( ) ,
1913+ data : ( & ft. fee_transfer . data ) . try_into ( ) ? ,
19441914 status : ( & ft. fee_transfer . status ) . into ( ) ,
19451915 } ,
1946- new_accounts : ft. new_accounts . iter ( ) . map ( Into :: into) . collect ( ) ,
1916+ new_accounts : ft
1917+ . new_accounts
1918+ . iter ( )
1919+ . map ( TryInto :: try_into)
1920+ . collect :: < Result < _ , _ > > ( ) ?,
19471921 burned_tokens : ft. burned_tokens . clone ( ) . into ( ) ,
1948- } ,
1949- ) ,
1950- Coinbase ( cb) => transaction_applied:: Varying :: Coinbase ( transaction_applied:: CoinbaseApplied {
1951- coinbase : WithStatus {
1952- data : crate :: scan_state:: transaction_logic:: Coinbase {
1953- receiver : ( & cb. coinbase . data . receiver ) . into ( ) ,
1954- amount : cb. coinbase . data . amount . clone ( ) . into ( ) ,
1955- fee_transfer : cb. coinbase . data . fee_transfer . as_ref ( ) . map ( |ft| {
1956- crate :: scan_state:: transaction_logic:: CoinbaseFeeTransfer {
1957- receiver_pk : ( & ft. receiver_pk ) . into ( ) ,
1958- fee : Fee :: from_u64 ( ft. fee . as_u64 ( ) ) ,
1959- }
1960- } ) ,
1922+ } )
1923+ }
1924+ Coinbase ( cb) => {
1925+ transaction_applied:: Varying :: Coinbase ( transaction_applied:: CoinbaseApplied {
1926+ coinbase : WithStatus {
1927+ data : crate :: scan_state:: transaction_logic:: Coinbase {
1928+ receiver : ( & cb. coinbase . data . receiver ) . try_into ( ) ?,
1929+ amount : cb. coinbase . data . amount . clone ( ) . into ( ) ,
1930+ fee_transfer : match cb. coinbase . data . fee_transfer . as_ref ( ) {
1931+ Some ( ft) => Some (
1932+ crate :: scan_state:: transaction_logic:: CoinbaseFeeTransfer {
1933+ receiver_pk : ( & ft. receiver_pk ) . try_into ( ) ?,
1934+ fee : Fee :: from_u64 ( ft. fee . as_u64 ( ) ) ,
1935+ } ,
1936+ ) ,
1937+ None => None ,
1938+ } ,
1939+ } ,
1940+ status : ( & cb. coinbase . status ) . into ( ) ,
19611941 } ,
1962- status : ( & cb. coinbase . status ) . into ( ) ,
1963- } ,
1964- new_accounts : cb. new_accounts . iter ( ) . map ( Into :: into) . collect ( ) ,
1965- burned_tokens : cb. burned_tokens . clone ( ) . into ( ) ,
1966- } )
1967- }
1942+ new_accounts : cb
1943+ . new_accounts
1944+ . iter ( )
1945+ . map ( TryInto :: try_into)
1946+ . collect :: < Result < _ , _ > > ( ) ?,
1947+ burned_tokens : cb. burned_tokens . clone ( ) . into ( ) ,
1948+ } )
1949+ }
1950+ } ;
1951+
1952+ Ok ( result)
19681953 }
19691954}
19701955
1971- impl From <& TransactionSnarkScanStateTransactionWithWitnessStableV2 > for TransactionWithWitness {
1972- fn from( value : & TransactionSnarkScanStateTransactionWithWitnessStableV2 ) -> Self {
1956+ impl TryFrom < & TransactionSnarkScanStateTransactionWithWitnessStableV2 > for TransactionWithWitness {
1957+ type Error = InvalidBigInt ;
1958+
1959+ fn try_from (
1960+ value : & TransactionSnarkScanStateTransactionWithWitnessStableV2 ,
1961+ ) -> Result < Self , Self :: Error > {
19731962 // use mina_p2p_messages::v2::TransactionSnarkPendingCoinbaseStackStateInitStackStableV1::{Base, Merge};
19741963 use mina_p2p_messages:: v2:: MinaStateSnarkedLedgerStatePendingCoinbaseStackStateInitStackStableV1 :: { Base , Merge } ;
19751964 use crate :: scan_state:: scan_state:: transaction_snark:: InitStack ;
1976-
1977- Self {
1965+
1966+ Ok ( Self {
19781967 transaction_with_info : TransactionApplied {
1979- previous_hash : value. transaction_with_info . previous_hash . to_field ( ) ,
1980- varying : ( & value. transaction_with_info . varying ) . into ( ) ,
1968+ previous_hash : value. transaction_with_info . previous_hash . to_field ( ) ? ,
1969+ varying : ( & value. transaction_with_info . varying ) . try_into ( ) ? ,
19811970 } ,
19821971 state_hash : {
19831972 let ( state, body) = & value. state_hash ;
@@ -1997,7 +1986,7 @@ impl From<&TransactionSnarkScanStateTransactionWithWitnessStableV2> for Transact
19971986 first_pass_ledger_witness : ( & value. first_pass_ledger_witness ) . try_into ( ) ?,
19981987 second_pass_ledger_witness : ( & value. second_pass_ledger_witness ) . try_into ( ) ?,
19991988 block_global_slot : Slot :: from_u32 ( value. block_global_slot . as_u32 ( ) ) ,
2000- }
1989+ } )
20011990 }
20021991}
20031992
0 commit comments