MyBitFoundation / MyBit-Network.tech

🔷 The MyBit Network™ technology - Smart contracts and APIs to interact with the MyBit ecosystem
https://tech.mybit.io
GNU General Public License v3.0
20 stars 19 forks source link

Auto refresh on metamask account switch - MyBit Trust #197

Closed mybit-bot closed 5 years ago

mybit-bot commented 5 years ago

Introduction: To enhance the user experience of MyBit Trust (trust.mybit.io) we want the application to automatically refresh when a user switches between different metamask wallets.

Current behaviour: Requires manual page refresh by user.

Desired behaviour: Automatically refreshes when new wallet in metamask is selected.

To Submit:

  1. Comment on task with a staging URL to get approval for design and placement.
  2. Please submit a pull request with the final version once complete.

Disclaimer All work completed via the MyBit Decentralised Development Fund is property of the MyBit Foundation (CHE-177.186.963) and may be used, re-used, and/or distributed, re-distributed by the MyBit Foundation for financial gain. The contributor holds no warrant nor claims for any future payments resulting from monetisation schemes originating from the MyBit Foundation or any of its affiliates. Where law permits outside of open source regulations, the contributor is not permitted to distribute any work completed via the MyBit Decentralised Development Fund (DDF) for personal gain.

status-open-bounty commented 5 years ago

Balance: 0 ETH Tokens: MYB: 2500.00 Contract address: 0x5a8f88ca7a3baae84e8c5083bb36f6525c70e095 Network: Mainnet Paid to: jjperezaguinaga Visit https://openbounty.status.im to learn more.

cryptomental commented 5 years ago

Hi @mybit-bot ! I found a solution and opened a pull request https://github.com/MyBitFoundation/MyBit-Trust.website/pull/4

I set up a callback in BlockchainInfo context that listens to 'update' event on Metamask publicConfigStore. This callback is triggered whenever there is an update to the store. If selectedAddress is different than the current one, automatic refresh happens. I can apply later the same solution to 'Will' app.

I will try to push to the staging area today.

cryptomental commented 5 years ago

Hmm that's interesting, there is no open claim visible https://openbounty.status.im/app#/ perhaps it is because the pull request is in the different repo than this one?

cryptnotiq commented 5 years ago

@csmartinsfct can you review?

cryptomental commented 5 years ago

@cryptnotiq @csmartinsfct and it is deployed here : https://mybit-trust-user-autorefresh.herokuapp.com/

You can verify this by opening Metamask and changing the user while the app is running.

cryptnotiq commented 5 years ago

@csmartinsfct @kyledewy can you test that staging URL? None of the buttons are functioning for me, but could be a bad internet connection.

cryptnotiq commented 5 years ago

hey @cryptomental the staging link isn't working for any of us. It loads eventually but then none of the buttons are functional. Can you look into it?

cryptomental commented 5 years ago

Hi @cryptnotiq @csmartinsfct @kyledewy indeed! It hangs now on api.bancor.network perhaps it hit Bancor calls limit ?

An hour ago the staging app worked blazing fast but I was trying it out for 15-20 minutes so it might have triggered too many calls. I will wait a few minutes and try again.

I am thinking whether to switch to another staging area provider, perhaps free Heroku tier is not enough... What are you using for staging area?

csmartinsfct commented 5 years ago

We use now.sh

csmartinsfct commented 5 years ago

But a bancor widget problem shouldn't make the website unusable, should it? @cryptomental

Feel free to host a version with the bancor widget disabled because if that is the issue then we'll have to fix it but it isn't related to this PR.

cryptomental commented 5 years ago

Ok thank you @csmartinsfct I will try out now.sh.

I nailed down that it hangs here:

hanging

which is https://api.bancor.network/0.1/currencies/rate?toCurrencyCode=ETH&fromCurrencyCodes=USD,EUR

This works perfectly locally for me (website deployed locally as well).

csmartinsfct commented 5 years ago

I wonder why it's hanging, we're using the widget in our Go dApp and never had that issue. Although the implementation is different in both projects.

Yea feel free to post a staging URL with the widget disabled.

cryptomental commented 5 years ago

I deployed to https://react-boilerplate-pzlgkzurmq.now.sh/ but it is even worse , interesting it hangs on api.amplitude.com (I am wondering what is that).

I will have a look at this again in the evening and see if I can disable the widget.

cryptomental commented 5 years ago

screenshot from 2018-11-06 15 46 34

cryptomental commented 5 years ago

