@@ -91,6 +91,7 @@ import {copyinvoice, createBolt11Lud16, parseandreplacenpubs, zaprequest} from "
import {requestProvider} from "webln";
import {Event, EventBuilder, EventId, PublicKey} from "@rust-nostr/nostr-sdk";
import amberSignerService from "@/components/android-signer/AndroidSigner";
+import zap, {zap_lud16} from "@/components/helper/Zap.vue";
const props = defineProps<{
@@ -145,56 +146,16 @@ async function react(eventid, authorid){
}
-async function zap(lud16, eventid, authorid){
+async function zap_local(lud16, eventid, authorid){
- if(lud16 != Null && lud16 != ""){
- let invoice = await zaprequest(lud16, 21 , "with love from noogle.lol", eventid, authorid, store.state.relays) //Not working yet
- // let invoice = await createBolt11Lud16(lud16, 21)
- let webln;
- try {
- webln = await requestProvider();
- } catch (err) {
- if (invoice === null){
- invoice = await createBolt11Lud16(lud16, 21)
- }
-
- await copyinvoice(invoice)
-
-
- }
- if (webln) {
- try{
- let response = await webln.sendPayment(invoice)
- if(response.preimage != null && response.preimage != ""){
-
-
- let objects = (props.data.find(x=> x.id === eventid))
+ let success = await zap_lud16(lud16, eventid, authorid)
+ if (success){
+ let objects = props.data.find(x=> x.id === eventid)
if (objects !== undefined){
- // console.log(objects.zapped)
objects.zapped = true
objects.zapAmount += 21000
- }
+ }
- /* if (objects != undefined && objects.length > 0){
- console.log(objects[0])
- props.data.find(x=> x.id === eventid).zapped.push.apply(props.data.find(x=> x.id === eventid).zapped, true)
-
-
- }*/
-
-
- // miniToastr.showMessage("Zapped " + author , "Success" , VueNotifications.types.warn)
- console.log(response)
-
- }
-
-
- }
- catch(err){
- console.log(err)
- await copyinvoice(invoice)
- }
- }
}
}
diff --git a/ui/noogle/src/components/ProfileResultTable.vue b/ui/noogle/src/components/ProfileResultTable.vue
index dee97ab..e45943c 100644
--- a/ui/noogle/src/components/ProfileResultTable.vue
+++ b/ui/noogle/src/components/ProfileResultTable.vue
@@ -5,15 +5,10 @@
:items="store.state.profile_results" >
+ {{ author }}
+
diff --git a/ui/noogle/src/components/RecommendationGeneration.vue b/ui/noogle/src/components/RecommendationGeneration.vue
index d2e31bb..01f9ef0 100644
--- a/ui/noogle/src/components/RecommendationGeneration.vue
+++ b/ui/noogle/src/components/RecommendationGeneration.vue
@@ -11,7 +11,7 @@ import {
EventBuilder,
Tag,
EventId,
- Nip19Event, Alphabet, Keys, nip04_decrypt, SecretKey, Duration
+ Nip19Event, Alphabet, Keys, nip04_decrypt, SecretKey, Duration, SingleLetterTag
} from "@rust-nostr/nostr-sdk";
import store from '../store';
import miniToastr from "mini-toastr";
@@ -22,7 +22,9 @@ import {data} from "autoprefixer";
import {requestProvider} from "webln";
import Newnote from "@/components/Newnote.vue";
import SummarizationGeneration from "@/components/SummarizationGeneration.vue"
-import {post_note, schedule, copyurl, copyinvoice, sleep, getEvents, get_user_infos, get_zaps, zaprequest, get_reactions, nextInput, createBolt11Lud16, getEventsOriginalOrder, parseandreplacenpubsName} from "../components/helper/Helper.vue"
+import {post_note, schedule, copyurl, copyinvoice, sleep, getEvents, get_user_infos, get_zaps, get_reactions, nextInput, getEventsOriginalOrder, parseandreplacenpubsName} from "../components/helper/Helper.vue"
+import {zap, createBolt11Lud16, zaprequest} from "../components/helper/Zap.vue"
+
import amberSignerService from "./android-signer/AndroidSigner";
import StringUtil from "@/components/helper/string.ts";
@@ -100,9 +102,6 @@ async function generate_feed(id) {
}
}
-
-
-
async function listen() {
let client = store.state.client
let pubkey = store.state.pubkey
@@ -228,7 +227,7 @@ async function listen() {
authors.push(evt.author)
}
catch(error){
- console.log(error)
+ //console.log(error)
}
}
@@ -242,7 +241,11 @@ async function listen() {
let ids = []
for (let evt of events){
- ids.push(evt.id)
+ try {ids.push(evt.id)}
+ catch(error){
+ console.log(error)
+ }
+
}
let zaps = await get_zaps(ids)
let items = []
@@ -323,22 +326,18 @@ async function listen() {
client.handleNotifications(handle);
}
-
-const urlinput = ref("");
-
-
async function addAllContentDVMs() {
- let relevent_dvms = []
+ let relevant_dvms = []
for (const el of store.state.nip89dvms) {
for (const tag of JSON.parse(el.event).tags) {
if (tag[0] === "k" && tag[1] === "5300") {
- relevent_dvms.push(PublicKey.parse(el.id))
+ relevant_dvms.push(PublicKey.parse(el.id))
}
}
}
let active_dvms = []
- for (let id of relevent_dvms) {
+ for (let id of relevant_dvms) {
let jsonentry = {
id: id.toHex(),
last_active: 0
@@ -349,7 +348,7 @@ async function addAllContentDVMs() {
console.log(active_dvms)
- const filtera = new Filter().authors(relevent_dvms).kinds([6300, 7000])
+ const filtera = new Filter().authors(relevant_dvms).kinds([6300, 7000])
let client = store.state.client
let activities = await client.getEventsOf([filtera], Duration.fromSecs(1))
@@ -367,10 +366,10 @@ async function addAllContentDVMs() {
// console.log(last_active)
// If DVM hasn't been active for 3 weeks, don't consider it.
- console.log(active_dvms)
+ //console.log(active_dvms)
let final_dvms = []
for (let element of active_dvms) {
- if (element.last_active > Timestamp.now().asSecs() - 60 * 60 * 24 * 7) {
+ if (element.last_active > Timestamp.now().asSecs() - 60 * 60 * 24 * 21) {
final_dvms.push(store.state.nip89dvms.find(x => x.id === element.id))
}
@@ -389,7 +388,8 @@ async function addAllContentDVMs() {
amount: el.amount,
bolt11: "",
lud16: el.lud16,
- subscription: ""
+ subscription: "",
+ nip88: el.nip88
}
@@ -503,21 +503,75 @@ async function addDVM(event){
}
-async function subscribe(lud16, days, amountperday, eventid, authorid) {
- if (lud16 !== "") {
- let profiles = await get_user_infos([PublicKey.parse(authorid)])
- if (profiles.length > 0) {
- let current = profiles[0]
- lud16 = current.profile.lud16
+
+
+async function subscribe(zaps, amount, cadence, activesubscriptioneventid, tierevent, tiereventid, dvmid) {
+
+ // We only arrive here if no subscription exists, we might create a 7001 if it doesnt exist and we zap it
+ let client = store.state.client
+
+ console.log(dvmid)
+ console.log(tiereventid)
+ console.log(JSON.stringify(tierevent))
+ console.log(amount)
+ console.log(activesubscriptioneventid)
+
+
+ if (activesubscriptioneventid === ""){
+ console.log("Creating 7001 event")
+ let tags = [
+ Tag.parse([ "p", dvmid]),
+ Tag.parse([ "e" , tiereventid]),
+ Tag.parse([ "event", JSON.stringify(tierevent)]),
+ Tag.parse([ "amount", (amount).toString(), "msats", cadence]),
+ // Zap-splits todo order and splits
+ // Tag.parse([ "zap", authorid, "19" ]), // 95%
+ // Tag.parse([ "zap", "fa984bd7dbb282f07e16e7ae87b26a2a7b9b90b7246a44771f0cf5ae58018f52", "1" ]), // 5% to client developer where subscription was created
+ ]
+
+ for(let zap of zaps){
+ let zaptag = Tag.parse([ "zap", zap.key, zap.split])
+ tags.push(zaptag)
}
+
+ console.log(tags)
+ let evt = new EventBuilder(7001, "Subscription from noogle.lol", tags)
+ let res = await client.sendEventBuilder(evt);
+ activesubscriptioneventid = res.toHex()
+
}
- let invoice = await zaprequest(lud16, days * amountperday, "paid from noogle.lol", eventid, authorid, store.state.relays)
- console.log(invoice)
- await zap(invoice)
+
+ let overallsplit = 0
+ for (let zap of zaps){
+ overallsplit += parseInt(zap.split)
+ }
+ for (let zap of zaps){
+ let profiles = await get_user_infos([PublicKey.parse(zap.key)])
+ if (profiles.length > 0) {
+ let current = profiles[0]
+ let lud16 = current.profile.lud16
+ let splitted_amount = Math.floor((zap.split/overallsplit) * amount/1000)
+ console.log(splitted_amount)
+ console.log(overallsplit)
+ console.log(activesubscriptioneventid)
+ let invoice = await zaprequest(lud16, splitted_amount, "paid for " + cadence + " from noogle.lol", activesubscriptioneventid, dvmid, store.state.relays)
+ console.log(invoice)
+ await zapSubscription(invoice)
+ }
+ }
+
+
+
+ dvms.find(x => x.nip88.eventid === tiereventid ).hasActiveSubscription = true
+
+
+
+ // next, the dvm should listen to these 7001 events addressed to it and (or rather 9735 tagging the 7001 and the subscription should be considered valid for both)
+
}
-async function zap(invoice) {
+async function zapSubscription(invoice) {
let webln;
//this.dvmpaymentaddr = `https://chart.googleapis.com/chart?cht=qr&chl=${invoice}&chs=250x250&chld=M|0`;
@@ -531,8 +585,9 @@ async function zap(invoice) {
if (webln) {
try{
let response = await webln.sendPayment(invoice)
- dvms.find(i => i.bolt11 === invoice).status = "paid"
- store.commit('set_recommendation_dvms', dvms)
+
+ //dvms.find(i => i.bolt11 === invoice).status = "paid"
+ // store.commit('set_recommendation_dvms', dvms)
}
catch(err){
console.log(err)
@@ -542,6 +597,17 @@ async function zap(invoice) {
}
+async function zap_local(invoice) {
+
+ let success = await zap(invoice)
+ if (success){
+ dvms.find(i => i.bolt11 === invoice).status = "paid"
+ store.commit('set_recommendation_dvms', dvms)
+ }
+
+}
+
+
defineProps({
msg: {
type: String,
@@ -554,6 +620,7 @@ import ModalComponent from "../components/Newnote.vue";
import VueDatePicker from "@vuepic/vue-datepicker";
import {timestamp} from "@vueuse/core";
import NoteTable from "@/components/NoteTable.vue";
+import {nostrzapper_nwc} from "@rust-nostr/nostr-sdk/pkg/nostr_sdk_js_bg.wasm.js";
@@ -667,37 +734,22 @@ const submitHandler = async () => {
{{dvm.status}}
-
Done
+
Done, again?
Paid, waiting for DVM..
Error
-
{{ dvm.amount/1000 }} Sats
-
-
+
{{ dvm.amount/1000 }} Sats
+
Subscription required
-
-
-
-
-
Subscribe for a day
-
- {{ dvm.amount/1000 }} Sats
-
- Subscribe for a month
-
- {{ 30 * dvm.amount/1000 }} Sats
-
-
-
-
-
Subscribed. Request job
-
Request
-
+
+
+
+ Request
+
+
@@ -723,13 +775,85 @@ const submitHandler = async () => {
Free
-
Flexible
-
Subscription
-
-
+
+
+
+
+
+
+
+ Subscription
+
+
+
+
+
+
+
+
{{dvm.nip88.title}}
+
+
{{dvm.nip88.description}}
+
+
+
Subscribe and pay {{index.cadence}}
+ {{ index.amount/1000 }} Sats
+
+
+
+
+
+
+
+
+
+
+ Active Subscription
+
+
+
+
+
+
+
+
+
+
{{dvm.nip88.title}}
+
+
{{dvm.nip88.description}}
+
+
Perks:
+
+
+
Subscription active until
+ {{Timestamp.fromSecs(parseInt(dvm.nip88.subscribedUntil)).toHumanDatetime().split("T")[0].split("-")[2].trim()}}.{{Timestamp.fromSecs(parseInt(dvm.nip88.subscribedUntil)).toHumanDatetime().split("T")[0].split("-")[1].trim()}}.{{Timestamp.fromSecs(parseInt(dvm.nip88.subscribedUntil)).toHumanDatetime().split("T")[0].split("-")[0].trim().slice(2)}} {{Timestamp.fromSecs(parseInt(dvm.nip88.subscribedUntil)).toHumanDatetime().split("T")[1].split("Z")[0].trim()}}
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
-->
-
@@ -787,6 +911,7 @@ const submitHandler = async () => {
.sub-Button{
@apply btn hover:bg-nostr border-orange-500 text-base;
+
bottom: 0;
}
diff --git a/ui/noogle/src/components/RecommendationGeneration_old.vue b/ui/noogle/src/components/RecommendationGeneration_old.vue
index 002a884..0f66e06 100644
--- a/ui/noogle/src/components/RecommendationGeneration_old.vue
+++ b/ui/noogle/src/components/RecommendationGeneration_old.vue
@@ -308,31 +308,19 @@ async function addDVM(event){
store.commit('set_recommendation_dvms', dvms)
}
-async function zap(invoice) {
- let webln;
- //this.dvmpaymentaddr = `https://chart.googleapis.com/chart?cht=qr&chl=${invoice}&chs=250x250&chld=M|0`;
- //this.dvminvoice = invoice
- try {
- webln = await requestProvider();
- } catch (err) {
- await copyinvoice(invoice)
- }
+async function zap_local(invoice) {
- if (webln) {
- try{
- let response = await webln.sendPayment(invoice)
- dvms.find(i => i.bolt11 === invoice).status = "paid"
+ let success = await zap(invoice)
+ if (success){
+ dvms.find(i => i.bolt11 === invoice).status = "paid"
store.commit('set_recommendation_results', dvms)
- }
- catch(err){
- console.log(err)
- await copyinvoice(invoice)
- }
}
+
}
+
defineProps({
msg: {
type: String,
@@ -345,6 +333,7 @@ import ModalComponent from "../components/Newnote.vue";
import VueDatePicker from "@vuepic/vue-datepicker";
import {timestamp} from "@vueuse/core";
import NoteTable from "@/components/NoteTable.vue";
+import zap from "@/components/helper/Zap.vue";
const isModalOpened = ref(false);
const modalcontent = ref("");
@@ -456,7 +445,7 @@ const submitHandler = async () => {
Paid, waiting for DVM..
Error
-
{{ dvm.amount/1000 }} Sats
+
{{ dvm.amount/1000 }} Sats
diff --git a/ui/noogle/src/components/SummarizationGeneration.vue b/ui/noogle/src/components/SummarizationGeneration.vue
index 7624427..3e19eef 100644
--- a/ui/noogle/src/components/SummarizationGeneration.vue
+++ b/ui/noogle/src/components/SummarizationGeneration.vue
@@ -28,6 +28,7 @@ import ModalComponent from "../components/Newnote.vue";
import VueDatePicker from "@vuepic/vue-datepicker";
import {timestamp} from "@vueuse/core";
import NoteTable from "@/components/NoteTable.vue";
+import {zap} from "@/components/helper/Zap.vue";
let dvms =[]
async function summarizefeed(eventids) {
@@ -245,36 +246,16 @@ async function listen() {
}
-async function zap(invoice) {
- let webln;
+async function zap_local(invoice) {
- //this.dvmpaymentaddr = `https://chart.googleapis.com/chart?cht=qr&chl=${invoice}&chs=250x250&chld=M|0`;
- //this.dvminvoice = invoice
-
-
- try {
- webln = await requestProvider();
- } catch (err) {
- await copyinvoice(invoice)
+ let success = await zap(invoice)
+ if (success){
+ dvms.find(i => i.bolt11 === invoice).status = "paid"
+ store.commit('set_summarization_dvms', dvms)
}
- if (webln) {
- try{
- let response = await webln.sendPayment(invoice)
- dvms.find(i => i.bolt11 === invoice).status = "paid"
- store.commit('set_summarization_dvms', dvms)
- }
- catch(err){
- console.log(err)
- await copyinvoice(invoice)
- }
-
- }
-
-
}
-
defineProps({
events: {
type: Array,
@@ -364,7 +345,7 @@ const submitHandler = async () => {