diff --git a/.github/workflows/client.yml b/.github/workflows/client.yml index 91c2a1c..a2c9fe2 100644 --- a/.github/workflows/client.yml +++ b/.github/workflows/client.yml @@ -29,6 +29,12 @@ jobs: with: command: build args: --release --all-features + - name: Wasm pack installation + uses: jetli/wasm-pack-action@v0.3.0 + with: + version: 'latest' + - name: Wasm pack build + run: wasm-pack build --target web lints: name: Lints (fmt + clippy) runs-on: ubuntu-latest diff --git a/.github/workflows/js-helpers.yml b/.github/workflows/js-helpers.yml index dbb382e..0026bbf 100644 --- a/.github/workflows/js-helpers.yml +++ b/.github/workflows/js-helpers.yml @@ -29,6 +29,12 @@ jobs: with: command: build args: --release --all-features + - name: Wasm pack installation + uses: jetli/wasm-pack-action@v0.3.0 + with: + version: 'latest' + - name: Wasm pack build + run: wasm-pack build --target web lints: name: Lints (fmt + clippy) runs-on: ubuntu-latest diff --git a/.github/workflows/wallet.yml b/.github/workflows/wallet.yml index b359361..38f12ad 100644 --- a/.github/workflows/wallet.yml +++ b/.github/workflows/wallet.yml @@ -29,6 +29,12 @@ jobs: with: command: build args: --release --all-features + - name: Wasm build + uses: jetli/wasm-pack-action@v0.3.0 + with: + version: 'latest' + - name: Wasm pack build + run: wasm-pack build --target web lints: name: Lints (fmt + clippy) runs-on: ubuntu-latest diff --git a/Cargo.toml b/Cargo.toml index fa044a1..6c06b6c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,4 +22,4 @@ debug = false debug-assertions = false [patch.crates-io] -cosmos-sdk-proto = { git = "https://github.com/forbole/cosmos-rust", branch = "main"} +cosmos-sdk-proto = { git = "https://github.com/forbole/cosmos-rust", branch = "grpc-web-clients-generation"} diff --git a/modules/js-helpers/Cargo.toml b/modules/js-helpers/Cargo.toml index 84308f8..56f4605 100644 --- a/modules/js-helpers/Cargo.toml +++ b/modules/js-helpers/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "crw-js-helpers" -version = "0.1.0" +version = "0.1.1" authors = ["bragaz Result .into(); Ok(JsValue::from_serde(&wallet).unwrap()) + + } #[cfg(test)] @@ -75,6 +78,7 @@ mod test { use crate::signer::import_wallet; use crw_wallet::crypto::WalletJs; use wasm_bindgen_test::*; + wasm_bindgen_test_configure!(run_in_browser); #[wasm_bindgen_test] async fn import_wallet_works() { @@ -87,11 +91,12 @@ mod test { let wallet_js: WalletJs = js_wallet.into_serde().unwrap(); assert_eq!( - wallet_js.bech32_address, + wallet_js.bech32_address.as_str(), "desmos1k8u92hx3k33a5vgppkyzq6m4frxx7ewnlkyjrh" ); + assert_eq!( - wallet_js.public_key, + wallet_js.public_key.as_str(), "02f5bf794ef934cb419bb9113f3a94c723ec6c2881a8d99eef851fd05b61ad698d" ) } diff --git a/packages/crw-client/Cargo.toml b/packages/crw-client/Cargo.toml index d601ee1..141b6a9 100644 --- a/packages/crw-client/Cargo.toml +++ b/packages/crw-client/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "crw-client" -version = "0.1.0" +version = "0.1.1" authors = ["bragaz Result { - // TODO move this externally to create it one time only - // Create channel connection to the gRPC server - let channel = Channel::builder(self.grpc_addr.parse::().unwrap()) - .connect() - .await - .map_err(|err| Error::Grpc(err.to_string()))?; - // Create gRPC query auth client from channel - let mut client = QueryClient::new(channel); + let client = Query::new(self.grpc_addr.clone()); // Build a new request - let request = Request::new(QueryAccountRequest { address }); + let request = QueryAccountRequest { address }; // Send request and wait for response let response = client .account(request) .await - .map_err(|err| Error::Grpc(err.to_string()))? - .into_inner(); + .map_err(|err| Error::Grpc(err.to_string()))?; // Decode response body into BaseAccount let base_account: BaseAccount = @@ -76,14 +67,8 @@ impl ChainClient { tx_bytes: Vec, broadcast_mode: BroadcastMode, ) -> Result { - // Create channel connection to the gRPC server - let channel = Channel::builder(self.grpc_addr.parse::().unwrap()) - .connect() - .await - .map_err(|err| Error::Grpc(err.to_string()))?; - // Create gRPC tx client from channel - let mut tx_client = ServiceClient::new(channel); + let tx_client = Service::new(self.grpc_addr.clone()); let mode = match broadcast_mode { BroadcastMode::Unspecified => 0, @@ -92,13 +77,12 @@ impl ChainClient { BroadcastMode::Async => 3, }; - let request = Request::new(BroadcastTxRequest { tx_bytes, mode }); + let request = BroadcastTxRequest { tx_bytes, mode }; let tx_response = tx_client .broadcast_tx(request) .await .map_err(|err| Error::Grpc(err.to_string()))? - .into_inner() .tx_response .unwrap(); diff --git a/packages/crw-types/Cargo.toml b/packages/crw-types/Cargo.toml index 7a07183..f5608e6 100644 --- a/packages/crw-types/Cargo.toml +++ b/packages/crw-types/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "crw-types" -version = "0.1.0" +version = "0.1.1" authors = ["bragaz , +} + +impl From for Any { + fn from(any_wrap: AnyWrapper) -> Any { + Any { + type_url: any_wrap.type_url, + value: any_wrap.value, + } + } +} + +impl From for Fee { + fn from(any_wrap: AnyWrapper) -> Fee { + prost::Message::decode(any_wrap.value.as_slice()).unwrap() + } +} diff --git a/packages/crw-types/src/lib.rs b/packages/crw-types/src/lib.rs index a968ed1..5abbe89 100644 --- a/packages/crw-types/src/lib.rs +++ b/packages/crw-types/src/lib.rs @@ -1,2 +1,3 @@ +pub mod any_wrapper; pub mod error; pub mod msg; diff --git a/packages/crw-types/src/msg.rs b/packages/crw-types/src/msg.rs index ed3e3f7..ba9542b 100644 --- a/packages/crw-types/src/msg.rs +++ b/packages/crw-types/src/msg.rs @@ -1,12 +1,5 @@ //! Transaction Message representation use prost_types::Any; -use serde::{Deserialize, Serialize}; - -#[derive(Serialize, Deserialize)] -pub struct AnyWrapper { - pub type_url: String, - pub value: Vec, -} /// Transaction message wrapper pub struct Msg(pub Any); @@ -31,12 +24,3 @@ impl From for Any { msg.0 } } - -impl From for Any { - fn from(any_wrap: AnyWrapper) -> Any { - Any { - type_url: any_wrap.type_url, - value: any_wrap.value, - } - } -} diff --git a/packages/crw-wallet/Cargo.toml b/packages/crw-wallet/Cargo.toml index 8d3cc5c..ff80f05 100644 --- a/packages/crw-wallet/Cargo.toml +++ b/packages/crw-wallet/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "crw-wallet" -version = "0.1.0" +version = "0.1.1" authors = ["bragaz