problem: we are not publishing merit transfers

This commit is contained in:
gsovereignty
2024-08-12 13:50:27 +08:00
parent 47be660c52
commit 1cb0a9b4bd
3 changed files with 88 additions and 9 deletions

View File

@@ -65,8 +65,8 @@ their Merits.
</div>
{#if $associatedAddresses.size == 0}You do not have any registered addresses{:else}
Your registered addresses:
<ul class="m-2 flex">
{#each $associatedAddresses as address}<li>{address}</li>{/each}
<ul class="m-2 flex flex-col">
{#each $associatedAddresses as address}<li class="list-item list-disc">{address}</li>{/each}
</ul>
{/if}
Add a new address now

View 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>