diff --git a/tutorials/02_run_dvm.py b/tutorials/02_run_dvm.py index c090afc..7000817 100644 --- a/tutorials/02_run_dvm.py +++ b/tutorials/02_run_dvm.py @@ -11,6 +11,7 @@ from pathlib import Path import dotenv +from nostr_dvm.framework import DVMFramework from nostr_dvm.tasks.generic_dvm import GenericDVM from nostr_sdk import Kind, Keys from nostr_dvm.utils.admin_utils import AdminConfig @@ -20,6 +21,10 @@ from nostr_dvm.utils.zap_utils import change_ln_address def run_dvm(identifier): + + # Initialize the framework + framework = DVMFramework() + # This function will either create or load the parameters of our DVMConfig. # Make sure you replace the identifier down in the main function with the one you generated in tutorial 2, or we will create a new one here. dvm_config = build_default_config(identifier) @@ -60,8 +65,11 @@ def run_dvm(identifier): return result dvm.process = process # now we simply overwrite our DVM's process function with the one we defined here. - # and finally we run the DVM #RunDVM - dvm.run() + + # we add each DVM to the framework, in this case the one we just built + framework.add(dvm) + # and finally we run the framework #RunDVM + framework.run() # When the DVM is running you should see a blue message with the name and the public key in bech32 and hex format. # For the next exercise, copy the Hex key, and let this DVM run, you will need it :) diff --git a/tutorials/05_announce_dvm.py b/tutorials/05_announce_dvm.py index 7a8c632..f14fc81 100644 --- a/tutorials/05_announce_dvm.py +++ b/tutorials/05_announce_dvm.py @@ -10,6 +10,8 @@ import os from pathlib import Path import dotenv + +from nostr_dvm.framework import DVMFramework from nostr_dvm.tasks.generic_dvm import GenericDVM from nostr_sdk import Kind, Keys from nostr_dvm.utils.admin_utils import AdminConfig @@ -19,6 +21,10 @@ from nostr_dvm.utils.zap_utils import change_ln_address # We keep the main code structure almost the same as in tutorial02. def run_dvm(identifier, announce): + + # Initialize the framework + framework = DVMFramework() + dvm_config = build_default_config(identifier) kind = Kind(5050) dvm_config.KIND = kind @@ -93,7 +99,9 @@ def run_dvm(identifier, announce): return result dvm.process = process - dvm.run() + framework.add(dvm) + + framework.run() diff --git a/tutorials/06_dvm_config.py b/tutorials/06_dvm_config.py index 54e30eb..9a89260 100644 --- a/tutorials/06_dvm_config.py +++ b/tutorials/06_dvm_config.py @@ -8,6 +8,8 @@ import os from pathlib import Path import dotenv + +from nostr_dvm.framework import DVMFramework from nostr_dvm.tasks.generic_dvm import GenericDVM from nostr_sdk import Kind, Keys from nostr_dvm.utils.admin_utils import AdminConfig @@ -19,6 +21,9 @@ from nostr_dvm.utils.zap_utils import change_ln_address # We keep the main code structure almost the same as in tutorial02 and 05. def run_dvm(identifier, announce): + # Initialize the framework + framework = DVMFramework() + # Remember, with build_default_config(identifier) the framework will either create or load certain information # such as private nostr keys, wallet information, and d tags. dvm_config = build_default_config(identifier) @@ -144,7 +149,9 @@ def run_dvm(identifier, announce): return result dvm.process = process - dvm.run() + framework.add(dvm) + + framework.run() diff --git a/tutorials/07_admin_config.py b/tutorials/07_admin_config.py index 7c98250..6df6ccf 100644 --- a/tutorials/07_admin_config.py +++ b/tutorials/07_admin_config.py @@ -7,6 +7,8 @@ import os from pathlib import Path import dotenv + +from nostr_dvm.framework import DVMFramework from nostr_dvm.tasks.generic_dvm import GenericDVM from nostr_sdk import Kind, Keys from nostr_dvm.utils.admin_utils import AdminConfig @@ -18,6 +20,8 @@ from nostr_dvm.utils.zap_utils import change_ln_address # We keep the main code structure almost the same as in tutorial02 and 05. def run_dvm(identifier, announce): + # Initialize the framework + framework = DVMFramework() dvm_config = build_default_config(identifier) kind = Kind(5050) @@ -119,7 +123,9 @@ def run_dvm(identifier, announce): return result dvm.process = process - dvm.run() + framework.add(dvm) + + framework.run() diff --git a/tutorials/08_dvm_with_nutwallet.py b/tutorials/08_dvm_with_nutwallet.py index f15b8f0..9917e5f 100644 --- a/tutorials/08_dvm_with_nutwallet.py +++ b/tutorials/08_dvm_with_nutwallet.py @@ -14,6 +14,8 @@ import os from pathlib import Path import dotenv + +from nostr_dvm.framework import DVMFramework from nostr_dvm.tasks.generic_dvm import GenericDVM from nostr_sdk import Kind, Keys from nostr_dvm.utils.admin_utils import AdminConfig @@ -25,6 +27,8 @@ from nostr_dvm.utils.zap_utils import change_ln_address def run_dvm(identifier, announce): + # Initialize the framework + framework = DVMFramework() dvm_config = build_default_config(identifier) kind = Kind(5050) @@ -71,7 +75,8 @@ def run_dvm(identifier, announce): return result dvm.process = process - dvm.run(True) + framework.add(dvm) + framework.run()