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

use mempoolInstance across the app. #684

Merged
merged 3 commits into from
Oct 26, 2023
Merged

use mempoolInstance across the app. #684

merged 3 commits into from
Oct 26, 2023

Conversation

ubbabeck
Copy link
Contributor

@ubbabeck ubbabeck commented Oct 18, 2023

This enables the user to use their preferred blockexplorer mempool 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.

@ubbabeck ubbabeck self-assigned this Oct 18, 2023
@ubbabeck ubbabeck added this to the v0.2.4 alpha(sdk) milestone Oct 18, 2023
@ubbabeck ubbabeck force-pushed the ubbabeck-blockexplorer branch from 3ede527 to 1257413 Compare October 18, 2023 09:37
@ubbabeck ubbabeck added the QA-testing QA testing needed label Oct 18, 2023
@ubbabeck
Copy link
Contributor Author

ubbabeck commented Oct 18, 2023

How to test

  1. Go to network page (accessible from side menu)
  2. Change mempool explorer to another Mempool space instance
  3. press Save
  4. Verify that the app uses the new Mempool instace. by checking ongoing swaps or closed channels.

@ubbabeck ubbabeck force-pushed the ubbabeck-blockexplorer branch from 1257413 to 00fda81 Compare October 18, 2023 09:46
@@ -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!}",
Copy link
Member

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)" ?

Copy link
Contributor Author

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.

Copy link
Member

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)

@ubbabeck ubbabeck requested a review from roeierez October 18, 2023 12:12
@ubbabeck ubbabeck force-pushed the ubbabeck-blockexplorer branch from 3f0521f to 501c3ad Compare October 18, 2023 12:20
@ubbabeck ubbabeck changed the title get blockexplorer from ServiceInjector get blockexplorer Oct 18, 2023
@ubbabeck ubbabeck force-pushed the ubbabeck-blockexplorer branch 2 times, most recently from 967b219 to 573a5e7 Compare October 19, 2023 11:56
Copy link
Collaborator

@ademar111190 ademar111190 left a 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/bloc/network/network_settings_bloc.dart Outdated Show resolved Hide resolved
@@ -46,19 +46,20 @@ class _TxLink extends StatelessWidget {
@override
Widget build(BuildContext context) {
final text = context.texts();
final mempoolHelper = MempoolHelper();
Copy link
Collaborator

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

Copy link
Contributor Author

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.

Copy link
Collaborator

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

Copy link
Contributor Author

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.

@ubbabeck
Copy link
Contributor Author

I saw you mention Blockstream and mempool (of course), but other than that; do you know what explorers are being supported by these changes?

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.

@ademar111190
Copy link
Collaborator

I saw you mention Blockstream and mempool (of course), but other than that; do you know what explorers are being supported by these changes?

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?

@ubbabeck
Copy link
Contributor Author

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();
Copy link
Member

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).

Copy link
Contributor Author

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?

@ubbabeck ubbabeck changed the title get blockexplorer use mempoolInstance across the app. Oct 19, 2023
@ubbabeck ubbabeck requested a review from ademar111190 October 19, 2023 14:54
lib/bloc/network/network_settings_bloc.dart Outdated Show resolved Hide resolved
lib/bloc/network/network_settings_bloc.dart Outdated Show resolved Hide resolved
lib/bloc/network/network_settings_bloc.dart Outdated Show resolved Hide resolved
lib/utils/mempool_helper.dart Outdated Show resolved Hide resolved
lib/bloc/network/network_settings_bloc.dart Outdated Show resolved Hide resolved
lib/bloc/network/network_settings_bloc.dart Outdated Show resolved Hide resolved
lib/bloc/network/network_settings_bloc.dart Outdated Show resolved Hide resolved
@ubbabeck ubbabeck force-pushed the ubbabeck-blockexplorer branch from 4ea84da to 61014f3 Compare October 25, 2023 07:44
update tests

rename to mempoolInstance

get mempool instance from NetworkSettingsBloc

create blockchain explorer utils
@ubbabeck ubbabeck force-pushed the ubbabeck-blockexplorer branch from 61014f3 to 0a19912 Compare October 25, 2023 11:43
@ubbabeck ubbabeck merged commit f78963d into main Oct 26, 2023
1 check passed
@erdemyerebasmaz erdemyerebasmaz deleted the ubbabeck-blockexplorer branch November 16, 2023 20:11
@erdemyerebasmaz erdemyerebasmaz restored the ubbabeck-blockexplorer branch November 16, 2023 20:12
@erdemyerebasmaz erdemyerebasmaz deleted the ubbabeck-blockexplorer branch November 16, 2023 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
QA-testing QA testing needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants