mirror of
https://github.com/aljazceru/breez-sdk-liquid.git
synced 2025-12-18 22:44:22 +01:00
Add Go/CS bindings (#147)
* Publish Go/CS packages * Fix optional param ordering * Fix CI installed bindgens
This commit is contained in:
@@ -10,7 +10,7 @@ Pod::Spec.new do |s|
|
||||
s.license = package["license"]
|
||||
s.authors = package["author"]
|
||||
|
||||
s.platforms = { :ios => "11.0" }
|
||||
s.platforms = { :ios => "13.0" }
|
||||
s.source = { :git => "https://github.com/breez/breez-sdk-liquid.git", :tag => "#{s.version}" }
|
||||
|
||||
s.source_files = "ios/**/*.{h,m,mm,swift}"
|
||||
|
||||
@@ -1156,26 +1156,26 @@ fun asPayment(payment: ReadableMap): Payment? {
|
||||
) {
|
||||
return null
|
||||
}
|
||||
val destination = if (hasNonNullKey(payment, "destination")) payment.getString("destination") else null
|
||||
val txId = if (hasNonNullKey(payment, "txId")) payment.getString("txId") else null
|
||||
val timestamp = payment.getInt("timestamp").toUInt()
|
||||
val amountSat = payment.getDouble("amountSat").toULong()
|
||||
val feesSat = payment.getDouble("feesSat").toULong()
|
||||
val paymentType = payment.getString("paymentType")?.let { asPaymentType(it) }!!
|
||||
val status = payment.getString("status")?.let { asPaymentState(it) }!!
|
||||
val destination = if (hasNonNullKey(payment, "destination")) payment.getString("destination") else null
|
||||
val txId = if (hasNonNullKey(payment, "txId")) payment.getString("txId") else null
|
||||
val details = if (hasNonNullKey(payment, "details")) payment.getMap("details")?.let { asPaymentDetails(it) } else null
|
||||
return Payment(destination, txId, timestamp, amountSat, feesSat, paymentType, status, details)
|
||||
return Payment(timestamp, amountSat, feesSat, paymentType, status, destination, txId, details)
|
||||
}
|
||||
|
||||
fun readableMapOf(payment: Payment): ReadableMap =
|
||||
readableMapOf(
|
||||
"destination" to payment.destination,
|
||||
"txId" to payment.txId,
|
||||
"timestamp" to payment.timestamp,
|
||||
"amountSat" to payment.amountSat,
|
||||
"feesSat" to payment.feesSat,
|
||||
"paymentType" to payment.paymentType.name.lowercase(),
|
||||
"status" to payment.status.name.lowercase(),
|
||||
"destination" to payment.destination,
|
||||
"txId" to payment.txId,
|
||||
"details" to payment.details?.let { readableMapOf(it) },
|
||||
)
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ Pod::Spec.new do |s|
|
||||
s.license = package["license"]
|
||||
s.authors = package["author"]
|
||||
|
||||
s.platforms = { :ios => "11.0" }
|
||||
s.platforms = { :ios => "13.0" }
|
||||
s.source = { :git => "https://github.com/breez/breez-sdk-liquid.git", :tag => "#{s.version}" }
|
||||
|
||||
s.source_files = "ios/**/*.{h,m,mm,swift}"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require_relative '../node_modules/react-native/scripts/react_native_pods'
|
||||
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
|
||||
|
||||
platform :ios, '12.4'
|
||||
platform :ios, '13'
|
||||
install! 'cocoapods', :deterministic_uuids => false
|
||||
|
||||
target 'BreezSDKLiquidExample' do
|
||||
@@ -39,7 +39,7 @@ target 'BreezSDKLiquidExample' do
|
||||
# should also work.
|
||||
installer.pods_project.targets.each do |target|
|
||||
target.build_configurations.each do |config|
|
||||
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.4'
|
||||
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13'
|
||||
end
|
||||
end
|
||||
__apply_Xcode_12_5_M1_post_install_workaround(installer)
|
||||
|
||||
@@ -1350,20 +1350,6 @@ enum BreezSDKLiquidMapper {
|
||||
}
|
||||
|
||||
static func asPayment(payment: [String: Any?]) throws -> Payment {
|
||||
var destination: String?
|
||||
if hasNonNilKey(data: payment, key: "destination") {
|
||||
guard let destinationTmp = payment["destination"] as? String else {
|
||||
throw SdkError.Generic(message: errUnexpectedValue(fieldName: "destination"))
|
||||
}
|
||||
destination = destinationTmp
|
||||
}
|
||||
var txId: String?
|
||||
if hasNonNilKey(data: payment, key: "txId") {
|
||||
guard let txIdTmp = payment["txId"] as? String else {
|
||||
throw SdkError.Generic(message: errUnexpectedValue(fieldName: "txId"))
|
||||
}
|
||||
txId = txIdTmp
|
||||
}
|
||||
guard let timestamp = payment["timestamp"] as? UInt32 else {
|
||||
throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "timestamp", typeName: "Payment"))
|
||||
}
|
||||
@@ -1383,23 +1369,37 @@ enum BreezSDKLiquidMapper {
|
||||
}
|
||||
let status = try asPaymentState(paymentState: statusTmp)
|
||||
|
||||
var destination: String?
|
||||
if hasNonNilKey(data: payment, key: "destination") {
|
||||
guard let destinationTmp = payment["destination"] as? String else {
|
||||
throw SdkError.Generic(message: errUnexpectedValue(fieldName: "destination"))
|
||||
}
|
||||
destination = destinationTmp
|
||||
}
|
||||
var txId: String?
|
||||
if hasNonNilKey(data: payment, key: "txId") {
|
||||
guard let txIdTmp = payment["txId"] as? String else {
|
||||
throw SdkError.Generic(message: errUnexpectedValue(fieldName: "txId"))
|
||||
}
|
||||
txId = txIdTmp
|
||||
}
|
||||
var details: PaymentDetails?
|
||||
if let detailsTmp = payment["details"] as? [String: Any?] {
|
||||
details = try asPaymentDetails(paymentDetails: detailsTmp)
|
||||
}
|
||||
|
||||
return Payment(destination: destination, txId: txId, timestamp: timestamp, amountSat: amountSat, feesSat: feesSat, paymentType: paymentType, status: status, details: details)
|
||||
return Payment(timestamp: timestamp, amountSat: amountSat, feesSat: feesSat, paymentType: paymentType, status: status, destination: destination, txId: txId, details: details)
|
||||
}
|
||||
|
||||
static func dictionaryOf(payment: Payment) -> [String: Any?] {
|
||||
return [
|
||||
"destination": payment.destination == nil ? nil : payment.destination,
|
||||
"txId": payment.txId == nil ? nil : payment.txId,
|
||||
"timestamp": payment.timestamp,
|
||||
"amountSat": payment.amountSat,
|
||||
"feesSat": payment.feesSat,
|
||||
"paymentType": valueOf(paymentType: payment.paymentType),
|
||||
"status": valueOf(paymentState: payment.status),
|
||||
"destination": payment.destination == nil ? nil : payment.destination,
|
||||
"txId": payment.txId == nil ? nil : payment.txId,
|
||||
"details": payment.details == nil ? nil : dictionaryOf(paymentDetails: payment.details!),
|
||||
]
|
||||
}
|
||||
|
||||
@@ -212,13 +212,13 @@ export interface PayOnchainRequest {
|
||||
}
|
||||
|
||||
export interface Payment {
|
||||
destination?: string
|
||||
txId?: string
|
||||
timestamp: number
|
||||
amountSat: number
|
||||
feesSat: number
|
||||
paymentType: PaymentType
|
||||
status: PaymentState
|
||||
destination?: string
|
||||
txId?: string
|
||||
details?: PaymentDetails
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user