From 6e2c380c5345716431d63b2f5b393219af5e1c45 Mon Sep 17 00:00:00 2001 From: smartgoo Date: Sat, 16 Nov 2024 08:32:40 -0500 Subject: [PATCH] Bindings dirs (#124) * bindings dir for python * rpc/wrpc/wasm -> rpc/wrpc/bindings/wasm * wallet/core/src/wasm -> wallet/core/src/bindings/wasm/ * crypto/txscript/src/wasm -> crypto/txscript/src/bindings/wasm * rpc/core/src/wasm -> rpc/core/src/bindings/wasm --- Cargo.toml | 8 ++--- crypto/txscript/src/bindings/mod.rs | 7 ++++ .../src/{wasm => bindings}/opcodes.rs | 0 .../src/{ => bindings}/python/builder.rs | 2 +- crypto/txscript/src/bindings/python/mod.rs | 2 ++ .../src/{ => bindings}/wasm/builder.rs | 0 .../txscript/src/{ => bindings}/wasm/mod.rs | 6 ++-- crypto/txscript/src/lib.rs | 6 ++-- crypto/txscript/src/python/mod.rs | 9 ----- python/src/lib.rs | 34 +++++++++---------- rpc/core/src/bindings/mod.rs | 5 +++ .../src/{ => bindings}/python/messages.rs | 0 rpc/core/src/{ => bindings}/python/mod.rs | 0 rpc/core/src/{ => bindings}/wasm/convert.rs | 0 rpc/core/src/{ => bindings}/wasm/message.rs | 0 rpc/core/src/{ => bindings}/wasm/mod.rs | 0 rpc/core/src/lib.rs | 6 ++-- rpc/wrpc/{ => bindings}/python/Cargo.toml | 0 rpc/wrpc/{ => bindings}/python/src/client.rs | 0 rpc/wrpc/{ => bindings}/python/src/lib.rs | 0 .../{ => bindings}/python/src/resolver.rs | 0 rpc/wrpc/{ => bindings}/wasm/.gitignore | 0 rpc/wrpc/{ => bindings}/wasm/Cargo.toml | 0 rpc/wrpc/{ => bindings}/wasm/build-node | 0 rpc/wrpc/{ => bindings}/wasm/build-web | 0 rpc/wrpc/{ => bindings}/wasm/nodejs/index.js | 0 .../{ => bindings}/wasm/nodejs/package.json | 0 rpc/wrpc/{ => bindings}/wasm/src/client.rs | 2 +- rpc/wrpc/{ => bindings}/wasm/src/imports.rs | 0 rpc/wrpc/{ => bindings}/wasm/src/lib.rs | 0 rpc/wrpc/{ => bindings}/wasm/src/notify.rs | 0 rpc/wrpc/{ => bindings}/wasm/src/resolver.rs | 0 rpc/wrpc/{ => bindings}/wasm/web/index.html | 0 wallet/core/src/bindings/mod.rs | 5 +++ .../core/src/{ => bindings}/python/message.rs | 0 wallet/core/src/{ => bindings}/python/mod.rs | 0 .../core/src/{ => bindings}/python/signer.rs | 2 +- .../python/tx/generator/generator.rs | 4 +-- .../{ => bindings}/python/tx/generator/mod.rs | 0 .../python/tx/generator/pending.rs | 0 .../python/tx/generator/summary.rs | 0 .../core/src/{ => bindings}/python/tx/mass.rs | 0 .../core/src/{ => bindings}/python/tx/mod.rs | 0 .../src/{ => bindings}/python/tx/utils.rs | 2 +- .../core/src/{ => bindings}/python/utils.rs | 0 .../src/{ => bindings}/wasm/api/extensions.rs | 0 .../src/{ => bindings}/wasm/api/message.rs | 4 +-- .../core/src/{ => bindings}/wasm/api/mod.rs | 0 .../core/src/{ => bindings}/wasm/balance.rs | 0 .../core/src/{ => bindings}/wasm/cryptobox.rs | 0 .../src/{ => bindings}/wasm/encryption.rs | 0 wallet/core/src/{ => bindings}/wasm/events.rs | 0 .../core/src/{ => bindings}/wasm/message.rs | 0 wallet/core/src/{ => bindings}/wasm/mod.rs | 0 wallet/core/src/{ => bindings}/wasm/notify.rs | 0 wallet/core/src/{ => bindings}/wasm/signer.rs | 0 .../core/src/{ => bindings}/wasm/tx/fees.rs | 0 .../wasm/tx/generator/generator.rs | 6 ++-- .../{ => bindings}/wasm/tx/generator/mod.rs | 0 .../wasm/tx/generator/pending.rs | 2 +- .../wasm/tx/generator/summary.rs | 0 .../core/src/{ => bindings}/wasm/tx/mass.rs | 0 wallet/core/src/{ => bindings}/wasm/tx/mod.rs | 0 .../core/src/{ => bindings}/wasm/tx/utils.rs | 2 +- wallet/core/src/{ => bindings}/wasm/utils.rs | 0 .../src/{ => bindings}/wasm/utxo/context.rs | 4 +-- .../core/src/{ => bindings}/wasm/utxo/mod.rs | 0 .../src/{ => bindings}/wasm/utxo/processor.rs | 4 ++- .../src/{ => bindings}/wasm/wallet/keydata.rs | 0 .../src/{ => bindings}/wasm/wallet/mod.rs | 0 .../src/{ => bindings}/wasm/wallet/storage.rs | 0 .../src/{ => bindings}/wasm/wallet/wallet.rs | 2 +- wallet/core/src/lib.rs | 7 ++-- wasm/src/lib.rs | 16 ++++----- 74 files changed, 76 insertions(+), 71 deletions(-) create mode 100644 crypto/txscript/src/bindings/mod.rs rename crypto/txscript/src/{wasm => bindings}/opcodes.rs (100%) rename crypto/txscript/src/{ => bindings}/python/builder.rs (99%) create mode 100644 crypto/txscript/src/bindings/python/mod.rs rename crypto/txscript/src/{ => bindings}/wasm/builder.rs (100%) rename crypto/txscript/src/{ => bindings}/wasm/mod.rs (65%) delete mode 100644 crypto/txscript/src/python/mod.rs create mode 100644 rpc/core/src/bindings/mod.rs rename rpc/core/src/{ => bindings}/python/messages.rs (100%) rename rpc/core/src/{ => bindings}/python/mod.rs (100%) rename rpc/core/src/{ => bindings}/wasm/convert.rs (100%) rename rpc/core/src/{ => bindings}/wasm/message.rs (100%) rename rpc/core/src/{ => bindings}/wasm/mod.rs (100%) rename rpc/wrpc/{ => bindings}/python/Cargo.toml (100%) rename rpc/wrpc/{ => bindings}/python/src/client.rs (100%) rename rpc/wrpc/{ => bindings}/python/src/lib.rs (100%) rename rpc/wrpc/{ => bindings}/python/src/resolver.rs (100%) rename rpc/wrpc/{ => bindings}/wasm/.gitignore (100%) rename rpc/wrpc/{ => bindings}/wasm/Cargo.toml (100%) rename rpc/wrpc/{ => bindings}/wasm/build-node (100%) rename rpc/wrpc/{ => bindings}/wasm/build-web (100%) rename rpc/wrpc/{ => bindings}/wasm/nodejs/index.js (100%) rename rpc/wrpc/{ => bindings}/wasm/nodejs/package.json (100%) rename rpc/wrpc/{ => bindings}/wasm/src/client.rs (99%) rename rpc/wrpc/{ => bindings}/wasm/src/imports.rs (100%) rename rpc/wrpc/{ => bindings}/wasm/src/lib.rs (100%) rename rpc/wrpc/{ => bindings}/wasm/src/notify.rs (100%) rename rpc/wrpc/{ => bindings}/wasm/src/resolver.rs (100%) rename rpc/wrpc/{ => bindings}/wasm/web/index.html (100%) create mode 100644 wallet/core/src/bindings/mod.rs rename wallet/core/src/{ => bindings}/python/message.rs (100%) rename wallet/core/src/{ => bindings}/python/mod.rs (100%) rename wallet/core/src/{ => bindings}/python/signer.rs (96%) rename wallet/core/src/{ => bindings}/python/tx/generator/generator.rs (98%) rename wallet/core/src/{ => bindings}/python/tx/generator/mod.rs (100%) rename wallet/core/src/{ => bindings}/python/tx/generator/pending.rs (100%) rename wallet/core/src/{ => bindings}/python/tx/generator/summary.rs (100%) rename wallet/core/src/{ => bindings}/python/tx/mass.rs (100%) rename wallet/core/src/{ => bindings}/python/tx/mod.rs (100%) rename wallet/core/src/{ => bindings}/python/tx/utils.rs (96%) rename wallet/core/src/{ => bindings}/python/utils.rs (100%) rename wallet/core/src/{ => bindings}/wasm/api/extensions.rs (100%) rename wallet/core/src/{ => bindings}/wasm/api/message.rs (99%) rename wallet/core/src/{ => bindings}/wasm/api/mod.rs (100%) rename wallet/core/src/{ => bindings}/wasm/balance.rs (100%) rename wallet/core/src/{ => bindings}/wasm/cryptobox.rs (100%) rename wallet/core/src/{ => bindings}/wasm/encryption.rs (100%) rename wallet/core/src/{ => bindings}/wasm/events.rs (100%) rename wallet/core/src/{ => bindings}/wasm/message.rs (100%) rename wallet/core/src/{ => bindings}/wasm/mod.rs (100%) rename wallet/core/src/{ => bindings}/wasm/notify.rs (100%) rename wallet/core/src/{ => bindings}/wasm/signer.rs (100%) rename wallet/core/src/{ => bindings}/wasm/tx/fees.rs (100%) rename wallet/core/src/{ => bindings}/wasm/tx/generator/generator.rs (98%) rename wallet/core/src/{ => bindings}/wasm/tx/generator/mod.rs (100%) rename wallet/core/src/{ => bindings}/wasm/tx/generator/pending.rs (99%) rename wallet/core/src/{ => bindings}/wasm/tx/generator/summary.rs (100%) rename wallet/core/src/{ => bindings}/wasm/tx/mass.rs (100%) rename wallet/core/src/{ => bindings}/wasm/tx/mod.rs (100%) rename wallet/core/src/{ => bindings}/wasm/tx/utils.rs (99%) rename wallet/core/src/{ => bindings}/wasm/utils.rs (100%) rename wallet/core/src/{ => bindings}/wasm/utxo/context.rs (99%) rename wallet/core/src/{ => bindings}/wasm/utxo/mod.rs (100%) rename wallet/core/src/{ => bindings}/wasm/utxo/processor.rs (98%) rename wallet/core/src/{ => bindings}/wasm/wallet/keydata.rs (100%) rename wallet/core/src/{ => bindings}/wasm/wallet/mod.rs (100%) rename wallet/core/src/{ => bindings}/wasm/wallet/storage.rs (100%) rename wallet/core/src/{ => bindings}/wasm/wallet/wallet.rs (98%) diff --git a/Cargo.toml b/Cargo.toml index bdf2e8ca53..f25c2e01d0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -39,8 +39,8 @@ members = [ "rpc/wrpc/server", "rpc/wrpc/client", "rpc/wrpc/proxy", - "rpc/wrpc/python", - "rpc/wrpc/wasm", + "rpc/wrpc/bindings/python", + "rpc/wrpc/bindings/wasm", "rpc/wrpc/examples/subscriber", "rpc/wrpc/examples/simple_client", "mining", @@ -137,9 +137,9 @@ kaspa-wasm = { version = "0.15.2", path = "wasm" } kaspa-wasm-core = { version = "0.15.2", path = "wasm/core" } kaspa-wrpc-client = { version = "0.15.2", path = "rpc/wrpc/client" } kaspa-wrpc-proxy = { version = "0.15.2", path = "rpc/wrpc/proxy" } -kaspa-wrpc-python = { version = "0.15.2", path = "rpc/wrpc/python" } +kaspa-wrpc-python = { version = "0.15.2", path = "rpc/wrpc/bindings/python" } kaspa-wrpc-server = { version = "0.15.2", path = "rpc/wrpc/server" } -kaspa-wrpc-wasm = { version = "0.15.2", path = "rpc/wrpc/wasm" } +kaspa-wrpc-wasm = { version = "0.15.2", path = "rpc/wrpc/bindings/wasm" } kaspa-wrpc-example-subscriber = { version = "0.15.2", path = "rpc/wrpc/examples/subscriber" } kaspad = { version = "0.15.2", path = "kaspad" } kaspa-alloc = { version = "0.15.2", path = "utils/alloc" } diff --git a/crypto/txscript/src/bindings/mod.rs b/crypto/txscript/src/bindings/mod.rs new file mode 100644 index 0000000000..7c0cb4800f --- /dev/null +++ b/crypto/txscript/src/bindings/mod.rs @@ -0,0 +1,7 @@ +pub mod opcodes; + +#[cfg(feature = "py-sdk")] +pub mod python; + +#[cfg(any(feature = "wasm32-core", feature = "wasm32-sdk"))] +pub mod wasm; diff --git a/crypto/txscript/src/wasm/opcodes.rs b/crypto/txscript/src/bindings/opcodes.rs similarity index 100% rename from crypto/txscript/src/wasm/opcodes.rs rename to crypto/txscript/src/bindings/opcodes.rs diff --git a/crypto/txscript/src/python/builder.rs b/crypto/txscript/src/bindings/python/builder.rs similarity index 99% rename from crypto/txscript/src/python/builder.rs rename to crypto/txscript/src/bindings/python/builder.rs index 3cdc24f9ae..a612fa783d 100644 --- a/crypto/txscript/src/python/builder.rs +++ b/crypto/txscript/src/bindings/python/builder.rs @@ -1,4 +1,4 @@ -use crate::wasm::opcodes::Opcodes; +use crate::bindings::opcodes::Opcodes; use crate::{script_builder as native, standard}; use kaspa_consensus_core::tx::ScriptPublicKey; use kaspa_python_core::types::PyBinary; diff --git a/crypto/txscript/src/bindings/python/mod.rs b/crypto/txscript/src/bindings/python/mod.rs new file mode 100644 index 0000000000..d3fddd29c9 --- /dev/null +++ b/crypto/txscript/src/bindings/python/mod.rs @@ -0,0 +1,2 @@ +pub mod builder; +pub use self::builder::*; diff --git a/crypto/txscript/src/wasm/builder.rs b/crypto/txscript/src/bindings/wasm/builder.rs similarity index 100% rename from crypto/txscript/src/wasm/builder.rs rename to crypto/txscript/src/bindings/wasm/builder.rs diff --git a/crypto/txscript/src/wasm/mod.rs b/crypto/txscript/src/bindings/wasm/mod.rs similarity index 65% rename from crypto/txscript/src/wasm/mod.rs rename to crypto/txscript/src/bindings/wasm/mod.rs index 0d293916fc..849efad492 100644 --- a/crypto/txscript/src/wasm/mod.rs +++ b/crypto/txscript/src/bindings/wasm/mod.rs @@ -6,12 +6,10 @@ use cfg_if::cfg_if; cfg_if! { if #[cfg(any(feature = "wasm32-sdk", feature = "wasm32-core"))] { - pub mod opcodes; + // pub mod opcodes; pub mod builder; - pub use self::opcodes::*; + pub use crate::bindings::opcodes::*; pub use self::builder::*; - } else if #[cfg(feature = "py-sdk")] { - pub mod opcodes; } } diff --git a/crypto/txscript/src/lib.rs b/crypto/txscript/src/lib.rs index 50f19bc848..0978222926 100644 --- a/crypto/txscript/src/lib.rs +++ b/crypto/txscript/src/lib.rs @@ -1,18 +1,16 @@ extern crate alloc; extern crate core; +#[cfg(any(feature = "wasm32-sdk", feature = "py-sdk", feature = "py-sdk"))] +pub mod bindings; pub mod caches; mod data_stack; pub mod error; pub mod opcodes; -#[cfg(feature = "py-sdk")] -pub mod python; pub mod result; pub mod script_builder; pub mod script_class; pub mod standard; -#[cfg(any(feature = "wasm32-sdk", feature = "py-sdk"))] -pub mod wasm; use crate::caches::Cache; use crate::data_stack::{DataStack, Stack}; diff --git a/crypto/txscript/src/python/mod.rs b/crypto/txscript/src/python/mod.rs deleted file mode 100644 index 480725c727..0000000000 --- a/crypto/txscript/src/python/mod.rs +++ /dev/null @@ -1,9 +0,0 @@ -use cfg_if::cfg_if; - -cfg_if! { - if #[cfg(feature = "py-sdk")] { - pub mod builder; - - pub use self::builder::*; - } -} diff --git a/python/src/lib.rs b/python/src/lib.rs index 88e71b42ac..be1d4a6124 100644 --- a/python/src/lib.rs +++ b/python/src/lib.rs @@ -29,24 +29,24 @@ cfg_if::cfg_if! { m.add_class::()?; m.add_class::()?; - m.add_class::()?; - m.add_class::()?; + m.add_class::()?; + m.add_class::()?; - m.add_function(wrap_pyfunction!(kaspa_wallet_core::python::message::py_sign_message, m)?)?; - m.add_function(wrap_pyfunction!(kaspa_wallet_core::python::message::py_verify_message, m)?)?; - m.add_function(wrap_pyfunction!(kaspa_wallet_core::python::signer::py_sign_transaction, m)?)?; - m.add_class::()?; - m.add_class::()?; - m.add_class::()?; - m.add_function(wrap_pyfunction!(kaspa_wallet_core::python::tx::mass::calculate_unsigned_transaction_fee, m)?)?; - m.add_function(wrap_pyfunction!(kaspa_wallet_core::python::tx::mass::calculate_unsigned_transaction_mass, m)?)?; - m.add_function(wrap_pyfunction!(kaspa_wallet_core::python::tx::mass::update_unsigned_transaction_mass, m)?)?; - m.add_function(wrap_pyfunction!(kaspa_wallet_core::python::tx::utils::create_transaction_py, m)?)?; - m.add_function(wrap_pyfunction!(kaspa_wallet_core::python::tx::utils::create_transactions_py, m)?)?; - m.add_function(wrap_pyfunction!(kaspa_wallet_core::python::tx::utils::estimate_transactions_py, m)?)?; - m.add_function(wrap_pyfunction!(kaspa_wallet_core::python::utils::kaspa_to_sompi, m)?)?; - m.add_function(wrap_pyfunction!(kaspa_wallet_core::python::utils::sompi_to_kaspa, m)?)?; - m.add_function(wrap_pyfunction!(kaspa_wallet_core::python::utils::sompi_to_kaspa_string_with_suffix, m)?)?; + m.add_function(wrap_pyfunction!(kaspa_wallet_core::bindings::python::message::py_sign_message, m)?)?; + m.add_function(wrap_pyfunction!(kaspa_wallet_core::bindings::python::message::py_verify_message, m)?)?; + m.add_function(wrap_pyfunction!(kaspa_wallet_core::bindings::python::signer::py_sign_transaction, m)?)?; + m.add_class::()?; + m.add_class::()?; + m.add_class::()?; + m.add_function(wrap_pyfunction!(kaspa_wallet_core::bindings::python::tx::mass::calculate_unsigned_transaction_fee, m)?)?; + m.add_function(wrap_pyfunction!(kaspa_wallet_core::bindings::python::tx::mass::calculate_unsigned_transaction_mass, m)?)?; + m.add_function(wrap_pyfunction!(kaspa_wallet_core::bindings::python::tx::mass::update_unsigned_transaction_mass, m)?)?; + m.add_function(wrap_pyfunction!(kaspa_wallet_core::bindings::python::tx::utils::create_transaction_py, m)?)?; + m.add_function(wrap_pyfunction!(kaspa_wallet_core::bindings::python::tx::utils::create_transactions_py, m)?)?; + m.add_function(wrap_pyfunction!(kaspa_wallet_core::bindings::python::tx::utils::estimate_transactions_py, m)?)?; + m.add_function(wrap_pyfunction!(kaspa_wallet_core::bindings::python::utils::kaspa_to_sompi, m)?)?; + m.add_function(wrap_pyfunction!(kaspa_wallet_core::bindings::python::utils::sompi_to_kaspa, m)?)?; + m.add_function(wrap_pyfunction!(kaspa_wallet_core::bindings::python::utils::sompi_to_kaspa_string_with_suffix, m)?)?; m.add_class::()?; m.add_class::()?; diff --git a/rpc/core/src/bindings/mod.rs b/rpc/core/src/bindings/mod.rs new file mode 100644 index 0000000000..b35fa03fb4 --- /dev/null +++ b/rpc/core/src/bindings/mod.rs @@ -0,0 +1,5 @@ +#[cfg(feature = "py-sdk")] +pub mod python; + +#[cfg(feature = "wasm32-sdk")] +pub mod wasm; diff --git a/rpc/core/src/python/messages.rs b/rpc/core/src/bindings/python/messages.rs similarity index 100% rename from rpc/core/src/python/messages.rs rename to rpc/core/src/bindings/python/messages.rs diff --git a/rpc/core/src/python/mod.rs b/rpc/core/src/bindings/python/mod.rs similarity index 100% rename from rpc/core/src/python/mod.rs rename to rpc/core/src/bindings/python/mod.rs diff --git a/rpc/core/src/wasm/convert.rs b/rpc/core/src/bindings/wasm/convert.rs similarity index 100% rename from rpc/core/src/wasm/convert.rs rename to rpc/core/src/bindings/wasm/convert.rs diff --git a/rpc/core/src/wasm/message.rs b/rpc/core/src/bindings/wasm/message.rs similarity index 100% rename from rpc/core/src/wasm/message.rs rename to rpc/core/src/bindings/wasm/message.rs diff --git a/rpc/core/src/wasm/mod.rs b/rpc/core/src/bindings/wasm/mod.rs similarity index 100% rename from rpc/core/src/wasm/mod.rs rename to rpc/core/src/bindings/wasm/mod.rs diff --git a/rpc/core/src/lib.rs b/rpc/core/src/lib.rs index 5cd684b679..4884447342 100644 --- a/rpc/core/src/lib.rs +++ b/rpc/core/src/lib.rs @@ -2,13 +2,13 @@ #![recursion_limit = "256"] pub mod api; +#[cfg(any(feature = "wasm32-sdk", feature = "py-sdk"))] +pub mod bindings; pub mod convert; pub mod error; pub mod model; pub mod notify; -#[cfg(feature = "py-sdk")] -pub mod python; -pub mod wasm; +// pub mod wasm; pub mod prelude { pub use super::api::notifications::*; diff --git a/rpc/wrpc/python/Cargo.toml b/rpc/wrpc/bindings/python/Cargo.toml similarity index 100% rename from rpc/wrpc/python/Cargo.toml rename to rpc/wrpc/bindings/python/Cargo.toml diff --git a/rpc/wrpc/python/src/client.rs b/rpc/wrpc/bindings/python/src/client.rs similarity index 100% rename from rpc/wrpc/python/src/client.rs rename to rpc/wrpc/bindings/python/src/client.rs diff --git a/rpc/wrpc/python/src/lib.rs b/rpc/wrpc/bindings/python/src/lib.rs similarity index 100% rename from rpc/wrpc/python/src/lib.rs rename to rpc/wrpc/bindings/python/src/lib.rs diff --git a/rpc/wrpc/python/src/resolver.rs b/rpc/wrpc/bindings/python/src/resolver.rs similarity index 100% rename from rpc/wrpc/python/src/resolver.rs rename to rpc/wrpc/bindings/python/src/resolver.rs diff --git a/rpc/wrpc/wasm/.gitignore b/rpc/wrpc/bindings/wasm/.gitignore similarity index 100% rename from rpc/wrpc/wasm/.gitignore rename to rpc/wrpc/bindings/wasm/.gitignore diff --git a/rpc/wrpc/wasm/Cargo.toml b/rpc/wrpc/bindings/wasm/Cargo.toml similarity index 100% rename from rpc/wrpc/wasm/Cargo.toml rename to rpc/wrpc/bindings/wasm/Cargo.toml diff --git a/rpc/wrpc/wasm/build-node b/rpc/wrpc/bindings/wasm/build-node similarity index 100% rename from rpc/wrpc/wasm/build-node rename to rpc/wrpc/bindings/wasm/build-node diff --git a/rpc/wrpc/wasm/build-web b/rpc/wrpc/bindings/wasm/build-web similarity index 100% rename from rpc/wrpc/wasm/build-web rename to rpc/wrpc/bindings/wasm/build-web diff --git a/rpc/wrpc/wasm/nodejs/index.js b/rpc/wrpc/bindings/wasm/nodejs/index.js similarity index 100% rename from rpc/wrpc/wasm/nodejs/index.js rename to rpc/wrpc/bindings/wasm/nodejs/index.js diff --git a/rpc/wrpc/wasm/nodejs/package.json b/rpc/wrpc/bindings/wasm/nodejs/package.json similarity index 100% rename from rpc/wrpc/wasm/nodejs/package.json rename to rpc/wrpc/bindings/wasm/nodejs/package.json diff --git a/rpc/wrpc/wasm/src/client.rs b/rpc/wrpc/bindings/wasm/src/client.rs similarity index 99% rename from rpc/wrpc/wasm/src/client.rs rename to rpc/wrpc/bindings/wasm/src/client.rs index 81487172fe..f20cec84d9 100644 --- a/rpc/wrpc/wasm/src/client.rs +++ b/rpc/wrpc/bindings/wasm/src/client.rs @@ -12,7 +12,7 @@ use kaspa_notify::events::EventType; use kaspa_notify::listener; use kaspa_notify::notification::Notification as NotificationT; use kaspa_rpc_core::api::ctl; -pub use kaspa_rpc_core::wasm::message::*; +pub use kaspa_rpc_core::bindings::wasm::message::*; pub use kaspa_rpc_macros::{ build_wrpc_wasm_bindgen_interface, build_wrpc_wasm_bindgen_subscriptions, declare_typescript_wasm_interface as declare, }; diff --git a/rpc/wrpc/wasm/src/imports.rs b/rpc/wrpc/bindings/wasm/src/imports.rs similarity index 100% rename from rpc/wrpc/wasm/src/imports.rs rename to rpc/wrpc/bindings/wasm/src/imports.rs diff --git a/rpc/wrpc/wasm/src/lib.rs b/rpc/wrpc/bindings/wasm/src/lib.rs similarity index 100% rename from rpc/wrpc/wasm/src/lib.rs rename to rpc/wrpc/bindings/wasm/src/lib.rs diff --git a/rpc/wrpc/wasm/src/notify.rs b/rpc/wrpc/bindings/wasm/src/notify.rs similarity index 100% rename from rpc/wrpc/wasm/src/notify.rs rename to rpc/wrpc/bindings/wasm/src/notify.rs diff --git a/rpc/wrpc/wasm/src/resolver.rs b/rpc/wrpc/bindings/wasm/src/resolver.rs similarity index 100% rename from rpc/wrpc/wasm/src/resolver.rs rename to rpc/wrpc/bindings/wasm/src/resolver.rs diff --git a/rpc/wrpc/wasm/web/index.html b/rpc/wrpc/bindings/wasm/web/index.html similarity index 100% rename from rpc/wrpc/wasm/web/index.html rename to rpc/wrpc/bindings/wasm/web/index.html diff --git a/wallet/core/src/bindings/mod.rs b/wallet/core/src/bindings/mod.rs new file mode 100644 index 0000000000..bb1b4185f2 --- /dev/null +++ b/wallet/core/src/bindings/mod.rs @@ -0,0 +1,5 @@ +#[cfg(feature = "py-sdk")] +pub mod python; + +#[cfg(any(feature = "wasm32-sdk", feature = "wasm32-core"))] +pub mod wasm; diff --git a/wallet/core/src/python/message.rs b/wallet/core/src/bindings/python/message.rs similarity index 100% rename from wallet/core/src/python/message.rs rename to wallet/core/src/bindings/python/message.rs diff --git a/wallet/core/src/python/mod.rs b/wallet/core/src/bindings/python/mod.rs similarity index 100% rename from wallet/core/src/python/mod.rs rename to wallet/core/src/bindings/python/mod.rs diff --git a/wallet/core/src/python/signer.rs b/wallet/core/src/bindings/python/signer.rs similarity index 96% rename from wallet/core/src/python/signer.rs rename to wallet/core/src/bindings/python/signer.rs index 6859ff177c..69d92f498a 100644 --- a/wallet/core/src/python/signer.rs +++ b/wallet/core/src/bindings/python/signer.rs @@ -1,5 +1,5 @@ +use crate::bindings::wasm::signer::{sign_hash, sign_transaction}; use crate::imports::*; -use crate::wasm::signer::{sign_hash, sign_transaction}; use kaspa_consensus_client::Transaction; use kaspa_consensus_core::hashing::wasm::SighashType; use kaspa_consensus_core::sign::sign_input; diff --git a/wallet/core/src/python/tx/generator/generator.rs b/wallet/core/src/bindings/python/tx/generator/generator.rs similarity index 98% rename from wallet/core/src/python/tx/generator/generator.rs rename to wallet/core/src/bindings/python/tx/generator/generator.rs index ea9a93d872..b6b64bc923 100644 --- a/wallet/core/src/python/tx/generator/generator.rs +++ b/wallet/core/src/bindings/python/tx/generator/generator.rs @@ -1,6 +1,6 @@ +use crate::bindings::python::tx::generator::pending::PendingTransaction; +use crate::bindings::python::tx::generator::summary::GeneratorSummary; use crate::imports::*; -use crate::python::tx::generator::pending::PendingTransaction; -use crate::python::tx::generator::summary::GeneratorSummary; use crate::tx::{generator as native, Fees, PaymentDestination, PaymentOutput, PaymentOutputs}; pub struct PyUtxoEntries { diff --git a/wallet/core/src/python/tx/generator/mod.rs b/wallet/core/src/bindings/python/tx/generator/mod.rs similarity index 100% rename from wallet/core/src/python/tx/generator/mod.rs rename to wallet/core/src/bindings/python/tx/generator/mod.rs diff --git a/wallet/core/src/python/tx/generator/pending.rs b/wallet/core/src/bindings/python/tx/generator/pending.rs similarity index 100% rename from wallet/core/src/python/tx/generator/pending.rs rename to wallet/core/src/bindings/python/tx/generator/pending.rs diff --git a/wallet/core/src/python/tx/generator/summary.rs b/wallet/core/src/bindings/python/tx/generator/summary.rs similarity index 100% rename from wallet/core/src/python/tx/generator/summary.rs rename to wallet/core/src/bindings/python/tx/generator/summary.rs diff --git a/wallet/core/src/python/tx/mass.rs b/wallet/core/src/bindings/python/tx/mass.rs similarity index 100% rename from wallet/core/src/python/tx/mass.rs rename to wallet/core/src/bindings/python/tx/mass.rs diff --git a/wallet/core/src/python/tx/mod.rs b/wallet/core/src/bindings/python/tx/mod.rs similarity index 100% rename from wallet/core/src/python/tx/mod.rs rename to wallet/core/src/bindings/python/tx/mod.rs diff --git a/wallet/core/src/python/tx/utils.rs b/wallet/core/src/bindings/python/tx/utils.rs similarity index 96% rename from wallet/core/src/python/tx/utils.rs rename to wallet/core/src/bindings/python/tx/utils.rs index a99266a129..88930145ef 100644 --- a/wallet/core/src/python/tx/utils.rs +++ b/wallet/core/src/bindings/python/tx/utils.rs @@ -1,5 +1,5 @@ +use crate::bindings::python::tx::generator::{Generator, GeneratorSummary, PendingTransaction, PyOutputs, PyUtxoEntries}; use crate::imports::*; -use crate::python::tx::generator::{Generator, GeneratorSummary, PendingTransaction, PyOutputs, PyUtxoEntries}; use kaspa_consensus_client::*; use kaspa_consensus_core::subnets::SUBNETWORK_ID_NATIVE; diff --git a/wallet/core/src/python/utils.rs b/wallet/core/src/bindings/python/utils.rs similarity index 100% rename from wallet/core/src/python/utils.rs rename to wallet/core/src/bindings/python/utils.rs diff --git a/wallet/core/src/wasm/api/extensions.rs b/wallet/core/src/bindings/wasm/api/extensions.rs similarity index 100% rename from wallet/core/src/wasm/api/extensions.rs rename to wallet/core/src/bindings/wasm/api/extensions.rs diff --git a/wallet/core/src/wasm/api/message.rs b/wallet/core/src/bindings/wasm/api/message.rs similarity index 99% rename from wallet/core/src/wasm/api/message.rs rename to wallet/core/src/bindings/wasm/api/message.rs index 8a023267b8..befc92aff2 100644 --- a/wallet/core/src/wasm/api/message.rs +++ b/wallet/core/src/bindings/wasm/api/message.rs @@ -3,10 +3,10 @@ use super::extensions::*; use crate::account::descriptor::IAccountDescriptor; use crate::api::message::*; +use crate::bindings::wasm::tx::fees::IFees; +use crate::bindings::wasm::tx::GeneratorSummary; use crate::imports::*; use crate::tx::{Fees, PaymentDestination, PaymentOutputs}; -use crate::wasm::tx::fees::IFees; -use crate::wasm::tx::GeneratorSummary; use js_sys::Array; use serde_wasm_bindgen::from_value; use workflow_wasm::serde::to_value; diff --git a/wallet/core/src/wasm/api/mod.rs b/wallet/core/src/bindings/wasm/api/mod.rs similarity index 100% rename from wallet/core/src/wasm/api/mod.rs rename to wallet/core/src/bindings/wasm/api/mod.rs diff --git a/wallet/core/src/wasm/balance.rs b/wallet/core/src/bindings/wasm/balance.rs similarity index 100% rename from wallet/core/src/wasm/balance.rs rename to wallet/core/src/bindings/wasm/balance.rs diff --git a/wallet/core/src/wasm/cryptobox.rs b/wallet/core/src/bindings/wasm/cryptobox.rs similarity index 100% rename from wallet/core/src/wasm/cryptobox.rs rename to wallet/core/src/bindings/wasm/cryptobox.rs diff --git a/wallet/core/src/wasm/encryption.rs b/wallet/core/src/bindings/wasm/encryption.rs similarity index 100% rename from wallet/core/src/wasm/encryption.rs rename to wallet/core/src/bindings/wasm/encryption.rs diff --git a/wallet/core/src/wasm/events.rs b/wallet/core/src/bindings/wasm/events.rs similarity index 100% rename from wallet/core/src/wasm/events.rs rename to wallet/core/src/bindings/wasm/events.rs diff --git a/wallet/core/src/wasm/message.rs b/wallet/core/src/bindings/wasm/message.rs similarity index 100% rename from wallet/core/src/wasm/message.rs rename to wallet/core/src/bindings/wasm/message.rs diff --git a/wallet/core/src/wasm/mod.rs b/wallet/core/src/bindings/wasm/mod.rs similarity index 100% rename from wallet/core/src/wasm/mod.rs rename to wallet/core/src/bindings/wasm/mod.rs diff --git a/wallet/core/src/wasm/notify.rs b/wallet/core/src/bindings/wasm/notify.rs similarity index 100% rename from wallet/core/src/wasm/notify.rs rename to wallet/core/src/bindings/wasm/notify.rs diff --git a/wallet/core/src/wasm/signer.rs b/wallet/core/src/bindings/wasm/signer.rs similarity index 100% rename from wallet/core/src/wasm/signer.rs rename to wallet/core/src/bindings/wasm/signer.rs diff --git a/wallet/core/src/wasm/tx/fees.rs b/wallet/core/src/bindings/wasm/tx/fees.rs similarity index 100% rename from wallet/core/src/wasm/tx/fees.rs rename to wallet/core/src/bindings/wasm/tx/fees.rs diff --git a/wallet/core/src/wasm/tx/generator/generator.rs b/wallet/core/src/bindings/wasm/tx/generator/generator.rs similarity index 98% rename from wallet/core/src/wasm/tx/generator/generator.rs rename to wallet/core/src/bindings/wasm/tx/generator/generator.rs index 5724b84811..269337e31e 100644 --- a/wallet/core/src/wasm/tx/generator/generator.rs +++ b/wallet/core/src/bindings/wasm/tx/generator/generator.rs @@ -1,11 +1,11 @@ +use crate::bindings::wasm::tx::generator::*; +use crate::bindings::wasm::tx::IFees; use crate::imports::*; use crate::result::Result; use crate::tx::{generator as native, Fees, PaymentDestination, PaymentOutputs}; use crate::utxo::{TryIntoUtxoEntryReferences, UtxoEntryReference}; -use crate::wasm::tx::generator::*; -use crate::wasm::tx::IFees; // use crate::wasm::wallet::Account; -use crate::wasm::UtxoContext; +use crate::bindings::wasm::UtxoContext; // TODO-WASM fix outputs #[wasm_bindgen(typescript_custom_section)] diff --git a/wallet/core/src/wasm/tx/generator/mod.rs b/wallet/core/src/bindings/wasm/tx/generator/mod.rs similarity index 100% rename from wallet/core/src/wasm/tx/generator/mod.rs rename to wallet/core/src/bindings/wasm/tx/generator/mod.rs diff --git a/wallet/core/src/wasm/tx/generator/pending.rs b/wallet/core/src/bindings/wasm/tx/generator/pending.rs similarity index 99% rename from wallet/core/src/wasm/tx/generator/pending.rs rename to wallet/core/src/bindings/wasm/tx/generator/pending.rs index 58c36375d6..7f45fda4d2 100644 --- a/wallet/core/src/wasm/tx/generator/pending.rs +++ b/wallet/core/src/bindings/wasm/tx/generator/pending.rs @@ -1,7 +1,7 @@ +use crate::bindings::wasm::PrivateKeyArrayT; use crate::imports::*; use crate::result::Result; use crate::tx::generator as native; -use crate::wasm::PrivateKeyArrayT; use kaspa_consensus_client::{numeric, string}; use kaspa_consensus_client::{Transaction, TransactionT}; use kaspa_consensus_core::hashing::wasm::SighashType; diff --git a/wallet/core/src/wasm/tx/generator/summary.rs b/wallet/core/src/bindings/wasm/tx/generator/summary.rs similarity index 100% rename from wallet/core/src/wasm/tx/generator/summary.rs rename to wallet/core/src/bindings/wasm/tx/generator/summary.rs diff --git a/wallet/core/src/wasm/tx/mass.rs b/wallet/core/src/bindings/wasm/tx/mass.rs similarity index 100% rename from wallet/core/src/wasm/tx/mass.rs rename to wallet/core/src/bindings/wasm/tx/mass.rs diff --git a/wallet/core/src/wasm/tx/mod.rs b/wallet/core/src/bindings/wasm/tx/mod.rs similarity index 100% rename from wallet/core/src/wasm/tx/mod.rs rename to wallet/core/src/bindings/wasm/tx/mod.rs diff --git a/wallet/core/src/wasm/tx/utils.rs b/wallet/core/src/bindings/wasm/tx/utils.rs similarity index 99% rename from wallet/core/src/wasm/tx/utils.rs rename to wallet/core/src/bindings/wasm/tx/utils.rs index c1229444a1..d99ad8bbd9 100644 --- a/wallet/core/src/wasm/tx/utils.rs +++ b/wallet/core/src/bindings/wasm/tx/utils.rs @@ -1,7 +1,7 @@ +use crate::bindings::wasm::tx::generator::*; use crate::imports::*; use crate::result::Result; use crate::tx::{IPaymentOutputArray, PaymentOutputs}; -use crate::wasm::tx::generator::*; use kaspa_consensus_client::*; use kaspa_consensus_core::subnets::SUBNETWORK_ID_NATIVE; use kaspa_wallet_macros::declare_typescript_wasm_interface as declare; diff --git a/wallet/core/src/wasm/utils.rs b/wallet/core/src/bindings/wasm/utils.rs similarity index 100% rename from wallet/core/src/wasm/utils.rs rename to wallet/core/src/bindings/wasm/utils.rs diff --git a/wallet/core/src/wasm/utxo/context.rs b/wallet/core/src/bindings/wasm/utxo/context.rs similarity index 99% rename from wallet/core/src/wasm/utxo/context.rs rename to wallet/core/src/bindings/wasm/utxo/context.rs index 3298a4829e..0e2563549a 100644 --- a/wallet/core/src/wasm/utxo/context.rs +++ b/wallet/core/src/bindings/wasm/utxo/context.rs @@ -1,9 +1,9 @@ +use crate::bindings::wasm::utxo::UtxoProcessor; +use crate::bindings::wasm::{Balance, BalanceStrings}; use crate::imports::*; use crate::result::Result; use crate::utxo as native; use crate::utxo::{UtxoContextBinding, UtxoContextId}; -use crate::wasm::utxo::UtxoProcessor; -use crate::wasm::{Balance, BalanceStrings}; use kaspa_addresses::AddressOrStringArrayT; use kaspa_consensus_client::UtxoEntryReferenceArrayT; use kaspa_hashes::Hash; diff --git a/wallet/core/src/wasm/utxo/mod.rs b/wallet/core/src/bindings/wasm/utxo/mod.rs similarity index 100% rename from wallet/core/src/wasm/utxo/mod.rs rename to wallet/core/src/bindings/wasm/utxo/mod.rs diff --git a/wallet/core/src/wasm/utxo/processor.rs b/wallet/core/src/bindings/wasm/utxo/processor.rs similarity index 98% rename from wallet/core/src/wasm/utxo/processor.rs rename to wallet/core/src/bindings/wasm/utxo/processor.rs index d68f10f763..905833325f 100644 --- a/wallet/core/src/wasm/utxo/processor.rs +++ b/wallet/core/src/bindings/wasm/utxo/processor.rs @@ -1,9 +1,11 @@ +use crate::bindings::wasm::notify::{ + UtxoProcessorEventTarget, UtxoProcessorNotificationCallback, UtxoProcessorNotificationTypeOrCallback, +}; use crate::error::Error; use crate::events::{EventKind, Events}; use crate::imports::*; use crate::result::Result; use crate::utxo as native; -use crate::wasm::notify::{UtxoProcessorEventTarget, UtxoProcessorNotificationCallback, UtxoProcessorNotificationTypeOrCallback}; use kaspa_consensus_core::network::NetworkIdT; use kaspa_wallet_macros::declare_typescript_wasm_interface as declare; use kaspa_wasm_core::events::{get_event_targets, Sink}; diff --git a/wallet/core/src/wasm/wallet/keydata.rs b/wallet/core/src/bindings/wasm/wallet/keydata.rs similarity index 100% rename from wallet/core/src/wasm/wallet/keydata.rs rename to wallet/core/src/bindings/wasm/wallet/keydata.rs diff --git a/wallet/core/src/wasm/wallet/mod.rs b/wallet/core/src/bindings/wasm/wallet/mod.rs similarity index 100% rename from wallet/core/src/wasm/wallet/mod.rs rename to wallet/core/src/bindings/wasm/wallet/mod.rs diff --git a/wallet/core/src/wasm/wallet/storage.rs b/wallet/core/src/bindings/wasm/wallet/storage.rs similarity index 100% rename from wallet/core/src/wasm/wallet/storage.rs rename to wallet/core/src/bindings/wasm/wallet/storage.rs diff --git a/wallet/core/src/wasm/wallet/wallet.rs b/wallet/core/src/bindings/wasm/wallet/wallet.rs similarity index 98% rename from wallet/core/src/wasm/wallet/wallet.rs rename to wallet/core/src/bindings/wasm/wallet/wallet.rs index bd91bedf22..5359649427 100644 --- a/wallet/core/src/wasm/wallet/wallet.rs +++ b/wallet/core/src/bindings/wasm/wallet/wallet.rs @@ -1,8 +1,8 @@ +use crate::bindings::wasm::notify::{WalletEventTarget, WalletNotificationCallback, WalletNotificationTypeOrCallback}; use crate::imports::*; use crate::storage::local::interface::LocalStore; use crate::storage::WalletDescriptor; use crate::wallet as native; -use crate::wasm::notify::{WalletEventTarget, WalletNotificationCallback, WalletNotificationTypeOrCallback}; use kaspa_wallet_macros::declare_typescript_wasm_interface as declare; use kaspa_wasm_core::events::{get_event_targets, Sink}; use kaspa_wrpc_wasm::{IConnectOptions, Resolver, RpcClient, RpcConfig, WrpcEncoding}; diff --git a/wallet/core/src/lib.rs b/wallet/core/src/lib.rs index 3593f464bd..f1bf1b85b0 100644 --- a/wallet/core/src/lib.rs +++ b/wallet/core/src/lib.rs @@ -111,11 +111,8 @@ pub mod wallet; // } -#[cfg(any(feature = "wasm32-sdk", feature = "wasm32-core"))] -pub mod wasm; - -#[cfg(feature = "py-sdk")] -pub mod python; +#[cfg(any(feature = "wasm32-sdk", feature = "wasm32-core", feature = "py-sdk"))] +pub mod bindings; /// Returns the version of the Wallet framework. pub fn version() -> String { diff --git a/wasm/src/lib.rs b/wasm/src/lib.rs index 77c5e16ea8..5ed4022463 100644 --- a/wasm/src/lib.rs +++ b/wasm/src/lib.rs @@ -145,7 +145,7 @@ cfg_if::cfg_if! { pub use kaspa_addresses::{Address, Version as AddressVersion}; pub use kaspa_consensus_core::tx::{ScriptPublicKey, Transaction, TransactionInput, TransactionOutpoint, TransactionOutput}; pub use kaspa_pow::wasm::*; - pub use kaspa_txscript::wasm::*; + pub use kaspa_txscript::bindings::wasm::*; pub mod rpc { //! Kaspa RPC interface @@ -156,7 +156,7 @@ cfg_if::cfg_if! { pub use kaspa_rpc_core::model::message::*; } pub use kaspa_rpc_core::api::rpc::RpcApi; - pub use kaspa_rpc_core::wasm::message::*; + pub use kaspa_rpc_core::bindings::wasm::message::*; pub use kaspa_wrpc_wasm::client::*; pub use kaspa_wrpc_wasm::resolver::*; @@ -165,14 +165,14 @@ cfg_if::cfg_if! { pub use kaspa_consensus_wasm::*; pub use kaspa_wallet_keys::prelude::*; - pub use kaspa_wallet_core::wasm::*; + pub use kaspa_wallet_core::bindings::wasm::*; } else if #[cfg(feature = "wasm32-core")] { pub use kaspa_addresses::{Address, Version as AddressVersion}; pub use kaspa_consensus_core::tx::{ScriptPublicKey, Transaction, TransactionInput, TransactionOutpoint, TransactionOutput}; pub use kaspa_pow::wasm::*; - pub use kaspa_txscript::wasm::*; + pub use kaspa_txscript::bindings::wasm::*; pub mod rpc { //! Kaspa RPC interface @@ -183,7 +183,7 @@ cfg_if::cfg_if! { pub use kaspa_rpc_core::model::message::*; } pub use kaspa_rpc_core::api::rpc::RpcApi; - pub use kaspa_rpc_core::wasm::message::*; + pub use kaspa_rpc_core::bindings::wasm::message::*; pub use kaspa_wrpc_wasm::client::*; pub use kaspa_wrpc_wasm::resolver::*; @@ -192,13 +192,13 @@ cfg_if::cfg_if! { pub use kaspa_consensus_wasm::*; pub use kaspa_wallet_keys::prelude::*; - pub use kaspa_wallet_core::wasm::*; + pub use kaspa_wallet_core::bindings::wasm::*; } else if #[cfg(feature = "wasm32-rpc")] { pub use kaspa_rpc_core::api::rpc::RpcApi; - pub use kaspa_rpc_core::wasm::message::*; - pub use kaspa_rpc_core::wasm::message::IPingRequest; + pub use kaspa_rpc_core::bindings::wasm::message::*; + pub use kaspa_rpc_core::bindings::wasm::message::IPingRequest; pub use kaspa_wrpc_wasm::client::*; pub use kaspa_wrpc_wasm::resolver::*; pub use kaspa_wrpc_wasm::notify::*;