Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"And gate" for EnsureOrigin #369

Open
gavofyork opened this issue Jul 8, 2019 · 2 comments
Open

"And gate" for EnsureOrigin #369

gavofyork opened this issue Jul 8, 2019 · 2 comments
Labels
C1-mentor A task where a mentor is available. Please indicate in the issue who the mentor could be. D0-easy Can be fixed primarily by duplicating and adapting code by an intermediate coder. I5-enhancement An additional feature request. T1-FRAME This PR/Issue is related to core FRAME, the framework.

Comments

@gavofyork
Copy link
Member

It should be possible to easily specify that two (independent) EnsureOrigin implementations must both agree that dispatch should happen as a third EnsureOrigin.

Since the origin cannot be collected together, it would necessitate a module which retained state over dispatch/proposal hashes, allowing one origin to approve a hash first, and the other origin to approve it later causing the dispatch.

An analogous "Or gate" would also be useful.

@bowd
Copy link

bowd commented Aug 26, 2019

@gavofyork ✋I'm willing to give this a shot but I'm totally new to Substrate. I'm a quick learner though and I'm used to finding my way around code and resources as long as I'm pushed in the right direction. I have some rust experience, enough to make sense of things but will probably have questions on finer points.

@expenses
Copy link

Would you mind going into a little bit more detail about this issue? Would something like the following be sufficient?

pub struct EnsureBoth<OriginA, OriginB>(rstd::marker::PhantomData<(OriginA, OriginB)>);

impl<
	AO: Clone, BO: Clone,
	OriginA: EnsureOrigin<AO>, OriginB: EnsureOrigin<BO>,
> EnsureOrigin<(AO, BO)> for EnsureBoth<OriginA, OriginB> {
	type Success = (OriginA::Success, OriginB::Success);

	fn try_origin((a, b): (AO, BO)) -> Result<Self::Success, (AO, BO)> {
		let a_result = OriginA::try_origin(a.clone());
		let b_result = OriginB::try_origin(b.clone());

		match (a_result, b_result) {
			(Ok(a_s), Ok(b_s)) => Ok((a_s, b_s)),
			_ => Err((a, b))
		}
	}
}

@juangirini juangirini transferred this issue from paritytech/substrate Aug 24, 2023
@the-right-joyce the-right-joyce added I5-enhancement An additional feature request. C1-mentor A task where a mentor is available. Please indicate in the issue who the mentor could be. T1-FRAME This PR/Issue is related to core FRAME, the framework. D0-easy Can be fixed primarily by duplicating and adapting code by an intermediate coder. and removed J0-enhancement labels Aug 25, 2023
claravanstaden pushed a commit to Snowfork/polkadot-sdk that referenced this issue Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C1-mentor A task where a mentor is available. Please indicate in the issue who the mentor could be. D0-easy Can be fixed primarily by duplicating and adapting code by an intermediate coder. I5-enhancement An additional feature request. T1-FRAME This PR/Issue is related to core FRAME, the framework.
Projects
Status: Backlog
Development

No branches or pull requests

5 participants