feat: Handle deep links#334
Conversation
|
How have you been testing? Will this work with BIP321 URIs? |
|
I've been throwing links in a url shortening service (tinyurl.com), and clicking on them from my phone and opening with ecash app. And yes it should work with BIP321 URIs. |
| @@ -0,0 +1,193 @@ | |||
| import 'package:ecashapp/deep_link_handler.dart'; | |||
There was a problem hiding this comment.
How do I run these tests locally? Can you add a just command for doing that?
There was a problem hiding this comment.
Added just test command
| app_links_platform_interface: | ||
| dependency: transitive | ||
| description: | ||
| name: app_links_platform_interface | ||
| sha256: "05f5379577c513b534a29ddea68176a4d4802c46180ee8e2e966257158772a3f" | ||
| url: "https://pub.dev" | ||
| source: hosted | ||
| version: "2.0.2" | ||
| app_links_web: | ||
| dependency: transitive | ||
| description: | ||
| name: app_links_web | ||
| sha256: af060ed76183f9e2b87510a9480e56a5352b6c249778d07bd2c95fc35632a555 | ||
| url: "https://pub.dev" | ||
| source: hosted | ||
| version: "1.0.4" |
There was a problem hiding this comment.
Do we need these two? We don't support the web
There was a problem hiding this comment.
yeah, I think these are required
|
Needs rebase |
Opens the following types of links - bicoin: - lightning: - lnurl: - lnurlp: - lnurlw:
bdccde3 to
03b6caf
Compare
| final result = await parseScannedTextForFederation( | ||
| text: deepLink.data, | ||
| federation: fed, | ||
| ); | ||
|
|
||
| final action = result.$1; | ||
|
|
||
| switch (action) { | ||
| case ParsedText_LightningInvoice(:final field0): | ||
| // Show payment preview for BOLT11 invoice | ||
| if (!mounted) return; | ||
| await showAppModalBottomSheet( | ||
| context: context, | ||
| childBuilder: () async { | ||
| final preview = await paymentPreview( | ||
| federationId: fed.federationId, | ||
| bolt11: field0, | ||
| ); | ||
| return PaymentPreviewWidget( | ||
| fed: fed, | ||
| paymentPreview: preview, | ||
| ); | ||
| }, | ||
| ); | ||
| _onJoinPressed(fed, false); | ||
| break; | ||
|
|
||
| case ParsedText_LightningAddressOrLnurl(:final field0): | ||
| // For LNURL/Lightning Address, go to number pad for amount entry | ||
| final btcPrices = await fetchAllBtcPrices(); | ||
| if (!mounted) return; | ||
| await Navigator.push( | ||
| context, | ||
| MaterialPageRoute( | ||
| builder: (_) => NumberPad( | ||
| fed: fed, | ||
| paymentType: PaymentType.lightning, | ||
| btcPrices: btcPrices, | ||
| onWithdrawCompleted: null, | ||
| lightningAddressOrLnurl: field0, | ||
| ), | ||
| ), | ||
| ); | ||
| break; |
There was a problem hiding this comment.
This logic looks very similar to what we have in scan.dart. They're in different contexts though so I don't see an easy way to unify the logic.
03b6caf to
e05aee4
Compare
m1sterc001guy
left a comment
There was a problem hiding this comment.
Ok, I have tested this! I tried:
bitcoin:
lightning:
lnurl:
lnurlp:
lnurlw:
They all work! The one weird one is lnurlw though. In the app, that one is handled identically to lnurl and lnurlp, which I think is wrong. I don't think we support LNURL withdraw currently. We could support it by handling lnurlw and generating an invoice in response, but we don't do this currently. I think we should just remove lnurlw for now.
Otherwise LGTM, I say we merge after we remove lnurlw.
e05aee4 to
87f18dc
Compare
Opens the following types of links
Testing: