Skip to content

Commit

Permalink
Merge branch 'ok300-rename-rust'
Browse files Browse the repository at this point in the history
# Conflicts:
#	lib/ls-sdk-bindings/makefile
  • Loading branch information
ok300 committed May 2, 2024
2 parents 080698c + 77c9962 commit a0a852b
Show file tree
Hide file tree
Showing 92 changed files with 464 additions and 362 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Liquid Swap SDK
# Breez Liquid SDK

- `lib`: [lib/README.md](lib/ls-sdk-core/README.md)
- `cli`: [cli/README.md](cli/README.md)
- Bindings
- `python`: [lib/bindings-python/README.md]()

## Roadmap
- [x] Send/Recieve Lightning payments
Expand Down
2 changes: 1 addition & 1 deletion cli/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# breez-sdk-liquid-cli
# breez-liquid-sdk-cli

## Setup

Expand Down
2 changes: 1 addition & 1 deletion lib/ls-sdk-bindings/bindings-android/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ gen-external-apklibs
# End of https://www.toptal.com/developers/gitignore/api/android

lib/src/main/jniLibs/
lib/src/main/kotlin/ls_sdk
lib/src/main/kotlin/breez_liquid_sdk
12 changes: 6 additions & 6 deletions lib/ls-sdk-bindings/bindings-android/buildForJitpack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ fi
echo "JitPack building version $VERSION."
cd $(dirname $0)

curl https://mvn.breez.technology/releases/ls_sdk/bindings-android/$VERSION/bindings-android-$VERSION.aar --output bindings-android-$VERSION.aar
curl https://mvn.breez.technology/releases/ls_sdk/bindings-android/$VERSION/bindings-android-$VERSION.module --output bindings-android-$VERSION.module
curl https://mvn.breez.technology/releases/ls_sdk/bindings-android/$VERSION/bindings-android-$VERSION-sources.jar --output bindings-android-$VERSION-sources.jar
curl https://mvn.breez.technology/releases/ls_sdk/bindings-android/$VERSION/bindings-android-$VERSION.pom --output bindings-android-$VERSION.pom
curl https://mvn.breez.technology/releases/breez_liquid_sdk/bindings-android/$VERSION/bindings-android-$VERSION.aar --output bindings-android-$VERSION.aar
curl https://mvn.breez.technology/releases/breez_liquid_sdk/bindings-android/$VERSION/bindings-android-$VERSION.module --output bindings-android-$VERSION.module
curl https://mvn.breez.technology/releases/breez_liquid_sdk/bindings-android/$VERSION/bindings-android-$VERSION-sources.jar --output bindings-android-$VERSION-sources.jar
curl https://mvn.breez.technology/releases/breez_liquid_sdk/bindings-android/$VERSION/bindings-android-$VERSION.pom --output bindings-android-$VERSION.pom

mvn org.apache.maven.plugins:maven-install-plugin:3.1.1:install-file -Dfile=bindings-android-$VERSION.aar -DpomFile=bindings-android-$VERSION.pom
mvn org.apache.maven.plugins:maven-install-plugin:3.1.1:install-file -Dfile=bindings-android-$VERSION.module -DpomFile=bindings-android-$VERSION.pom
mvn org.apache.maven.plugins:maven-install-plugin:3.1.1:install-file -Dfile=bindings-android-$VERSION-sources.jar -DpomFile=bindings-android-$VERSION.pom -Dclassifier=sources

