diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e8c831e8..e88e7bab 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -105,4 +105,8 @@ jobs: uses: ./.github/actions/build-dependencies - name: Run Tests - run: GITHUB_CI=true RUST_BACKTRACE=1 cargo test --all-features -p serai-client + run: | + GITHUB_CI=true RUST_BACKTRACE=1 cargo test --all-features -p serai-client-bitcoin + GITHUB_CI=true RUST_BACKTRACE=1 cargo test --all-features -p serai-client-ethereum + GITHUB_CI=true RUST_BACKTRACE=1 cargo test --all-features -p serai-client-monero + GITHUB_CI=true RUST_BACKTRACE=1 cargo test --all-features -p serai-client diff --git a/Cargo.toml b/Cargo.toml index 37026a61..c55577f4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -62,8 +62,8 @@ members = [ "processor/ethereum/primitives", "processor/ethereum/test-primitives", "processor/ethereum/deployer", - "processor/ethereum/router", "processor/ethereum/erc20", + "processor/ethereum/router", "processor/ethereum", "processor/monero", @@ -93,6 +93,9 @@ members = [ "substrate/runtime", "substrate/node", + "substrate/client/bitcoin", + "substrate/client/ethereum", + "substrate/client/monero", "substrate/client", "orchestration", diff --git a/processor/bitcoin/Cargo.toml b/processor/bitcoin/Cargo.toml index 6a7c907f..e1b93cff 100644 --- a/processor/bitcoin/Cargo.toml +++ b/processor/bitcoin/Cargo.toml @@ -30,7 +30,8 @@ frost = { package = "modular-frost", path = "../../crypto/frost", default-featur secp256k1 = { version = "0.29", default-features = false, features = ["std", "global-context", "rand-std"] } bitcoin-serai = { path = "../../networks/bitcoin", default-features = false, features = ["std"] } -serai-client = { path = "../../substrate/client", default-features = false, features = ["bitcoin"] } +serai-primitives = { path = "../../substrate/primitives", default-features = false, features = ["std"] } +serai-client-bitcoin = { path = "../../substrate/client/bitcoin", default-features = false } zalloc = { path = "../../common/zalloc" } log = { version = "0.4", default-features = false, features = ["std"] } diff --git a/processor/bitcoin/src/primitives/block.rs b/processor/bitcoin/src/primitives/block.rs index ac93ccb0..29765624 100644 --- a/processor/bitcoin/src/primitives/block.rs +++ b/processor/bitcoin/src/primitives/block.rs @@ -6,7 +6,7 @@ use ciphersuite_kp256::Secp256k1; use bitcoin_serai::bitcoin::block::{Header, Block as BBlock}; -use serai_client::networks::bitcoin::Address; +use serai_client_bitcoin::Address; use serai_db::Db; use primitives::{ReceivedOutput, EventualityTracker}; diff --git a/processor/bitcoin/src/primitives/output.rs b/processor/bitcoin/src/primitives/output.rs index 0fef53d2..d0b78a11 100644 --- a/processor/bitcoin/src/primitives/output.rs +++ b/processor/bitcoin/src/primitives/output.rs @@ -13,14 +13,12 @@ use bitcoin_serai::{ use borsh::{BorshSerialize, BorshDeserialize}; use serai_db::Get; -use serai_client::{ - primitives::{ - coin::ExternalCoin, - balance::{Amount, ExternalBalance}, - address::ExternalAddress, - }, - networks::bitcoin::Address, +use serai_primitives::{ + coin::ExternalCoin, + balance::{Amount, ExternalBalance}, + address::ExternalAddress, }; +use serai_client_bitcoin::Address; use primitives::{OutputType, ReceivedOutput}; diff --git a/processor/bitcoin/src/primitives/transaction.rs b/processor/bitcoin/src/primitives/transaction.rs index bfb8ad23..00b984b8 100644 --- a/processor/bitcoin/src/primitives/transaction.rs +++ b/processor/bitcoin/src/primitives/transaction.rs @@ -18,7 +18,7 @@ use bitcoin_serai::{ use borsh::{BorshSerialize, BorshDeserialize}; -use serai_client::networks::bitcoin::Address; +use serai_client_bitcoin::Address; use crate::output::OutputId; diff --git a/processor/bitcoin/src/rpc.rs b/processor/bitcoin/src/rpc.rs index 19cb1781..9a7b421d 100644 --- a/processor/bitcoin/src/rpc.rs +++ b/processor/bitcoin/src/rpc.rs @@ -2,7 +2,7 @@ use core::future::Future; use bitcoin_serai::rpc::{RpcError, Rpc as BRpc}; -use serai_client::primitives::{network_id::ExternalNetworkId, coin::ExternalCoin, balance::Amount}; +use serai_primitives::{network_id::ExternalNetworkId, coin::ExternalCoin, balance::Amount}; use serai_db::Db; use scanner::ScannerFeed; diff --git a/processor/bitcoin/src/scan.rs b/processor/bitcoin/src/scan.rs index 975b75bc..a78ceec3 100644 --- a/processor/bitcoin/src/scan.rs +++ b/processor/bitcoin/src/scan.rs @@ -12,7 +12,7 @@ use bitcoin_serai::{ wallet::Scanner, }; -use serai_client::networks::bitcoin::Address; +use serai_client_bitcoin::Address; use serai_db::Get; use primitives::OutputType; diff --git a/processor/bitcoin/src/scheduler.rs b/processor/bitcoin/src/scheduler.rs index 0c5e1325..df998819 100644 --- a/processor/bitcoin/src/scheduler.rs +++ b/processor/bitcoin/src/scheduler.rs @@ -8,10 +8,8 @@ use bitcoin_serai::{ wallet::{TransactionError, SignableTransaction as BSignableTransaction, p2tr_script_buf}, }; -use serai_client::{ - primitives::{coin::ExternalCoin, balance::Amount}, - networks::bitcoin::Address, -}; +use serai_primitives::{coin::ExternalCoin, balance::Amount}; +use serai_client_bitcoin::Address; use serai_db::Db; use primitives::{OutputType, ReceivedOutput, Payment}; diff --git a/processor/ethereum/Cargo.toml b/processor/ethereum/Cargo.toml index fb105f9f..6f215650 100644 --- a/processor/ethereum/Cargo.toml +++ b/processor/ethereum/Cargo.toml @@ -39,7 +39,8 @@ alloy-simple-request-transport = { path = "../../networks/ethereum/alloy-simple- alloy-rpc-client = { version = "1", default-features = false } alloy-provider = { version = "1", default-features = false } -serai-client = { path = "../../substrate/client", default-features = false, features = ["ethereum"] } +serai-primitives = { path = "../../substrate/primitives", default-features = false, features = ["std"] } +serai-client-ethereum = { path = "../../substrate/client/ethereum", default-features = false } zalloc = { path = "../../common/zalloc" } log = { version = "0.4", default-features = false, features = ["std"] } diff --git a/processor/ethereum/router/Cargo.toml b/processor/ethereum/router/Cargo.toml index 5ccca030..8b6572ea 100644 --- a/processor/ethereum/router/Cargo.toml +++ b/processor/ethereum/router/Cargo.toml @@ -41,7 +41,8 @@ ethereum-primitives = { package = "serai-processor-ethereum-primitives", path = ethereum-deployer = { package = "serai-processor-ethereum-deployer", path = "../deployer", default-features = false } erc20 = { package = "serai-processor-ethereum-erc20", path = "../erc20", default-features = false } -serai-client = { path = "../../../substrate/client", default-features = false, features = ["ethereum"] } +serai-primitives = { path = "../../../substrate/primitives", default-features = false, features = ["std"] } +serai-client-ethereum = { path = "../../../substrate/client/ethereum", default-features = false } futures-util = { version = "0.3", default-features = false, features = ["std"] } diff --git a/processor/ethereum/router/src/lib.rs b/processor/ethereum/router/src/lib.rs index 795d08e3..29b3c3b3 100644 --- a/processor/ethereum/router/src/lib.rs +++ b/processor/ethereum/router/src/lib.rs @@ -21,9 +21,8 @@ use alloy_rpc_types_eth::{BlockId, Log, Filter, TransactionInput, TransactionReq use alloy_transport::{TransportErrorKind, RpcError}; use alloy_provider::{Provider, RootProvider}; -use serai_client::{ - primitives::instructions::RefundableInInstruction, networks::ethereum::Address as SeraiAddress, -}; +use serai_primitives::instructions::RefundableInInstruction; +use serai_client_ethereum::Address as SeraiAddress; use ethereum_primitives::LogIndex; use ethereum_schnorr::{PublicKey, Signature}; diff --git a/processor/ethereum/router/src/tests/in_instruction.rs b/processor/ethereum/router/src/tests/in_instruction.rs index 2a6c8642..4869ad65 100644 --- a/processor/ethereum/router/src/tests/in_instruction.rs +++ b/processor/ethereum/router/src/tests/in_instruction.rs @@ -5,9 +5,9 @@ use alloy_sol_types::SolCall; use alloy_consensus::{TxLegacy, Signed}; -use serai_client::{ - primitives::SeraiAddress, - primitives::instructions::{InInstruction as SeraiInInstruction, RefundableInInstruction}, +use serai_primitives::{ + address::SeraiAddress, + instructions::{InInstruction as SeraiInInstruction, RefundableInInstruction}, }; use ethereum_primitives::LogIndex; @@ -17,8 +17,8 @@ use crate::{InInstruction, tests::*}; impl Test { pub(crate) fn in_instruction() -> RefundableInInstruction { RefundableInInstruction { - origin: None, - instruction: SeraiInInstruction::Transfer(SeraiAddress([0xff; 32])), + return_address: None, + instruction: SeraiInInstruction::Transfer { to: SeraiAddress([0xff; 32]) }, } } @@ -140,7 +140,7 @@ async fn test_erc20_router_in_instruction() { input: crate::abi::inInstructionCall::new(( coin.into(), amount, - borsh::to_vec(shorthand).unwrap().into(), + borsh::to_vec(&shorthand).unwrap().into(), )) .abi_encode() .into(), diff --git a/processor/ethereum/router/src/tests/mod.rs b/processor/ethereum/router/src/tests/mod.rs index 0ab366e7..202fee3f 100644 --- a/processor/ethereum/router/src/tests/mod.rs +++ b/processor/ethereum/router/src/tests/mod.rs @@ -20,7 +20,7 @@ use alloy_provider::{ use alloy_node_bindings::{Anvil, AnvilInstance}; -use serai_client::networks::ethereum::{ContractDeployment, Address as SeraiEthereumAddress}; +use serai_client_ethereum::{ContractDeployment, Address as SeraiEthereumAddress}; use ethereum_schnorr::{PublicKey, Signature}; use ethereum_deployer::Deployer; diff --git a/processor/ethereum/src/main.rs b/processor/ethereum/src/main.rs index df39f76e..f5bc9925 100644 --- a/processor/ethereum/src/main.rs +++ b/processor/ethereum/src/main.rs @@ -14,7 +14,7 @@ use alloy_simple_request_transport::SimpleRequest; use alloy_rpc_client::ClientBuilder; use alloy_provider::{Provider, RootProvider}; -use serai_client::primitives::validator_sets::Session; +use serai_primitives::validator_sets::Session; use serai_env as env; use serai_db::{Get, DbTxn, create_db}; diff --git a/processor/ethereum/src/primitives/block.rs b/processor/ethereum/src/primitives/block.rs index 7ace3d02..5d46a1d7 100644 --- a/processor/ethereum/src/primitives/block.rs +++ b/processor/ethereum/src/primitives/block.rs @@ -3,7 +3,7 @@ use std::collections::HashMap; use ciphersuite::*; use ciphersuite_kp256::Secp256k1; -use serai_client::networks::ethereum::Address; +use serai_client_ethereum::Address; use primitives::{ReceivedOutput, EventualityTracker}; diff --git a/processor/ethereum/src/primitives/mod.rs b/processor/ethereum/src/primitives/mod.rs index 859c1458..c3406de9 100644 --- a/processor/ethereum/src/primitives/mod.rs +++ b/processor/ethereum/src/primitives/mod.rs @@ -1,6 +1,6 @@ use alloy_core::primitives::{FixedBytes, Address}; -use serai_client::primitives::balance::Amount; +use serai_primitives::balance::Amount; pub(crate) mod output; pub(crate) mod transaction; diff --git a/processor/ethereum/src/primitives/output.rs b/processor/ethereum/src/primitives/output.rs index 44ae80eb..a8b42788 100644 --- a/processor/ethereum/src/primitives/output.rs +++ b/processor/ethereum/src/primitives/output.rs @@ -7,14 +7,12 @@ use alloy_core::primitives::U256; use borsh::{BorshSerialize, BorshDeserialize}; -use serai_client::{ - primitives::{ - network_id::ExternalNetworkId, - coin::ExternalCoin, - balance::{Amount, ExternalBalance}, - }, - networks::ethereum::Address, +use serai_primitives::{ + network_id::ExternalNetworkId, + coin::ExternalCoin, + balance::{Amount, ExternalBalance}, }; +use serai_client_ethereum::Address; use primitives::{OutputType, ReceivedOutput}; use ethereum_router::{Coin as EthereumCoin, InInstruction as EthereumInInstruction}; diff --git a/processor/ethereum/src/primitives/transaction.rs b/processor/ethereum/src/primitives/transaction.rs index 931815db..d9145557 100644 --- a/processor/ethereum/src/primitives/transaction.rs +++ b/processor/ethereum/src/primitives/transaction.rs @@ -5,7 +5,7 @@ use frost::dkg::ThresholdKeys; use alloy_core::primitives::{U256, Address as EthereumAddress}; -use serai_client::networks::ethereum::Address; +use serai_client_ethereum::Address; use scheduler::SignableTransaction; diff --git a/processor/ethereum/src/rpc.rs b/processor/ethereum/src/rpc.rs index 908f5a3f..a7816fdf 100644 --- a/processor/ethereum/src/rpc.rs +++ b/processor/ethereum/src/rpc.rs @@ -6,7 +6,7 @@ use alloy_rpc_types_eth::{Header, BlockNumberOrTag}; use alloy_transport::{RpcError, TransportErrorKind}; use alloy_provider::{Provider, RootProvider}; -use serai_client::primitives::{network_id::ExternalNetworkId, coin::ExternalCoin, balance::Amount}; +use serai_primitives::{network_id::ExternalNetworkId, coin::ExternalCoin, balance::Amount}; use tokio::task::JoinSet; diff --git a/processor/ethereum/src/scheduler.rs b/processor/ethereum/src/scheduler.rs index b487dcbe..a09f5ebb 100644 --- a/processor/ethereum/src/scheduler.rs +++ b/processor/ethereum/src/scheduler.rs @@ -2,10 +2,8 @@ use std::collections::HashMap; use alloy_core::primitives::U256; -use serai_client::{ - primitives::{network_id::ExternalNetworkId, coin::ExternalCoin, balance::ExternalBalance}, - networks::ethereum::Address, -}; +use serai_primitives::{network_id::ExternalNetworkId, coin::ExternalCoin, balance::ExternalBalance}; +use serai_client_ethereum::Address; use serai_db::Db; diff --git a/processor/monero/Cargo.toml b/processor/monero/Cargo.toml index 58ce8a51..9ca23be9 100644 --- a/processor/monero/Cargo.toml +++ b/processor/monero/Cargo.toml @@ -31,7 +31,8 @@ frost = { package = "modular-frost", path = "../../crypto/frost", default-featur monero-wallet = { git = "https://github.com/monero-oxide/monero-oxide", rev = "030c60974f0f0306849c1795bca854a3bbb757b4", default-features = false, features = ["std", "multisig"] } monero-simple-request-rpc = { git = "https://github.com/monero-oxide/monero-oxide", rev = "030c60974f0f0306849c1795bca854a3bbb757b4", default-features = false } -serai-client = { path = "../../substrate/client", default-features = false, features = ["monero"] } +serai-primitives = { path = "../../substrate/primitives", default-features = false, features = ["std"] } +serai-client-monero = { path = "../../substrate/client/monero", default-features = false } zalloc = { path = "../../common/zalloc" } log = { version = "0.4", default-features = false, features = ["std"] } diff --git a/processor/monero/src/primitives/block.rs b/processor/monero/src/primitives/block.rs index f449746a..9df6e880 100644 --- a/processor/monero/src/primitives/block.rs +++ b/processor/monero/src/primitives/block.rs @@ -8,7 +8,7 @@ use monero_wallet::{ GuaranteedScanner, }; -use serai_client::networks::monero::Address; +use serai_client_monero::Address; use primitives::{ReceivedOutput, EventualityTracker}; use crate::{ diff --git a/processor/monero/src/primitives/output.rs b/processor/monero/src/primitives/output.rs index c71911e2..6365cea0 100644 --- a/processor/monero/src/primitives/output.rs +++ b/processor/monero/src/primitives/output.rs @@ -7,13 +7,11 @@ use monero_wallet::WalletOutput; use borsh::{BorshSerialize, BorshDeserialize}; -use serai_client::{ - primitives::{ - coin::ExternalCoin, - balance::{Amount, ExternalBalance}, - }, - networks::monero::Address, +use serai_primitives::{ + coin::ExternalCoin, + balance::{Amount, ExternalBalance}, }; +use serai_client_monero::Address; use primitives::{OutputType, ReceivedOutput}; diff --git a/processor/monero/src/rpc.rs b/processor/monero/src/rpc.rs index 161e16cd..59cd1a3d 100644 --- a/processor/monero/src/rpc.rs +++ b/processor/monero/src/rpc.rs @@ -2,7 +2,7 @@ use core::future::Future; use monero_simple_request_rpc::{prelude::*, SimpleRequestTransport}; -use serai_client::primitives::{network_id::ExternalNetworkId, coin::ExternalCoin, balance::Amount}; +use serai_primitives::{network_id::ExternalNetworkId, coin::ExternalCoin, balance::Amount}; use scanner::ScannerFeed; use signers::TransactionPublisher; diff --git a/processor/monero/src/scheduler.rs b/processor/monero/src/scheduler.rs index fbe557a0..db604ffe 100644 --- a/processor/monero/src/scheduler.rs +++ b/processor/monero/src/scheduler.rs @@ -9,10 +9,8 @@ use dalek_ff_group::Ed25519; use monero_wallet::interface::prelude::*; -use serai_client::{ - primitives::{coin::ExternalCoin, balance::Amount}, - networks::monero::Address, -}; +use serai_primitives::{coin::ExternalCoin, balance::Amount}; +use serai_client_monero::Address; use primitives::{OutputType, ReceivedOutput, Payment}; use scanner::{KeyFor, AddressFor, OutputFor, BlockFor}; diff --git a/substrate/client/Cargo.toml b/substrate/client/Cargo.toml index 3bdcdc0d..7f34b956 100644 --- a/substrate/client/Cargo.toml +++ b/substrate/client/Cargo.toml @@ -39,11 +39,9 @@ async-lock = "3" simple-request = { path = "../../common/request", version = "0.3", optional = true } -bitcoin = { version = "0.32", optional = true } - -ciphersuite = { path = "../../crypto/ciphersuite", optional = true } -dalek-ff-group = { path = "../../crypto/dalek-ff-group", optional = true } -monero-address = { git = "https://github.com/monero-oxide/monero-oxide", rev = "030c60974f0f0306849c1795bca854a3bbb757b4", version = "0.1.0", default-features = false, features = ["std"], optional = true } +serai-client-bitcoin = { path = "./bitcoin", optional = true } +serai-client-ethereum = { path = "./ethereum", optional = true } +serai-client-monero = { path = "./monero", optional = true } [dev-dependencies] rand_core = "0.6" @@ -67,9 +65,9 @@ serai-docker-tests = { path = "../../tests/docker" } serai = ["thiserror/std", "scale", "serde", "serde_json", "multiaddr", "sp-core", "sp-runtime", "frame-system", "simple-request"] networks = [] -bitcoin = ["networks", "dep:bitcoin"] -ethereum = ["networks"] -monero = ["networks", "ciphersuite", "dalek-ff-group", "monero-address"] +bitcoin = ["networks", "serai-client-bitcoin"] +ethereum = ["networks", "serai-client-ethereum"] +monero = ["networks", "serai-client-monero"] # Assumes the default usage is to use Serai as a DEX, which doesn't actually # require connecting to a Serai node diff --git a/substrate/client/bitcoin/Cargo.toml b/substrate/client/bitcoin/Cargo.toml new file mode 100644 index 00000000..be79745e --- /dev/null +++ b/substrate/client/bitcoin/Cargo.toml @@ -0,0 +1,27 @@ +[package] +name = "serai-client-bitcoin" +version = "0.1.0" +description = "Bitcoin client library for the Serai network" +license = "MIT" +repository = "https://github.com/serai-dex/serai/tree/develop/substrate/client/bitcoin" +authors = ["Luke Parker "] +keywords = ["serai"] +edition = "2021" +rust-version = "1.85" + +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + +[lints] +workspace = true + +[dependencies] +borsh = { version = "1", default-features = false, features = ["derive"] } + +serai-primitives = { path = "../../primitives", version = "0.1", default-features = false } + +bitcoin = { version = "0.32", default-features = false } + +[features] +std = ["borsh/std", "serai-primitives/std", "bitcoin/std"] diff --git a/substrate/client/bitcoin/LICENSE b/substrate/client/bitcoin/LICENSE new file mode 100644 index 00000000..32ff304a --- /dev/null +++ b/substrate/client/bitcoin/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022-2025 Luke Parker + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/substrate/client/src/networks/bitcoin.rs b/substrate/client/bitcoin/src/lib.rs similarity index 98% rename from substrate/client/src/networks/bitcoin.rs rename to substrate/client/bitcoin/src/lib.rs index 9c42756d..f3c476ba 100644 --- a/substrate/client/src/networks/bitcoin.rs +++ b/substrate/client/bitcoin/src/lib.rs @@ -1,3 +1,5 @@ +#![no_std] + use core::{str::FromStr, fmt}; use borsh::{BorshSerialize, BorshDeserialize}; @@ -10,7 +12,7 @@ use bitcoin::{ address::{AddressType, NetworkChecked, Address as BAddress}, }; -use crate::primitives::address::ExternalAddress; +use serai_primitives::address::ExternalAddress; // SCALE-encodable representation of Bitcoin addresses, used internally. #[derive(Clone, PartialEq, Eq, Debug, BorshSerialize, BorshDeserialize)] diff --git a/substrate/client/ethereum/Cargo.toml b/substrate/client/ethereum/Cargo.toml new file mode 100644 index 00000000..afa9314c --- /dev/null +++ b/substrate/client/ethereum/Cargo.toml @@ -0,0 +1,28 @@ +[package] +name = "serai-client-ethereum" +version = "0.1.0" +description = "Ethereum client library for the Serai network" +license = "MIT" +repository = "https://github.com/serai-dex/serai/tree/develop/substrate/client/ethereum" +authors = ["Luke Parker "] +keywords = ["serai"] +edition = "2021" +rust-version = "1.85" + +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + +[lints] +workspace = true + +[dependencies] +std-shims = { path = "../../../common/std-shims", default-features = false, features = ["alloc"] } + +hex = { version = "0.4", default-features = false, features = ["alloc"] } +borsh = { version = "1", default-features = false, features = ["derive"] } + +serai-primitives = { path = "../../primitives", default-features = false, version = "0.1" } + +[features] +std = ["std-shims/std", "borsh/std", "serai-primitives/std"] diff --git a/substrate/client/ethereum/LICENSE b/substrate/client/ethereum/LICENSE new file mode 100644 index 00000000..32ff304a --- /dev/null +++ b/substrate/client/ethereum/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022-2025 Luke Parker + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/substrate/client/src/networks/ethereum.rs b/substrate/client/ethereum/src/lib.rs similarity index 97% rename from substrate/client/src/networks/ethereum.rs rename to substrate/client/ethereum/src/lib.rs index b55ce7f9..8615b4b3 100644 --- a/substrate/client/src/networks/ethereum.rs +++ b/substrate/client/ethereum/src/lib.rs @@ -1,9 +1,11 @@ +#![no_std] + use core::str::FromStr; -use std::io::Read; +use std_shims::{vec::Vec, io::Read}; use borsh::{BorshSerialize, BorshDeserialize}; -use crate::primitives::address::ExternalAddress; +use serai_primitives::address::ExternalAddress; /// THe maximum amount of gas an address is allowed to specify as its gas limit. /// diff --git a/substrate/client/monero/Cargo.toml b/substrate/client/monero/Cargo.toml new file mode 100644 index 00000000..db922dc0 --- /dev/null +++ b/substrate/client/monero/Cargo.toml @@ -0,0 +1,26 @@ +[package] +name = "serai-client-monero" +version = "0.1.0" +description = "Monero client library for the Serai network" +license = "MIT" +repository = "https://github.com/serai-dex/serai/tree/develop/substrate/client/monero" +authors = ["Luke Parker "] +keywords = ["serai"] +edition = "2021" +rust-version = "1.85" + +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + +[lints] +workspace = true + +[dependencies] +borsh = { version = "1", default-features = false, features = ["std"] } + +serai-primitives = { path = "../../primitives", version = "0.1", default-features = false, features = ["std"] } + +ciphersuite = { path = "../../../crypto/ciphersuite", default-features = false, features = ["std"] } +dalek-ff-group = { path = "../../../crypto/dalek-ff-group", default-features = false, features = ["std"] } +monero-address = { git = "https://github.com/monero-oxide/monero-oxide", rev = "030c60974f0f0306849c1795bca854a3bbb757b4", version = "0.1.0", default-features = false, features = ["std"] } diff --git a/substrate/client/monero/LICENSE b/substrate/client/monero/LICENSE new file mode 100644 index 00000000..32ff304a --- /dev/null +++ b/substrate/client/monero/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022-2025 Luke Parker + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/substrate/client/src/networks/monero.rs b/substrate/client/monero/src/lib.rs similarity index 98% rename from substrate/client/src/networks/monero.rs rename to substrate/client/monero/src/lib.rs index d370c8da..23e950d5 100644 --- a/substrate/client/src/networks/monero.rs +++ b/substrate/client/monero/src/lib.rs @@ -5,7 +5,7 @@ use ciphersuite::GroupIo; use monero_address::{Network, AddressType as MoneroAddressType, MoneroAddress}; -use crate::primitives::address::ExternalAddress; +use serai_primitives::address::ExternalAddress; #[derive(Clone, Copy, PartialEq, Eq, Debug)] enum AddressType { diff --git a/substrate/client/src/networks.rs b/substrate/client/src/networks.rs new file mode 100644 index 00000000..a142997e --- /dev/null +++ b/substrate/client/src/networks.rs @@ -0,0 +1,8 @@ +#[cfg(feature = "bitcoin")] +pub use serai_client_bitcoin; + +#[cfg(feature = "ethereum")] +pub mod serai_client_ethereum; + +#[cfg(feature = "monero")] +pub mod serai_client_monero; diff --git a/substrate/client/src/networks/mod.rs b/substrate/client/src/networks/mod.rs deleted file mode 100644 index 7a99631a..00000000 --- a/substrate/client/src/networks/mod.rs +++ /dev/null @@ -1,8 +0,0 @@ -#[cfg(feature = "bitcoin")] -pub mod bitcoin; - -#[cfg(feature = "ethereum")] -pub mod ethereum; - -#[cfg(feature = "monero")] -pub mod monero; diff --git a/tests/no-std/Cargo.toml b/tests/no-std/Cargo.toml index 2552d7aa..208a649e 100644 --- a/tests/no-std/Cargo.toml +++ b/tests/no-std/Cargo.toml @@ -46,6 +46,9 @@ frost-schnorrkel = { path = "../../crypto/schnorrkel", default-features = false, bitcoin-serai = { path = "../../networks/bitcoin", default-features = false, features = ["hazmat"], optional = true } +serai-client-bitcoin = { path = "../../substrate/client/bitcoin", default-features = false, optional = true } +serai-client-ethereum = { path = "../../substrate/client/ethereum", default-features = false, optional = true } + [features] alloc = [ "std-shims/alloc", @@ -75,4 +78,7 @@ alloc = [ "frost-schnorrkel", "bitcoin-serai", + + "serai-client-bitcoin", + "serai-client-ethereum", ] diff --git a/tests/no-std/src/lib.rs b/tests/no-std/src/lib.rs index 320a3c87..49372095 100644 --- a/tests/no-std/src/lib.rs +++ b/tests/no-std/src/lib.rs @@ -30,4 +30,7 @@ pub mod alloc { pub use frost_schnorrkel; pub use bitcoin_serai; + + pub use serai_client_bitcoin; + pub use serai_client_ethereum; }