mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 13:27:57 +00:00
Enrich metadata with type information (#8615)
* Cargo.lock after merge * Restore scale-info feature * Fully qualify TypeInfo derive * Skip PendingSwap T * Add missing skip_type_params attr * metadata docs features * Reduce pallet event attribute to struct * Cargo.lock * Update frame/balances/src/tests_composite.rs Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> * Line widths check * Cargo.lock * Add scale-info/std * Update frame/system/src/lib.rs Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> * Use `skip_type_params` to remove `TypeInfo` requirements on checks * Revert "Remove unused Call metadata stuff" This reverts commit 41311f85 * Skip BalanceSwapAction type parameter * Remove unused event metadata macro * Update frame-metadata * Update primitives/npos-elections/compact/src/codec.rs Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> * Manual TypeInfo for Header * Remove TypeInfo requirement for consts in BoundedVec etc. * Another TypeInfo bound removed * review: fix indentation * TypeInfo impls for Identity types * Add some todos to add custom TypeInfo impls * Update frame/support/procedural/src/pallet/expand/pallet_struct.rs Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> * Add some todos to add custom TypeInfo impls * Add a test for manual Data TypeInfo impl * Add custom TypeInfo impl for Vote * Era custom TypeInfo crimes * Revert finality-grandpa version to 0.14.z * review: renamed module to pallet_constants_metadata * New line at end of file * Add missing scale-info/std * Update frame/support/src/storage/types/mod.rs Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> * Remove StorageEntryType::Map unused flag * Add missing scale-info dependency after merge * SignedExtension::AdditionalSigned metadata * Update frame-metadata, use abbreviated docs and args fields * Update frame/example/Cargo.toml Co-authored-by: Keith Yeung <kungfukeith11@gmail.com> * Add scale_info/std and remove unused scale-info dependency * Remove scale-info dependency * Remove treasury pallet::metadata * Remove redundant Event test * Add back scale-info as dev dependency * fix error metadata when no error defined in decl_module * Add Module3 to tests * Fix metadata test * Add docs feature to frame-support test * WIP fixing pallet metadata test * Remove redundant FunctionMetadata, FunctionArgumentMetadata as per https://github.com/paritytech/frame-metadata/pull/20 * Use main branch of frame-metadata * Use patch of scale-info for latest changes * Use latest patched scale-info * Manual TypeInfo for DigestItem * Manual TypeInfo for DigestItem * Update scale-info * Skip __Ignore variants for Error, depends on https://github.com/paritytech/scale-info/pull/117 * Named fields for FRAME v2 pallet Call variants * Named fields for FRAME v1 pallet Call variants * Add missing scale-info dependency * WIP expand benchmark call variant * fix benchmark with new function create a new function for each variant of a pallet call. This function is called by benchmarking macro in order not to break call creation with unnamed argument * fix tests * more fix * Fix staking tests * Fix offchain workers calls * Cherry pick rustfmt.toml from master * cargo +nightly-2021-06-22 fmt --all * Update to new call variant structs * More call variant struct updates * Remove unused import * More call variant structs * More call variant structs * Even more call variant structs * Mooar variant structs * Evermore variant structs * Call variant structs ad infinitum * Fmt * More call variants * Last call variant * Call variants all done? * Fix SS58Prefix type * Potential workaround for BitFlags<IdentityFields> TypeInfo * Enable docs capturing for Call, Event, and Error types * Fix IdentityFields TypeInfo * Remove metadata-docs feature * Add capture_docs = true for legacy Call, Event and Error types * Fmt * Fix metadata test type * Update benchmarks with call struct variants * Fmt * More test fixes * Fmt * Fix benches * Use latest capture_docs attr * Latest scale_info * Fmt * review: change &Vec to &[] * Remove pallet metadata attr * review: remove commented out test code * review: skip_type_params trailing comma suggestion * Update to scale-info 0.10.0 * Update construct_runtime ui tests, different because of metadata TypeInfo impls * Add some TypeInfo derives for UI tests * Update storage ensure span ui stderrs * Update call argument bound ui tests Possibly changed because change from tuple to struct variants? * Add scale-info dev dependency * Update to latest finality-grandpa release * review: missing newline * review: missing scale-info/std * review: remove duplicate scale-info/std * review: remove fully qualified TypeInfo * review: add missing scale-info/std * review: remove unnecessary imports. * Fmt * Use crates.io RC version of frame-metadata * Remove scale-info/std because it is a dev dependency * Add missing scale_info dev-dependency for test * Delete empty metadata folder * Fix sp_std import * review: improve manual UncheckedExtrinsic TypeInfo impl * review: use full scale-info for dev-dependency * Remove DefaultByteGetter impl * review: derive TypeInfo for generic header * Fmt * Update primitives/runtime/src/generic/unchecked_extrinsic.rs Co-authored-by: Keith Yeung <kungfukeith11@gmail.com> * Update primitives/runtime/src/generic/unchecked_extrinsic.rs Co-authored-by: Keith Yeung <kungfukeith11@gmail.com> * Update bin/node/executor/Cargo.toml Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update frame/identity/src/types.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Update frame/support/src/dispatch.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Remove redundant derive * Simplify scale-info dependency * Strip underscore prefix from call variant struct names * Another underscore field * More underscore fields * Another underscore field * Update to frame-metadata 14.0.0-rc.2 with combined StorageEntryType::Map * Fmt * Revert weights formatting * Fix up some tests * Fix up some tests for StorageEntryTypeMetadata * scale-info dev dependency * Fix test error * Add missing TypeInfo derives * Add back missing scale-info dependency * Add back missing scale-info dependency * Fix npos compact impls * Cargo.lock * Fmt * Fix errors * Fmt * Fix renamed raw_solution field * Fix error * Fmt * Fix some benchmarks * Fmt * Stray R * Fix * Add missing TypeInfos * ui test fix * Fix line widths * Revert "ui test fix" This reverts commit 2d15ec058a216e3f92d713f1174603a2bb1eac65. * Upgrade to scale-info 0.11.0 * Revert "Upgrade to scale-info 0.11.0" This reverts commit 047bb179085a0059c36cd20ab405f55cf0867e28. * Add Runtime type * Update to scale-info 0.12 * Update to scale-info 1.0 * Update frame-metadata to version 14.0.0 * Patch finality-grandpa until release available * Fix metadata tests * Fix metadata tests * Fmt * Remove patched finality-grandpa * Fix tests, use scale_info imports * Fix pallet tests * Add BlockNumber TypeInfo bound * ui test fix * Cargo.lock * Remove pallet metadata * Cargo.lock * Add missing scale-info dependency * Remove pallet event metadata * Fix error * Fix collective errors * Semicolol * Fmt * Remove another metadata attribute * Add new variant to custom digest TypeInfo * Fmt * Cargo.lock from master * Remove comma lol * Fix example call error * Fix example call error properly Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> Co-authored-by: Keith Yeung <kungfukeith11@gmail.com> Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
@@ -14,6 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
[dependencies]
|
||||
codec = { package = "parity-scale-codec", version = "2.2.0", default-features = false, features = ["max-encoded-len"] }
|
||||
scale-info = { version = "1.0", default-features = false, features = ["derive"] }
|
||||
frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" }
|
||||
frame-system = { version = "4.0.0-dev", default-features = false, path = "../system" }
|
||||
sp-io = { version = "4.0.0-dev", default-features = false, path = "../../primitives/io" }
|
||||
@@ -31,6 +32,7 @@ pallet-utility = { version = "4.0.0-dev", path = "../utility" }
|
||||
default = ["std"]
|
||||
std = [
|
||||
"codec/std",
|
||||
"scale-info/std",
|
||||
"sp-runtime/std",
|
||||
"frame-support/std",
|
||||
"frame-system/std",
|
||||
|
||||
@@ -83,7 +83,7 @@ benchmarks! {
|
||||
T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
|
||||
// ... and "real" is the traditional caller. This is not a typo.
|
||||
let real: T::AccountId = whitelisted_caller();
|
||||
let call: <T as Config>::Call = frame_system::Call::<T>::remark(vec![]).into();
|
||||
let call: <T as Config>::Call = frame_system::Call::<T>::remark { remark: vec![] }.into();
|
||||
}: _(RawOrigin::Signed(caller), real, Some(T::ProxyType::default()), Box::new(call))
|
||||
verify {
|
||||
assert_last_event::<T>(Event::ProxyExecuted(Ok(())).into())
|
||||
@@ -98,7 +98,7 @@ benchmarks! {
|
||||
T::Currency::make_free_balance_be(&delegate, BalanceOf::<T>::max_value());
|
||||
// ... and "real" is the traditional caller. This is not a typo.
|
||||
let real: T::AccountId = whitelisted_caller();
|
||||
let call: <T as Config>::Call = frame_system::Call::<T>::remark(vec![]).into();
|
||||
let call: <T as Config>::Call = frame_system::Call::<T>::remark { remark: vec![] }.into();
|
||||
Proxy::<T>::announce(
|
||||
RawOrigin::Signed(delegate.clone()).into(),
|
||||
real.clone(),
|
||||
@@ -118,7 +118,7 @@ benchmarks! {
|
||||
T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
|
||||
// ... and "real" is the traditional caller. This is not a typo.
|
||||
let real: T::AccountId = whitelisted_caller();
|
||||
let call: <T as Config>::Call = frame_system::Call::<T>::remark(vec![]).into();
|
||||
let call: <T as Config>::Call = frame_system::Call::<T>::remark { remark: vec![] }.into();
|
||||
Proxy::<T>::announce(
|
||||
RawOrigin::Signed(caller.clone()).into(),
|
||||
real.clone(),
|
||||
@@ -139,7 +139,7 @@ benchmarks! {
|
||||
T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
|
||||
// ... and "real" is the traditional caller. This is not a typo.
|
||||
let real: T::AccountId = whitelisted_caller();
|
||||
let call: <T as Config>::Call = frame_system::Call::<T>::remark(vec![]).into();
|
||||
let call: <T as Config>::Call = frame_system::Call::<T>::remark { remark: vec![] }.into();
|
||||
Proxy::<T>::announce(
|
||||
RawOrigin::Signed(caller.clone()).into(),
|
||||
real.clone(),
|
||||
@@ -161,7 +161,7 @@ benchmarks! {
|
||||
// ... and "real" is the traditional caller. This is not a typo.
|
||||
let real: T::AccountId = whitelisted_caller();
|
||||
add_announcements::<T>(a, Some(caller.clone()), None)?;
|
||||
let call: <T as Config>::Call = frame_system::Call::<T>::remark(vec![]).into();
|
||||
let call: <T as Config>::Call = frame_system::Call::<T>::remark { remark: vec![] }.into();
|
||||
let call_hash = T::CallHasher::hash_of(&call);
|
||||
}: _(RawOrigin::Signed(caller.clone()), real.clone(), call_hash)
|
||||
verify {
|
||||
|
||||
@@ -42,6 +42,7 @@ use frame_support::{
|
||||
RuntimeDebug,
|
||||
};
|
||||
use frame_system::{self as system};
|
||||
use scale_info::TypeInfo;
|
||||
use sp_io::hashing::blake2_256;
|
||||
use sp_runtime::{
|
||||
traits::{Dispatchable, Hash, Saturating, Zero},
|
||||
@@ -60,7 +61,17 @@ type BalanceOf<T> =
|
||||
/// The parameters under which a particular account has a proxy relationship with some other
|
||||
/// account.
|
||||
#[derive(
|
||||
Encode, Decode, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, RuntimeDebug, MaxEncodedLen,
|
||||
Encode,
|
||||
Decode,
|
||||
Clone,
|
||||
Copy,
|
||||
Eq,
|
||||
PartialEq,
|
||||
Ord,
|
||||
PartialOrd,
|
||||
RuntimeDebug,
|
||||
MaxEncodedLen,
|
||||
TypeInfo,
|
||||
)]
|
||||
pub struct ProxyDefinition<AccountId, ProxyType, BlockNumber> {
|
||||
/// The account which may act on behalf of another.
|
||||
@@ -73,7 +84,7 @@ pub struct ProxyDefinition<AccountId, ProxyType, BlockNumber> {
|
||||
}
|
||||
|
||||
/// Details surrounding a specific instance of an announcement to make a call.
|
||||
#[derive(Encode, Decode, Clone, Copy, Eq, PartialEq, RuntimeDebug, MaxEncodedLen)]
|
||||
#[derive(Encode, Decode, Clone, Copy, Eq, PartialEq, RuntimeDebug, MaxEncodedLen, TypeInfo)]
|
||||
pub struct Announcement<AccountId, Hash, BlockNumber> {
|
||||
/// The account which made the announcement.
|
||||
real: AccountId,
|
||||
@@ -534,12 +545,6 @@ pub mod pallet {
|
||||
}
|
||||
|
||||
#[pallet::event]
|
||||
#[pallet::metadata(
|
||||
T::AccountId = "AccountId",
|
||||
T::ProxyType = "ProxyType",
|
||||
CallHashOf<T> = "Hash",
|
||||
T::BlockNumber = "BlockNumber",
|
||||
)]
|
||||
#[pallet::generate_deposit(pub(super) fn deposit_event)]
|
||||
pub enum Event<T: Config> {
|
||||
/// A proxy was executed correctly, with the given \[result\].
|
||||
@@ -782,12 +787,13 @@ impl<T: Config> Pallet<T> {
|
||||
match c.is_sub_type() {
|
||||
// Proxy call cannot add or remove a proxy with more permissions than it already
|
||||
// has.
|
||||
Some(Call::add_proxy(_, ref pt, _)) | Some(Call::remove_proxy(_, ref pt, _))
|
||||
if !def.proxy_type.is_superset(&pt) =>
|
||||
Some(Call::add_proxy { ref proxy_type, .. }) |
|
||||
Some(Call::remove_proxy { ref proxy_type, .. })
|
||||
if !def.proxy_type.is_superset(&proxy_type) =>
|
||||
false,
|
||||
// Proxy call cannot remove all proxies or kill anonymous proxies unless it has full
|
||||
// permissions.
|
||||
Some(Call::remove_proxies(..)) | Some(Call::kill_anonymous(..))
|
||||
Some(Call::remove_proxies { .. }) | Some(Call::kill_anonymous { .. })
|
||||
if def.proxy_type != T::ProxyType::default() =>
|
||||
false,
|
||||
_ => def.proxy_type.filter(c),
|
||||
|
||||
@@ -107,7 +107,17 @@ parameter_types! {
|
||||
pub const AnnouncementDepositFactor: u64 = 1;
|
||||
}
|
||||
#[derive(
|
||||
Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, RuntimeDebug, MaxEncodedLen,
|
||||
Copy,
|
||||
Clone,
|
||||
Eq,
|
||||
PartialEq,
|
||||
Ord,
|
||||
PartialOrd,
|
||||
Encode,
|
||||
Decode,
|
||||
RuntimeDebug,
|
||||
MaxEncodedLen,
|
||||
scale_info::TypeInfo,
|
||||
)]
|
||||
pub enum ProxyType {
|
||||
Any,
|
||||
@@ -124,9 +134,9 @@ impl InstanceFilter<Call> for ProxyType {
|
||||
match self {
|
||||
ProxyType::Any => true,
|
||||
ProxyType::JustTransfer => {
|
||||
matches!(c, Call::Balances(pallet_balances::Call::transfer(..)))
|
||||
matches!(c, Call::Balances(pallet_balances::Call::transfer { .. }))
|
||||
},
|
||||
ProxyType::JustUtility => matches!(c, Call::Utility(..)),
|
||||
ProxyType::JustUtility => matches!(c, Call::Utility { .. }),
|
||||
}
|
||||
}
|
||||
fn is_superset(&self, o: &Self) -> bool {
|
||||
@@ -138,7 +148,7 @@ impl Contains<Call> for BaseFilter {
|
||||
fn contains(c: &Call) -> bool {
|
||||
match *c {
|
||||
// Remark is used as a no-op call in the benchmarking
|
||||
Call::System(SystemCall::remark(_)) => true,
|
||||
Call::System(SystemCall::remark { .. }) => true,
|
||||
Call::System(_) => false,
|
||||
_ => true,
|
||||
}
|
||||
@@ -190,6 +200,10 @@ fn expect_events(e: Vec<Event>) {
|
||||
assert_eq!(last_events(e.len()), e);
|
||||
}
|
||||
|
||||
fn call_transfer(dest: u64, value: u64) -> Call {
|
||||
Call::Balances(BalancesCall::transfer { dest, value })
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn announcement_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
@@ -272,7 +286,7 @@ fn announcer_must_be_proxy() {
|
||||
fn delayed_requires_pre_announcement() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_ok!(Proxy::add_proxy(Origin::signed(1), 2, ProxyType::Any, 1));
|
||||
let call = Box::new(Call::Balances(BalancesCall::transfer(6, 1)));
|
||||
let call = Box::new(call_transfer(6, 1));
|
||||
let e = Error::<Test>::Unannounced;
|
||||
assert_noop!(Proxy::proxy(Origin::signed(2), 1, None, call.clone()), e);
|
||||
let e = Error::<Test>::Unannounced;
|
||||
@@ -289,7 +303,7 @@ fn proxy_announced_removes_announcement_and_returns_deposit() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_ok!(Proxy::add_proxy(Origin::signed(1), 3, ProxyType::Any, 1));
|
||||
assert_ok!(Proxy::add_proxy(Origin::signed(2), 3, ProxyType::Any, 1));
|
||||
let call = Box::new(Call::Balances(BalancesCall::transfer(6, 1)));
|
||||
let call = Box::new(call_transfer(6, 1));
|
||||
let call_hash = BlakeTwo256::hash_of(&call);
|
||||
assert_ok!(Proxy::announce(Origin::signed(3), 1, call_hash));
|
||||
assert_ok!(Proxy::announce(Origin::signed(3), 2, call_hash));
|
||||
@@ -313,7 +327,7 @@ fn filtering_works() {
|
||||
assert_ok!(Proxy::add_proxy(Origin::signed(1), 3, ProxyType::JustTransfer, 0));
|
||||
assert_ok!(Proxy::add_proxy(Origin::signed(1), 4, ProxyType::JustUtility, 0));
|
||||
|
||||
let call = Box::new(Call::Balances(BalancesCall::transfer(6, 1)));
|
||||
let call = Box::new(call_transfer(6, 1));
|
||||
assert_ok!(Proxy::proxy(Origin::signed(2), 1, None, call.clone()));
|
||||
System::assert_last_event(ProxyEvent::ProxyExecuted(Ok(())).into());
|
||||
assert_ok!(Proxy::proxy(Origin::signed(3), 1, None, call.clone()));
|
||||
@@ -323,9 +337,10 @@ fn filtering_works() {
|
||||
|
||||
let derivative_id = Utility::derivative_account_id(1, 0);
|
||||
assert!(Balances::mutate_account(&derivative_id, |a| a.free = 1000).is_ok());
|
||||
let inner = Box::new(Call::Balances(BalancesCall::transfer(6, 1)));
|
||||
let inner = Box::new(call_transfer(6, 1));
|
||||
|
||||
let call = Box::new(Call::Utility(UtilityCall::as_derivative(0, inner.clone())));
|
||||
let call =
|
||||
Box::new(Call::Utility(UtilityCall::as_derivative { index: 0, call: inner.clone() }));
|
||||
assert_ok!(Proxy::proxy(Origin::signed(2), 1, None, call.clone()));
|
||||
System::assert_last_event(ProxyEvent::ProxyExecuted(Ok(())).into());
|
||||
assert_ok!(Proxy::proxy(Origin::signed(3), 1, None, call.clone()));
|
||||
@@ -333,7 +348,7 @@ fn filtering_works() {
|
||||
assert_ok!(Proxy::proxy(Origin::signed(4), 1, None, call.clone()));
|
||||
System::assert_last_event(ProxyEvent::ProxyExecuted(Err(DispatchError::BadOrigin)).into());
|
||||
|
||||
let call = Box::new(Call::Utility(UtilityCall::batch(vec![*inner])));
|
||||
let call = Box::new(Call::Utility(UtilityCall::batch { calls: vec![*inner] }));
|
||||
assert_ok!(Proxy::proxy(Origin::signed(2), 1, None, call.clone()));
|
||||
expect_events(vec![
|
||||
UtilityEvent::BatchCompleted.into(),
|
||||
@@ -347,8 +362,9 @@ fn filtering_works() {
|
||||
ProxyEvent::ProxyExecuted(Ok(())).into(),
|
||||
]);
|
||||
|
||||
let inner = Box::new(Call::Proxy(ProxyCall::add_proxy(5, ProxyType::Any, 0)));
|
||||
let call = Box::new(Call::Utility(UtilityCall::batch(vec![*inner])));
|
||||
let inner =
|
||||
Box::new(Call::Proxy(ProxyCall::new_call_variant_add_proxy(5, ProxyType::Any, 0)));
|
||||
let call = Box::new(Call::Utility(UtilityCall::batch { calls: vec![*inner] }));
|
||||
assert_ok!(Proxy::proxy(Origin::signed(2), 1, None, call.clone()));
|
||||
expect_events(vec![
|
||||
UtilityEvent::BatchCompleted.into(),
|
||||
@@ -362,7 +378,7 @@ fn filtering_works() {
|
||||
ProxyEvent::ProxyExecuted(Ok(())).into(),
|
||||
]);
|
||||
|
||||
let call = Box::new(Call::Proxy(ProxyCall::remove_proxies()));
|
||||
let call = Box::new(Call::Proxy(ProxyCall::remove_proxies {}));
|
||||
assert_ok!(Proxy::proxy(Origin::signed(3), 1, None, call.clone()));
|
||||
System::assert_last_event(ProxyEvent::ProxyExecuted(Err(DispatchError::BadOrigin)).into());
|
||||
assert_ok!(Proxy::proxy(Origin::signed(4), 1, None, call.clone()));
|
||||
@@ -431,7 +447,7 @@ fn proxying_works() {
|
||||
assert_ok!(Proxy::add_proxy(Origin::signed(1), 2, ProxyType::JustTransfer, 0));
|
||||
assert_ok!(Proxy::add_proxy(Origin::signed(1), 3, ProxyType::Any, 0));
|
||||
|
||||
let call = Box::new(Call::Balances(BalancesCall::transfer(6, 1)));
|
||||
let call = Box::new(call_transfer(6, 1));
|
||||
assert_noop!(
|
||||
Proxy::proxy(Origin::signed(4), 1, None, call.clone()),
|
||||
Error::<Test>::NotProxy
|
||||
@@ -444,14 +460,14 @@ fn proxying_works() {
|
||||
System::assert_last_event(ProxyEvent::ProxyExecuted(Ok(())).into());
|
||||
assert_eq!(Balances::free_balance(6), 1);
|
||||
|
||||
let call = Box::new(Call::System(SystemCall::set_code(vec![])));
|
||||
let call = Box::new(Call::System(SystemCall::set_code { code: vec![] }));
|
||||
assert_ok!(Proxy::proxy(Origin::signed(3), 1, None, call.clone()));
|
||||
System::assert_last_event(ProxyEvent::ProxyExecuted(Err(DispatchError::BadOrigin)).into());
|
||||
|
||||
let call = Box::new(Call::Balances(BalancesCall::transfer_keep_alive(6, 1)));
|
||||
assert_ok!(
|
||||
Call::Proxy(super::Call::proxy(1, None, call.clone())).dispatch(Origin::signed(2))
|
||||
);
|
||||
let call =
|
||||
Box::new(Call::Balances(BalancesCall::transfer_keep_alive { dest: 6, value: 1 }));
|
||||
assert_ok!(Call::Proxy(super::Call::new_call_variant_proxy(1, None, call.clone()))
|
||||
.dispatch(Origin::signed(2)));
|
||||
System::assert_last_event(ProxyEvent::ProxyExecuted(Err(DispatchError::BadOrigin)).into());
|
||||
assert_ok!(Proxy::proxy(Origin::signed(3), 1, None, call.clone()));
|
||||
System::assert_last_event(ProxyEvent::ProxyExecuted(Ok(())).into());
|
||||
@@ -483,13 +499,19 @@ fn anonymous_works() {
|
||||
System::set_block_number(2);
|
||||
assert_ok!(Proxy::anonymous(Origin::signed(1), ProxyType::Any, 0, 0));
|
||||
|
||||
let call = Box::new(Call::Balances(BalancesCall::transfer(6, 1)));
|
||||
let call = Box::new(call_transfer(6, 1));
|
||||
assert_ok!(Balances::transfer(Origin::signed(3), anon, 5));
|
||||
assert_ok!(Proxy::proxy(Origin::signed(1), anon, None, call));
|
||||
System::assert_last_event(ProxyEvent::ProxyExecuted(Ok(())).into());
|
||||
assert_eq!(Balances::free_balance(6), 1);
|
||||
|
||||
let call = Box::new(Call::Proxy(ProxyCall::kill_anonymous(1, ProxyType::Any, 0, 1, 0)));
|
||||
let call = Box::new(Call::Proxy(ProxyCall::new_call_variant_kill_anonymous(
|
||||
1,
|
||||
ProxyType::Any,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
)));
|
||||
assert_ok!(Proxy::proxy(Origin::signed(2), anon2, None, call.clone()));
|
||||
let de = DispatchError::from(Error::<Test>::NoPermission).stripped();
|
||||
System::assert_last_event(ProxyEvent::ProxyExecuted(Err(de)).into());
|
||||
|
||||
Reference in New Issue
Block a user