Skip to content

Commit

Permalink
fix(rpc): verify and adjust common node API parameter names 2/4 (#5284)
Browse files Browse the repository at this point in the history
  • Loading branch information
hanabi1224 authored Feb 13, 2025
1 parent 4c12c3e commit c019d5f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 26 deletions.
13 changes: 9 additions & 4 deletions src/rpc/methods/gas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const MIN_GAS_PREMIUM: f64 = 100000.0;
pub enum GasEstimateFeeCap {}
impl RpcMethod<3> for GasEstimateFeeCap {
const NAME: &'static str = "Filecoin.GasEstimateFeeCap";
const PARAM_NAMES: [&'static str; 3] = ["message", "max_queue_blocks", "tipset_key"];
const PARAM_NAMES: [&'static str; 3] = ["message", "maxQueueBlocks", "tipsetKey"];
const API_PATHS: ApiPaths = ApiPaths::V1;
const PERMISSION: Permission = Permission::Read;

Expand Down Expand Up @@ -68,7 +68,12 @@ fn estimate_fee_cap<DB: Blockstore>(
pub enum GasEstimateGasPremium {}
impl RpcMethod<4> for GasEstimateGasPremium {
const NAME: &'static str = "Filecoin.GasEstimateGasPremium";
const PARAM_NAMES: [&'static str; 4] = ["nblocksincl", "sender", "gas_limit", "tipset_key"];
const PARAM_NAMES: [&'static str; 4] = [
"numberOfBlocksToInclude",
"senderAddress",
"gasLimit",
"tipsetKey",
];
const API_PATHS: ApiPaths = ApiPaths::V1;
const PERMISSION: Permission = Permission::Read;

Expand Down Expand Up @@ -166,7 +171,7 @@ pub async fn estimate_gas_premium<DB: Blockstore>(
pub enum GasEstimateGasLimit {}
impl RpcMethod<2> for GasEstimateGasLimit {
const NAME: &'static str = "Filecoin.GasEstimateGasLimit";
const PARAM_NAMES: [&'static str; 2] = ["msg", "tsk"];
const PARAM_NAMES: [&'static str; 2] = ["message", "tipsetKey"];
const API_PATHS: ApiPaths = ApiPaths::V1;
const PERMISSION: Permission = Permission::Read;

Expand Down Expand Up @@ -261,7 +266,7 @@ impl GasEstimateGasLimit {
pub enum GasEstimateMessageGas {}
impl RpcMethod<3> for GasEstimateMessageGas {
const NAME: &'static str = "Filecoin.GasEstimateMessageGas";
const PARAM_NAMES: [&'static str; 3] = ["msg", "spec", "tsk"];
const PARAM_NAMES: [&'static str; 3] = ["message", "messageSendSpec", "tipsetKey"];
const API_PATHS: ApiPaths = ApiPaths::V1;
const PERMISSION: Permission = Permission::Read;

Expand Down
18 changes: 9 additions & 9 deletions src/rpc/methods/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ impl RpcMethod<0> for NetInfo {
pub enum NetConnect {}
impl RpcMethod<1> for NetConnect {
const NAME: &'static str = "Filecoin.NetConnect";
const PARAM_NAMES: [&'static str; 1] = ["info"];
const PARAM_NAMES: [&'static str; 1] = ["peerAddressInfo"];
const API_PATHS: ApiPaths = ApiPaths::V1;
const PERMISSION: Permission = Permission::Write;

Expand Down Expand Up @@ -166,7 +166,7 @@ impl RpcMethod<1> for NetConnect {
pub enum NetDisconnect {}
impl RpcMethod<1> for NetDisconnect {
const NAME: &'static str = "Filecoin.NetDisconnect";
const PARAM_NAMES: [&'static str; 1] = ["id"];
const PARAM_NAMES: [&'static str; 1] = ["peerId"];
const API_PATHS: ApiPaths = ApiPaths::V1;
const PERMISSION: Permission = Permission::Write;

Expand All @@ -175,9 +175,9 @@ impl RpcMethod<1> for NetDisconnect {

async fn handle(
ctx: Ctx<impl Blockstore>,
(id,): Self::Params,
(peer_id,): Self::Params,
) -> Result<Self::Ok, ServerError> {
let peer_id = PeerId::from_str(&id)?;
let peer_id = PeerId::from_str(&peer_id)?;

let (tx, rx) = flume::bounded(1);
let req = NetworkMessage::JSONRPCRequest {
Expand All @@ -194,7 +194,7 @@ impl RpcMethod<1> for NetDisconnect {
pub enum NetAgentVersion {}
impl RpcMethod<1> for NetAgentVersion {
const NAME: &'static str = "Filecoin.NetAgentVersion";
const PARAM_NAMES: [&'static str; 1] = ["id"];
const PARAM_NAMES: [&'static str; 1] = ["peerId"];
const API_PATHS: ApiPaths = ApiPaths::V1;
const PERMISSION: Permission = Permission::Read;

Expand All @@ -203,9 +203,9 @@ impl RpcMethod<1> for NetAgentVersion {

async fn handle(
ctx: Ctx<impl Blockstore>,
(id,): Self::Params,
(peer_id,): Self::Params,
) -> Result<Self::Ok, ServerError> {
let peer_id = PeerId::from_str(&id)?;
let peer_id = PeerId::from_str(&peer_id)?;
let (tx, rx) = flume::bounded(1);
ctx.network_send()
.send_async(NetworkMessage::JSONRPCRequest {
Expand Down Expand Up @@ -255,7 +255,7 @@ impl RpcMethod<0> for NetVersion {
pub enum NetProtectAdd {}
impl RpcMethod<1> for NetProtectAdd {
const NAME: &'static str = "Filecoin.NetProtectAdd";
const PARAM_NAMES: [&'static str; 1] = ["peer_ids"];
const PARAM_NAMES: [&'static str; 1] = ["peerIdList"];
const API_PATHS: ApiPaths = ApiPaths::V1;
const PERMISSION: Permission = Permission::Admin;

Expand Down Expand Up @@ -309,7 +309,7 @@ impl RpcMethod<0> for NetProtectList {
pub enum NetProtectRemove {}
impl RpcMethod<1> for NetProtectRemove {
const NAME: &'static str = "Filecoin.NetProtectRemove";
const PARAM_NAMES: [&'static str; 1] = ["peer_ids"];
const PARAM_NAMES: [&'static str; 1] = ["peerIdList"];
const API_PATHS: ApiPaths = ApiPaths::Both;
const PERMISSION: Permission = Permission::Admin;

Expand Down
26 changes: 13 additions & 13 deletions src/rpc/methods/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const INITIAL_PLEDGE_DEN: u64 = 100;
pub enum StateCall {}
impl RpcMethod<2> for StateCall {
const NAME: &'static str = "Filecoin.StateCall";
const PARAM_NAMES: [&'static str; 2] = ["message", "tsk"];
const PARAM_NAMES: [&'static str; 2] = ["message", "tipsetKey"];
const API_PATHS: ApiPaths = ApiPaths::V1;
const PERMISSION: Permission = Permission::Read;

Expand Down Expand Up @@ -161,7 +161,7 @@ pub enum StateAccountKey {}

impl RpcMethod<2> for StateAccountKey {
const NAME: &'static str = "Filecoin.StateAccountKey";
const PARAM_NAMES: [&'static str; 2] = ["address", "tipset_key"];
const PARAM_NAMES: [&'static str; 2] = ["address", "tipsetKey"];
const API_PATHS: ApiPaths = ApiPaths::V1;
const PERMISSION: Permission = Permission::Read;

Expand Down Expand Up @@ -256,7 +256,7 @@ pub enum StateGetActor {}

impl RpcMethod<2> for StateGetActor {
const NAME: &'static str = "Filecoin.StateGetActor";
const PARAM_NAMES: [&'static str; 2] = ["address", "tipset_key"];
const PARAM_NAMES: [&'static str; 2] = ["address", "tipsetKey"];
const API_PATHS: ApiPaths = ApiPaths::V1;
const PERMISSION: Permission = Permission::Read;

Expand Down Expand Up @@ -1528,7 +1528,7 @@ pub enum StateCirculatingSupply {}

impl RpcMethod<1> for StateCirculatingSupply {
const NAME: &'static str = "Filecoin.StateCirculatingSupply";
const PARAM_NAMES: [&'static str; 1] = ["tipset_key"];
const PARAM_NAMES: [&'static str; 1] = ["tipsetKey"];
const API_PATHS: ApiPaths = ApiPaths::V1;
const PERMISSION: Permission = Permission::Read;

Expand Down Expand Up @@ -1714,7 +1714,7 @@ pub enum StateDealProviderCollateralBounds {}

impl RpcMethod<3> for StateDealProviderCollateralBounds {
const NAME: &'static str = "Filecoin.StateDealProviderCollateralBounds";
const PARAM_NAMES: [&'static str; 3] = ["size", "verified", "tipset_key"];
const PARAM_NAMES: [&'static str; 3] = ["size", "verified", "tipsetKey"];
const API_PATHS: ApiPaths = ApiPaths::V1;
const PERMISSION: Permission = Permission::Read;

Expand Down Expand Up @@ -2305,7 +2305,7 @@ pub enum StateGetClaim {}

impl RpcMethod<3> for StateGetClaim {
const NAME: &'static str = "Filecoin.StateGetClaim";
const PARAM_NAMES: [&'static str; 3] = ["address", "claim_id", "tipset_key"];
const PARAM_NAMES: [&'static str; 3] = ["address", "claimId", "tipsetKey"];
const API_PATHS: ApiPaths = ApiPaths::V1;
const PERMISSION: Permission = Permission::Read;

Expand All @@ -2325,7 +2325,7 @@ pub enum StateGetClaims {}

impl RpcMethod<2> for StateGetClaims {
const NAME: &'static str = "Filecoin.StateGetClaims";
const PARAM_NAMES: [&'static str; 2] = ["address", "tipset_key"];
const PARAM_NAMES: [&'static str; 2] = ["address", "tipsetKey"];
const API_PATHS: ApiPaths = ApiPaths::V1;
const PERMISSION: Permission = Permission::Read;

Expand Down Expand Up @@ -2359,7 +2359,7 @@ pub enum StateGetAllClaims {}

impl RpcMethod<1> for StateGetAllClaims {
const NAME: &'static str = "Filecoin.StateGetAllClaims";
const PARAM_NAMES: [&'static str; 1] = ["tipset_key"];
const PARAM_NAMES: [&'static str; 1] = ["tipsetKey"];
const API_PATHS: ApiPaths = ApiPaths::V1;
const PERMISSION: Permission = Permission::Read;

Expand All @@ -2379,7 +2379,7 @@ pub enum StateGetAllocation {}

impl RpcMethod<3> for StateGetAllocation {
const NAME: &'static str = "Filecoin.StateGetAllocation";
const PARAM_NAMES: [&'static str; 3] = ["address", "allocation_id", "tipset_key"];
const PARAM_NAMES: [&'static str; 3] = ["address", "allocationId", "tipsetKey"];
const API_PATHS: ApiPaths = ApiPaths::V1;
const PERMISSION: Permission = Permission::Read;

Expand All @@ -2401,7 +2401,7 @@ pub enum StateGetAllocations {}

impl RpcMethod<2> for StateGetAllocations {
const NAME: &'static str = "Filecoin.StateGetAllocations";
const PARAM_NAMES: [&'static str; 2] = ["address", "tipset_key"];
const PARAM_NAMES: [&'static str; 2] = ["address", "tipsetKey"];
const API_PATHS: ApiPaths = ApiPaths::V1;
const PERMISSION: Permission = Permission::Read;

Expand Down Expand Up @@ -2568,7 +2568,7 @@ pub enum StateGetAllAllocations {}

impl RpcMethod<1> for crate::rpc::prelude::StateGetAllAllocations {
const NAME: &'static str = "Filecoin.StateGetAllAllocations";
const PARAM_NAMES: [&'static str; 1] = ["tipset_key"];
const PARAM_NAMES: [&'static str; 1] = ["tipsetKey"];
const API_PATHS: ApiPaths = ApiPaths::V1;
const PERMISSION: Permission = Permission::Read;

Expand All @@ -2588,7 +2588,7 @@ pub enum StateGetAllocationIdForPendingDeal {}

impl RpcMethod<2> for StateGetAllocationIdForPendingDeal {
const NAME: &'static str = "Filecoin.StateGetAllocationIdForPendingDeal";
const PARAM_NAMES: [&'static str; 2] = ["deal_id", "tipset_key"];
const PARAM_NAMES: [&'static str; 2] = ["dealId", "tipsetKey"];
const API_PATHS: ApiPaths = ApiPaths::V1;
const PERMISSION: Permission = Permission::Read;

Expand Down Expand Up @@ -2621,7 +2621,7 @@ pub enum StateGetAllocationForPendingDeal {}

impl RpcMethod<2> for StateGetAllocationForPendingDeal {
const NAME: &'static str = "Filecoin.StateGetAllocationForPendingDeal";
const PARAM_NAMES: [&'static str; 2] = ["deal_id", "tipset_key"];
const PARAM_NAMES: [&'static str; 2] = ["dealId", "tipsetKey"];
const API_PATHS: ApiPaths = ApiPaths::V1;
const PERMISSION: Permission = Permission::Read;

Expand Down

0 comments on commit c019d5f

Please sign in to comment.