Skip to content

Commit

Permalink
fix: bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
hydra-yse committed Dec 24, 2024
1 parent 9fd6369 commit 422ae39
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 13 deletions.
84 changes: 73 additions & 11 deletions packages/dart/lib/src/frb_generated.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1699,7 +1699,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
Config dco_decode_config(dynamic raw) {
// Codec=Dco (DartCObject based), see doc to use other codecs
final arr = raw as List<dynamic>;
if (arr.length != 12) throw Exception('unexpected arr length: expect 12 but see ${arr.length}');
if (arr.length != 13) throw Exception('unexpected arr length: expect 13 but see ${arr.length}');
return Config(
liquidElectrumUrl: dco_decode_String(arr[0]),
bitcoinElectrumUrl: dco_decode_String(arr[1]),
Expand All @@ -1709,10 +1709,11 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
network: dco_decode_liquid_network(arr[5]),
paymentTimeoutSec: dco_decode_u_64(arr[6]),
zeroConfMinFeeRateMsat: dco_decode_u_32(arr[7]),
zeroConfMaxAmountSat: dco_decode_opt_box_autoadd_u_64(arr[8]),
breezApiKey: dco_decode_opt_String(arr[9]),
externalInputParsers: dco_decode_opt_list_external_input_parser(arr[10]),
useDefaultExternalInputParsers: dco_decode_bool(arr[11]),
syncServiceUrl: dco_decode_String(arr[8]),
zeroConfMaxAmountSat: dco_decode_opt_box_autoadd_u_64(arr[9]),
breezApiKey: dco_decode_opt_String(arr[10]),
externalInputParsers: dco_decode_opt_list_external_input_parser(arr[11]),
useDefaultExternalInputParsers: dco_decode_bool(arr[12]),
);
}

Expand Down Expand Up @@ -1963,6 +1964,12 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
}
}

@protected
List<PaymentState> dco_decode_list_payment_state(dynamic raw) {
// Codec=Dco (DartCObject based), see doc to use other codecs
return (raw as List<dynamic>).map(dco_decode_payment_state).toList();
}

@protected
List<PaymentType> dco_decode_list_payment_type(dynamic raw) {
// Codec=Dco (DartCObject based), see doc to use other codecs
Expand All @@ -1973,14 +1980,15 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
ListPaymentsRequest dco_decode_list_payments_request(dynamic raw) {
// Codec=Dco (DartCObject based), see doc to use other codecs
final arr = raw as List<dynamic>;
if (arr.length != 6) throw Exception('unexpected arr length: expect 6 but see ${arr.length}');
if (arr.length != 7) throw Exception('unexpected arr length: expect 7 but see ${arr.length}');
return ListPaymentsRequest(
filters: dco_decode_opt_list_payment_type(arr[0]),
fromTimestamp: dco_decode_opt_box_autoadd_i_64(arr[1]),
toTimestamp: dco_decode_opt_box_autoadd_i_64(arr[2]),
offset: dco_decode_opt_box_autoadd_u_32(arr[3]),
limit: dco_decode_opt_box_autoadd_u_32(arr[4]),
details: dco_decode_opt_box_autoadd_list_payment_details(arr[5]),
states: dco_decode_opt_list_payment_state(arr[1]),
fromTimestamp: dco_decode_opt_box_autoadd_i_64(arr[2]),
toTimestamp: dco_decode_opt_box_autoadd_i_64(arr[3]),
offset: dco_decode_opt_box_autoadd_u_32(arr[4]),
limit: dco_decode_opt_box_autoadd_u_32(arr[5]),
details: dco_decode_opt_box_autoadd_list_payment_details(arr[6]),
);
}

Expand Down Expand Up @@ -2504,6 +2512,12 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
return raw == null ? null : dco_decode_list_external_input_parser(raw);
}

@protected
List<PaymentState>? dco_decode_opt_list_payment_state(dynamic raw) {
// Codec=Dco (DartCObject based), see doc to use other codecs
return raw == null ? null : dco_decode_list_payment_state(raw);
}

