Skip to content

Commit

Permalink
update nostr-sdk js and python, minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
believethehype committed May 17, 2024
1 parent 756fa7a commit 947ed3c
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 23 deletions.
6 changes: 3 additions & 3 deletions nostr_dvm/tasks/content_discovery_currently_popular.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions nostr_dvm/tasks/content_discovery_currently_popular_topic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions nostr_dvm/utils/mediasource_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 2 additions & 3 deletions nostr_dvm/utils/nip88_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)


Expand Down
2 changes: 1 addition & 1 deletion nostr_dvm/utils/zap_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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')

Expand All @@ -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",
Expand Down
1 change: 0 additions & 1 deletion tests/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion ui/noogle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
12 changes: 6 additions & 6 deletions ui/noogle/src/components/Login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down

0 comments on commit 947ed3c

Please sign in to comment.