specter-desktop/docs/archblog.md
kdmukai 7b27c79907
Feature: Service integration - Swan (#1517)
* fix create_order issue
* fix url and better error-handling
* basic balances tab
* activating services
* Service management
* Improve settings page and default to it if token unset
* Fix history tab
* Fix trade error handling
* Add withdraw
* calling specter-cloud for creating vaultoro orders
* Improve trade screen and fixes
* sidebar fix
* black
* refactor Service integration
* refactor to have Service Classes like manifests
* maturity
* dynamic initialisation of service-classes and blueprints
* fix sidebar_services
* migrated templates and static into vaultoro folder
* refactor config to manifest
* some minor things
* swan initial
* rename and fix test
* adding ServiceApiKeyStorageUserAware
* fix
* store the access token
* directory indirection to shield templates from each others blueprint
* first attempts with automatic withdrawals
* proper tab highlighting
* Update service_apikey_storage.py
* Update oauth2_success.jinja
* Awaiting refresh_token support
* Service logo display on Addresses
* Associate addr with a Service
* address-data component reorg
Separates the presentation html from the data as much as possible.
* Services data/icon added to tx History
* Now hitting the updated Swan endpoint to save deposit addrs
* Simplified injecting Services data into JS
* Reducing js calls back to server in tx-data; templatizing utxo in/outs
* renaming "reserving" to "associating" an Address with a Service.
* rename `manifest.py` files to `service.py`.
* rename "api_data" to "service_data" to make the storage a bit more generalized. `ServiceApiKeyStorage` is now `ServiceEncryptedStorage` to match.
* Beginning of factoring out Swan api to its own `api.py` file; need to rectify with `swan_client.py`.
* Removed tx-table/row/data changes and address-table/row/data
Kept only the bare minimum changes required to display the Services icon, plus optimizations.
* deleted no longer used CustomElement
* Adding services docs to mkdocs
* Configuration for Services
* more clever configuration
* fix test
* deleted swan_client
* Changing the address abbreviation format to 7...7 and little big fix for not vertically aligned addresses in Firefox.
* Better state management if Auth method changes
* Cleanup, better user messaging; pulling Service methods out of controller and User
* Redirect to services endpoint after setting up authentication.
* PR cleanup, bug fixes, test suite updates
* Fixed test case problem
* First fix for delete API key button.
* Service hooks; Option to fully remove Swan Integration; Logout clears plaintext_user_secret
* Restoring bugfix from @moneymanolis
* cleanup and black
* Make service-decovery in AppImage work
* import hashlib, maybe fix cypress
* Update service_encrypted_storage.py
* further bugfix on update
* TODO: remove debugging in client.py before first release
* fix controller-test
* fix singleton testing issues

Co-authored-by: Kim Neunert <k9ert@gmx.de>
Co-authored-by: benk10 <ben.kaufman10@gmail.com>
Co-authored-by: Kim Neunert <kneunert@gmail.com>
Co-authored-by: moneymanolis <moneymanolis@protonmail.com>
2022-01-13 11:47:28 +01:00

28 lines
No EOL
4 KiB
Markdown

# Purpose
Let's find a place to docoment non straightforward design decisions.
## 02nd Oct 2020 - Kim
It's already mentioned in Development.md. I spend far too much time figuring out that we have created a nasty workaround in server.py.
So the problem looks like this: The fixtures are creating the app anew for each test in test_controller. For some reason hwi-view-endpoints are somehow treated differently then the normal endpoints. As a result, the second test gets a app-object which, for some reason doesn't have the normal endpoints, but just the hwi-endpoint. A healthy app.view_functions looks like this:
```
{'static': <bound method _PackageBoundObject.send_static_file of <Flask 'cryptoadvance.specter.server'>>, 'hwi_server.index': <function index at 0x7f3d67e64d40>, 'hwi_server.api': <function api at 0x7f3d67e64c20>, 'hwi_server.hwi_bridge_settings': <function hwi_bridge_settings at 0x7f3d67e64b00>, 'combine': <function combine at 0x7f3d674bed40>, 'broadcast': <function broadcast at 0x7f3d6739a200>, 'index': <function index at 0x7f3d6739a320>, 'about': <function about at 0x7f3d6739a680>, 'login': <function login at 0x7f3d6739ac20>, 'register': <function register at 0x7f3d6739af80>, 'logout': <function logout at 0x7f3d6739ad40>, 'settings': <function settings at 0x7f3d673a05f0>, 'hwi_settings': <function hwi_settings at 0x7f3d673a04d0>, 'general_settings': <function general_settings at 0x7f3d673a09e0>, 'bitcoin_core_settings': <function bitcoin_core_settings at 0x7f3d673a0d40>, 'auth_settings': <function auth_settings at 0x7f3d673a4320>, 'new_wallet_type': <function new_wallet_type at 0x7f3d673a4440>, 'new_wallet': <function new_wallet at 0x7f3d673a47a0>, 'wallet': <function wallet at 0x7f3d673a4b00>, 'wallets_overview': <function wallets_overview at 0x7f3d673a4f80>, 'singlesig_setup_wizard': <function singlesig_setup_wizard at 0x7f3d673af200>, 'wallet_tx': <function wallet_tx at 0x7f3d673af560>, 'wallet_tx_history': <function wallet_tx_history at 0x7f3d673af8c0>, 'wallet_tx_utxo': <function wallet_tx_utxo at 0x7f3d673afc20>, 'wallet_receive': <function wallet_receive at 0x7f3d673aff80>, 'fees': <function fees at 0x7f3d67339320>, 'txout_set_info': <function txout_set_info at 0x7f3d67339680>, 'get_scantxoutset_status': <function get_scantxoutset_status at 0x7f3d673399e0>, 'get_wallet_rescan_progress': <function get_wallet_rescan_progress at 0x7f3d67339d40>, 'wallet_send': <function wallet_send at 0x7f3d67340320>, 'wallet_sendnew': <function wallet_sendnew at 0x7f3d67340440>, 'wallet_importpsbt': <function wallet_importpsbt at 0x7f3d673407a0>, 'wallet_sendpending': <function wallet_sendpending at 0x7f3d67340b00>, 'wallet_settings': <function wallet_settings at 0x7f3d67340f80>, 'new_device': <function new_device at 0x7f3d67347200>, 'device': <function device at 0x7f3d67347560>}
```
An unhelathy like this:
```
{'static': <bound method _PackageBoundObject.send_static_file of <Flask 'cryptoadvance.specter.server'>>, 'hwi_server.index': <function index at 0x7f12b3475d40>, 'hwi_server.api': <function api at 0x7f12b3475c20>, 'hwi_server.hwi_bridge_settings': <function hwi_bridge_settings at 0x7f12b3475b00>}
```
Feel free to beat me for the brittle if-clause in server.py but please solve the issue in the first place for this as well :-).
## 19nd Feb 2020 - k9ert
The ApplicationFactory-pattern is not that straightforward. There are loads of pifalls and different ways to go. While finding a proper way to do it, one thing became clear: You need to separate the instantiation and the initialisation of the Application.
(from singleton.py)
```python __main__.py
app = logic.create_app()
app.app_context().push()
# (...)
logic.init_app(app)
```
If you would put everything in the create-call, you can't import code which is dependent on an initialized ApplicationContext, you can't do "from flask import current_app". So you have to push the app_context but on the other side, you don't want to do that from within the create_app-function because this would be a quite shitty side-effect which srews up your whole dependency injection.