ls /home/jitpack/.m2/repository/ls_sdk/bindings-android
ls /home/jitpack/.m2/repository/breez_liquid_sdk/bindings-android
echo "---"
ls /home/jitpack/.m2/repository/ls_sdk/bindings-android/$VERSION/
ls /home/jitpack/.m2/repository/breez_liquid_sdk/bindings-android/$VERSION/
16 changes: 8 additions & 8 deletions lib/ls-sdk-bindings/bindings-android/lib/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ publishing {
}
maven {
name = "breezGitHubPackages"
url = uri("https://maven.pkg.github.com/breez/breez-sdk-liquid")
url = uri("https://maven.pkg.github.com/breez/breez-liquid-sdk")
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
Expand All @@ -63,7 +63,7 @@ publishing {
}
publications {
create<MavenPublication>("maven") {
groupId = "ls_sdk"
groupId = "breez_liquid_sdk"
artifactId = "bindings-android"
version = libraryVersion

Expand All @@ -72,19 +72,19 @@ publishing {
}

pom {
name.set("ls-sdk")
description.set("The Liquid Swap SDK enables mobile developers to integrate Liquid swaps into their apps with a very shallow learning curve.")
name.set("breez-liquid-sdk")
description.set("The Breez Liquid SDK enables mobile developers to integrate Liquid swaps into their apps with a very shallow learning curve.")
url.set("https://breez.technology")
licenses {
license {
name.set("MIT")
url.set("https://github.com/breez/breez-sdk-liquid/blob/main/LICENSE")
url.set("https://github.com/breez/breez-liquid-sdk/blob/main/LICENSE")
}
}
scm {
connection.set("scm:git:github.com/breez/breez-sdk-liquid.git")
developerConnection.set("scm:git:ssh://github.com/breez/breez-sdk-liquid.git")
url.set("https://github.com/breez/breez-sdk-liquid")
connection.set("scm:git:github.com/breez/breez-liquid-sdk.git")
developerConnection.set("scm:git:ssh://github.com/breez/breez-liquid-sdk.git")
url.set("https://github.com/breez/breez-liquid-sdk")
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/ls-sdk-bindings/bindings-android/lib/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
-dontwarn java.awt.*
-keep class com.sun.jna.** { *; }
-keep class technology.breez.* { *; }
-keep class ls_sdk.** { *; }
-keep class breez_liquid_sdk.** { *; }
-keepclassmembers class * extends technology.breez.* { public *; }
-keepclassmembers class * extends ls_sdk.** { public *; }
-keepclassmembers class * extends breez_liquid_sdk.** { public *; }
-keepclassmembers class * extends com.sun.jna.** { public *; }
5 changes: 5 additions & 0 deletions lib/ls-sdk-bindings/bindings-python/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
src/breez_liquid_sdk/*
!src/breez_liquid_sdk/__init__.py
*.egg-info
build
dist
37 changes: 37 additions & 0 deletions lib/ls-sdk-bindings/bindings-python/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Breez Liquid SDK bindings for Python

## Usage

```
pip install breez_liquid_sdk
```

``` python
import breez_liquid_sdk
```

## Python Package

Run the GitHub workflow 'Publish Python Bindings' when creating a new release of Breez Liquid SDK.
It will create wheels for the following Python versions and Platforms and upload them to [PyPi.org](https://pypi.org/project/breez-liquid-sdk/).

### Supported Wheels

| | GNU/Linux amd64 | GNU/Linux arm64v8 | macOS x86_64 | macOS aarch64 | Windows x86_64 | Windows 32 |
|-----------------|-----------------|-------------------|--------------|---------------|----------------|------------|
| **Python 3.8** |||||||
| **Python 3.9** |||||||
| **Python 3.10** |||||||
| **Python 3.11** |||||||
| **Python 3.12** |||||||

## Building Manually

To build the package manually inside this directory use the supplied `makefile`:

``` shell
make darwin # builds the package for macos
make linux # builds the package for linux
```

The artifacts will be placed in `src/breez_liquid_sdk/`.
13 changes: 13 additions & 0 deletions lib/ls-sdk-bindings/bindings-python/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.PHONY: init
init:
make -C ../ init

darwin:
make -C ../ python-darwin
cp ../ffi/python/breez_liquid_sdk.py src/breez_liquid_sdk
cp ../ffi/python/libbreez_liquid_sdk_bindings.dylib src/breez_liquid_sdk

linux:
make -C ../ python-linux
cp ../ffi/python/breez_liquid_sdk.py src/breez_liquid_sdk
cp ../ffi/python/libbreez_liquid_sdk_bindings.so src/breez_liquid_sdk
3 changes: 3 additions & 0 deletions lib/ls-sdk-bindings/bindings-python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
29 changes: 29 additions & 0 deletions lib/ls-sdk-bindings/bindings-python/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env python

from setuptools import setup

LONG_DESCRIPTION = """# Breez Liquid SDK
Python language bindings for the [Breez Liquid SDK](https://github.com/breez/breez-liquid-sdk).
## Installing
```shell
pip install breez_liquid_sdk
```
"""

setup(
name="breez_liquid_sdk",
version="0.2.7.dev9",
description="Python language bindings for the Breez Liquid SDK",
long_description=LONG_DESCRIPTION,
long_description_content_type="text/markdown",
packages=["breez_liquid_sdk"],
package_dir={"breez_liquid_sdk": "./src/breez_liquid_sdk"},
include_package_data=True,
package_data={"breez_liquid_sdk": ["*.dylib", "*.so", "*.dll"]},
url="https://github.com/breez/breez-liquid-sdk",
author="Breez <[email protected]>",
license="MIT",
has_ext_modules=lambda: True,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from breez_liquid_sdk.breez_liquid_sdk import *
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{%- import "macros.kt" as kt -%}
package com.lssdk
import ls_sdk.*
package com.breezliquidsdk
import breez_liquid_sdk.*
import com.facebook.react.bridge.*
import com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEmitter
import java.io.File
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.lssdk
package com.breezliquidsdk

import ls_sdk.*
import breez_liquid_sdk.*
import com.facebook.react.bridge.*
import com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEmitter
import java.io.File
Expand All @@ -9,12 +9,12 @@ import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors
{% import "macros.kt" as kt %}

class LiquidSwapSDKModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
class BreezLiquidSDKModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
private lateinit var executor: ExecutorService
private var bindingWallet: BindingWallet? = null

companion object {
const val TAG = "RNLiquidSwapSDK"
const val TAG = "RNBreezLiquidSDK"
}

override fun initialize() {
Expand Down Expand Up @@ -58,7 +58,7 @@ class LiquidSwapSDKModule(reactContext: ReactApplicationContext) : ReactContextB

executor.execute {
try {
val dataDirTmp = dataDir.takeUnless { it.isEmpty() } ?: run { reactApplicationContext.filesDir.toString() + "/lsSdk" }
val dataDirTmp = dataDir.takeUnless { it.isEmpty() } ?: run { reactApplicationContext.filesDir.toString() + "/breezLiquidSdk" }
val networkTmp = asNetwork(network)
bindingWallet = connect(mnemonic, dataDirTmp, networkTmp)
promise.resolve(readableMapOf("status" to "ok"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,14 +209,14 @@ pub mod filters {
}
match t {
Type::Enum(_) | Type::Record(_) => Ok(format!(
"LiquidSwapSDKMapper.dictionaryOf({}: res{})",
"BreezLiquidSDKMapper.dictionaryOf({}: res{})",
name, optional_suffix
)),
Type::Sequence(inner) => {
let unboxed = inner.as_ref();
match unboxed {
Type::Enum(_) | Type::Record(_) => Ok(format!(
"LiquidSwapSDKMapper.arrayOf({}List: res{})",
"BreezLiquidSDKMapper.arrayOf({}List: res{})",
name, optional_suffix
)),
_ => Ok(format!("res{}", optional_suffix)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
{%- when Type::Enum(inner) %}
{%- let e = ci.get_enum_definition(inner).unwrap() %}
{%- if e.is_flat() %}
let {{arg.name()|var_name|unquote|temporary}} = try LiquidSwapSDKMapper.as{{arg.type_()|type_name}}({{ arg.type_()|type_name|var_name|unquote }}: {{ arg.name()|var_name|unquote }})
let {{arg.name()|var_name|unquote|temporary}} = try BreezLiquidSDKMapper.as{{arg.type_()|type_name}}({{ arg.type_()|type_name|var_name|unquote }}: {{ arg.name()|var_name|unquote }})
{%- else %}
let {{arg.name()|var_name|unquote|temporary}} = try LiquidSwapSDKMapper.as{{arg.type_()|type_name}}({{ arg.type_()|type_name|var_name|unquote }}: {{ arg.name()|var_name|unquote }})
let {{arg.name()|var_name|unquote|temporary}} = try BreezLiquidSDKMapper.as{{arg.type_()|type_name}}({{ arg.type_()|type_name|var_name|unquote }}: {{ arg.name()|var_name|unquote }})
{%- endif %}
{%- when Type::Optional(_) %}
let {{arg.name()|var_name|unquote|temporary}} = {{ arg.type_()|rn_convert_type(arg.name()|var_name|unquote) -}}
{%- when Type::Record(_) %}
let {{arg.type_()|type_name|var_name|unquote}} = try LiquidSwapSDKMapper.as{{arg.type_()|type_name}}({{ arg.type_()|type_name|var_name|unquote }}: {{ arg.name()|var_name|unquote }})
let {{arg.type_()|type_name|var_name|unquote}} = try BreezLiquidSDKMapper.as{{arg.type_()|type_name}}({{ arg.type_()|type_name|var_name|unquote }}: {{ arg.name()|var_name|unquote }})
{%- else %}
{%- endmatch %}
{%- endfor %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#import <React/RCTBridgeModule.h>
#import <React/RCTEventEmitter.h>

@interface RCT_EXTERN_MODULE(RNLiquidSwapSDK, RCTEventEmitter)
@interface RCT_EXTERN_MODULE(RNBreezLiquidSDK, RCTEventEmitter)
{% for func in ci.function_definitions() %}
{%- if func.name()|ignored_function == false -%}
{% include "ExternFunctionTemplate.m" %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{%- import "macros.swift" as swift -%}
import Foundation
import LiquidSwapSDK
import BreezLiquidSDK

enum LiquidSwapSDKMapper {
enum BreezLiquidSDKMapper {

{%- include "Types.swift" %}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import Foundation
import LiquidSwapSDK
import BreezLiquidSDK

@objc(RNLiquidSwapSDK)
class RNLiquidSwapSDK: RCTEventEmitter {
static let TAG: String = "LiquidSwapSDK"
@objc(RNBreezLiquidSDK)
class RNBreezLiquidSDK: RCTEventEmitter {
static let TAG: String = "BreezLiquidSDK"

public static var emitter: RCTEventEmitter!
public static var hasListeners: Bool = false
Expand All @@ -13,12 +13,12 @@ class RNLiquidSwapSDK: RCTEventEmitter {
static var defaultDataDir: URL {
let applicationDirectory = FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask).first!

return applicationDirectory.appendingPathComponent("lsSdk", isDirectory: true)
return applicationDirectory.appendingPathComponent("breezLiquidSdk", isDirectory: true)
}

override init() {
super.init()
RNLiquidSwapSDK.emitter = self
RNBreezLiquidSDK.emitter = self
}

@objc
Expand All @@ -31,11 +31,11 @@ class RNLiquidSwapSDK: RCTEventEmitter {
}

override func startObserving() {
RNLiquidSwapSDK.hasListeners = true
RNBreezLiquidSDK.hasListeners = true
}

override func stopObserving() {
RNLiquidSwapSDK.hasListeners = false
RNBreezLiquidSDK.hasListeners = false
}

@objc
Expand All @@ -51,7 +51,7 @@ class RNLiquidSwapSDK: RCTEventEmitter {
throw LsSdkError.Generic(message: "Not initialized")
}

{% let obj_interface = "LiquidSwapSDK." -%}
{% let obj_interface = "BreezLiquidSDK." -%}
{% for func in ci.function_definitions() %}
{%- if func.name()|ignored_function == false -%}
{% include "TopLevelFunctionTemplate.swift" %}
Expand All @@ -65,9 +65,9 @@ class RNLiquidSwapSDK: RCTEventEmitter {
}

do {
let dataDirTmp = dataDir.isEmpty ? RNLiquidSwapSDK.defaultDataDir.path : dataDir
let networkTmp = try LiquidSwapSDKMapper.asNetwork(network: network)
bindingWallet = try LiquidSwapSDK.connect(mnemonic: mnemonic, dataDir: dataDirTmp, network: networkTmp)
let dataDirTmp = dataDir.isEmpty ? RNBreezLiquidSDK.defaultDataDir.path : dataDir
let networkTmp = try BreezLiquidSDKMapper.asNetwork(network: network)
bindingWallet = try BreezLiquidSDK.connect(mnemonic: mnemonic, dataDir: dataDirTmp, network: networkTmp)
resolve(["status": "ok"])
} catch let err {
rejectErr(err: err, reject: reject)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ static KEYWORDS: Lazy<HashSet<String>> = Lazy::new(|| {
});

static IGNORED_FUNCTIONS: Lazy<HashSet<String>> = Lazy::new(|| {
let list: Vec<&str> = vec![];
let list: Vec<&str> = vec!["connect"];
HashSet::from_iter(list.into_iter().map(|s| s.to_string()))
});

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

export const connect = async (mnemonic: string, dataDir: string = "", network: Network): Promise<void> => {
const response = await BreezLiquidSDK.connect(mnemonic, dataDir, network)
return response
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{%- match func.return_type() -%}
{%- when Some with (return_type) %}
export const {{ func.name()|fn_name }} = async ({%- call ts::arg_list_decl(func) -%}): Promise<{{ return_type|return_type_name }}> => {
const response = await LiquidSwapSDK.{{func.name()|fn_name}}({%- call ts::arg_list(func) -%})
const response = await BreezLiquidSDK.{{func.name()|fn_name}}({%- call ts::arg_list(func) -%})
return response
}
{%- when None %}
export const {{ func.name()|fn_name }} = async ({%- call ts::arg_list_decl(func) -%}): Promise<void> => {
await LiquidSwapSDK.{{ func.name()|fn_name }}({%- call ts::arg_list(func) -%})
await BreezLiquidSDK.{{ func.name()|fn_name }}({%- call ts::arg_list(func) -%})
}
{%- endmatch %}
Loading

0 comments on commit a0a852b

Please sign in to comment.