Skip to content

Commit

Permalink
feat(rpc) Implement Filecoin.EthProtocolVersion (#4513)
Browse files Browse the repository at this point in the history
Co-authored-by: David Himmelstrup <david.himmelstrup@chainsafe.io>
Co-authored-by: LeshyBot <114995399+LeshyBot@users.noreply.github.com>
Co-authored-by: github-merge-queue <118344674+github-merge-queue@users.noreply.github.com>
  • Loading branch information
4 people committed Jul 16, 2024
1 parent 793c480 commit c2c3bf2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/rpc/methods/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1722,6 +1722,26 @@ impl RpcMethod<0> for EthMaxPriorityFeePerGas {
}
}

pub enum EthProtocolVersion {}
impl RpcMethod<0> for EthProtocolVersion {
const NAME: &'static str = "Filecoin.EthProtocolVersion";
const PARAM_NAMES: [&'static str; 0] = [];
const API_PATHS: ApiPaths = ApiPaths::V1;
const PERMISSION: Permission = Permission::Read;

type Params = ();
type Ok = Uint64;

async fn handle(
ctx: Ctx<impl Blockstore + Send + Sync + 'static>,
(): Self::Params,
) -> Result<Self::Ok, ServerError> {
let epoch = ctx.chain_store.heaviest_tipset().epoch();
let version = u32::from(ctx.state_manager.get_network_version(epoch).0);
Ok(Uint64(version.into()))
}
}

pub enum EthGetTransactionHashByCid {}
impl RpcMethod<1> for EthGetTransactionHashByCid {
const NAME: &'static str = "Filecoin.EthGetTransactionHashByCid";
Expand Down
1 change: 1 addition & 0 deletions src/rpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ macro_rules! for_each_method {
$callback!(crate::rpc::eth::EthGetMessageCidByTransactionHash);
$callback!(crate::rpc::eth::EthGetTransactionCount);
$callback!(crate::rpc::eth::EthMaxPriorityFeePerGas);
$callback!(crate::rpc::eth::EthProtocolVersion);
$callback!(crate::rpc::eth::EthGetTransactionHashByCid);

// gas vertical
Expand Down
1 change: 1 addition & 0 deletions src/tool/subcommands/api_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1144,6 +1144,7 @@ fn eth_tests() -> Vec<RpcTest> {
),
RpcTest::basic(Web3ClientVersion::request(()).unwrap()),
RpcTest::identity(EthMaxPriorityFeePerGas::request(()).unwrap()),
RpcTest::identity(EthProtocolVersion::request(()).unwrap()),
]
}

Expand Down

0 comments on commit c2c3bf2

Please sign in to comment.