Skip to content

Commit a447f3f

Browse files
smaller changes
1 parent f1626ef commit a447f3f

File tree

1 file changed

+17
-6
lines changed
  • target_chains/ethereum/sdk/stylus/contracts/src/utils

1 file changed

+17
-6
lines changed

target_chains/ethereum/sdk/stylus/contracts/src/utils/mod.rs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
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::{
53
alloy_primitives::Address,
6-
call::{call, delegate_call},
4+
call::{call, delegate_call, Call},
75
storage::TopLevelStorage,
8-
},
6+
}
97
};
108

119
/// The revert message when failing to decode the data
@@ -45,10 +43,23 @@ pub fn delegate_call_helper<C: SolCall>(
4543
pub fn call_helper<C: SolCall>(
4644
storage: &mut impl TopLevelStorage,
4745
address: Address,
48-
args: <C::Parameters<'_> as SolType>::RustType,
46+
args: <C::Parameters<'_> as SolType>::RustType
4947
) -> Result<C::Return, Vec<u8>> {
5048
let calldata = C::new(args).abi_encode();
5149
let res = call(storage, address, &calldata).map_err(map_call_error)?;
5250
C::abi_decode_returns(&res, false /* validate */)
5351
.map_err(|_| CALL_RETDATA_DECODING_ERROR_MESSAGE.to_vec())
5452
}
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

Comments
 (0)