From 947ed3c146d6fc21c10b29ac28f5de79518ec03b Mon Sep 17 00:00:00 2001 From: Believethehype <1097224+believethehype@users.noreply.github.com> Date: Fri, 17 May 2024 12:50:31 +0200 Subject: [PATCH] update nostr-sdk js and python, minor fixes --- .../tasks/content_discovery_currently_popular.py | 6 +++--- .../content_discovery_currently_popular_followers.py | 4 ++-- .../content_discovery_currently_popular_topic.py | 4 ++-- nostr_dvm/utils/mediasource_utils.py | 4 ++-- nostr_dvm/utils/nip88_utils.py | 5 ++--- nostr_dvm/utils/zap_utils.py | 2 +- setup.py | 4 ++-- tests/test_events.py | 1 - ui/noogle/package.json | 2 +- ui/noogle/src/components/Login.vue | 12 ++++++------ 10 files changed, 21 insertions(+), 23 deletions(-) diff --git a/nostr_dvm/tasks/content_discovery_currently_popular.py b/nostr_dvm/tasks/content_discovery_currently_popular.py index f43417a..cd97ad7 100644 --- a/nostr_dvm/tasks/content_discovery_currently_popular.py +++ b/nostr_dvm/tasks/content_discovery_currently_popular.py @@ -11,7 +11,7 @@ from nostr_dvm.utils.dvmconfig import DVMConfig, build_default_config from nostr_dvm.utils.nip88_utils import NIP88Config, check_and_set_d_tag_nip88, check_and_set_tiereventid_nip88 from nostr_dvm.utils.nip89_utils import NIP89Config, check_and_set_d_tag -from nostr_dvm.utils.output_utils import post_process_list_to_events, post_process_list_to_users +from nostr_dvm.utils.output_utils import post_process_list_to_events """ This File contains a Module to discover popular notes @@ -154,7 +154,7 @@ def post_process(self, result, event): if tag.as_vec()[0] == 'output': format = tag.as_vec()[1] if format == "text/plain": # check for output type - result = post_process_list_to_users(result) + result = post_process_list_to_events(result) # if not text/plain, don't post-process return result @@ -302,7 +302,7 @@ def build_example_subscription(name, identifier, admin_config, options, processi #admin_config.REBROADCAST_NIP88 = False # admin_config.FETCH_NIP88 = True - # admin_config.EVENTID = "63a791cdc7bf78c14031616963105fce5793f532bb231687665b14fb6d805fdb" + # admin_config.EVENTID = "" # admin_config.PRIVKEY = dvm_config.PRIVATE_KEY return DicoverContentCurrentlyPopular(name=name, dvm_config=dvm_config, nip89config=nip89config, diff --git a/nostr_dvm/tasks/content_discovery_currently_popular_followers.py b/nostr_dvm/tasks/content_discovery_currently_popular_followers.py index 3855b0f..6a3d02f 100644 --- a/nostr_dvm/tasks/content_discovery_currently_popular_followers.py +++ b/nostr_dvm/tasks/content_discovery_currently_popular_followers.py @@ -12,7 +12,7 @@ from nostr_dvm.utils.dvmconfig import DVMConfig, build_default_config from nostr_dvm.utils.nip88_utils import NIP88Config, check_and_set_d_tag_nip88, check_and_set_tiereventid_nip88 from nostr_dvm.utils.nip89_utils import NIP89Config, check_and_set_d_tag -from nostr_dvm.utils.output_utils import post_process_list_to_events, post_process_list_to_users +from nostr_dvm.utils.output_utils import post_process_list_to_events """ This File contains a Module to discover popular notes @@ -171,7 +171,7 @@ def post_process(self, result, event): if tag.as_vec()[0] == 'output': format = tag.as_vec()[1] if format == "text/plain": # check for output type - result = post_process_list_to_users(result) + result = post_process_list_to_events(result) # if not text/plain, don't post-process return result diff --git a/nostr_dvm/tasks/content_discovery_currently_popular_topic.py b/nostr_dvm/tasks/content_discovery_currently_popular_topic.py index a9c9bf5..13ea6f5 100644 --- a/nostr_dvm/tasks/content_discovery_currently_popular_topic.py +++ b/nostr_dvm/tasks/content_discovery_currently_popular_topic.py @@ -11,7 +11,7 @@ from nostr_dvm.utils.dvmconfig import DVMConfig, build_default_config from nostr_dvm.utils.nip88_utils import NIP88Config, check_and_set_d_tag_nip88, check_and_set_tiereventid_nip88 from nostr_dvm.utils.nip89_utils import NIP89Config, check_and_set_d_tag -from nostr_dvm.utils.output_utils import post_process_list_to_events, post_process_list_to_users +from nostr_dvm.utils.output_utils import post_process_list_to_events """ This File contains a Module to discover popular notes @@ -126,7 +126,7 @@ def post_process(self, result, event): if tag.as_vec()[0] == 'output': format = tag.as_vec()[1] if format == "text/plain": # check for output type - result = post_process_list_to_users(result) + result = post_process_list_to_events(result) # if not text/plain, don't post-process return result diff --git a/nostr_dvm/utils/mediasource_utils.py b/nostr_dvm/utils/mediasource_utils.py index 11bf758..0d799c2 100644 --- a/nostr_dvm/utils/mediasource_utils.py +++ b/nostr_dvm/utils/mediasource_utils.py @@ -19,14 +19,14 @@ def input_data_file_duration(event, dvm_config, client, start=0, end=0): if tag.as_vec()[0] == 'i': input_value = tag.as_vec()[1] input_type = tag.as_vec()[2] - count = count+1 + count = count + 1 if input_type == "text": return len(input_value) if input_type == "event": # NIP94 event if count > 1: - return 1 # we ignore length for multiple event inputs for now + return 1 # we ignore length for multiple event inputs for now evt = get_event_by_id(input_value, client=client, config=dvm_config) if evt is not None: input_value, input_type = check_nip94_event_for_media(evt, input_value, input_type) diff --git a/nostr_dvm/utils/nip88_utils.py b/nostr_dvm/utils/nip88_utils.py index 188cadc..6628803 100644 --- a/nostr_dvm/utils/nip88_utils.py +++ b/nostr_dvm/utils/nip88_utils.py @@ -5,8 +5,7 @@ import dotenv from nostr_sdk import Filter, Tag, Keys, EventBuilder, Client, EventId, PublicKey, Event, Timestamp, SingleLetterTag, \ - Alphabet -from nostr_sdk.nostr_sdk import Duration + Alphabet, Kind from nostr_dvm.utils import definitions from nostr_dvm.utils.definitions import EventDefinitions @@ -85,7 +84,7 @@ def nip88_delete_announcement(eid: str, keys: Keys, dtag: str, client: Client, c e_tag = Tag.parse(["e", eid]) a_tag = Tag.parse( ["a", str(EventDefinitions.KIND_NIP88_TIER_EVENT) + ":" + keys.public_key().to_hex() + ":" + dtag]) - event = EventBuilder(5, "", [e_tag, a_tag]).to_event(keys) + event = EventBuilder(Kind(5), "", [e_tag, a_tag]).to_event(keys) send_event(event, client, config) diff --git a/nostr_dvm/utils/zap_utils.py b/nostr_dvm/utils/zap_utils.py index 7e1cd4e..6870763 100644 --- a/nostr_dvm/utils/zap_utils.py +++ b/nostr_dvm/utils/zap_utils.py @@ -8,7 +8,7 @@ from Crypto.Cipher import AES from Crypto.Util.Padding import pad from bech32 import bech32_decode, convertbits, bech32_encode -from nostr_sdk import nostr_sdk, PublicKey, SecretKey, Event, EventBuilder, Tag, Keys, generate_shared_key, Kind, \ +from nostr_sdk import PublicKey, SecretKey, Event, EventBuilder, Tag, Keys, generate_shared_key, Kind, \ Timestamp from nostr_dvm.utils.nostr_utils import get_event_by_id, check_and_decrypt_own_tags diff --git a/setup.py b/setup.py index 3399fc3..f411e80 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ from setuptools import setup, find_packages -VERSION = '0.4.2' +VERSION = '0.4.3' DESCRIPTION = 'A framework to build and run Nostr NIP90 Data Vending Machines' LONG_DESCRIPTION = ('A framework to build and run Nostr NIP90 Data Vending Machines. See the github repository for more information') @@ -14,7 +14,7 @@ long_description=LONG_DESCRIPTION, packages=find_packages(include=['nostr_dvm', 'nostr_dvm.*']), - install_requires=["nostr-sdk==0.11.0", + install_requires=["nostr-sdk==0.12.0", "bech32", "pycryptodome==3.20.0", "python-dotenv==1.0.0", diff --git a/tests/test_events.py b/tests/test_events.py index fd0a4e4..217cc8e 100644 --- a/tests/test_events.py +++ b/tests/test_events.py @@ -2,7 +2,6 @@ from pathlib import Path import dotenv -import nostr_sdk from nostr_sdk import Keys, Client, Tag, EventBuilder, Filter, HandleNotification, Timestamp, nip04_decrypt, \ nip04_encrypt, EventId, Options, PublicKey, Event, NostrSigner, Nip19Event diff --git a/ui/noogle/package.json b/ui/noogle/package.json index 7f418c5..ca26d1f 100644 --- a/ui/noogle/package.json +++ b/ui/noogle/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@getalby/sdk": "^3.4.0", - "@rust-nostr/nostr-sdk": "^0.13.1", + "@rust-nostr/nostr-sdk": "^0.14.0", "@vuepic/vue-datepicker": "^7.4.1", "@vueuse/core": "^10.7.2", "bech32": "^2.0.0", diff --git a/ui/noogle/src/components/Login.vue b/ui/noogle/src/components/Login.vue index 4eaea7b..2450cc1 100644 --- a/ui/noogle/src/components/Login.vue +++ b/ui/noogle/src/components/Login.vue @@ -869,14 +869,14 @@ export default { jsonentry.event = entry.asJson() jsonentry.kind = entry.tags[tag].asVec()[1] - - - //jsonentry.nip90Params = JSON.parse(jsonentry.nip90Params) - nip89dvms.push(jsonentry); - + if(nip89dvms.find(x=> x.id === jsonentry.id && x.kind === jsonentry.kind) === undefined) + { + nip89dvms.push(jsonentry); + } + } catch (error){ - //console.log(error) + console.log(error) } }