Skip to content
This repository has been archived by the owner on Aug 2, 2024. It is now read-only.

chore: split starknetRPC in two traits to follow openRPC spec definition #1274

Merged
merged 2 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Next release

- chore: split StarknetRpcApi trait in two, like in openRPC specs
- refacto: move starknet runtime api in it's own crate
- chore: update README.md and getting-started.md
- chore: remove crates that have been copy-pasted from plkdtSDK
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 26 additions & 22 deletions crates/client/rpc-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,34 @@ use starknet_core::types::{
#[derive(Serialize, Deserialize)]
pub struct Felt(#[serde_as(as = "UfeHex")] pub FieldElement);

/// Starknet write rpc interface.
#[rpc(server, namespace = "starknet")]
pub trait StarknetWriteRpcApi {
/// Submit a new transaction to be added to the chain
#[method(name = "addInvokeTransaction")]
async fn add_invoke_transaction(
&self,
invoke_transaction: BroadcastedInvokeTransaction,
) -> RpcResult<InvokeTransactionResult>;

/// Submit a new class declaration transaction
#[method(name = "addDeployAccountTransaction")]
async fn add_deploy_account_transaction(
&self,
deploy_account_transaction: BroadcastedDeployAccountTransaction,
) -> RpcResult<DeployAccountTransactionResult>;

/// Submit a new deploy account transaction
#[method(name = "addDeclareTransaction")]
async fn add_declare_transaction(
&self,
declare_transaction: BroadcastedDeclareTransaction,
) -> RpcResult<DeclareTransactionResult>;
}

/// Starknet rpc interface.
#[rpc(server, namespace = "starknet")]
pub trait StarknetRpcApi {
pub trait StarknetReadRpcApi {
/// Get the most recent accepted block number
#[method(name = "blockNumber")]
fn block_number(&self) -> RpcResult<u64>;
Expand Down Expand Up @@ -83,20 +108,6 @@ pub trait StarknetRpcApi {
#[method(name = "chainId")]
fn chain_id(&self) -> RpcResult<Felt>;

/// Add an Invoke Transaction to invoke a contract function
#[method(name = "addInvokeTransaction")]
async fn add_invoke_transaction(
&self,
invoke_transaction: BroadcastedInvokeTransaction,
) -> RpcResult<InvokeTransactionResult>;

/// Add a Deploy Account Transaction
#[method(name = "addDeployAccountTransaction")]
async fn add_deploy_account_transaction(
&self,
deploy_account_transaction: BroadcastedDeployAccountTransaction,
) -> RpcResult<DeployAccountTransactionResult>;

/// Estimate the fee associated with transaction
#[method(name = "estimateFee")]
async fn estimate_fee(
Expand All @@ -121,13 +132,6 @@ pub trait StarknetRpcApi {
#[method(name = "getEvents")]
async fn get_events(&self, filter: EventFilterWithPage) -> RpcResult<EventsPage>;

/// Submit a new transaction to be added to the chain
#[method(name = "addDeclareTransaction")]
async fn add_declare_transaction(
&self,
declare_transaction: BroadcastedDeclareTransaction,
) -> RpcResult<DeclareTransactionResult>;

/// Returns the information about a transaction by transaction hash.
#[method(name = "getTransactionByHash")]
fn get_transaction_by_hash(&self, transaction_hash: FieldElement) -> RpcResult<Transaction>;
Expand Down
1 change: 1 addition & 0 deletions crates/client/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ starknet-core = { workspace = true }
starknet-ff = { workspace = true }
starknet_api = { workspace = true, default-features = false }
# Others
anyhow = { workspace = true }
hex = { workspace = true, default-features = true }
jsonrpsee = { workspace = true, default-features = true, features = [
"server",
Expand Down
Loading