mirror of
https://github.com/aljazceru/hypergolic.git
synced 2025-12-18 22:14:21 +01:00
problem: we are not publishing merit transfers
This commit is contained in:
@@ -65,8 +65,8 @@ their Merits.
|
|||||||
</div>
|
</div>
|
||||||
{#if $associatedAddresses.size == 0}You do not have any registered addresses{:else}
|
{#if $associatedAddresses.size == 0}You do not have any registered addresses{:else}
|
||||||
Your registered addresses:
|
Your registered addresses:
|
||||||
<ul class="m-2 flex">
|
<ul class="m-2 flex flex-col">
|
||||||
{#each $associatedAddresses as address}<li>{address}</li>{/each}
|
{#each $associatedAddresses as address}<li class="list-item list-disc">{address}</li>{/each}
|
||||||
</ul>
|
</ul>
|
||||||
{/if}
|
{/if}
|
||||||
Add a new address now
|
Add a new address now
|
||||||
|
|||||||
71
src/components/BuyAMR.svelte
Normal file
71
src/components/BuyAMR.svelte
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { Button, buttonVariants } from '$lib/components/ui/button/index.js';
|
||||||
|
import * as Dialog from '$lib/components/ui/dialog/index.js';
|
||||||
|
import * as Alert from '@/components/ui/alert';
|
||||||
|
import type { AMRAuction } from '@/event_helpers/rockets';
|
||||||
|
import { ndk } from '@/ndk';
|
||||||
|
import { currentUser } from '@/stores/session';
|
||||||
|
import { NDKEvent } from '@nostr-dev-kit/ndk';
|
||||||
|
import type NDKSvelte from '@nostr-dev-kit/ndk-svelte';
|
||||||
|
import { Name } from '@nostr-dev-kit/ndk-svelte-components';
|
||||||
|
import { Terminal } from 'lucide-svelte';
|
||||||
|
|
||||||
|
export let auction: AMRAuction;
|
||||||
|
let o = false;
|
||||||
|
|
||||||
|
function publish(ndk: NDKSvelte) {
|
||||||
|
if (!ndk.signer) {
|
||||||
|
throw new Error('no ndk signer found');
|
||||||
|
}
|
||||||
|
let e = new NDKEvent(ndk);
|
||||||
|
let author = $currentUser;
|
||||||
|
if (!author) {
|
||||||
|
throw new Error('no current user');
|
||||||
|
}
|
||||||
|
e.author = author;
|
||||||
|
e.kind = 1216;
|
||||||
|
e.created_at = Math.floor(new Date().getTime() / 1000);
|
||||||
|
//todo validate d tag
|
||||||
|
|
||||||
|
// e.publish().then((x) => {
|
||||||
|
// console.log(x);
|
||||||
|
// o = false;
|
||||||
|
// goto(`${base}/rockets/${getRocketURL(rocketEvent)}`);
|
||||||
|
// });
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<Dialog.Root bind:open={o}>
|
||||||
|
<Dialog.Trigger class={buttonVariants({ variant: 'default' })}>Buy Now</Dialog.Trigger>
|
||||||
|
<Dialog.Content class="sm:max-w-[425px]">
|
||||||
|
{#if !currentUser}
|
||||||
|
<Alert.Root>
|
||||||
|
<Terminal class="h-4 w-4" />
|
||||||
|
<Alert.Title>Heads up!</Alert.Title>
|
||||||
|
<Alert.Description>You need a nostr signing extension to use Nostrocket!</Alert.Description>
|
||||||
|
</Alert.Root>
|
||||||
|
{:else}
|
||||||
|
<Dialog.Header>
|
||||||
|
<Dialog.Title>Buy Merits from <Name pubkey={auction.Owner} /></Dialog.Title>
|
||||||
|
</Dialog.Header>
|
||||||
|
<p>
|
||||||
|
To buy these merits you MUST send {auction.Merits / 100000000} BTC from one of your registered
|
||||||
|
addresses to {auction.RxAddress}.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Once the transaction has 2 confirmations the Merits will automatically be transferred to
|
||||||
|
your npub.
|
||||||
|
</p>
|
||||||
|
<Dialog.Footer>
|
||||||
|
Todo: ask user to publish an event before making transaction so that multiple people don't
|
||||||
|
pay for the same Merits.
|
||||||
|
<!-- <Button
|
||||||
|
on:click={() => {
|
||||||
|
publish($ndk);
|
||||||
|
}}
|
||||||
|
type="submit">Publish</Button
|
||||||
|
> -->
|
||||||
|
</Dialog.Footer>
|
||||||
|
{/if}
|
||||||
|
</Dialog.Content>
|
||||||
|
</Dialog.Root>
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Button from '@/components/ui/button/button.svelte';
|
|
||||||
import * as Table from '@/components/ui/table';
|
import * as Table from '@/components/ui/table';
|
||||||
import { AMRAuction, MeritPurchase, Rocket } from '@/event_helpers/rockets';
|
import { AMRAuction, MeritPurchase, Rocket } from '@/event_helpers/rockets';
|
||||||
import { ndk } from '@/ndk';
|
import { ndk } from '@/ndk';
|
||||||
@@ -7,12 +6,15 @@
|
|||||||
import { currentUser } from '@/stores/session';
|
import { currentUser } from '@/stores/session';
|
||||||
import { NDKEvent } from '@nostr-dev-kit/ndk';
|
import { NDKEvent } from '@nostr-dev-kit/ndk';
|
||||||
import { Avatar } from '@nostr-dev-kit/ndk-svelte-components';
|
import { Avatar } from '@nostr-dev-kit/ndk-svelte-components';
|
||||||
import { onDestroy, onMount } from 'svelte';
|
import { onDestroy } from 'svelte';
|
||||||
import { derived } from 'svelte/store';
|
import { derived } from 'svelte/store';
|
||||||
import AssociateBitcoinAddress from '../../components/AssociateBitcoinAddress.svelte';
|
import AssociateBitcoinAddress from '../../components/AssociateBitcoinAddress.svelte';
|
||||||
import Heading from '../../components/Heading.svelte';
|
import Heading from '../../components/Heading.svelte';
|
||||||
import Login from '../../components/Login.svelte';
|
import Login from '../../components/Login.svelte';
|
||||||
import MeritAuctions from '../../stateupdaters/MeritAuctions.svelte';
|
import MeritAuctions from '../../stateupdaters/MeritAuctions.svelte';
|
||||||
|
import BuyAmr from '../../components/BuyAMR.svelte';
|
||||||
|
import { goto } from '$app/navigation';
|
||||||
|
import { base } from '$app/paths';
|
||||||
let rocketEvents = $ndk.storeSubscribe([{ kinds: [31108 as number] }], { subId: 'all_rockets' });
|
let rocketEvents = $ndk.storeSubscribe([{ kinds: [31108 as number] }], { subId: 'all_rockets' });
|
||||||
onDestroy(() => {
|
onDestroy(() => {
|
||||||
rocketEvents?.unsubscribe();
|
rocketEvents?.unsubscribe();
|
||||||
@@ -104,8 +106,14 @@
|
|||||||
|
|
||||||
nextSoldButNotInState.subscribe((t) => {
|
nextSoldButNotInState.subscribe((t) => {
|
||||||
if (t) {
|
if (t) {
|
||||||
console.log(t.rocket.UpsertMeritTransfer(t)?.rawEvent());
|
//console.log(t.rocket.UpsertMeritTransfer(t)?.rawEvent());
|
||||||
//t.rocket.UpsertMeritTransfer(t)?.publish().then(x=>{console.log(goto(...))})
|
let e = t.rocket.UpsertMeritTransfer(t);
|
||||||
|
if (e) {
|
||||||
|
e.publish().then((x) => {
|
||||||
|
console.log(goto(`${base}/${new Rocket(e).URL()}`));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
//t.rocket.UpsertMeritTransfer(t)?.publish()
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -171,9 +179,9 @@
|
|||||||
}}>{p.RxAddress}</Table.Cell
|
}}>{p.RxAddress}</Table.Cell
|
||||||
>
|
>
|
||||||
<Table.Cell
|
<Table.Cell
|
||||||
>{#if p.Status(rocket, $bitcoinTip.height, $transactions.get(p.RxAddress)) == 'OPEN'}<Button
|
>{#if p.Status(rocket, $bitcoinTip.height, $transactions.get(p.RxAddress)) == 'OPEN'}<BuyAmr
|
||||||
>BUY NOW</Button
|
auction={p}
|
||||||
>{/if}</Table.Cell
|
/>{/if}</Table.Cell
|
||||||
>
|
>
|
||||||
</Table.Row>
|
</Table.Row>
|
||||||
{/each}
|
{/each}
|
||||||
|
|||||||
Reference in New Issue
Block a user