mirror of
https://github.com/aljazceru/hypergolic.git
synced 2025-12-19 14:34:20 +01:00
problem: Revenue table doesn't work
This commit is contained in:
@@ -40,6 +40,12 @@
|
|||||||
{:else}
|
{:else}
|
||||||
<PayNow {product} rocketProduct={rocket.Products().get(product.ID())} {rocket} />
|
<PayNow {product} rocketProduct={rocket.Products().get(product.ID())} {rocket} />
|
||||||
{/if}
|
{/if}
|
||||||
|
<a
|
||||||
|
href="#"
|
||||||
|
on:click={() => {
|
||||||
|
console.log(product);
|
||||||
|
}}>print to console</a
|
||||||
|
>
|
||||||
</Card.Footer>
|
</Card.Footer>
|
||||||
</Card.Root>
|
</Card.Root>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -11,12 +11,12 @@
|
|||||||
//export let products: Product[];
|
//export let products: Product[];
|
||||||
export let rocket: Rocket;
|
export let rocket: Rocket;
|
||||||
|
|
||||||
export let unratifiedZaps:Map<string, number>; //todo upstream bind this and pass outstanding zaps to merits and satflow component.
|
export let unratifiedZaps: Map<string, number>;
|
||||||
|
|
||||||
let zaps = $ndk.storeSubscribe(
|
let zaps = $ndk.storeSubscribe(
|
||||||
[{ '#a': [`31108:${rocket.Event.author.pubkey}:${rocket.Event.dTag}`], kinds: [9735] }],
|
[{ '#a': [`31108:${rocket.Event.author.pubkey}:${rocket.Event.dTag}`], kinds: [9735] }],
|
||||||
{
|
{
|
||||||
subId: rocket.Name() + "_zaps"
|
subId: rocket.Name() + '_zaps'
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -24,22 +24,14 @@
|
|||||||
zaps?.unsubscribe();
|
zaps?.unsubscribe();
|
||||||
});
|
});
|
||||||
|
|
||||||
// let productEvent: NDKEvent | undefined;
|
|
||||||
|
|
||||||
// onMount(() => {
|
|
||||||
// $ndk.fetchEvent(product.ID).then((e) => {
|
|
||||||
// if (e) {
|
|
||||||
// productEvent = e;
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
|
|
||||||
function productsInclude(id: string) {
|
function productsInclude(id: string) {
|
||||||
let included = false
|
let included = false;
|
||||||
for (let p of products) {
|
for (let p of products) {
|
||||||
if (p.ID() == id) {included = true}
|
if (p.ID() == id) {
|
||||||
|
included = true;
|
||||||
}
|
}
|
||||||
return included
|
}
|
||||||
|
return included;
|
||||||
}
|
}
|
||||||
|
|
||||||
let validZaps = derived(zaps, ($zaps) => {
|
let validZaps = derived(zaps, ($zaps) => {
|
||||||
@@ -63,22 +55,24 @@
|
|||||||
return zapMap;
|
return zapMap;
|
||||||
});
|
});
|
||||||
|
|
||||||
let validPubkeys = writable(new Set<string>())
|
let validPubkeys = writable(new Set<string>());
|
||||||
|
|
||||||
zapsNotInRocket.subscribe((z) => {
|
zapsNotInRocket.subscribe((z) => {
|
||||||
z.forEach((z) => {
|
z.forEach((z) => {
|
||||||
ValidateZapPublisher(rocket.Event, z.ZapReceipt).then((result) => {
|
ValidateZapPublisher(rocket.Event, z.ZapReceipt).then((result) => {
|
||||||
if (result) {
|
if (result) {
|
||||||
validPubkeys.update(existing=>{
|
validPubkeys.update((existing) => {
|
||||||
existing.add(z.ZapReceipt.pubkey);
|
existing.add(z.ZapReceipt.pubkey);
|
||||||
return existing
|
return existing;
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
let validatedZapsNotInRocket = derived([zapsNotInRocket, validPubkeys], ([$zapsNotInRocket, $validPubkeys]) => {
|
let validatedZapsNotInRocket = derived(
|
||||||
|
[zapsNotInRocket, validPubkeys],
|
||||||
|
([$zapsNotInRocket, $validPubkeys]) => {
|
||||||
let zapMap = new Map<string, ZapPurchase>();
|
let zapMap = new Map<string, ZapPurchase>();
|
||||||
for (let [id, zap] of $zapsNotInRocket) {
|
for (let [id, zap] of $zapsNotInRocket) {
|
||||||
if ($validPubkeys.has(zap.ZapReceipt.pubkey)) {
|
if ($validPubkeys.has(zap.ZapReceipt.pubkey)) {
|
||||||
@@ -86,14 +80,15 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return zapMap;
|
return zapMap;
|
||||||
});
|
|
||||||
|
|
||||||
validatedZapsNotInRocket.subscribe(zaps=>{
|
|
||||||
for (let [_, z] of zaps) {
|
|
||||||
unratifiedZaps.set(z.ZapReceipt.id, z.Amount)
|
|
||||||
}
|
}
|
||||||
unratifiedZaps = unratifiedZaps
|
);
|
||||||
})
|
|
||||||
|
validatedZapsNotInRocket.subscribe((zaps) => {
|
||||||
|
for (let [_, z] of zaps) {
|
||||||
|
unratifiedZaps.set(z.ZapReceipt.id, z.Amount);
|
||||||
|
}
|
||||||
|
unratifiedZaps = unratifiedZaps;
|
||||||
|
});
|
||||||
|
|
||||||
//todo: get existing purchases from rocket and render them
|
//todo: get existing purchases from rocket and render them
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,21 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { ndk } from '@/ndk';
|
import { ndk } from '@/ndk';
|
||||||
import type { NDKEvent } from '@nostr-dev-kit/ndk';
|
|
||||||
import { onDestroy } from 'svelte';
|
import { onDestroy } from 'svelte';
|
||||||
import ProductCard from './ProductCard.svelte';
|
|
||||||
import { derived } from 'svelte/store';
|
import { derived } from 'svelte/store';
|
||||||
|
import ProductCard from './ProductCard.svelte';
|
||||||
|
import { Product, type Rocket } from '@/event_helpers/rockets';
|
||||||
|
import * as Card from '@/components/ui/card';
|
||||||
|
|
||||||
export let rocket: NDKEvent;
|
export let rocket: Rocket;
|
||||||
|
|
||||||
let proposals = $ndk.storeSubscribe(
|
let proposals = $ndk.storeSubscribe(
|
||||||
[{ '#a': [`31108:${rocket.author.pubkey}:${rocket.dTag}`], kinds: [1908 as number] }],
|
[
|
||||||
{ subId: rocket.dTag }
|
{
|
||||||
|
'#a': [`31108:${rocket.Event.author.pubkey}:${rocket.Event.dTag}`],
|
||||||
|
kinds: [1908 as number]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
{ subId: rocket.Name() }
|
||||||
);
|
);
|
||||||
|
|
||||||
onDestroy(() => {
|
onDestroy(() => {
|
||||||
@@ -17,16 +23,23 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
let unratified = derived(proposals, ($proposals) => {
|
let unratified = derived(proposals, ($proposals) => {
|
||||||
return $proposals.filter((p) => {
|
$proposals = $proposals.filter((p) => {
|
||||||
let found = false;
|
return Boolean(!rocket.Products().get(p.id));
|
||||||
for (let product of rocket.getMatchingTags('product')) {
|
|
||||||
if (product[1].split(':')[0] == p.id) {
|
|
||||||
found = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return !found;
|
|
||||||
});
|
});
|
||||||
|
let products = new Map<string, Product>();
|
||||||
|
for (let p of $proposals) {
|
||||||
|
products.set(p.id, new Product(p));
|
||||||
|
}
|
||||||
|
return products;
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#each $unratified as r (r.id)}<ProductCard {rocket} product={r} />{/each}
|
{#if $unratified.size > 0}
|
||||||
|
<Card.Root>
|
||||||
|
<Card.Header>PROPOSED PRODUCTS</Card.Header>
|
||||||
|
<Card.Content>
|
||||||
|
TODO: make this look better
|
||||||
|
{#each $unratified as [_, product] (product.ID())}<ProductCard {rocket} {product} />{/each}
|
||||||
|
</Card.Content>
|
||||||
|
</Card.Root>
|
||||||
|
{/if}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
<ProductFomo bind:unratifiedZaps rocket={new Rocket(rocket)} />
|
<ProductFomo bind:unratifiedZaps rocket={new Rocket(rocket)} />
|
||||||
|
|
||||||
<ProposedProducts {rocket} />
|
<ProposedProducts rocket={new Rocket(rocket)} />
|
||||||
|
|
||||||
<MeritRequests rocket={new Rocket(rocket)} />
|
<MeritRequests rocket={new Rocket(rocket)} />
|
||||||
<BitcoinAssociations rocket={new Rocket(rocket)} />
|
<BitcoinAssociations rocket={new Rocket(rocket)} />
|
||||||
|
|||||||
Reference in New Issue
Block a user