@csmartinsfct @cryptnotiq @kyledewy I decided not to waste time and deployed on a private VPS hosted in Germany. Please have a look now.

http://51.75.66.221:3000

0xjjpa commented 5 years ago

Hi @cryptomental , regarding your comment on sending a pull-request to claim a bounty, yes, you need to create a new one in this repository with "Fixes #197" in title or description. As a work around you can there in the description link to the actual project pull request.

0xjjpa commented 5 years ago

@cryptomental Also, our Circle CI build generates URLs based on changes you might provide in your pull-requests so you don't have to create VPS or other infra on your own. Click on the status links for a reference.

cryptomental commented 5 years ago

Hi @jjperezaguinaga thanks for the information! I tried with different settings adding Fixes #197 unfortunately none of them work, unless I must create a new pull request... When I add "Fixes #197" in https://github.com/MyBitFoundation/MyBit-Trust.website GitHub repository pull request it tries to reference the 197 issue in https://github.com/MyBitFoundation/MyBit-Trust.website GitHub repository and issue #197 does not exist there , perhaps that is why status does not recognize it.

cryptomental commented 5 years ago

Oh and about circleci, it is not configured for https://github.com/MyBitFoundation/MyBit-Trust.website unless there is another place where it is defined. I would be grateful if you could paste a link.

0xjjpa commented 5 years ago

@cryptomental , you are actually right about the Trust website, thank you for bringing that up! I'll create an issue to tackle that.

Regarding the Fix 197, I meant create a Pull Request in this repository, and in in that pull-request reference this one 😊 .

cryptomental commented 5 years ago

Ahh smart! Thanks for the hint ;)

0xjjpa commented 5 years ago

@cryptomental That should work! Make sure your Open Bounty account is synced, as it's currently not showing up in my Dashboard.

In the meantime, @csmartinsfct , @kyledewy take some time to review the update

cryptomental commented 5 years ago

@jjperezaguinaga indeed, this worked for my previous openbounty but this time no matter what I enter in the pull request, https://openbounty.status.im/app#/ does not display the claim. My account seems to be synced.

p.s. http://51.75.66.221:3000 is still alive to check switching accounts in Metamask.

cryptomental commented 5 years ago

Hah there is no way I can force https://openbounty.status.im/app#/ to recognize my claim to this bounty :)

I tried numerous approaches. This pr https://github.com/MyBitFoundation/MyBit-Network.tech/pull/200 should be also enough. The previous bounty was executed without any issues.

0xjjpa commented 5 years ago

@cryptomental Yeah, last one had no issues, I don't know what's happening with Open Bounty. At this rate I would prefer for you to send us your address and I can revoke the MYB in there and send it to you there when it's solved.

You can send me that information securely via comment in Github by going to https://keybase.io/encrypt and selecting jjperezaguinaga in the recipient. Then just paste the result as a comment.

cryptomental commented 5 years ago

Thank you @jjperezaguinaga . I appreciate your help.

-----BEGIN PGP MESSAGE-----
Version: Keybase OpenPGP v2.0.80
Comment: https://keybase.io/crypto

wcBMA6gpy0Zv/UOFAQgAwYDMVrmZlHcdwQwQe89R2LeKHTHMpkoNGUYXAuCo5X6x
8rQ4IA20VpRPcpOAZWpVwlGNUKVeM7FH+Fio4JLeA07xr2sqplVZNSFFZ8kzt6bT
EJUwcNQoLjPG9Zv9cX1yNHkT6g6vqOFyD3VgIPvuc4YLqDnxDfpadfFfJdU9QuVL
Pi8Grj4VWtB3wEx2mcLnlzub1jfCfmH19LSvzjPk6N57aBH+HlVpuxNIID+phsvD
vjPA7dHIvhOvW3Nn6ullrTeDxg0v8m+f4ReDr9oaZ4QPDt1BCcMgA87KOaKPNDUF
cl3nlM5hiYo+7vBis5FvOhx6Gr0ZuPBK0LfJsjL9qNJmARA062BmvYkG6B4sQup7
q8DHssQTwKlH4uEZn5gCTz3gnhXBVQseM22+T3BvYMi95Hd2cjziP0M4CrrCMz+V
y8V3IReLQQEVd0cC+QzG40WQDK1D5k8UvW3WB1nWBb9UqY6fGPt7
=v/Iz
-----END PGP MESSAGE-----
0xjjpa commented 5 years ago

@cryptomental Sent! Thank you for your work! ☺️

cryptomental commented 5 years ago

Hi @jjperezaguinaga thank you, too!