|
1 | 1 | use { |
2 | | - alloc::vec::Vec, |
3 | | - alloy_sol_types::{SolCall, SolType}, |
4 | | - stylus_sdk::{ |
| 2 | + alloc::vec::Vec, alloy_primitives::U256, alloy_sol_types::{SolCall, SolType}, stylus_sdk::{ |
5 | 3 | alloy_primitives::Address, |
6 | | - call::{call, delegate_call}, |
| 4 | + call::{call, delegate_call, Call}, |
7 | 5 | storage::TopLevelStorage, |
8 | | - }, |
| 6 | + } |
9 | 7 | }; |
10 | 8 |
|
11 | 9 | /// The revert message when failing to decode the data |
@@ -45,10 +43,23 @@ pub fn delegate_call_helper<C: SolCall>( |
45 | 43 | pub fn call_helper<C: SolCall>( |
46 | 44 | storage: &mut impl TopLevelStorage, |
47 | 45 | address: Address, |
48 | | - args: <C::Parameters<'_> as SolType>::RustType, |
| 46 | + args: <C::Parameters<'_> as SolType>::RustType |
49 | 47 | ) -> Result<C::Return, Vec<u8>> { |
50 | 48 | let calldata = C::new(args).abi_encode(); |
51 | 49 | let res = call(storage, address, &calldata).map_err(map_call_error)?; |
52 | 50 | C::abi_decode_returns(&res, false /* validate */) |
53 | 51 | .map_err(|_| CALL_RETDATA_DECODING_ERROR_MESSAGE.to_vec()) |
54 | 52 | } |
| 53 | + |
| 54 | + |
| 55 | +pub fn call_helper_value<C: SolCall>( |
| 56 | + storage: &mut impl TopLevelStorage, |
| 57 | + address: Address, |
| 58 | + args: <C::Parameters<'_> as SolType>::RustType, |
| 59 | + value:U256 |
| 60 | +) -> Result<C::Return, Vec<u8>> { |
| 61 | + let calldata = C::new(args).abi_encode(); |
| 62 | + let res = call(Call::new_in(storage).value(value), address, &calldata).map_err(map_call_error)?; |
| 63 | + C::abi_decode_returns(&res, false /* validate */) |
| 64 | + .map_err(|_| CALL_RETDATA_DECODING_ERROR_MESSAGE.to_vec()) |
| 65 | +} |
0 commit comments