Skip to content

Commit

Permalink
Rooch fix sdk&dashboard (#885)
Browse files Browse the repository at this point in the history
* fix

* fix

* fix

* add theme setting

* fix rust lint

* fix test && publish sdk package

* fix sdk test
  • Loading branch information
wow-sven authored Sep 28, 2023
1 parent 84eb6a6 commit 5928176
Show file tree
Hide file tree
Showing 46 changed files with 979 additions and 838 deletions.
18 changes: 0 additions & 18 deletions crates/rooch-open-rpc-spec/schemas/openrpc.json
Original file line number Diff line number Diff line change
Expand Up @@ -202,24 +202,6 @@
}
}
},
{
"name": "rooch_getTransactionByHash",
"params": [
{
"name": "hash",
"required": true,
"schema": {
"$ref": "#/components/schemas/H256View"
}
}
],
"result": {
"name": "TransactionView",
"schema": {
"$ref": "#/components/schemas/TransactionView"
}
}
},
{
"name": "rooch_getTransactionsByHash",
"params": [
Expand Down
5 changes: 3 additions & 2 deletions crates/rooch-rpc-api/src/api/rooch_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,9 @@ pub trait RoochAPI {
// filter: EventFilterView,
// ) -> RpcResult<Vec<Option<AnnotatedEventView>>>;

#[method(name = "getTransactionByHash")]
async fn get_transaction_by_hash(&self, hash: H256View) -> RpcResult<Option<TransactionView>>;
// TODO:
// #[method(name = "getTransactionByHash")]
// async fn get_transaction_by_hash(&self, hash: H256View) -> RpcResult<Option<TransactionView>>;

#[method(name = "getTransactionsByHash")]
async fn get_transactions_by_hash(
Expand Down
14 changes: 5 additions & 9 deletions crates/rooch-rpc-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,9 @@ use rooch_rpc_api::jsonrpc_types::{
};
use rooch_rpc_api::{
api::rooch_api::RoochAPIClient,
jsonrpc_types::{
AnnotatedStateView, ExecuteTransactionResponseView, StateView, TransactionView,
},
};
use rooch_types::{
account::Account, address::RoochAddress, transaction::rooch::RoochTransaction, H256,
jsonrpc_types::{AnnotatedStateView, ExecuteTransactionResponseView, StateView},
};
use rooch_types::{account::Account, address::RoochAddress, transaction::rooch::RoochTransaction};
use std::sync::Arc;
use std::time::Duration;

Expand Down Expand Up @@ -138,9 +134,9 @@ impl Client {
.await?)
}

pub async fn get_transactions_by_hash(&self, hash: H256) -> Result<Option<TransactionView>> {
Ok(self.rpc.http.get_transaction_by_hash(hash.into()).await?)
}
// pub async fn get_transactions_by_hash(&self, hash: H256) -> Result<Option<TransactionView>> {
// Ok(self.rpc.http.get_transaction_by_hash(hash.into()).await?)
// }

pub async fn get_sequence_number(&self, sender: RoochAddress) -> Result<u64> {
Ok(self
Expand Down
16 changes: 8 additions & 8 deletions crates/rooch-rpc-server/src/server/rooch_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,14 +221,14 @@ impl RoochAPIServer for RoochServer {
// .collect())
// }

async fn get_transaction_by_hash(&self, hash: H256View) -> RpcResult<Option<TransactionView>> {
let resp = self
.rpc_service
.get_transaction_by_hash(hash.into())
.await?
.map(Into::into);
Ok(resp)
}
// async fn get_transaction_by_hash(&self, hash: H256View) -> RpcResult<Option<TransactionView>> {
// let resp = self
// .rpc_service
// .get_transaction_by_hash(hash.into())
// .await?
// .map(Into::into);
// Ok(resp)
// }

async fn get_transactions_by_hash(
&self,
Expand Down
50 changes: 25 additions & 25 deletions crates/rooch/src/commands/transaction/commands/get_tx_by_hash.rs
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
// Copyright (c) RoochNetwork
// SPDX-License-Identifier: Apache-2.0

use crate::cli_types::{CommandAction, WalletContextOptions};
use async_trait::async_trait;
use rooch_rpc_api::jsonrpc_types::TransactionView;
use rooch_types::{error::RoochResult, H256};
// use crate::cli_types::{CommandAction, WalletContextOptions};
// use async_trait::async_trait;
// use rooch_rpc_api::jsonrpc_types::TransactionView;
// use rooch_types::{error::RoochResult, H256};

/// Get transaction by hash
#[derive(Debug, clap::Parser)]
pub struct GetByHashCommand {
/// Transaction's hash
#[clap(long)]
pub hash: H256,

#[clap(flatten)]
pub(crate) context_options: WalletContextOptions,
}

#[async_trait]
impl CommandAction<Option<TransactionView>> for GetByHashCommand {
async fn execute(self) -> RoochResult<Option<TransactionView>> {
let client = self.context_options.build().await?.get_client().await?;

let resp = client.get_transactions_by_hash(self.hash).await?;

Ok(resp)
}
}
// Get transaction by hash
// #[derive(Debug, clap::Parser)]
// pub struct GetByHashCommand {
// /// Transaction's hash
// #[clap(long)]
// pub hash: H256,
//
// #[clap(flatten)]
// pub(crate) context_options: WalletContextOptions,
// }
//
// #[async_trait]
// impl CommandAction<Option<TransactionView>> for GetByHashCommand {
// async fn execute(self) -> RoochResult<Option<TransactionView>> {
// let client = self.context_options.build().await?.get_client().await?;
//
// let resp = client.get_transactions_by_hash(self.hash).await?;
//
// Ok(resp)
// }
// }
2 changes: 1 addition & 1 deletion crates/rooch/src/commands/transaction/commands/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) RoochNetwork
// SPDX-License-Identifier: Apache-2.0

pub mod get_tx_by_hash;
// pub mod get_tx_by_hash;
6 changes: 3 additions & 3 deletions crates/rooch/src/commands/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

use crate::cli_types::CommandAction;
use crate::commands::transaction::commands::get_tx_by_hash::GetByHashCommand;
// use crate::commands::transaction::commands::get_tx_by_hash::GetByHashCommand;
use async_trait::async_trait;
use rooch_types::error::RoochResult;

Expand All @@ -19,12 +19,12 @@ pub struct Transaction {
impl CommandAction<String> for Transaction {
async fn execute(self) -> RoochResult<String> {
match self.cmd {
TransactionCommand::GetByHash(cmd) => cmd.execute_serialized().await,
// TransactionCommand::GetByHash(cmd) => cmd.execute_serialized().await,
}
}
}

#[derive(clap::Subcommand)]
pub enum TransactionCommand {
GetByHash(GetByHashCommand),
// GetByHash(GetByHashCommand),
}
2 changes: 0 additions & 2 deletions crates/testsuite/features/cmd.feature
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ Feature: Rooch CLI integration tests
Then cmd: "session-key create --sender-account {default} --scope 0x3::empty::empty"
Then cmd: "move run --function 0x3::empty::empty --sender-account {default} --session-key {{$.session-key[-1].authentication_key}}"

Then cmd: "transaction get-by-hash --hash {{$.account[0].execution_info.tx_hash}}"

# event example
Then cmd: "move publish -p ../../examples/event --sender-account {default} --named-addresses rooch_examples={default}"
Then cmd: "move run --function {default}::event_test::emit_event --sender-account {default} --args 10u64"
Expand Down
4 changes: 3 additions & 1 deletion dashboard/src/@core/components/card-snippet/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ const CardSnippet = (props: CardSnippetProps) => {
onChange={(e, newValue) => (newValue !== null ? setTabValue(newValue) : null)}
>
{codes.map((v, i) => (
<ToggleButton value={i}>{v.lng}</ToggleButton>
<ToggleButton key={v.lng} value={i}>
{v.lng}
</ToggleButton>
))}
</ToggleButtonGroup>
</Box>
Expand Down
Loading

0 comments on commit 5928176

Please sign in to comment.