mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 09:51:10 +00:00
contracts: Convert to framev2 macros (#8157)
* contracts: Convert to framev2 * Reduce the API surface of the crate * Remove unused import * Merge import block * Use pallet::metadata to reduce metadata diff * Remove the explicit "Null" from AccountCounter
This commit is contained in:
committed by
GitHub
parent
4f4a0c5b38
commit
b2f393945a
@@ -20,13 +20,11 @@
|
||||
//!
|
||||
//! Most likely you should use `define_env` macro.
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! convert_args {
|
||||
() => (vec![]);
|
||||
( $( $t:ty ),* ) => ( vec![ $( { use $crate::wasm::env_def::ConvertibleToWasm; <$t>::VALUE_TYPE }, )* ] );
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! gen_signature {
|
||||
( ( $( $params: ty ),* ) ) => (
|
||||
{
|
||||
@@ -43,7 +41,6 @@ macro_rules! gen_signature {
|
||||
);
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! gen_signature_dispatch {
|
||||
(
|
||||
$needle_name:ident,
|
||||
@@ -102,7 +99,6 @@ where
|
||||
f
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! unmarshall_then_body_then_marshall {
|
||||
( $args_iter:ident, $ctx:ident, ( $( $names:ident : $params:ty ),* ) -> $returns:ty => $body:tt ) => ({
|
||||
let body = $crate::wasm::env_def::macros::constrain_closure::<
|
||||
@@ -128,7 +124,6 @@ macro_rules! unmarshall_then_body_then_marshall {
|
||||
})
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! define_func {
|
||||
( < E: $seal_ty:tt > $name:ident ( $ctx: ident $(, $names:ident : $params:ty)*) $(-> $returns:ty)* => $body:tt ) => {
|
||||
fn $name< E: $seal_ty >(
|
||||
@@ -152,7 +147,6 @@ macro_rules! define_func {
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! register_func {
|
||||
( $reg_cb:ident, < E: $seal_ty:tt > ; ) => {};
|
||||
|
||||
@@ -215,9 +209,9 @@ mod tests {
|
||||
use sp_runtime::traits::Zero;
|
||||
use sp_sandbox::{ReturnValue, Value};
|
||||
use crate::{
|
||||
Weight,
|
||||
wasm::{Runtime, runtime::TrapReason, tests::MockExt},
|
||||
exec::Ext,
|
||||
gas::Gas,
|
||||
};
|
||||
|
||||
struct TestRuntime {
|
||||
@@ -282,7 +276,7 @@ mod tests {
|
||||
#[test]
|
||||
fn macro_define_func() {
|
||||
define_func!( <E: Ext> seal_gas (_ctx, amount: u32) => {
|
||||
let amount = Gas::from(amount);
|
||||
let amount = Weight::from(amount);
|
||||
if !amount.is_zero() {
|
||||
Ok(())
|
||||
} else {
|
||||
@@ -334,7 +328,7 @@ mod tests {
|
||||
|
||||
define_env!(Env, <E: Ext>,
|
||||
seal_gas( _ctx, amount: u32 ) => {
|
||||
let amount = Gas::from(amount);
|
||||
let amount = Weight::from(amount);
|
||||
if !amount.is_zero() {
|
||||
Ok(())
|
||||
} else {
|
||||
|
||||
@@ -22,7 +22,7 @@ use sp_sandbox::Value;
|
||||
use parity_wasm::elements::{FunctionType, ValueType};
|
||||
|
||||
#[macro_use]
|
||||
pub(crate) mod macros;
|
||||
pub mod macros;
|
||||
|
||||
pub trait ConvertibleToWasm: Sized {
|
||||
const VALUE_TYPE: ValueType;
|
||||
@@ -67,13 +67,13 @@ impl ConvertibleToWasm for u64 {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) type HostFunc<E> =
|
||||
pub type HostFunc<E> =
|
||||
fn(
|
||||
&mut Runtime<E>,
|
||||
&[sp_sandbox::Value]
|
||||
) -> Result<sp_sandbox::ReturnValue, sp_sandbox::HostError>;
|
||||
|
||||
pub(crate) trait FunctionImplProvider<E: Ext> {
|
||||
pub trait FunctionImplProvider<E: Ext> {
|
||||
fn impls<F: FnMut(&[u8], HostFunc<E>)>(f: &mut F);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user