1+ use alloy:: primitives:: utils:: parse_units;
2+ use alloy:: sol_types:: SolCall ;
13use eyre:: Result ;
24
35mod signal_slot;
46use signal_slot:: get_signal_slot;
57
6- mod utils;
7- use utils:: { deploy_eth_bridge, deploy_signal_service, get_proofs, get_provider, SignalProof } ;
8+ use minimal_rollup:: {
9+ deploy_eth_bridge, deploy_signal_service, get_proofs, get_provider, SignalProof ,
10+ } ;
811
9- use alloy:: hex:: decode;
12+ use alloy:: hex:: { self , decode} ;
1013use alloy:: primitives:: { Address , Bytes , FixedBytes , U256 } ;
1114use std:: fs;
1215
16+ use alloy:: sol;
17+
18+ sol ! {
19+ function somePayableFunction( uint256 someArg) external payable returns ( uint256) ;
20+ function someNonpayableFunction( uint256 someArg) external returns ( uint256) ;
21+ }
22+
1323fn expand_vector ( vec : Vec < Bytes > , name : & str ) -> String {
1424 let mut expanded = String :: new ( ) ;
1525 for ( i, item) in vec. iter ( ) . enumerate ( ) {
@@ -20,7 +30,7 @@ fn expand_vector(vec: Vec<Bytes>, name: &str) -> String {
2030 return expanded;
2131}
2232
23- fn create_deposit_call (
33+ pub fn create_deposit_call (
2434 proof : SignalProof ,
2535 nonce : usize ,
2636 signer : Address ,
@@ -66,14 +76,33 @@ fn deposit_specification() -> Vec<DepositSpecification> {
6676 // This is an address on the destination chain, so it seems natural to use one generated there
6777 // In this case, the CrossChainDepositExists.sol test case defines _randomAddress("recipient");
6878 let recipient = "0x99A270Be1AA5E97633177041859aEEB9a0670fAa" ;
79+
6980 // Use both zero and non-zero amounts (in this case 4 ether)
70- let amounts = vec ! [ 0_u128 , 4000000000000000000_u128 ] ;
81+ let amounts: Vec < U256 > = vec ! [ U256 :: ZERO , parse_units( "4" , "ether" ) . unwrap( ) . into( ) ] ;
82+
7183 // Use different calldata to try different functions and inputs
84+ let valid_payable_function_call = somePayableFunctionCall {
85+ someArg : U256 :: from ( 1234 ) ,
86+ }
87+ . abi_encode ( ) ;
88+ let invalid_payable_function_call = somePayableFunctionCall {
89+ someArg : U256 :: from ( 1235 ) ,
90+ }
91+ . abi_encode ( ) ;
92+ let valid_nonpayable_function_call = someNonpayableFunctionCall {
93+ someArg : U256 :: from ( 1234 ) ,
94+ }
95+ . abi_encode ( ) ;
96+
97+ let valid_payable_encoded = hex:: encode ( valid_payable_function_call) ;
98+ let invalid_payable_encoded = hex:: encode ( invalid_payable_function_call) ;
99+ let valid_nonpayable_encoded = hex:: encode ( valid_nonpayable_function_call) ;
100+
72101 let calldata = vec ! [
73- "" , // empty
74- "9b28f6fb00000000000000000000000000000000000000000000000000000000000004d2" , // (valid) call to somePayableFunction(1234)
75- "9b28f6fb00000000000000000000000000000000000000000000000000000000000004d3" , // (invalid) call to somePayableFunction(1235)
76- "5932a71200000000000000000000000000000000000000000000000000000000000004d2" , // (valid) call to `someNonPayableFunction(1234)`
102+ "" ,
103+ & valid_payable_encoded ,
104+ & invalid_payable_encoded ,
105+ & valid_nonpayable_encoded ,
77106 ] ;
78107
79108 let zero_canceler = Address :: ZERO ;
@@ -102,6 +131,7 @@ async fn main() -> Result<()> {
102131 let deposits = deposit_specification ( ) ;
103132 assert ! ( deposits. len( ) > 0 , "No deposits to prove" ) ;
104133 let mut ids: Vec < FixedBytes < 32 > > = vec ! [ ] ;
134+
105135 // Perform all deposits
106136 for ( _i, spec) in deposits. iter ( ) . enumerate ( ) {
107137 let tx = eth_bridge
@@ -150,7 +180,7 @@ async fn main() -> Result<()> {
150180 . as_str ( ) ;
151181 }
152182
153- let template = fs:: read_to_string ( "offchain/sample_deposit_proof.tmpl" ) ?;
183+ let template = fs:: read_to_string ( "offchain/tmpl/ sample_deposit_proof.tmpl" ) ?;
154184 let formatted = template
155185 . replace (
156186 "{signal_service_address}" ,
0 commit comments