@@ -1805,7 +1805,7 @@ pub mod zkapp_command {
1805
1805
}
1806
1806
1807
1807
impl EpochLedger {
1808
- pub fn epoch_ledger ( & self , t : protocol_state:: EpochLedger < Fp > ) -> Result < ( ) , String > {
1808
+ pub fn epoch_ledger ( & self , t : & protocol_state:: EpochLedger < Fp > ) -> Result < ( ) , String > {
1809
1809
self . hash . zcheck ( "epoch_ledger_hash" . to_string ( ) , t. hash ) ?;
1810
1810
self . total_currency
1811
1811
. zcheck ( "epoch_ledger_total_currency" . to_string ( ) , t. total_currency )
@@ -1908,9 +1908,9 @@ pub mod zkapp_command {
1908
1908
pub fn epoch_data (
1909
1909
& self ,
1910
1910
label : & str ,
1911
- t : protocol_state:: EpochData < Fp > ,
1911
+ t : & protocol_state:: EpochData < Fp > ,
1912
1912
) -> Result < ( ) , String > {
1913
- self . ledger . epoch_ledger ( t. ledger ) ?;
1913
+ self . ledger . epoch_ledger ( & t. ledger ) ?;
1914
1914
// ignore seed
1915
1915
self . start_checkpoint . zcheck (
1916
1916
format ! ( "{}_{}" , label, "start_checkpoint" ) ,
@@ -1954,7 +1954,7 @@ pub mod zkapp_command {
1954
1954
1955
1955
impl ZkAppPreconditions {
1956
1956
/// zkapp check
1957
- pub fn zcheck ( & self , s : ProtocolStateView ) -> Result < ( ) , String > {
1957
+ pub fn zcheck ( & self , s : & ProtocolStateView ) -> Result < ( ) , String > {
1958
1958
self . snarked_ledger_hash
1959
1959
. zcheck ( "snarker_ledger_hash" . to_string ( ) , s. snarked_ledger_hash ) ?;
1960
1960
self . blockchain_length
@@ -1968,9 +1968,9 @@ pub mod zkapp_command {
1968
1968
s. global_slot_since_genesis ,
1969
1969
) ?;
1970
1970
self . staking_epoch_data
1971
- . epoch_data ( "staking_epoch_data" , s. staking_epoch_data ) ?;
1971
+ . epoch_data ( "staking_epoch_data" , & s. staking_epoch_data ) ?;
1972
1972
self . next_epoch_data
1973
- . epoch_data ( "next_epoch_data" , s. next_epoch_data )
1973
+ . epoch_data ( "next_epoch_data" , & s. next_epoch_data )
1974
1974
}
1975
1975
1976
1976
pub fn checked_zcheck ( & self , s : & ProtocolStateView , w : & mut Witness < Fp > ) -> Boolean {
@@ -2167,7 +2167,7 @@ pub mod zkapp_command {
2167
2167
2168
2168
impl Account {
2169
2169
/// zkapp check
2170
- pub fn zcheck < F > ( & self , new_account : bool , mut check : F , a : account:: Account )
2170
+ pub fn zcheck < F > ( & self , new_account : bool , mut check : F , a : & account:: Account )
2171
2171
where
2172
2172
F : FnMut ( TransactionFailure , bool ) ,
2173
2173
{
@@ -2179,9 +2179,12 @@ pub mod zkapp_command {
2179
2179
fn zchecks (
2180
2180
& self ,
2181
2181
new_account : bool ,
2182
- a : account:: Account ,
2182
+ a : & account:: Account ,
2183
2183
) -> Vec < ( TransactionFailure , Result < ( ) , String > ) > {
2184
- let zkapp = a. zkapp . unwrap_or_default ( ) ;
2184
+ let zkapp = match a. zkapp . as_ref ( ) {
2185
+ Some ( zkapp) => MyCow :: Borrow ( & * * zkapp) ,
2186
+ None => MyCow :: Own ( ZkAppAccount :: default ( ) ) ,
2187
+ } ;
2185
2188
let mut ret = vec ! [
2186
2189
(
2187
2190
TransactionFailure :: AccountBalancePreconditionUnsatisfied ,
@@ -2200,7 +2203,7 @@ pub mod zkapp_command {
2200
2203
TransactionFailure :: AccountDelegatePreconditionUnsatisfied ,
2201
2204
self . delegate. zcheck(
2202
2205
"delegate" . to_string( ) ,
2203
- a. delegate. unwrap_or_else( invalid_public_key) ,
2206
+ a. delegate. clone ( ) . unwrap_or_else( invalid_public_key) ,
2204
2207
) ,
2205
2208
) ,
2206
2209
(
@@ -5227,7 +5230,7 @@ pub mod protocol_state {
5227
5230
}
5228
5231
5229
5232
#[ must_use]
5230
- fn set_fee_excess ( & self , fee_excess : Signed < Amount > ) -> Self {
5233
+ pub fn set_fee_excess ( & self , fee_excess : Signed < Amount > ) -> Self {
5231
5234
let mut this = self . clone ( ) ;
5232
5235
this. fee_excess = fee_excess;
5233
5236
this
@@ -5244,7 +5247,7 @@ pub mod protocol_state {
5244
5247
this
5245
5248
}
5246
5249
5247
- fn block_global_slot ( & self ) -> Slot {
5250
+ pub fn block_global_slot ( & self ) -> Slot {
5248
5251
self . block_global_slot
5249
5252
}
5250
5253
}
@@ -5856,7 +5859,7 @@ where
5856
5859
. is_ok ( ) ,
5857
5860
) ,
5858
5861
Eff :: CheckProtocolStatePrecondition ( pred, global_state) => {
5859
- PerformResult :: Bool ( pred. zcheck ( global_state. protocol_state ) . is_ok ( ) )
5862
+ PerformResult :: Bool ( pred. zcheck ( & global_state. protocol_state ) . is_ok ( ) )
5860
5863
}
5861
5864
Eff :: CheckAccountPrecondition ( account_update, account, new_account, local_state) => {
5862
5865
let local_state = {
@@ -5865,7 +5868,7 @@ where
5865
5868
let check = |failure, b| {
5866
5869
_local_state = _local_state. add_check ( failure, b) ;
5867
5870
} ;
5868
- precondition_account. zcheck ( new_account, check, account) ;
5871
+ precondition_account. zcheck ( new_account, check, & account) ;
5869
5872
_local_state
5870
5873
} ;
5871
5874
PerformResult :: LocalState ( Box :: new ( local_state) )
@@ -7895,7 +7898,7 @@ pub fn validate_timing(
7895
7898
pub fn account_check_timing (
7896
7899
txn_global_slot : & Slot ,
7897
7900
account : & Account ,
7898
- ) -> ( TimingValidation , Timing ) {
7901
+ ) -> ( TimingValidation < bool > , Timing ) {
7899
7902
let ( invalid_timing, timing, _) =
7900
7903
validate_timing_with_min_balance_impl ( account, Amount :: from_u64 ( 0 ) , txn_global_slot) ;
7901
7904
// TODO: In OCaml the returned Timing is actually converted to None/Some(fields of Timing structure)
@@ -7958,9 +7961,9 @@ pub fn timing_error_to_user_command_status(
7958
7961
}
7959
7962
}
7960
7963
7961
- pub enum TimingValidation {
7962
- InsufficientBalance ( bool ) ,
7963
- InvalidTiming ( bool ) ,
7964
+ pub enum TimingValidation < B > {
7965
+ InsufficientBalance ( B ) ,
7966
+ InvalidTiming ( B ) ,
7964
7967
}
7965
7968
7966
7969
#[ derive( Debug ) ]
@@ -7970,7 +7973,7 @@ fn validate_timing_with_min_balance_impl(
7970
7973
account : & Account ,
7971
7974
txn_amount : Amount ,
7972
7975
txn_global_slot : & Slot ,
7973
- ) -> ( TimingValidation , Timing , MinBalance ) {
7976
+ ) -> ( TimingValidation < bool > , Timing , MinBalance ) {
7974
7977
use crate :: Timing :: * ;
7975
7978
use TimingValidation :: * ;
7976
7979
0 commit comments