feat: Add WASM support and browser extension infrastructure

- Add WASM build target and dependencies for all crates.
- Implement IndexedDB-based persistent storage for WASM.
- Create browser extension infrastructure (UI, scripting, etc.).
- Integrate Rhai scripting engine for secure automation.
- Implement user stories and documentation for the extension.
This commit is contained in:
2025-05-16 15:31:53 +03:00
parent 19f46d6edb
commit 13945a8725
25 changed files with 672 additions and 183 deletions

View File

@@ -1,17 +1,20 @@
use evm_client::provider::Transaction;
use evm_client::provider::{parse_signature_rs_v, get_balance};
use ethers_core::types::{Address, U256};
// This file contains native-only integration tests for EVM client balance and signing logic.
// All code is strictly separated from WASM code using cfg attributes.
#[cfg(not(target_arch = "wasm32"))]
mod native_tests {
use super::*;
use vault::{SessionManager, KeyType};
use tempfile::TempDir;
use kvstore::native::NativeStore;
use alloy_primitives::keccak256;
#[tokio::test]
async fn test_vault_sessionmanager_balance_for_new_keypair() {
use ethers_core::types::{Address, U256};
use evm_client::provider::get_balance;
let tmp_dir = TempDir::new().expect("create temp dir");
let store = NativeStore::open(tmp_dir.path().to_str().unwrap()).expect("Failed to open native store");
let mut vault = vault::Vault::new(store.clone());
@@ -40,11 +43,13 @@ mod native_tests {
}
}
use ethers_core::types::Bytes;
use ethers_core::types::Bytes;
#[test]
fn test_rlp_encode_unsigned() {
fn test_rlp_encode_unsigned() {
use ethers_core::types::{Address, U256, Bytes};
use evm_client::provider::Transaction;
let tx = Transaction {
nonce: U256::from(1),
to: Address::zero(),
@@ -59,7 +64,10 @@ fn test_rlp_encode_unsigned() {
}
#[test]
fn test_parse_signature_rs_v() {
fn test_parse_signature_rs_v() {
use ethers_core::types::U256;
use evm_client::provider::parse_signature_rs_v;
let mut sig = [0u8; 65];
sig[31] = 1; sig[63] = 2; sig[64] = 27;
let (r, s, v) = parse_signature_rs_v(&sig, 1).unwrap();
@@ -70,7 +78,10 @@ fn test_parse_signature_rs_v() {
#[cfg(not(target_arch = "wasm32"))]
#[tokio::test]
async fn test_get_balance_real_address() {
async fn test_get_balance_real_address() {
use ethers_core::types::{Address, U256};
use evm_client::provider::get_balance;
// Vitalik's address
let address = "d8dA6BF26964aF9D7eEd9e03E53415D37aA96045";
let address = ethers_core::types::Address::from_slice(&hex::decode(address).unwrap());

View File

@@ -1,3 +1,5 @@
// This file contains WASM-only integration tests for EVM client balance and signing logic.
// All code is strictly separated from native using cfg attributes.
#![cfg(target_arch = "wasm32")]
use wasm_bindgen_test::*;
wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);