Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support pasting LNURL #593

Merged
merged 5 commits into from
Jul 13, 2023
Merged

Support pasting LNURL #593

merged 5 commits into from
Jul 13, 2023

Conversation

erdemyerebasmaz
Copy link
Collaborator

@erdemyerebasmaz erdemyerebasmaz commented Jul 5, 2023

This PR addresses

Any input that can be handled by our InputHandler is now supported via "Paste Invoice or ID" option.

If input data can't be handled(unsupported input type, empty device clipboard) EnterPaymentInfoDialog will be displayed so users can manually enter their input.

This input will also be validated using parseInput API of SDK and checked against supported input types, an "Unsupported input" error message is shown for unsupported input types(Bitcoin Addresses).

Changelist:

  • Support all input types that can be handled by our InputHandler "Paste Invoice or ID" and EnterPaymentInfoDialog
  • Handle input on clicking "Paste Invoice or ID"
  • Update breez_translations for unsupported input's error message
  • Expose parseInput API through InputBloc
    • Remove utils/lnurl.dart as it's made obsolete by parsing inputs through SDK

@erdemyerebasmaz erdemyerebasmaz linked an issue Jul 5, 2023 that may be closed by this pull request
@erdemyerebasmaz erdemyerebasmaz added this to the v0.1.0-alpha milestone Jul 5, 2023
@erdemyerebasmaz erdemyerebasmaz added documentation Improvements or additions to documentation enhancement New feature or request labels Jul 5, 2023
Copy link
Contributor

@ubbabeck ubbabeck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a user copies the the nodeID@ipaddrress:port we do not recognise it being a node ID.

Do we wish to handle this here in C-breez or perhaps the SDK can handle this, what do you think?

Apart from this minor issue

Looks good to me 🥳

Copy link
Contributor

@ubbabeck ubbabeck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opened an issue in breez-sdk where we can handle this nodeID@address format issue instead breez/breez-sdk-greenlight#299

@ubbabeck
Copy link
Contributor

ubbabeck commented Jul 6, 2023

@erdemyerebasmaz after discussing with the team we decided that handling nodeURI should handle at in C-breez since this is how we do it in Breezmobile. I added this checking in the latest commit 3083a76

@ok300
Copy link
Collaborator

ok300 commented Jul 6, 2023

I added this logic in the SDK as well: breez/breez-sdk-greenlight#301

If you'd rather use that, then it's no need to handle this in the UI and you can revert the last commit here.

@ubbabeck
Copy link
Contributor

ubbabeck commented Jul 6, 2023

I added this logic in the SDK as well: breez/breez-sdk-greenlight#301

If you'd rather use that, then it's no need to handle this in the UI and you can revert the last commit here.

Awesome. I will revert the latest commit. Thank you🙏

@erdemyerebasmaz
Copy link
Collaborator Author

erdemyerebasmaz commented Jul 6, 2023

Context for latest changes with 222c64c

Even though this function is named paste tapped it assumes that the latest inputData on InputBloc's InputState comes from device's clipboard stream.

This caused unwanted behavior such as handling the existing inputData on InputBloc's InputState before permission is given to read clipboard value on iOS 14+ devices.

_pasteTapped, which renamed to _pasteFromClipboard now only handles the latest clipboard data and EnterPaymentInfoDialog is opened if:

  • there's an error getting the clipboard data,
  • clipboard data is empty,
  • clipboard data can't be parsed,
  • parsed clipboard data can't be handled(unsupported type),

⚠️ This logic looks really ugly and needs a refactor on multiple parts. ⚠️

Related changes:

  • A loader is displayed when clipboard data is being retrieved, parsed & handled. 88f17ee

Copy link
Contributor

@ubbabeck ubbabeck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

Tested on android emulator. NodeURI works too 👍

@@ -34,17 +34,18 @@ class HomeState extends State<Home> with AutoLockMixin, HandlerContextProvider {
final GlobalKey firstPaymentItemKey = GlobalKey();
final ScrollController scrollController = ScrollController();
final handlers = <Handler>[];
late final InputHandler inputHandler = InputHandler(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will break the lifecycle again.

I think SendOptionsBottomSheet should create its own InputHandler dealing with the lifecycle there.

A possibility is a duplication of event handling as there will be 2 or more InputHandlers. We should think of a mechanism to avoid that.

@erdemyerebasmaz
Copy link
Collaborator Author

This will break the lifecycle again.

I think SendOptionsBottomSheet should create its own InputHandler dealing with the lifecycle there.

A possibility is a duplication of event handling as there will be 2 or more InputHandlers. We should think of a mechanism to avoid that.

⚠️ Do not merge until lifecycle problem is addressed. ⚠️

@erdemyerebasmaz erdemyerebasmaz marked this pull request as draft July 11, 2023 06:16
@erdemyerebasmaz erdemyerebasmaz force-pushed the 591-support-pasting-lnurl branch 3 times, most recently from 485e095 to 2101306 Compare July 11, 2023 08:07
@erdemyerebasmaz
Copy link
Collaborator Author

InputHandler changes are reverted and lifecycle issue is resolved.

Clipboard item is parsed and passed to InputBloc if it's a supported type.
The clipboard item will be parsed on InputBloc again but there's no way to communicate if it was a supported type or not to open EnterPaymentInfoDialog from the UI w/o the use of async actions and altering InputBloc further.

@erdemyerebasmaz erdemyerebasmaz marked this pull request as ready for review July 11, 2023 08:09
ubbabeck and others added 4 commits July 13, 2023 17:41
- Update breez_translations for unsupported input's error message
- Expose parseInput api through InputBloc
- Remove utils/lnurl.dart
Handle input on clicking "Paste Invoice or ID"

Pass clipboard item to input bloc if it's a supported input type

Revert inputHandler changes

Display a loader when clipboard data is being retrieved, parsed & handled

Close bottom sheet upon clicking 'Paste Invoice or ID' button
@erdemyerebasmaz erdemyerebasmaz merged commit 4d0fbfe into main Jul 13, 2023
1 check passed
@erdemyerebasmaz erdemyerebasmaz deleted the 591-support-pasting-lnurl branch September 27, 2023 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support pasting LNURL
5 participants