Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zaps #4

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open

Zaps #4

wants to merge 18 commits into from

Conversation

chdwlch
Copy link
Collaborator

@chdwlch chdwlch commented Jun 6, 2023

Initial zaps with a single damus relay ATM.
LNBits LNURLP nostr extension is new (0.3) and not currently available on Voltage so I've been using a SaaS LNBits instance. The extension also has problems writing to certain relays... I think it bugs out trying to write to authenticated relays or something.

Still need to test this with Inngest and find some additional relays that work with the extension.

For the most part everything works the same as before. The only difference is that now a new invoice is generated when a match starts and when a match ends

Screenshot 2023-06-06 at 7 24 14 AM

@vercel
Copy link

vercel bot commented Jun 6, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
last-pay-wins ❌ Failed (Inspect) Jun 20, 2023 2:21pm

Copy link
Owner

@alexlwn123 alexlwn123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CACK... Left comments for some minor changes.

This is really awesome. :)

let eventId = previousPayer.eventId
if (previousPayer.jackpot === 0 || timeLeft < 0) {
// Multiple posts possible if two people start round at same time?
// await publishEvent(event)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point... thinking nostr events should be triggered within inngest to avoid double posts. Innget has a feature to "deduplicate" events. I'm using it to prevent double payouts.(https://www.inngest.com/docs/events#deduplication)

Copy link
Collaborator Author

@chdwlch chdwlch Jun 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I played around with this a little. I think it would work with an event like this:

  await inngest.send({
    id: `post-${someHash(previousPayer)}`,
    name: 'newRoundPost',
    data: event,
  })

It would also work if we added a round counter into the pusher cache data as well, but that might expire and reset back to 0.

It doesn't double post, but it can lose zaps if two people start the round at the same time.
Biggest issue is when you pay an invoice right when the round ends. Still trying to make it better

src/app/utils.ts Outdated
@@ -44,4 +53,121 @@ export const checkInvoiceStatus = (setChecking, hash, setHash, setSettled, toast
}
setChecking(false);
}).catch(_ => setChecking(false));
}

export async function getNewNostrPost(): Promise<{event: NostrEvent}> {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe separate these into a dedicated nostr-utils file:
(i.e. src/app/utils/nostr.ts, src/app/utils/invoices.ts)

src/app/page.tsx Outdated
@@ -72,24 +83,41 @@ export default function Home() {

// Get invoice
useEffect(() => {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer using an async/await over promise chains (.then)

...Nit pick :)

src/app/page.tsx Outdated
@@ -72,24 +83,41 @@ export default function Home() {

// Get invoice
useEffect(() => {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe move this into useZaps?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants