I'm playing around with custom RPC endpoints exposed from my substrate node, but I'm encountering an issue when trying to call it with polkadotjs. Initially, my endpoint only accepted a single parameter of type Bytes. Invocation from the frontend worked with any problems. After modifying the endpoint to also accept parameters with type Vec and u32 (note: this is only a change in params, the implementation was not changed), polkadotjs has an error when calling createType (when the endpoint is invoked), seemingly requiring an expected size:
createType(Vec<u8>):: Bytes: required length less than remainder, expected at least 54, found 32
Is this an issue with using Vec as a parameter or an issue with my configuration?
In my frontend I've added the following RPC config to the api creation:
const api = await ApiPromise.create({
provider,
rpc: {
iris: {
retrieveBytes: {
description: 'retrieve bytes from iris',
params: [
{
name: 'signature',
type: 'Vec<u8>'
},
{
name: 'message',
type: 'Bytes'
},
{
name: 'signer',
type: 'Vec<u8>'
},
{
name: 'asset_id',
type: 'u32'
}
],
type: 'Bytes'
}
}
}
});
Which I am calling using this:
await api.rpc.iris.retrieveBytes(signature, message, accountId, assetId)
.then(res => success_callback(res))
.catch(err => error_callback(err));
My api implementation does nothing but return empty bytes.
pub fn retrieve_bytes(
signature: Vec<u8>,
message: Bytes,
signer: Vec<u8>,
asset_id: u32,
) -> Bytes {
Bytes(Vec::new())
}