Skip to content

Commit

Permalink
Updated API semantics
Browse files Browse the repository at this point in the history
  • Loading branch information
i5hi committed Apr 22, 2024
1 parent 85c3de8 commit 50c3835
Show file tree
Hide file tree
Showing 15 changed files with 1,487 additions and 1,471 deletions.
212 changes: 107 additions & 105 deletions ios/Classes/frb_generated.h

Large diffs are not rendered by default.

83 changes: 42 additions & 41 deletions lib/src/generated/api/btc_ln.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import 'types.dart';
part 'btc_ln.freezed.dart';

@freezed
class BtcLnSwap with _$BtcLnSwap {
const BtcLnSwap._();
const factory BtcLnSwap({
class BtcLnV1Swap with _$BtcLnV1Swap {
const BtcLnV1Swap._();
const factory BtcLnV1Swap({
required String id,
required SwapType kind,
required Chain network,
Expand All @@ -25,16 +25,44 @@ class BtcLnSwap with _$BtcLnSwap {
required int outAmount,
required String electrumUrl,
required String boltzUrl,
}) = _BtcLnSwap;
Future<String> btcLnSubmarineRefund(
}) = _BtcLnV1Swap;
Future<String> claim(
{required String outAddress, required int absFee, dynamic hint}) =>
BoltzCore.instance.api.btcLnSwapBtcLnSubmarineRefund(
BoltzCore.instance.api.btcLnV1SwapClaim(
that: this,
outAddress: outAddress,
absFee: absFee,
);

static Future<BtcLnSwap> createReverseV1(
// HINT: Make it `#[frb(sync)]` to let it become the default constructor of Dart class.
static Future<BtcLnV1Swap> newInstance(
{required String id,
required SwapType kind,
required Chain network,
required KeyPair keys,
required PreImage preimage,
required String redeemScript,
required String invoice,
required String scriptAddress,
required int outAmount,
required String electrumUrl,
required String boltzUrl,
dynamic hint}) =>
BoltzCore.instance.api.btcLnV1SwapNew(
id: id,
kind: kind,
network: network,
keys: keys,
preimage: preimage,
redeemScript: redeemScript,
invoice: invoice,
scriptAddress: scriptAddress,
outAmount: outAmount,
electrumUrl: electrumUrl,
boltzUrl: boltzUrl,
hint: hint);

static Future<BtcLnV1Swap> newReverse(
{required String mnemonic,
required int index,
required int outAmount,
Expand All @@ -43,7 +71,7 @@ class BtcLnSwap with _$BtcLnSwap {
required String boltzUrl,
required String pairHash,
dynamic hint}) =>
BoltzCore.instance.api.btcLnSwapCreateReverseV1(
BoltzCore.instance.api.btcLnV1SwapNewReverse(
mnemonic: mnemonic,
index: index,
outAmount: outAmount,
Expand All @@ -53,7 +81,7 @@ class BtcLnSwap with _$BtcLnSwap {
pairHash: pairHash,
hint: hint);

static Future<BtcLnSwap> createSubmarineV1(
static Future<BtcLnV1Swap> newSubmarine(
{required String mnemonic,
required int index,
required String invoice,
Expand All @@ -62,7 +90,7 @@ class BtcLnSwap with _$BtcLnSwap {
required String boltzUrl,
required String pairHash,
dynamic hint}) =>
BoltzCore.instance.api.btcLnSwapCreateSubmarineV1(
BoltzCore.instance.api.btcLnV1SwapNewSubmarine(
mnemonic: mnemonic,
index: index,
invoice: invoice,
Expand All @@ -72,43 +100,16 @@ class BtcLnSwap with _$BtcLnSwap {
pairHash: pairHash,
hint: hint);

// HINT: Make it `#[frb(sync)]` to let it become the default constructor of Dart class.
static Future<BtcLnSwap> newInstance(
{required String id,
required SwapType kind,
required Chain network,
required KeyPair keys,
required PreImage preimage,
required String redeemScript,
required String invoice,
required String scriptAddress,
required int outAmount,
required String electrumUrl,
required String boltzUrl,
dynamic hint}) =>
BoltzCore.instance.api.btcLnSwapNew(
id: id,
kind: kind,
network: network,
keys: keys,
preimage: preimage,
redeemScript: redeemScript,
invoice: invoice,
scriptAddress: scriptAddress,
outAmount: outAmount,
electrumUrl: electrumUrl,
boltzUrl: boltzUrl,
hint: hint);

Future<String> reverseV1Claim(
Future<String> refund(
{required String outAddress, required int absFee, dynamic hint}) =>
BoltzCore.instance.api.btcLnSwapReverseV1Claim(
BoltzCore.instance.api.btcLnV1SwapRefund(
that: this,
outAddress: outAddress,
absFee: absFee,
);

Future<int> txSize({dynamic hint}) => BoltzCore.instance.api.btcLnSwapTxSize(
Future<int> txSize({dynamic hint}) =>
BoltzCore.instance.api.btcLnV1SwapTxSize(
that: this,
);
}
61 changes: 31 additions & 30 deletions lib/src/generated/api/btc_ln.freezed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods');

/// @nodoc
mixin _$BtcLnSwap {
mixin _$BtcLnV1Swap {
String get id => throw _privateConstructorUsedError;
SwapType get kind => throw _privateConstructorUsedError;
Chain get network => throw _privateConstructorUsedError;
Expand All @@ -29,14 +29,15 @@ mixin _$BtcLnSwap {
String get boltzUrl => throw _privateConstructorUsedError;

@JsonKey(ignore: true)
$BtcLnSwapCopyWith<BtcLnSwap> get copyWith =>
$BtcLnV1SwapCopyWith<BtcLnV1Swap> get copyWith =>
throw _privateConstructorUsedError;
}

/// @nodoc
abstract class $BtcLnSwapCopyWith<$Res> {
factory $BtcLnSwapCopyWith(BtcLnSwap value, $Res Function(BtcLnSwap) then) =
_$BtcLnSwapCopyWithImpl<$Res, BtcLnSwap>;
abstract class $BtcLnV1SwapCopyWith<$Res> {
factory $BtcLnV1SwapCopyWith(
BtcLnV1Swap value, $Res Function(BtcLnV1Swap) then) =
_$BtcLnV1SwapCopyWithImpl<$Res, BtcLnV1Swap>;
@useResult
$Res call(
{String id,
Expand All @@ -56,9 +57,9 @@ abstract class $BtcLnSwapCopyWith<$Res> {
}

/// @nodoc
class _$BtcLnSwapCopyWithImpl<$Res, $Val extends BtcLnSwap>
implements $BtcLnSwapCopyWith<$Res> {
_$BtcLnSwapCopyWithImpl(this._value, this._then);
class _$BtcLnV1SwapCopyWithImpl<$Res, $Val extends BtcLnV1Swap>
implements $BtcLnV1SwapCopyWith<$Res> {
_$BtcLnV1SwapCopyWithImpl(this._value, this._then);

// ignore: unused_field
final $Val _value;
Expand Down Expand Up @@ -146,11 +147,11 @@ class _$BtcLnSwapCopyWithImpl<$Res, $Val extends BtcLnSwap>
}

/// @nodoc
abstract class _$$BtcLnSwapImplCopyWith<$Res>
implements $BtcLnSwapCopyWith<$Res> {
factory _$$BtcLnSwapImplCopyWith(
_$BtcLnSwapImpl value, $Res Function(_$BtcLnSwapImpl) then) =
__$$BtcLnSwapImplCopyWithImpl<$Res>;
abstract class _$$BtcLnV1SwapImplCopyWith<$Res>
implements $BtcLnV1SwapCopyWith<$Res> {
factory _$$BtcLnV1SwapImplCopyWith(
_$BtcLnV1SwapImpl value, $Res Function(_$BtcLnV1SwapImpl) then) =
__$$BtcLnV1SwapImplCopyWithImpl<$Res>;
@override
@useResult
$Res call(
Expand All @@ -173,11 +174,11 @@ abstract class _$$BtcLnSwapImplCopyWith<$Res>
}

/// @nodoc
class __$$BtcLnSwapImplCopyWithImpl<$Res>
extends _$BtcLnSwapCopyWithImpl<$Res, _$BtcLnSwapImpl>
implements _$$BtcLnSwapImplCopyWith<$Res> {
__$$BtcLnSwapImplCopyWithImpl(
_$BtcLnSwapImpl _value, $Res Function(_$BtcLnSwapImpl) _then)
class __$$BtcLnV1SwapImplCopyWithImpl<$Res>
extends _$BtcLnV1SwapCopyWithImpl<$Res, _$BtcLnV1SwapImpl>
implements _$$BtcLnV1SwapImplCopyWith<$Res> {
__$$BtcLnV1SwapImplCopyWithImpl(
_$BtcLnV1SwapImpl _value, $Res Function(_$BtcLnV1SwapImpl) _then)
: super(_value, _then);

@pragma('vm:prefer-inline')
Expand All @@ -195,7 +196,7 @@ class __$$BtcLnSwapImplCopyWithImpl<$Res>
Object? electrumUrl = null,
Object? boltzUrl = null,
}) {
return _then(_$BtcLnSwapImpl(
return _then(_$BtcLnV1SwapImpl(
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
Expand Down Expand Up @@ -246,8 +247,8 @@ class __$$BtcLnSwapImplCopyWithImpl<$Res>

/// @nodoc
class _$BtcLnSwapImpl extends _BtcLnSwap {
const _$BtcLnSwapImpl(
class _$BtcLnV1SwapImpl extends _BtcLnV1Swap {
const _$BtcLnV1SwapImpl(
{required this.id,
required this.kind,
required this.network,
Expand Down Expand Up @@ -286,14 +287,14 @@ class _$BtcLnSwapImpl extends _BtcLnSwap {

@override
String toString() {
return 'BtcLnSwap(id: $id, kind: $kind, network: $network, keys: $keys, preimage: $preimage, redeemScript: $redeemScript, invoice: $invoice, scriptAddress: $scriptAddress, outAmount: $outAmount, electrumUrl: $electrumUrl, boltzUrl: $boltzUrl)';
return 'BtcLnV1Swap(id: $id, kind: $kind, network: $network, keys: $keys, preimage: $preimage, redeemScript: $redeemScript, invoice: $invoice, scriptAddress: $scriptAddress, outAmount: $outAmount, electrumUrl: $electrumUrl, boltzUrl: $boltzUrl)';
}

@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$BtcLnSwapImpl &&
other is _$BtcLnV1SwapImpl &&
(identical(other.id, id) || other.id == id) &&
(identical(other.kind, kind) || other.kind == kind) &&
(identical(other.network, network) || other.network == network) &&
Expand Down Expand Up @@ -331,12 +332,12 @@ class _$BtcLnSwapImpl extends _BtcLnSwap {
@JsonKey(ignore: true)
@override
@pragma('vm:prefer-inline')
_$$BtcLnSwapImplCopyWith<_$BtcLnSwapImpl> get copyWith =>
__$$BtcLnSwapImplCopyWithImpl<_$BtcLnSwapImpl>(this, _$identity);
_$$BtcLnV1SwapImplCopyWith<_$BtcLnV1SwapImpl> get copyWith =>
__$$BtcLnV1SwapImplCopyWithImpl<_$BtcLnV1SwapImpl>(this, _$identity);
}

abstract class _BtcLnSwap extends BtcLnSwap {
const factory _BtcLnSwap(
abstract class _BtcLnV1Swap extends BtcLnV1Swap {
const factory _BtcLnV1Swap(
{required final String id,
required final SwapType kind,
required final Chain network,
Expand All @@ -347,8 +348,8 @@ abstract class _BtcLnSwap extends BtcLnSwap {
required final String scriptAddress,
required final int outAmount,
required final String electrumUrl,
required final String boltzUrl}) = _$BtcLnSwapImpl;
const _BtcLnSwap._() : super._();
required final String boltzUrl}) = _$BtcLnV1SwapImpl;
const _BtcLnV1Swap._() : super._();

@override
String get id;
Expand All @@ -374,6 +375,6 @@ abstract class _BtcLnSwap extends BtcLnSwap {
String get boltzUrl;
@override
@JsonKey(ignore: true)
_$$BtcLnSwapImplCopyWith<_$BtcLnSwapImpl> get copyWith =>
_$$BtcLnV1SwapImplCopyWith<_$BtcLnV1SwapImpl> get copyWith =>
throw _privateConstructorUsedError;
}
Loading

0 comments on commit 50c3835

Please sign in to comment.