Please see edits 2 and beyond, as they reshape the question a lot.
TLDR: I need a way to mutate an origin for all but some specific calls so that it's dispatched as RawOrigin::Signed to pass ensure_signed and also so that it goes through pallet-transaction-payment's SignedExtension to charge fees.
I have a pallet that has it's own origin (which then gets appended to the overarching Origin made by construct_runtime), this pallet dispatches calls using it's own custom origin, but I would like this origin to be compatible with ensure_signed so it works naturally with other pallets, and to do that I need to implement Into<Result<RawOrigin, Origin>> for the overarching Origin of the runtime, which is already implemented by the construct_runtime macro.
I assume it just uses the _ pattern to return Err(origin) for anything that is not already Signed(accountid), but I want to override this impl to also return Ok(Signed(accountid)) when my custom origin's enum variant matches, but since it's inside the macro I'd assume there is a specific way to do that which I can't seem to find documented.
There's also the possibility that I'm completely missing some other simpler way to have ensure_signed accept my custom origin, which I wouldn't know, again, because of the lack of documentation.
Edit: I'm going to go further into what I want to modify:
From this line in the construct_runtime macro expansion: https://github.com/paritytech/substrate/blob/master/frame/support/procedural/src/construct_runtime/expand/origin.rs#L287
impl From<RuntimeOrigin> for #scrate::sp_std::result::Result<#system_path::Origin<#runtime>, RuntimeOrigin> {
fn from(val: RuntimeOrigin) -> Self {
if let OriginCaller::system(l) = val.caller {
Ok(l)
} else {
Err(val)
}
}
}
This piece of macro gets expanded inside my own runtime code, not in an external crate, so it's not just a matter of replacing it, I have no access to it simply because it's a macro that gets expanded on compile time. But here's what I want it to look like:
impl From<RuntimeOrigin> for #scrate::sp_std::result::Result<#system_path::Origin<#runtime>, RuntimeOrigin> {
fn from(val: RuntimeOrigin) -> Self {
match val.caller {
OriginCaller::system(l) => Ok(l),
OriginCaller::my_origin(c) => Ok(function_that_converts(c)),
_ => Err(val)
}
}
}
Edit 2: I found an open issue in paritytech/substrate about SignedExtension (https://github.com/paritytech/substrate/issues/3419#issuecomment-587387100) that, if implemented, would allow for me to do this by simply making a SignedExtension.
The linked comment mentions that with the implementation you would be able to mutate the origin of a call in the extension, which would be perfect as I could simply write logic to convert my custom origin to Signed(account_id) in the validate function.
However, as you can see, the issue is from 2019 and is still open, so either a better and undocumented solution was introduced, or this has just been ignored ever since.
Edit 3: The issue mentioned in the previous edit really seems to be what I'd actually need, as it would also allow me to properly charge fees for those transactions by placing them before the ChargeTransactionPayment SignedExtension and making them go through it like any other Signed origin.