-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Update dependencies to latest * Create ChainSwap Bloc * Apply BigInt/int changes on payment errors * Integrate Receive Chain Swap * Integrate Send Chain Swap
- Loading branch information
1 parent
a79f575
commit 9e18303
Showing
31 changed files
with
1,530 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import 'package:flutter_bloc/flutter_bloc.dart'; | ||
import 'package:flutter_breez_liquid/flutter_breez_liquid.dart'; | ||
import 'package:l_breez/bloc/account/breez_sdk_liquid.dart'; | ||
import 'package:l_breez/bloc/account/payment_error.dart'; | ||
import 'package:l_breez/bloc/chainswap/chainswap_state.dart'; | ||
|
||
class ChainSwapBloc extends Cubit<ChainSwapState> { | ||
final BreezSDKLiquid _liquidSdk; | ||
|
||
ChainSwapBloc(this._liquidSdk) : super(ChainSwapState.initial()); | ||
|
||
Future<OnchainPaymentLimitsResponse> fetchOnchainLimits() async { | ||
return await _liquidSdk.instance!.fetchOnchainLimits(); | ||
} | ||
|
||
Future<PreparePayOnchainResponse> preparePayOnchain({ | ||
required PreparePayOnchainRequest req, | ||
}) async { | ||
return await _liquidSdk.instance!.preparePayOnchain(req: req); | ||
} | ||
|
||
Future<SendPaymentResponse> payOnchain({ | ||
required PayOnchainRequest req, | ||
}) async { | ||
return await _liquidSdk.instance!.payOnchain(req: req); | ||
} | ||
|
||
Future<PrepareReceiveOnchainResponse> prepareReceiveOnchain({ | ||
required PrepareReceiveOnchainRequest req, | ||
}) async { | ||
return await _liquidSdk.instance!.prepareReceiveOnchain(req: req); | ||
} | ||
|
||
Future<ReceiveOnchainResponse> receiveOnchain({ | ||
required PrepareReceiveOnchainResponse req, | ||
}) async { | ||
return await _liquidSdk.instance!.receiveOnchain(req: req); | ||
} | ||
|
||
Future<RefundResponse> refund({ | ||
required RefundRequest req, | ||
}) async { | ||
return await _liquidSdk.instance!.refund(req: req); | ||
} | ||
|
||
Future<void> rescanOnchainSwaps() async { | ||
return await _liquidSdk.instance!.rescanOnchainSwaps(); | ||
} | ||
|
||
void validateSwap( | ||
BigInt amount, | ||
bool outgoing, | ||
OnchainPaymentLimitsResponse onchainLimits, | ||
) { | ||
var limits = outgoing ? onchainLimits.send : onchainLimits.receive; | ||
if (amount > limits.maxSat) { | ||
throw PaymentExceededLimitError(limits.maxSat); | ||
} | ||
if (amount < limits.minSat) { | ||
throw PaymentBelowLimitError(limits.minSat); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class ChainSwapState { | ||
ChainSwapState(); | ||
|
||
ChainSwapState.initial() : this(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.