@protected
List<PaymentType>? dco_decode_opt_list_payment_type(dynamic raw) {
// Codec=Dco (DartCObject based), see doc to use other codecs
Expand Down Expand Up @@ -3650,6 +3664,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
var var_network = sse_decode_liquid_network(deserializer);
var var_paymentTimeoutSec = sse_decode_u_64(deserializer);
var var_zeroConfMinFeeRateMsat = sse_decode_u_32(deserializer);
var var_syncServiceUrl = sse_decode_String(deserializer);
var var_zeroConfMaxAmountSat = sse_decode_opt_box_autoadd_u_64(deserializer);
var var_breezApiKey = sse_decode_opt_String(deserializer);
var var_externalInputParsers = sse_decode_opt_list_external_input_parser(deserializer);
Expand All @@ -3663,6 +3678,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
network: var_network,
paymentTimeoutSec: var_paymentTimeoutSec,
zeroConfMinFeeRateMsat: var_zeroConfMinFeeRateMsat,
syncServiceUrl: var_syncServiceUrl,
zeroConfMaxAmountSat: var_zeroConfMaxAmountSat,
breezApiKey: var_breezApiKey,
externalInputParsers: var_externalInputParsers,
Expand Down Expand Up @@ -3947,6 +3963,18 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
}
}

@protected
List<PaymentState> sse_decode_list_payment_state(SseDeserializer deserializer) {
// Codec=Sse (Serialization based), see doc to use other codecs

var len_ = sse_decode_i_32(deserializer);
var ans_ = <PaymentState>[];
for (var idx_ = 0; idx_ < len_; ++idx_) {
ans_.add(sse_decode_payment_state(deserializer));
}
return ans_;
}

@protected
List<PaymentType> sse_decode_list_payment_type(SseDeserializer deserializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
Expand All @@ -3963,13 +3991,15 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
ListPaymentsRequest sse_decode_list_payments_request(SseDeserializer deserializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
var var_filters = sse_decode_opt_list_payment_type(deserializer);
var var_states = sse_decode_opt_list_payment_state(deserializer);
var var_fromTimestamp = sse_decode_opt_box_autoadd_i_64(deserializer);
var var_toTimestamp = sse_decode_opt_box_autoadd_i_64(deserializer);
var var_offset = sse_decode_opt_box_autoadd_u_32(deserializer);
var var_limit = sse_decode_opt_box_autoadd_u_32(deserializer);
var var_details = sse_decode_opt_box_autoadd_list_payment_details(deserializer);
return ListPaymentsRequest(
filters: var_filters,
states: var_states,
fromTimestamp: var_fromTimestamp,
toTimestamp: var_toTimestamp,
offset: var_offset,
Expand Down Expand Up @@ -4570,6 +4600,17 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
}
}

@protected
List<PaymentState>? sse_decode_opt_list_payment_state(SseDeserializer deserializer) {
// Codec=Sse (Serialization based), see doc to use other codecs

if (sse_decode_bool(deserializer)) {
return (sse_decode_list_payment_state(deserializer));
} else {
return null;
}
}

@protected
List<PaymentType>? sse_decode_opt_list_payment_type(SseDeserializer deserializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
Expand Down Expand Up @@ -5777,6 +5818,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
sse_encode_liquid_network(self.network, serializer);
sse_encode_u_64(self.paymentTimeoutSec, serializer);
sse_encode_u_32(self.zeroConfMinFeeRateMsat, serializer);
sse_encode_String(self.syncServiceUrl, serializer);
sse_encode_opt_box_autoadd_u_64(self.zeroConfMaxAmountSat, serializer);
sse_encode_opt_String(self.breezApiKey, serializer);
sse_encode_opt_list_external_input_parser(self.externalInputParsers, serializer);
Expand Down Expand Up @@ -6007,6 +6049,15 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
}
}

@protected
void sse_encode_list_payment_state(List<PaymentState> self, SseSerializer serializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
sse_encode_i_32(self.length, serializer);
for (final item in self) {
sse_encode_payment_state(item, serializer);
}
}

