MyBitFoundation / MyBit-Go.app

🔷 The MyBit Platform™ for investing in alternative assets
https://app.mybit.io
GNU General Public License v3.0
9 stars 31 forks source link

SDK + IPFS + Airtable #490

Closed csmartinsfct closed 5 years ago

csmartinsfct commented 5 years ago

General description

This PR mostly addresses data traceability and allows our app to run in both IPFS mode and Airtable mode. The app is not yet ready from a UI/UX perspective for the way IPFS data is delivered, in the way that an asset in IPFS mode ends up broken into onChainData and offChainData. In Airtable mode this does not happen, as Airtable pull data even faster than the SDK (onChainData), so the asset is 100% completed from the get go. Once we have UI states that cover the gap between the availability times of onChainData and offChainData we can go in and fix the next thing which is:

Resource availability

It can apparently take anywhere from 1 to 4 minutes for a newly uploaded resource to become available in IPFS (namely clouldflare's gateway), this isn't necessarily a massive problem, as it delays asset availability for all users in the same way, in the sense they are all allowed to invest a few minutes later after listing. The problem is the app, which again, is not ready for that. So we need extra clever code to cover this and make sure data is displayed properly and that the user is kept in the loop about what is happening.

Neither of these things I mentioned are hard to fix so we'll get to them. Meanwhile both Airtable and IPFS will be kept updated with asset listings, asset models and operators (not really supported because we have no UI showcasing anything about the Operator right now) and both will hold the same information. Once we determine we can let go of Airtable it'll be trivial to do so.

The React side

Created a new context called AssetsContext just to manage this relation between the SDK, Airtable and IPFS, the output of this context are the assets, in a consumable way, with flags telling its children components whether data is loading, etc.

We are using some of the SDK's events, for when a contribution happens or a new asset listing or a new Asset Model is created, the UI refreshes on its own in those cases. For other types of data updates, such as when an Investor withdraws their profits, I call fetchAsset() on that assetID and reload the onChainData for that asset. This only happens in the user's side and that is fine as that type of data events in other assets don`t matter to the user.

Smaller things:

Note:

We don't have any UI for when resources are being uploaded to IPFS, the file size restrictions make this less of a problem but in slower connections users will be left wondering why the app has not yet triggered a transaction.