Skip to content

Commit

Permalink
refactor: Add logging and improve readability in sending transaction …
Browse files Browse the repository at this point in the history
…and extrinsic building functions
  • Loading branch information
S0c5 committed May 1, 2024
1 parent ccf63d7 commit 061f8a1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
9 changes: 6 additions & 3 deletions sube/examples/send_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use anyhow::{anyhow, Result};

#[async_std::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
env_logger::init();
let phrase = env::args().skip(1).collect::<Vec<_>>().join(" ");

let (vault, phrase) = if phrase.is_empty() {
Expand All @@ -30,15 +31,17 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {

let account = wallet.default_account();
let public = account.unwrap().public();
let public_hex = public.as_ref();
println!("hex: {}", hex::encode(public_hex));

let response = sube!("wss://rococo-rpc.polkadot.io/balances/transfer" => {
let response = sube!("wss://kreivo.io/balances/transfer_keep_alive" => {
signer: async |message: &[u8]| Ok(wallet.sign(message).await.expect("hello").as_bytes()) ,
sender: public.as_ref(),
body: json!({
"dest": {
"Id": public.as_ref()
"Id": hex::decode("e25b1e3758a5fbedb956b36113252f9e866d3ece688364cc9d34eb01f4b2125d").unwrap()
},
"value": 100000
"value": 1000000000
}),
})
.await
Expand Down
22 changes: 19 additions & 3 deletions sube/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ use serde_json::json;
#[cfg(feature = "builder")]
pub use paste::paste;

use crate::util::to_camel;
use crate::{meta::Registry, util::to_camel};

mod prelude {
pub use alloc::boxed::Box;
Expand Down Expand Up @@ -208,7 +208,7 @@ where
.ok_or_else(|| Error::PalletNotFound(pallet))?;

let reg = &meta.types;

let ty = pallet.calls().expect("pallet does not have calls").ty.id;

let mut encoded_call = vec![pallet.index];
Expand Down Expand Up @@ -266,10 +266,26 @@ where
hex::encode([Compact(era).encode(), Compact(nonce).encode(), Compact(tip).encode()].concat());

log::info!("extra_params_hex: {}", extra_params_hex);
let extensions = ();


// vec![0x00u8] sign extensions
// TODO: implement signed extensions
// meta.extrinsic.signed_extensions.iter().for_each(|ext| {
// log::info!("signed extension: {:?}", ext);
// let type_resolved = meta.types.resolve(ext.ty.id);
// log::info!("type_resolved: {:?}", type_resolved);
// log::info!("========================");
// });

[vec![era], Compact(nonce).encode(), Compact(tip).encode()].concat()
[
vec![era], Compact(nonce).encode(), Compact(tip).encode(), vec![0x00u8]
].concat()
};


log::info!("Hex {:?}", hex::encode(&extra_params));

let additional_params = {
let metadata = meta;

Expand Down

0 comments on commit 061f8a1

Please sign in to comment.