paritytech / jsonrpsee

Rust JSON-RPC library on top of async/await
MIT License
645 stars 173 forks source link

Should Jsonrpsee support scale encoded params in proc macro and not only json serialization and deserialization #1339

Closed MrishoLukamba closed 7 months ago

MrishoLukamba commented 7 months ago
pub trait Transaction {
    /// Takes in transaction function `call`, `sender address` and `receiver address`
    /// A transaction object will be built based on the params and the object will be subjected for confirmation
    #[method(name = "submit")]
    async fn submit_transaction(
        &self,
        call: Vec<u8>,
        sender: MultiAddress<u128,u32>,
        receiver: MultiAddress<u128,u32>,
    ) -> RpcResult<()>;

MultiAddress is scale encoded , but it cannot be a param as its not json serialized. This is a blocker, cant we support both.

MrishoLukamba commented 7 months ago

@dvdplm @quake @montekki @ascjones

niklasad1 commented 7 months ago

Hey hey,

This is a JSON-RPC library and it will not support scale encoding in the proc macro API.

I would suggest to open an issue in the repo that's exposing this API but I'm not sure where it comes from and would be better to write a wrapper on-top of the jsonrpsee proc macro or simply not to use it all.

Another solution is just to do:


pub trait Transaction {
    /// Takes in transaction function `call`, `sender address` and `receiver address`
    /// A transaction object will be built based on the params and the object will be subjected for confirmation
    #[method(name = "submit")]
    async fn submit_transaction(
        &self,
        call: Vec<u8>,
        // Decode/encode as scale bytes to MultiAddress or introduce a custom wrapper
        sender: Vec<u8>,
        // Decode/encode as scale bytes to MultiAddress or introduce a custom wrapper
        receiver: Vec<u8>
    ) -> RpcResult<()>;