-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
We introduce a new flow to fund the first position and with it the first channel. The idea is that the user does not have to have any on-chain funds before opening the first position. The flow is divided into two parts: 1) open a position using on-chain funds: if the user has already on-chain funds, then he can opt to use said funds and open the channel immediately 2) open a position using external funds: the user has the option to fund the wallet using an external wallet such as a lightning wallet, another on-chain wallet, or maybe even using a hardware wallet in the future. In this patch, we only introduce funding using an on-chain transaction. The app waits until it sees the funds incoming and then proceeds with the channel creation.
- Loading branch information
Showing
30 changed files
with
1,620 additions
and
73 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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,48 @@ | ||
import 'package:get_10101/bridge_generated/bridge_definitions.dart' as bridge; | ||
|
||
enum FundingChannelTaskStatus { | ||
pending, | ||
funded, | ||
orderCreated, | ||
failed; | ||
|
||
static (FundingChannelTaskStatus, String?) fromApi(dynamic taskStatus) { | ||
if (taskStatus is bridge.FundingChannelTask_Pending) { | ||
return (FundingChannelTaskStatus.pending, null); | ||
} | ||
|
||
if (taskStatus is bridge.FundingChannelTask_Funded) { | ||
return (FundingChannelTaskStatus.funded, null); | ||
} | ||
|
||
if (taskStatus is bridge.FundingChannelTask_Failed) { | ||
final error = taskStatus.field0; | ||
return (FundingChannelTaskStatus.failed, error); | ||
} | ||
|
||
if (taskStatus is bridge.FundingChannelTask_OrderCreated) { | ||
final orderId = taskStatus.field0; | ||
return (FundingChannelTaskStatus.orderCreated, orderId); | ||
} | ||
|
||
return (FundingChannelTaskStatus.pending, null); | ||
} | ||
|
||
static bridge.FundingChannelTask apiDummy() { | ||
return const bridge.FundingChannelTask_Pending(); | ||
} | ||
|
||
@override | ||
String toString() { | ||
switch (this) { | ||
case FundingChannelTaskStatus.pending: | ||
return "Pending"; | ||
case FundingChannelTaskStatus.failed: | ||
return "Failed"; | ||
case FundingChannelTaskStatus.funded: | ||
return "Funded"; | ||
case FundingChannelTaskStatus.orderCreated: | ||
return "OrderCreated"; | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
mobile/lib/common/funding_channel_task_change_notifier.dart
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,21 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:get_10101/common/application/event_service.dart'; | ||
import 'package:get_10101/bridge_generated/bridge_definitions.dart' as bridge; | ||
import 'package:get_10101/common/domain/funding_channel_task.dart'; | ||
import 'package:get_10101/logger/logger.dart'; | ||
|
||
class FundingChannelChangeNotifier extends ChangeNotifier implements Subscriber { | ||
FundingChannelTaskStatus? status; | ||
String? error; | ||
|
||
@override | ||
void notify(bridge.Event event) async { | ||
if (event is bridge.Event_FundingChannelNotification) { | ||
logger.d("Received a funding channel task notification. ${event.field0}"); | ||
var fromApi = FundingChannelTaskStatus.fromApi(event.field0); | ||
status = fromApi.$1; | ||
error = fromApi.$2; | ||
notifyListeners(); | ||
} | ||
} | ||
} |
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
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
Oops, something went wrong.