1
+ use alloy:: primitives:: utils:: parse_units;
2
+ use alloy:: sol_types:: SolCall ;
1
3
use eyre:: Result ;
2
4
3
5
mod signal_slot;
4
6
use signal_slot:: get_signal_slot;
5
7
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
+ } ;
8
11
9
- use alloy:: hex:: decode;
12
+ use alloy:: hex:: { self , decode} ;
10
13
use alloy:: primitives:: { Address , Bytes , FixedBytes , U256 } ;
11
14
use std:: fs;
12
15
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
+
13
23
fn expand_vector ( vec : Vec < Bytes > , name : & str ) -> String {
14
24
let mut expanded = String :: new ( ) ;
15
25
for ( i, item) in vec. iter ( ) . enumerate ( ) {
@@ -20,7 +30,7 @@ fn expand_vector(vec: Vec<Bytes>, name: &str) -> String {
20
30
return expanded;
21
31
}
22
32
23
- fn create_deposit_call (
33
+ pub fn create_deposit_call (
24
34
proof : SignalProof ,
25
35
nonce : usize ,
26
36
signer : Address ,
@@ -66,14 +76,33 @@ fn deposit_specification() -> Vec<DepositSpecification> {
66
76
// This is an address on the destination chain, so it seems natural to use one generated there
67
77
// In this case, the CrossChainDepositExists.sol test case defines _randomAddress("recipient");
68
78
let recipient = "0x99A270Be1AA5E97633177041859aEEB9a0670fAa" ;
79
+
69
80
// 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
+
71
83
// 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
+
72
101
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 ,
77
106
] ;
78
107
79
108
let zero_canceler = Address :: ZERO ;
@@ -102,6 +131,7 @@ async fn main() -> Result<()> {
102
131
let deposits = deposit_specification ( ) ;
103
132
assert ! ( deposits. len( ) > 0 , "No deposits to prove" ) ;
104
133
let mut ids: Vec < FixedBytes < 32 > > = vec ! [ ] ;
134
+
105
135
// Perform all deposits
106
136
for ( _i, spec) in deposits. iter ( ) . enumerate ( ) {
107
137
let tx = eth_bridge
@@ -150,7 +180,7 @@ async fn main() -> Result<()> {
150
180
. as_str ( ) ;
151
181
}
152
182
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" ) ?;
154
184
let formatted = template
155
185
. replace (
156
186
"{signal_service_address}" ,
0 commit comments