-
-
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
Showing
8 changed files
with
283 additions
and
71 deletions.
There are no files selected for viewing
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,35 @@ | ||
// XXX we don't use this yet ... | ||
// it's just showing that even buying credits | ||
// can eventually be a paid action | ||
|
||
import { ANON_USER_ID } from '@/lib/constants' | ||
|
||
export const anonable = true | ||
export const supportsPessimism = true | ||
export const supportsOptimism = true | ||
|
||
export async function getCost ({ amount }) { | ||
return BigInt(amount) * BigInt(1000) | ||
} | ||
|
||
export async function doStatements () { | ||
return [] | ||
} | ||
|
||
export async function onPaidStatements ({ invoice }, { models }) { | ||
return [ | ||
models.users.update({ | ||
where: { id: invoice.userId }, | ||
data: { balance: { increment: invoice.msatsReceived } } | ||
}) | ||
] | ||
} | ||
|
||
export async function resultsToResponse (results, args, context) { | ||
return null | ||
} | ||
|
||
export async function describe ({ amount }, { models, me }) { | ||
const user = await models.user.findUnique({ where: { id: me?.id ?? ANON_USER_ID } }) | ||
return `SN: buying credits for @${user.name}` | ||
} |
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
Oops, something went wrong.