-
Notifications
You must be signed in to change notification settings - Fork 2
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
use mempoolInstance across the app. #684
Conversation
3ede527
to
1257413
Compare
How to test
|
1257413
to
00fda81
Compare
@@ -36,7 +36,7 @@ class ClosedChannelPaymentDetailsWidget extends StatelessWidget { | |||
if (paymentMinutiae.paymentType == sdk.PaymentType.ClosedChannel && | |||
paymentMinutiae.closingTxid != null) ...[ | |||
TxWidget( | |||
txURL: "$blockExplorer/tx/${paymentMinutiae.closingTxid!}", | |||
txURL: "$blockexplorer/tx/${paymentMinutiae.closingTxid!}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do understand the attempt to use the ServiceInjector for the block explorer url but the format is specific to mempoolspace so perhaps we can abstract a block explorer service that format the final url?
Maybe we can set a service with one method "formatTransactionUrl(txID)
" ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I was not sure where to put it. I created a new helper class MempoolHelper
, feel free to suggest another name and two helper functions. I ended up creating two, one getter for the mempoolexplorer and one for the formater as you suggested. I landed on two since we often wish to display more than one transaction and do not need unnecessary future handling. Let me know what you think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would use one service (resolved by the ServiceInjector) called ChainExplorer. On this service we can add methods such as:
transactionUrl(string txID)
3f0521f
to
501c3ad
Compare
967b219
to
573a5e7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw you mention Blockstream and mempool (of course), but other than that; do you know what explorers are being supported by these changes?
lib/routes/home/widgets/payments_list/dialog/closed_channel_payment_details.dart
Show resolved
Hide resolved
@@ -46,19 +46,20 @@ class _TxLink extends StatelessWidget { | |||
@override | |||
Widget build(BuildContext context) { | |||
final text = context.texts(); | |||
final mempoolHelper = MempoolHelper(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better create it outside build method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we get it from the context.read<NetworkSettingsBloc>()
we will have to get it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is not a problem because we are getting an existing instance not creating a new instance
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note sure how this might cause a problem, could you expand on hos this might be an issue.
It is mostly so that people can use their own mempool.space instances for better privacy. Blocksteam does not have the mempool.space rest api so we cannot use them. |
We support custom mempool instances already; if you are not adding support for other providers (such as blockstream.info) what is this PR for? |
We do not use it across the app for tx lookups as we default to mempool.space. We do not properly check if the mempool instance works before setting it. This is what I am trying address. |
return FutureBuilder<Config>( | ||
future: Config.instance(), | ||
builder: (BuildContext context, AsyncSnapshot<Config> snapshot) { | ||
final mempoolHelper = MempoolHelper(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is better to resolve the MempoolHelper via the ServiceInjector (where all our services defined).
Also we can rename it to ChainExplorer or similar. The whole idea of abstracting the URL formatting is not to imply on a specific implementation (mempool space).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still want to explose the mempoolInstance to the serviceInjetor after we decided to change the scope of the pr from abstracting a chainexplorer to letting users use their own mempool instance?
lib/routes/home/widgets/payments_list/dialog/closed_channel_payment_details.dart
Show resolved
Hide resolved
4ea84da
to
61014f3
Compare
update tests rename to mempoolInstance get mempool instance from NetworkSettingsBloc create blockchain explorer utils
61014f3
to
0a19912
Compare
This enables the user to use their preferred
blockexplorermempool instance across the app. If it is not set we default to mempool.space.Added tests to verify that the instance supports mempool space's rest api too.