@protected
void sse_encode_list_payment_type(List<PaymentType> self, SseSerializer serializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
Expand All @@ -6020,6 +6071,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
void sse_encode_list_payments_request(ListPaymentsRequest self, SseSerializer serializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
sse_encode_opt_list_payment_type(self.filters, serializer);
sse_encode_opt_list_payment_state(self.states, serializer);
sse_encode_opt_box_autoadd_i_64(self.fromTimestamp, serializer);
sse_encode_opt_box_autoadd_i_64(self.toTimestamp, serializer);
sse_encode_opt_box_autoadd_u_32(self.offset, serializer);
Expand Down Expand Up @@ -6523,6 +6575,16 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
}
}

@protected
void sse_encode_opt_list_payment_state(List<PaymentState>? self, SseSerializer serializer) {
// Codec=Sse (Serialization based), see doc to use other codecs

sse_encode_bool(self != null, serializer);
if (self != null) {
sse_encode_list_payment_state(self, serializer);
}
}

@protected
void sse_encode_opt_list_payment_type(List<PaymentType>? self, SseSerializer serializer) {
// Codec=Sse (Serialization based), see doc to use other codecs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@ fun asConfig(config: ReadableMap): Config? {
"network",
"paymentTimeoutSec",
"zeroConfMinFeeRateMsat",
"useDefaultExternalInputParsers",
"syncServiceUrl",
"useDefaultExternalInputParsers",
),
)
) {
Expand Down
6 changes: 5 additions & 1 deletion packages/react-native/ios/BreezSDKLiquidMapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,9 @@ enum BreezSDKLiquidMapper {
guard let zeroConfMinFeeRateMsat = config["zeroConfMinFeeRateMsat"] as? UInt32 else {
throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "zeroConfMinFeeRateMsat", typeName: "Config"))
}
guard let syncServiceUrl = config["syncServiceUrl"] as? String else {
throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "syncServiceUrl", typeName: "Config"))
}
var breezApiKey: String?
if hasNonNilKey(data: config, key: "breezApiKey") {
guard let breezApiKeyTmp = config["breezApiKey"] as? String else {
Expand Down Expand Up @@ -336,7 +339,7 @@ enum BreezSDKLiquidMapper {
externalInputParsers = try asExternalInputParserList(arr: externalInputParsersTmp)
}

return Config(liquidElectrumUrl: liquidElectrumUrl, bitcoinElectrumUrl: bitcoinElectrumUrl, mempoolspaceUrl: mempoolspaceUrl, workingDir: workingDir, network: network, paymentTimeoutSec: paymentTimeoutSec, zeroConfMinFeeRateMsat: zeroConfMinFeeRateMsat, breezApiKey: breezApiKey, cacheDir: cacheDir, zeroConfMaxAmountSat: zeroConfMaxAmountSat, useDefaultExternalInputParsers: useDefaultExternalInputParsers, externalInputParsers: externalInputParsers)
return Config(liquidElectrumUrl: liquidElectrumUrl, bitcoinElectrumUrl: bitcoinElectrumUrl, mempoolspaceUrl: mempoolspaceUrl, workingDir: workingDir, network: network, paymentTimeoutSec: paymentTimeoutSec, zeroConfMinFeeRateMsat: zeroConfMinFeeRateMsat, syncServiceUrl: syncServiceUrl, breezApiKey: breezApiKey, cacheDir: cacheDir, zeroConfMaxAmountSat: zeroConfMaxAmountSat, useDefaultExternalInputParsers: useDefaultExternalInputParsers, externalInputParsers: externalInputParsers)
}

static func dictionaryOf(config: Config) -> [String: Any?] {
Expand All @@ -348,6 +351,7 @@ enum BreezSDKLiquidMapper {
"network": valueOf(liquidNetwork: config.network),
"paymentTimeoutSec": config.paymentTimeoutSec,
"zeroConfMinFeeRateMsat": config.zeroConfMinFeeRateMsat,
"syncServiceUrl": config.syncServiceUrl,
"breezApiKey": config.breezApiKey == nil ? nil : config.breezApiKey,
"cacheDir": config.cacheDir == nil ? nil : config.cacheDir,
"zeroConfMaxAmountSat": config.zeroConfMaxAmountSat == nil ? nil : config.zeroConfMaxAmountSat,
Expand Down

0 comments on commit 422ae39

Please sign in to comment.