sidan_csl_rs/wasm/
transaction.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use crate::{
    core::utils::{calculate_tx_hash, sign_transaction},
    *,
};

use model::JsVecString;
use wasm::WasmResult;

#[wasm_bindgen]
pub fn js_calculate_tx_hash(tx_hex: &str) -> WasmResult {
    let result = calculate_tx_hash(tx_hex);
    WasmResult::from_result(result)
}

#[wasm_bindgen]
pub fn js_sign_transaction(tx_hex: String, signing_keys: JsVecString) -> WasmResult {
    let result = sign_transaction(
        &tx_hex,
        signing_keys
            .iter()
            .map(|x| x.as_str())
            .collect::<Vec<&str>>()
            .as_slice(),
    );
    WasmResult::from_result(result)
}