-
-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1856520
commit e647d2e
Showing
19 changed files
with
936 additions
and
390 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { satsToMsats } from '@/lib/format' | ||
import { notifyDeposit } from '@/lib/webPush' | ||
export const anonable = true | ||
export const supportsPessimism = true | ||
export const supportsOptimism = false | ||
|
||
export async function getCost ({ sats }) { | ||
return satsToMsats(sats) | ||
} | ||
|
||
export async function invoiceablePeer ({ targetUserId }, { models }) { | ||
return targetUserId | ||
} | ||
|
||
export async function perform ({ invoiceId, sats, description, descriptionHash, comment, targetUserId }, { me, tx }) { | ||
const invoice = await tx.invoice.update({ | ||
where: { id: invoiceId }, | ||
data: { | ||
comment | ||
} | ||
}) | ||
await notifyDeposit(targetUserId, invoice) | ||
return { sats, targetUserId } | ||
} | ||
|
||
export async function describe ({ sats, description, descriptionHash }, context) { | ||
return `SN: ${description ?? ''}` | ||
} | ||
|
||
export async function describeHash ({ sats, description, descriptionHash }, context) { | ||
return descriptionHash | ||
} | ||
|
||
export async function getSybilFeePercent ({ sats, description, descriptionHash }, context) { | ||
return 10n | ||
} | ||
|
||
export async function onPaid ({ invoice }, { tx }) { | ||
const isP2P = !!invoice.invoiceForward | ||
if (isP2P) return | ||
if (!invoice?.msatsReceived) throw new Error('Not paid?') | ||
const targetUserId = invoice.actionArgs?.targetUserId | ||
if (!targetUserId) throw new Error('No targetUserId') | ||
|
||
await tx.user.update({ | ||
where: { id: targetUserId }, | ||
data: { | ||
msats: { | ||
increment: invoice.msatsReceived | ||
} | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
prisma/migrations/20241029160827_transfer_paid_action/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-- AlterEnum | ||
ALTER TYPE "InvoiceActionType" ADD VALUE 'TRANSFER'; |
Oops, something went wrong.