mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 21:37:56 +00:00
Contracts: Translate .wat fixtures to rust (#2654)
- Translate all pallet-contracts fixtures from `wat` to Rust files. - Fix read_sandbox_memory_as to not use MaxEncodedLen as this could break if used with types with a non-fixed encoded len. --------- Co-authored-by: alvicsam <alvicsam@gmail.com> Co-authored-by: Alexander Samusev <41779041+alvicsam@users.noreply.github.com> Co-authored-by: Alexander Theißen <alex.theissen@me.com> Co-authored-by: command-bot <>
This commit is contained in:
@@ -38,6 +38,7 @@ macro_rules! hash_fn {
|
||||
|
||||
// TODO remove cfg once used by all targets
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
#[inline(always)]
|
||||
fn extract_from_slice(output: &mut &mut [u8], new_len: usize) {
|
||||
debug_assert!(new_len <= output.len());
|
||||
let tmp = core::mem::take(output);
|
||||
@@ -45,7 +46,8 @@ fn extract_from_slice(output: &mut &mut [u8], new_len: usize) {
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
fn ptr_len_or_sentinel(data: &mut Option<&mut [u8]>) -> (*mut u8, u32) {
|
||||
#[inline(always)]
|
||||
fn ptr_len_or_sentinel(data: &mut Option<&mut &mut [u8]>) -> (*mut u8, u32) {
|
||||
match data {
|
||||
Some(ref mut data) => (data.as_mut_ptr(), data.len() as _),
|
||||
None => (crate::SENTINEL as _, 0),
|
||||
@@ -53,6 +55,7 @@ fn ptr_len_or_sentinel(data: &mut Option<&mut [u8]>) -> (*mut u8, u32) {
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
#[inline(always)]
|
||||
fn ptr_or_sentinel(data: &Option<&[u8]>) -> *const u8 {
|
||||
match data {
|
||||
Some(ref data) => data.as_ptr(),
|
||||
@@ -132,7 +135,7 @@ pub trait HostFn {
|
||||
gas: u64,
|
||||
value: &[u8],
|
||||
input_data: &[u8],
|
||||
output: Option<&mut [u8]>,
|
||||
output: Option<&mut &mut [u8]>,
|
||||
) -> Result;
|
||||
|
||||
/// Make a call to another contract.
|
||||
@@ -145,7 +148,7 @@ pub trait HostFn {
|
||||
gas: u64,
|
||||
value: &[u8],
|
||||
input_data: &[u8],
|
||||
output: Option<&mut [u8]>,
|
||||
output: Option<&mut &mut [u8]>,
|
||||
) -> Result;
|
||||
|
||||
/// Call (possibly transferring some amount of funds) into the specified account.
|
||||
@@ -186,7 +189,7 @@ pub trait HostFn {
|
||||
deposit: Option<&[u8]>,
|
||||
value: &[u8],
|
||||
input_data: &[u8],
|
||||
output: Option<&mut [u8]>,
|
||||
output: Option<&mut &mut [u8]>,
|
||||
) -> Result;
|
||||
|
||||
/// Call into the chain extension provided by the chain if any.
|
||||
@@ -211,7 +214,7 @@ pub trait HostFn {
|
||||
/// # Return
|
||||
///
|
||||
/// The chain extension returned value, if executed successfully.
|
||||
fn call_chain_extension(func_id: u32, input: &[u8], output: Option<&mut [u8]>) -> u32;
|
||||
fn call_chain_extension(func_id: u32, input: &[u8], output: Option<&mut &mut [u8]>) -> u32;
|
||||
|
||||
/// Call some dispatchable of the runtime.
|
||||
///
|
||||
@@ -374,7 +377,7 @@ pub trait HostFn {
|
||||
flags: CallFlags,
|
||||
code_hash: &[u8],
|
||||
input_data: &[u8],
|
||||
output: Option<&mut [u8]>,
|
||||
output: Option<&mut &mut [u8]>,
|
||||
) -> Result;
|
||||
|
||||
/// Deposit a contract event with the data buffer and optional list of topics. There is a limit
|
||||
@@ -485,8 +488,8 @@ pub trait HostFn {
|
||||
gas: u64,
|
||||
value: &[u8],
|
||||
input: &[u8],
|
||||
address: Option<&mut [u8]>,
|
||||
output: Option<&mut [u8]>,
|
||||
address: Option<&mut &mut [u8]>,
|
||||
output: Option<&mut &mut [u8]>,
|
||||
salt: &[u8],
|
||||
) -> Result;
|
||||
|
||||
@@ -534,8 +537,8 @@ pub trait HostFn {
|
||||
deposit: Option<&[u8]>,
|
||||
value: &[u8],
|
||||
input: &[u8],
|
||||
address: Option<&mut [u8]>,
|
||||
output: Option<&mut [u8]>,
|
||||
address: Option<&mut &mut [u8]>,
|
||||
output: Option<&mut &mut [u8]>,
|
||||
salt: &[u8],
|
||||
) -> Result;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user