Skip to content

Commit

Permalink
Feature owen sdk ts rooch client (#671)
Browse files Browse the repository at this point in the history
* add keypair && enable eslint && wrapper rooch-client

* feat: fix lint error

* feat: refactor sdk struct

* feat: test mock fetch

* feat: test json rpc provider

* feat: ok for mock jsonrpc resp

* feat: update json rpc test

* feat: update encode

* feat: create account

* feat: ok for call function and view function

* feat: remove rooch client

* feat: remove console.log

* feat: fmt code

* feat: reset dev addresses

* feat: update pnpm-lock

* feat: add rooch server for test

* feat: fmt sdk & lint sdk

* feat: debug callFunction

* feat: fix lint error

* feat: debug call function

* feat: fix sdk build error

---------

Co-authored-by: sven Tan <[email protected]>
  • Loading branch information
yubing744 and wow-sven authored Aug 24, 2023
1 parent bae607e commit f70e066
Show file tree
Hide file tree
Showing 55 changed files with 2,220 additions and 650 deletions.
4 changes: 4 additions & 0 deletions crates/rooch-rpc-server/src/server/rooch_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use rooch_rpc_api::{
use rooch_types::transaction::rooch::RoochTransaction;
use rooch_types::transaction::{AbstractTransaction, TypedTransaction};
use std::cmp::min;
use tracing::info;

pub struct RoochServer {
rpc_service: RpcService,
Expand All @@ -35,7 +36,10 @@ impl RoochServer {
#[async_trait]
impl RoochAPIServer for RoochServer {
async fn send_raw_transaction(&self, payload: StrView<Vec<u8>>) -> RpcResult<H256View> {
info!("send_raw_transaction payload: {:?}", payload);
let tx = bcs::from_bytes::<RoochTransaction>(&payload.0).map_err(anyhow::Error::from)?;
info!("send_raw_transaction tx: {:?}", tx);

let hash = tx.tx_hash();
self.rpc_service
.quene_tx(TypedTransaction::Rooch(tx))
Expand Down
4 changes: 3 additions & 1 deletion crates/rooch/src/commands/abi/commands/export_rooch_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use move_core_types::{
};
use moveos_types::transaction::MoveAction;
use rooch_types::error::RoochResult;
use rooch_types::transaction::rooch::RoochTransaction;
use serde_reflection::{Samples, Tracer, TracerConfig};
use std::fmt::Debug;
use std::fs;
Expand Down Expand Up @@ -77,12 +78,13 @@ fn export_rooch_types_yaml(file_path: &String) -> RoochResult<()> {
.trace_value(&mut samples, &example_struct_tag)
.unwrap();

let example_type_tag = TypeTag::Struct(Box::new(example_struct_tag));
let example_type_tag: TypeTag = TypeTag::Struct(Box::new(example_struct_tag));
tracer.trace_value(&mut samples, &example_type_tag).unwrap();

// Define TypeTag and MoveAction
tracer.trace_type::<TypeTag>(&samples).unwrap();
tracer.trace_type::<MoveAction>(&samples).unwrap();
tracer.trace_type::<RoochTransaction>(&samples).unwrap();

match tracer.registry() {
Ok(registry) => {
Expand Down
13 changes: 8 additions & 5 deletions sdk/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,17 @@
"@iarna/toml": "^2.2.5",
"@size-limit/preset-small-lib": "^8.2.4",
"@types/isomorphic-fetch": "^0.0.36",
"@typescript-eslint/eslint-plugin": "^6.3.0",
"@typescript-eslint/parser": "^6.3.0",
"@types/node": "^18.15.11",
"@types/ws": "^8.5.5",
"@typescript-eslint/eslint-plugin": "^6.3.0",
"@typescript-eslint/parser": "^6.3.0",
"commander": "^11.0.0",
"eslint": "8.23.0",
"eslint-config-airbnb-base": "15.0.0",
"eslint-config-airbnb-typescript": "17.0.0",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-import": "2.26.0",
"jest-fetch-mock": "^3.0.3",
"msw": "^1.2.1",
"prettier": "^3.0.0",
"ts-retry-promise": "^0.7.0",
Expand All @@ -80,8 +81,10 @@
"vite": "^4.2.3",
"vite-plugin-dts": "^3.3.1",
"vite-plugin-node-polyfills": "^0.9.0",
"vitest": "^0.32.0",
"wait-on": "^7.0.1"
"vitest": "^0.34.1",
"wait-on": "^7.0.1",
"ejs": "^3.1.9",
"fetch-mock": "^9.11.0"
},
"dependencies": {
"@kayahr/text-encoding": "^1.2.0",
Expand All @@ -91,8 +94,8 @@
"@suchipi/femver": "^1.0.0",
"@types/isomorphic-fetch": "^0.0.36",
"@types/ws": "^8.5.5",
"ejs": "^3.1.9",
"events": "^3.3.0",
"isomorphic-fetch": "^3.0.0",
"superstruct": "^1.0.3",
"tweetnacl": "^1.0.3"
}
Expand Down
Loading

0 comments on commit f70e066

Please sign in to comment.