I have an rpc
#[rpc]
pub trait ShivarthuApi<BlockHash> {
#[rpc(name = "shivarthu_challengerevidence")]
fn get_challengers_evidence(
&self,
at: Option<BlockHash>,
profile_citizenid: u128,
offset: u64,
limit: u16,
) -> Result<Vec<u128>>;
}
With curl when I pass null it gives results
curl http://localhost:9933 -H "Content-Type:application/json;charset=utf-8" -d '{
"jsonrpc":"2.0",
"id":1,
"method":"shivarthu_challengerevidence",
"params": [null, 0, 0, 5]
}'
But without null, it gives error:
{"jsonrpc":"2.0","error":{"code":-32602,"message":"Invalid params: invalid type: number, expected a (both 0x-prefixed or not) hex string with length of 64."},"id":1}
But with my front end code using polkadot js it gives error with null or undefined:
const api2 = await ApiPromise.create({
provider: wsProvider,
rpc: {
shivarthu: {
challengerevidence: {
description: 'Challenger Evidence',
params: [
{
name: 'at',
type: 'Hash',
isOptional: true,
},
{
name: 'profile_citizenid',
type: 'u128',
},
{
name: 'offset',
type: 'u64',
},
{
name: 'limit',
type: 'u16',
},
],
type: 'Vec<u128>',
},
},
},
})
let data = await api2.rpc.shivarthu.challengerevidence(null, 0, 0, 5)
console.log(data)
Error:
index.js:73 Uncaught (in promise) Error: 9876: Something wrong: Application, UnknownBlock, Header was not found in the database: 0x0000000000000000000000000000000000000000000000000000000000000000