-
Notifications
You must be signed in to change notification settings - Fork 2
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
Poc extension system #27
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks mostly fine
poc/extensions/src/dispatchable.rs
Outdated
type MethodName; | ||
type MethodIndex; | ||
fn query_method(method_name: Self::MethodName) -> Self::MethodIndex; | ||
fn dispatch(self) -> Vec<u8>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it could be useful to make this return an Result
poc/extensions/src/extension_core.rs
Outdated
use super::ExtensionTypeId; | ||
use parity_scale_codec::{Decode, Encode}; | ||
// SDK codes | ||
pub trait ExtensionCore: Dispatchable + TryFrom<(u32, Vec<u8>)> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TryFrom<(u32, Vec<u8>)
is not correct. It should be something like TryFrom<(Dispatchable::MethodIndex, Dispatchable::MethodName)>
(you need to figure out the right syntax. maybe with a whare clause(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and should have a trait Extension: Dispatchable + TryFrom<X, Y>
and have other extensions conforming it
poc/extensions/src/extension_core.rs
Outdated
}, | ||
} | ||
|
||
impl TryFrom<(u32, Vec<u8>)> for ExtensionCoreImpl { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually should just use the Decode
macro from parity_scale_codec to auto generate the decode logic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, so query_method is also redundant. The call details will embed in guest args.
The benefits of having indirect Enum implementations for extension functions are that we can implement some functionals later, like querying fees of the functions, right? |
I found accessing context in |
add trait bounds is fine |
} | ||
|
||
impl<Impl: ExtensionFungibles> ExtensionId for ExtensionFungiblesCall<Impl> { | ||
const EXTENSION_ID: ExtensionIdTy = Impl::EXTENSION_ID; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extension id should be generated by this macro
use core::marker::PhantomData; | ||
use parity_scale_codec::{Decode, Encode}; | ||
|
||
pub trait ExtensionFungibles: ExtensionId { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pub trait ExtensionFungibles: ExtensionId { | |
pub trait ExtensionFungibles { |
it is not up to the implementor of ExtensionFungibles
to determine the extension id
poc/extensions/src/lib.rs
Outdated
|
||
struct Context<E: ExtensionTuple, P: PermController> { | ||
invoke_source: InvokeSource, | ||
phantom_p: PhantomData<P>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
phantom_p: PhantomData<P>, | |
_marker: PhantomData<(P, E)>, |
so we don't need two of it
Close #8