Rename project: Rust, uniffi (#133)

* Rename rust crates, uniffi bindings

* Rename uniffi tests

* Rename uniffi UDL file
This commit is contained in:
ok300
2024-05-02 05:44:47 +00:00
committed by GitHub
parent aa86d350cc
commit cb7e753c95
17 changed files with 101 additions and 101 deletions

70
cli/Cargo.lock generated
View File

@@ -360,6 +360,41 @@ dependencies = [
"url",
]
[[package]]
name = "breez-liquid-cli"
version = "0.0.1"
dependencies = [
"anyhow",
"bip39",
"breez-liquid-sdk",
"clap",
"env_logger 0.11.3",
"log",
"qrcode-rs",
"rustyline",
"serde",
"serde_json",
]
[[package]]
name = "breez-liquid-sdk"
version = "0.0.1"
dependencies = [
"anyhow",
"bip39",
"boltz-client",
"flutter_rust_bridge",
"log",
"lwk_common",
"lwk_signer",
"lwk_wollet",
"openssl",
"rusqlite",
"rusqlite_migration",
"serde",
"thiserror",
]
[[package]]
name = "build-target"
version = "0.4.0"
@@ -1279,41 +1314,6 @@ version = "0.4.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c"
[[package]]
name = "ls-sdk"
version = "0.0.1"
dependencies = [
"anyhow",
"bip39",
"boltz-client",
"flutter_rust_bridge",
"log",
"lwk_common",
"lwk_signer",
"lwk_wollet",
"openssl",
"rusqlite",
"rusqlite_migration",
"serde",
"thiserror",
]
[[package]]
name = "ls-sdk-cli"
version = "0.0.1"
dependencies = [
"anyhow",
"bip39",
"clap",
"env_logger 0.11.3",
"log",
"ls-sdk",
"qrcode-rs",
"rustyline",
"serde",
"serde_json",
]
[[package]]
name = "lwk_common"
version = "0.3.0"

View File

@@ -1,5 +1,5 @@
[package]
name = "ls-sdk-cli"
name = "breez-liquid-cli"
edition = "2021"
version = "0.0.1"
@@ -8,10 +8,10 @@ version = "0.0.1"
[dependencies]
anyhow = "1.0.80"
bip39 = "2.0.0"
breez-liquid-sdk = { path = "../lib/ls-sdk-core" }
clap = { version = "4.5.1", features = ["derive"] }
env_logger = "0.11"
log = "0.4.20"
ls-sdk = { path = "../lib/ls-sdk-core" }
qrcode-rs = { version = "0.1", default-features = false }
rustyline = { version = "13.0.0", features = ["derive"] }
serde = { version = "1.0.197", features = ["derive"] }

View File

@@ -5,8 +5,8 @@ use std::thread;
use std::time::Duration;
use anyhow::Result;
use breez_liquid_sdk::{model::PrepareReceiveRequest, wallet::Wallet};
use clap::{arg, Parser};
use ls_sdk::{model::PrepareReceiveRequest, wallet::Wallet};
use qrcode_rs::render::unicode;
use qrcode_rs::{EcLevel, QrCode};
use rustyline::highlight::Highlighter;

View File

@@ -7,13 +7,13 @@ use std::{
};
use anyhow::{anyhow, Result};
use clap::Parser;
use commands::{handle_command, CliHelper, Command, CommandResult};
use log::{error, info};
use ls_sdk::{
use breez_liquid_sdk::{
model::Network,
wallet::{Wallet, DEFAULT_DATA_DIR},
};
use clap::Parser;
use commands::{handle_command, CliHelper, Command, CommandResult};
use log::{error, info};
use persist::CliPersistence;
use rustyline::{error::ReadlineError, hint::HistoryHinter, Editor};

62
lib/Cargo.lock generated
View File

@@ -483,6 +483,37 @@ dependencies = [
"url",
]
[[package]]
name = "breez-liquid-sdk"
version = "0.0.1"
dependencies = [
"anyhow",
"bip39",
"boltz-client",
"flutter_rust_bridge",
"log",
"lwk_common",
"lwk_signer",
"lwk_wollet",
"openssl",
"rusqlite",
"rusqlite_migration",
"serde",
"tempdir",
"thiserror",
"uuid",
]
[[package]]
name = "breez-liquid-sdk-bindings"
version = "0.0.1"
dependencies = [
"anyhow",
"breez-liquid-sdk",
"thiserror",
"uniffi 0.27.1",
]
[[package]]
name = "build-target"
version = "0.4.0"
@@ -1468,37 +1499,6 @@ version = "0.4.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c"
[[package]]
name = "ls-sdk"
version = "0.0.1"
dependencies = [
"anyhow",
"bip39",
"boltz-client",
"flutter_rust_bridge",
"log",
"lwk_common",
"lwk_signer",
"lwk_wollet",
"openssl",
"rusqlite",
"rusqlite_migration",
"serde",
"tempdir",
"thiserror",
"uuid",
]
[[package]]
name = "ls-sdk-bindings"
version = "0.0.1"
dependencies = [
"anyhow",
"ls-sdk",
"thiserror",
"uniffi 0.27.1",
]
[[package]]
name = "lwk_common"
version = "0.3.0"

View File

@@ -1,5 +1,5 @@
[package]
name = "ls-sdk-bindings"
name = "breez-liquid-sdk-bindings"
edition = "2021"
version.workspace = true
@@ -8,13 +8,13 @@ name = "uniffi-bindgen"
path = "uniffi-bindgen.rs"
[lib]
name = "ls_sdk_bindings"
name = "breez_liquid_sdk_bindings"
crate-type = ["staticlib", "cdylib", "lib"]
[dependencies]
anyhow = { workspace = true }
ls-sdk = { path = "../ls-sdk-core" }
breez-liquid-sdk = { path = "../ls-sdk-core" }
uniffi = { workspace = true, features = [ "bindgen-tests", "cli" ] }
thiserror = { workspace = true }

View File

@@ -19,7 +19,7 @@ fn main() {
let cli_binding_dir = cli.binding_dir.unwrap_or("../".into());
let cli_out_dir = cli.out_dir.unwrap_or("./".into());
let binding_dir = Utf8Path::new(cli_binding_dir.as_str());
let udl_file = binding_dir.join(Utf8Path::new("src/ls_sdk.udl"));
let udl_file = binding_dir.join(Utf8Path::new("src/breez_liquid_sdk.udl"));
let config = binding_dir.join(Utf8Path::new("uniffi.toml"));
let out_dir = Utf8Path::new(cli_out_dir.as_str());

View File

@@ -36,5 +36,5 @@ fn setup_x86_64_android_workaround() {
fn main() {
setup_x86_64_android_workaround();
uniffi::generate_scaffolding("src/ls_sdk.udl").unwrap();
uniffi::generate_scaffolding("src/breez_liquid_sdk.udl").unwrap();
}

View File

@@ -34,7 +34,7 @@ all: bindings-swift bindings-android python react-native
## Android
android: aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android
cargo run --features=uniffi/cli --bin uniffi-bindgen generate src/ls_sdk.udl --no-format --language kotlin -o ffi/kotlin
cargo run --features=uniffi/cli --bin uniffi-bindgen generate src/breez_liquid_sdk.udl --no-format --language kotlin -o ffi/kotlin
aarch64-linux-android: $(SOURCES) ndk-home
cargo ndk -t aarch64-linux-android -o ffi/kotlin/jniLibs build --release
@@ -62,7 +62,7 @@ bindings-android: android
## Kotlin
kotlin: $(SOURCES)
cargo build --release --target $(TARGET)
cargo run --features=uniffi/cli --bin uniffi-bindgen generate src/ls_sdk.udl --no-format --language kotlin -o ffi/kotlin
cargo run --features=uniffi/cli --bin uniffi-bindgen generate src/breez_liquid_sdk.udl --no-format --language kotlin -o ffi/kotlin
## Apple
ios-universal: $(SOURCES)
@@ -85,18 +85,18 @@ darwin-universal: $(SOURCES)
## Swift
swift-ios: ios-universal
cargo run --features=uniffi/cli --bin uniffi-bindgen generate src/ls_sdk.udl -l swift -o ffi/swift-ios
cargo run --features=uniffi/cli --bin uniffi-bindgen generate src/breez_liquid_sdk.udl -l swift -o ffi/swift-ios
cp ../target/ios-universal/release/libls_sdk_bindings.a ffi/swift-ios
cd ffi/swift-ios && "swiftc" "-emit-module" "-module-name" "ls_sdk_bindings" "-Xcc" "-fmodule-map-file=$(CURRENT_DIR)/ffi/swift-ios/ls_sdkFFI.modulemap" "-I" "." "-L" "." "-lls_sdk_bindings" ls_sdk.swift
swift-darwin: darwin-universal
cargo run --features=uniffi/cli --bin uniffi-bindgen generate src/ls_sdk.udl -l swift -o ffi/swift-darwin
cargo run --features=uniffi/cli --bin uniffi-bindgen generate src/breez_liquid_sdk.udl -l swift -o ffi/swift-darwin
cp ../target/darwin-universal/release/libls_sdk_bindings.dylib ffi/swift-darwin
cd ffi/swift-darwin && "swiftc" "-emit-module" "-module-name" "ls_sdk_bindings" "-Xcc" "-fmodule-map-file=$(CURRENT_DIR)/ffi/swift-darwin/ls_sdkFFI.modulemap" "-I" "." "-L" "." "-lls_sdk_bindings" ls_sdk.swift
bindings-swift: ios-universal darwin-universal
mkdir -p bindings-swift/Sources/LiquidSwapSDK
cargo run --features=uniffi/cli --bin uniffi-bindgen generate src/ls_sdk.udl --no-format --language swift -o bindings-swift/Sources/LiquidSwapSDK
cargo run --features=uniffi/cli --bin uniffi-bindgen generate src/breez_liquid_sdk.udl --no-format --language swift -o bindings-swift/Sources/LiquidSwapSDK
mv bindings-swift/Sources/LiquidSwapSDK/ls_sdk.swift bindings-swift/Sources/LiquidSwapSDK/LiquidSwapSDK.swift
cp bindings-swift/Sources/LiquidSwapSDK/ls_sdkFFI.h bindings-swift/ls_sdkFFI.xcframework/ios-arm64/ls_sdkFFI.framework/Headers
cp bindings-swift/Sources/LiquidSwapSDK/ls_sdkFFI.h bindings-swift/ls_sdkFFI.xcframework/ios-arm64_x86_64-simulator/ls_sdkFFI.framework/Headers
@@ -110,7 +110,7 @@ bindings-swift: ios-universal darwin-universal
## Python
python: $(SOURCES)
cargo build --release --target $(TARGET)
cargo run --features=uniffi/cli --bin uniffi-bindgen generate src/ls_sdk.udl --no-format --language python -o ffi/python
cargo run --features=uniffi/cli --bin uniffi-bindgen generate src/breez_liquid_sdk.udl --no-format --language python -o ffi/python
## React Native
react-native:

View File

@@ -56,7 +56,7 @@ dictionary ReceivePaymentResponse {
string invoice;
};
namespace ls_sdk {
namespace breez_liquid_sdk {
[Throws=LsSdkError]
BindingWallet connect(string mnemonic, string? data_dir, Network network);
};

View File

@@ -1,7 +1,7 @@
use std::sync::Arc;
use anyhow::{Error, Result};
use ls_sdk::{
use breez_liquid_sdk::{
error::PaymentError,
model::{
Network, PrepareReceiveRequest, PrepareReceiveResponse, PrepareSendResponse,
@@ -78,4 +78,4 @@ impl BindingWallet {
}
}
uniffi::include_scaffolding!("ls_sdk");
uniffi::include_scaffolding!("breez_liquid_sdk");

View File

@@ -1,6 +1,6 @@
try {
var mnemonic = "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about"
var sdk = ls_sdk.connect(mnemonic, null, ls_sdk.Network.LIQUID_TESTNET)
var sdk = breez_liquid_sdk.connect(mnemonic, null, breez_liquid_sdk.Network.LIQUID_TESTNET)
var nodeInfo = sdk.getInfo(false)
println("$nodeInfo")
assert(nodeInfo.pubkey.equals("03d902f35f560e0470c63313c7369168d9d7df2d49bf295fd9fb7cb109ccee0494"))

View File

@@ -1,8 +1,8 @@
import ls_sdk
import breez_liquid_sdk
def test():
mnemonic = "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about"
sdk = ls_sdk.connect(mnemonic, None, ls_sdk.Network.LIQUID_TESTNET)
sdk = breez_liquid_sdk.connect(mnemonic, None, breez_liquid_sdk.Network.LIQUID_TESTNET)
node_info = sdk.get_info(False)
print(node_info)
assert node_info.pubkey == "03d902f35f560e0470c63313c7369168d9d7df2d49bf295fd9fb7cb109ccee0494"

View File

@@ -1,7 +1,7 @@
import ls_sdk
import breez_liquid_sdk
let mnemonic = "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about";
let sdk = try ls_sdk.connect(mnemonic: mnemonic, dataDir: nil, network: .liquidTestnet);
let sdk = try breez_liquid_sdk.connect(mnemonic: mnemonic, dataDir: nil, network: .liquidTestnet);
let nodeInfo = try sdk.getInfo(withScan: false);
print(nodeInfo);
assert(nodeInfo.pubkey == "03d902f35f560e0470c63313c7369168d9d7df2d49bf295fd9fb7cb109ccee0494", "nodeInfo.pubkey");

View File

@@ -1,5 +1,5 @@
uniffi::build_foreign_language_testcases!(
"tests/bindings/test_ls_sdk.swift",
"tests/bindings/test_ls_sdk.kts",
"tests/bindings/test_ls_sdk.py"
"tests/bindings/test_breez_liquid_sdk.swift",
"tests/bindings/test_breez_liquid_sdk.kts",
"tests/bindings/test_breez_liquid_sdk.py"
);

View File

@@ -1,12 +1,12 @@
# https://mozilla.github.io/uniffi-rs/swift/configuration.html
[bindings.swift]
cdylib_name = "ls_sdk_bindings"
cdylib_name = "breez_liquid_sdk_bindings"
# https://mozilla.github.io/uniffi-rs/kotlin/configuration.html
[bindings.kotlin]
package_name = "ls_sdk"
cdylib_name = "ls_sdk_bindings"
package_name = "breez_liquid_sdk"
cdylib_name = "breez_liquid_sdk_bindings"
# https://mozilla.github.io/uniffi-rs/python/configuration.html
[bindings.python]
cdylib_name = "ls_sdk_bindings"
cdylib_name = "breez_liquid_sdk_bindings"

View File

@@ -1,10 +1,10 @@
[package]
name = "ls-sdk"
name = "breez-liquid-sdk"
edition = "2021"
version.workspace = true
[lib]
name = "ls_sdk"
name = "breez_liquid_sdk"
[dependencies]
anyhow = { workspace = true }