You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Feature: several things for Spectrum preparation (#1913)
* change Node persistence format
* Removing the Singleton
* mainly refactoring
* intermediate commit
* fix test
* Updated diagram
* fix tests
* removing simplejsons references
* fix tests
* remove update, tests working
* abstract Node
* refining Migration framework: run migrations until they suceed
* BrokenCoreConnectionException added to handle lost RPC + some minor error handling fixes
* clicking redirects to node config if there is no node connection
* AbstractNode
* BrokenCoreConnectionException added to handle lost RPC + some minor error handling fixes
* clicking redirects to node config if there is no node connection
* handling broken connection when there is no other error superseding (i.e. no wallets)
* Abstract Node improvements and issue fixing
* improving node_info handling
* fix test results, property device_manager in user, bcce in get_rpc in node, improved rpc property in node
* typos
* provide data_folders for extensions
* parametrizing include for node_info
* Remove initial_node_contribution refactoring welcome
* adding convenience methods
* extension data-storage
* Tests green
* Better failure resistence
* Enabling Node settings
* error handling
* adjust_view_model callback
* exception Handling
* Shielding core from extension flaws
* More consistent logging
* Refactoring wallets endpoints
* Make wallet_overview extendable
* butgifex and cleanup
* feedback by Manolis
* rename BusinessObject to PersistentObject
* fix Error-management and rollback information
* Nodes.md corrections
* frontend-aspects.md (small) corrections
* fix tests and address feedback and errormanagement
* fix tests, proper error-handling
* Fix test_util_reflection
* just some little addons to test_util_reflection
* fix cleanup_on_exit
* migration fix
* remove check, add redirect after saving node
* fix test (not that cool but what to do?)
* upgrade Flask as Flask-SQLAlchemy needs higher Flask version
* Revert "upgrade Flask as Flask-SQLAlchemy needs higher Flask version"
This reverts commit bf24120.
* update bug fixed + node manager added to node test
* cleanup external_node
Co-authored-by: moneymanolis <[email protected]>
Copy file name to clipboardExpand all lines: docs/extensions/data-storage.md
+4-6Lines changed: 4 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,24 +15,22 @@ It is up to each `Service` implementation to decide what data is stored; the `Se
15
15
This is also where `Service`-wide configuration or other information should be stored, _**even if it is not secret**_ (see above intro about not polluting other existing data stores).
16
16
17
17
## ServiceEncryptedStorageManager
18
-
Because the `ServiceEncryptedStorage` is specific to each individual user, this manager provides convenient access to automatically retrieve the `current_user` from the Flask context and provide the correct user's `ServiceEncryptedStorage`. It is implemented as a `Singleton` which can be retrieved simply by importing the class and calling `get_instance()`.
18
+
Because the `ServiceEncryptedStorage` is specific to each individual user, this manager provides convenient access to automatically retrieve the `current_user` from the Flask context and provide the correct user's `ServiceEncryptedStorage`.
19
19
20
20
This simplifies code to just asking for:
21
21
```python
22
22
from .service_encrypted_storage import ServiceEncryptedStorageManager
Whenever possible, external code should not directly access these `Service`-related support classes but rather should ask for them through the `Service` class.
35
-
36
34
## `ServiceUnencryptedStorage`
37
35
A disadvantage of the `ServiceEncryptedStorage` is, that the user needs to be freshly logged in in order to be able to decrypt the secrets. If you want to avoid that login but your extension should still store data on disk, you can use the `ServiceUnencryptedStorage`.
38
36
@@ -49,7 +47,7 @@ _Note: current `Service` implementations have not yet needed this feature so dis
49
47
50
48
Unfortunately, the two unencrypted classes are derived from the encrypted one rather than having it the other way around or having abstract classes. This makes the diagram maybe a bit confusing.
Efforts has been taken to provide `Service` data storage that is separate from existing data stores in order to keep those areas clean and simple. Where touchpoints are unavoidable, they are kept to the absolute bare minimum (e.g. `User.services` list in `users.json`, `Address.service_id` field).
Copy file name to clipboardExpand all lines: docs/extensions/frontend-aspects.md
+27-4Lines changed: 27 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,7 +41,7 @@ In your controller, the endpoint needs to be specified like this:
41
41
ui = RubberduckService.blueprints["ui"]
42
42
```
43
43
44
-
## Templates and Static Resources
44
+
## Templates and static resources
45
45
46
46
The minimal url routes for `Service` selection and management. As usualy in Flask, `templates` and `static` resources are in their respective subfolders. Please note that there is an additional directory with the id of the extension which looks redundant at first. This is due to the way blueprints are loading templates and ensures that there are no naming collisions. Maybe at a later stage, this can be used to let plugins override other plugin's templates.
47
47
@@ -66,8 +66,8 @@ You might have an extension which wants to inject e.g. JavaScript code into each
66
66
67
67
For this to work, the extension needs to be activated for the user, though.
68
68
69
-
###Extending dialogs
70
-
You can extend the settings dialog or the wallet-dialog with your own templates. To do that, create a callback method in your service like:
69
+
## Extending dialogs
70
+
You can extend the settings dialog or the walletdialog with your own templates. To do that, create a callback method in your service like:
71
71
72
72
```python
73
73
from cryptoadvance.specter.services import callbacks
@@ -120,7 +120,7 @@ The `some_settingspage.jinja` should probably look exactly like all the other se
@@ -146,3 +146,26 @@ A reasonable `mywalletdetails.jinja` would look like this:
146
146
147
147

148
148
149
+
## Extending certain pages or complete endpoints
150
+
151
+
For some endpoints, there is the possibility to extend/change parts of a page or the complete page. This works by declaring the `callback_adjust_view_model` method in your extension and modify the ViewModel which got passed into the callback. As there is only one callback for all types of ViewModels, you will need to check for the type that you're expecting and only adjust this type. Here is an example:
152
+
153
+
```python
154
+
from cryptoadvance.specter.server_endpoints.welcome.welcome_vm import WelcomeVm
In this example, a certain part of the page gets replaced. As you can read in the comments, you could also trigger a complete redirect to a different endpoint.
168
+
169
+
Currently, only two `ViewModels` are existing. Check them out. Don't hesitate to create an issue if you'd like to modify something where no ViewModel exists yet:
The whole programming-model is based on the Bitcoin-Core API. So we need Bitcoin Core nodes or elements nodes or at least something which behaves like that. So for the Spectrum Integration, we made extending the node possible. This is a short description of how that has been done and which extensionpoints might be helpfull here.
4
+
5
+
So to create your own Node, derive from `AbstractNode`:
6
+
7
+
```
8
+
from cryptoadvance.specter.node import AbstractNode
9
+
10
+
class MyNode(AbstractNode):
11
+
# [...]
12
+
@classmethod
13
+
def from_json(cls, node_dict, *args, **kwargs):
14
+
[...]
15
+
16
+
def node_info_template(self):
17
+
return "spectrum/components/spectrum_info.jinja"
18
+
```
19
+
20
+
That class will need its own `fromJson` method. Overwrite the `node_info_template` method to specify your own template for the info-page which comes up if you click on a fully configured and functional node in the upper left corner. In order to smuggle your node into existence, you could potentially use the `callback_after_serverpy_init_app` callback. Have a look how the spectrum-extension did it [here](https://github.com/cryptoadvance/spectrum/pull/9/files#diff-82be7977bfa33bdbb0a448c7a03b43de90c4749565bef6737d6d516956ff0823R51-R62). Alternatively, you could create your own frontend in your controller and maybe additionally adjust the `WelcomeVm` model class as described in the frontend section.
21
+
22
+
If the `node_settings` are clicked for that node, we also expect that you have a `node_settings` endpoint in your controller. Otherwise there will be errors. Something like:
0 commit comments