Skip to content

Commit

Permalink
Rename android, swift and react native bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
dangeross committed Apr 30, 2024
1 parent c817415 commit 7add324
Show file tree
Hide file tree
Showing 86 changed files with 366 additions and 360 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Liquid Swap SDK
# Breez Liquid SDK

- `lib`: [lib/README.md](lib/ls-sdk-core/README.md)
- `cli`: [cli/README.md](cli/README.md)
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 *; }
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 %}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { NativeModules, Platform } from "react-native"

const LINKING_ERROR =
`The package 'react-native-liquid-swap-sdk' doesn't seem to be linked. Make sure: \n\n` +
`The package 'react-native-breez-liquid-sdk' doesn't seem to be linked. Make sure: \n\n` +
Platform.select({ ios: "- You have run 'pod install'\n", default: "" }) +
"- You rebuilt the app after installing the package\n" +
"- You are not using Expo managed workflow\n"

const LiquidSwapSDK = NativeModules.RNLiquidSwapSDK
? NativeModules.RNLiquidSwapSDK
const BreezLiquidSDK = NativeModules.RNBreezLiquidSDK
? NativeModules.RNBreezLiquidSDK
: new Proxy(
{},
{
Expand Down
16 changes: 9 additions & 7 deletions lib/ls-sdk-bindings/bindings-react-native/src/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ impl RNBindingGenerator {
base_output_path: &Utf8Path,
) -> Result<()> {
// Create the path
let output_path = base_output_path.join(Utf8Path::new("android/src/main/java/com/lssdk"));
let output_path =
base_output_path.join(Utf8Path::new("android/src/main/java/com/breezliquidsdk"));
// Generate and write the binding to file
let bindings_output = self::gen_kotlin::MapperGenerator::new(config.clone(), ci)
.render()
Expand All @@ -45,7 +46,7 @@ impl RNBindingGenerator {
.write_bindings(
&bindings_output,
&output_path,
Utf8Path::new("LiquidSwapSDKMapper.kt"),
Utf8Path::new("BreezLiquidSDKMapper.kt"),
)
.unwrap();
// Lint binding
Expand All @@ -60,7 +61,8 @@ impl RNBindingGenerator {
base_output_path: &Utf8Path,
) -> Result<()> {
// Create the path
let output_path = base_output_path.join(Utf8Path::new("android/src/main/java/com/lssdk"));
let output_path =
base_output_path.join(Utf8Path::new("android/src/main/java/com/breezliquidsdk"));
// Generate and write the binding to file
let bindings_output = self::gen_kotlin::ModuleGenerator::new(config.clone(), ci)
.render()
Expand All @@ -69,7 +71,7 @@ impl RNBindingGenerator {
.write_bindings(
&bindings_output,
&output_path,
Utf8Path::new("LiquidSwapSDKModule.kt"),
Utf8Path::new("BreezLiquidSDKModule.kt"),
)
.unwrap();
// Lint binding
Expand Down Expand Up @@ -103,7 +105,7 @@ impl RNBindingGenerator {
.write_bindings(
&bindings_output,
&output_path,
Utf8Path::new("LiquidSwapSDKMapper.swift"),
Utf8Path::new("BreezLiquidSDKMapper.swift"),
)
.unwrap();
// Lint binding
Expand All @@ -127,7 +129,7 @@ impl RNBindingGenerator {
.write_bindings(
&bindings_output,
&output_path,
Utf8Path::new("RNLiquidSwapSDK.m"),
Utf8Path::new("RNBreezLiquidSDK.m"),
)
.unwrap();
// Lint binding
Expand All @@ -151,7 +153,7 @@ impl RNBindingGenerator {
.write_bindings(
&bindings_output,
&output_path,
Utf8Path::new("RNLiquidSwapSDK.swift"),
Utf8Path::new("RNBreezLiquidSDK.swift"),
)
.unwrap();
// Lint binding
Expand Down
8 changes: 4 additions & 4 deletions lib/ls-sdk-bindings/bindings-swift/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
.build/
*.xcodeproj
*.podspec
Sources/LiquidSwapSDK/LiquidSwapSDK.swift
**/ls_sdkFFI.h
**/ls_sdkFFI
**/ls_sdkFFI.modulemap
Sources/BreezLiquidSDK/BreezLiquidSDK.swift
**/breez_liquid_sdkFFI.h
**/breez_liquid_sdkFFI
**/breez_liquid_sdkFFI.modulemap
6 changes: 3 additions & 3 deletions lib/ls-sdk-bindings/bindings-swift/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ let package = Package(
.iOS(.v11),
],
products: [
.library(name: "LiquidSwapSDK", targets: ["ls_sdkFFI", "LiquidSwapSDK"]),
.library(name: "BreezLiquidSDK", targets: ["breez_liquid_sdkFFI", "BreezLiquidSDK"]),
],
targets: [
.binaryTarget(name: "ls_sdkFFI", path: "./ls_sdkFFI.xcframework"),
.target(name: "LiquidSwapSDK", dependencies: ["ls_sdkFFI"]),
.binaryTarget(name: "breez_liquid_sdkFFI", path: "./breez_liquid_sdkFFI.xcframework"),
.target(name: "BreezLiquidSDK", dependencies: ["breez_liquid_sdkFFI"]),
]
)
Loading

0 comments on commit 7add324

Please sign in to comment.