-
Notifications
You must be signed in to change notification settings - Fork 4
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
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this 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. :)
src/lib/pusher.ts
Outdated
let eventId = previousPayer.eventId | ||
if (previousPayer.jackpot === 0 || timeLeft < 0) { | ||
// Multiple posts possible if two people start round at same time? | ||
// await publishEvent(event) |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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}> { |
There was a problem hiding this comment.
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(() => { |
There was a problem hiding this comment.
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(() => { |
There was a problem hiding this comment.
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?
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