Skip to content

Commit

Permalink
Merge branch 'master' into feat-syntax-highlight
Browse files Browse the repository at this point in the history
  • Loading branch information
aegroto committed Nov 19, 2024
2 parents c71deb1 + c2dc0be commit dcb3755
Show file tree
Hide file tree
Showing 106 changed files with 1,342 additions and 640 deletions.
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ _Was anything unclear during your work on this PR? Anything we should definitely
**On a scale of 1-10 how well and how have you QA'd this change and any features it might affect? Please answer below:**


**For frontend changes: Tested on mobile? Please answer below:**
**For frontend changes: Tested on mobile, light and dark mode? Please answer below:**


**Did you introduce any new environment variables? If so, call them out explicitly here:**
11 changes: 9 additions & 2 deletions api/paidAction/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ stateDiagram-v2
| donations | x | | x | x | x | | |
| update posts | x | | x | | x | | x |
| update comments | x | | x | | x | | x |
| receive | | x | | x | x | x | x |

## Not-custodial zaps (ie p2p wrapped payments)
Zaps, and possibly other future actions, can be performed peer to peer and non-custodially. This means that the payment is made directly from the client to the recipient, without the server taking custody of the funds. Currently, in order to trigger this behavior, the recipient must have a receiving wallet attached and the sender must have insufficient funds in their custodial wallet to perform the requested zap.
Expand Down Expand Up @@ -139,8 +140,14 @@ Each paid action is implemented in its own file in the `paidAction` directory. E

### Boolean flags
- `anonable`: can be performed anonymously
- `supportsPessimism`: supports a pessimistic payment flow
- `supportsOptimism`: supports an optimistic payment flow

### Payment methods
- `paymentMethods`: an array of payment methods that the action supports ordered from most preferred to least preferred
- P2P: a p2p payment made directly from the client to the recipient
- after wrapping the invoice, anonymous users will follow a PESSIMISTIC flow to pay the invoice and logged in users will follow an OPTIMISTIC flow
- FEE_CREDIT: a payment made from the user's fee credit balance
- OPTIMISTIC: an optimistic payment flow
- PESSIMISTIC: a pessimistic payment flow

### Functions

Expand Down
8 changes: 6 additions & 2 deletions api/paidAction/boost.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { PAID_ACTION_PAYMENT_METHODS } from '@/lib/constants'
import { msatsToSats, satsToMsats } from '@/lib/format'

export const anonable = false
export const supportsPessimism = false
export const supportsOptimism = true

export const paymentMethods = [
PAID_ACTION_PAYMENT_METHODS.FEE_CREDIT,
PAID_ACTION_PAYMENT_METHODS.OPTIMISTIC
]

export async function getCost ({ sats }) {
return satsToMsats(sats)
Expand Down
26 changes: 0 additions & 26 deletions api/paidAction/buyCredits.js

This file was deleted.

9 changes: 6 additions & 3 deletions api/paidAction/donate.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { USER_ID } from '@/lib/constants'
import { PAID_ACTION_PAYMENT_METHODS, USER_ID } from '@/lib/constants'
import { satsToMsats } from '@/lib/format'

export const anonable = true
export const supportsPessimism = true
export const supportsOptimism = false

export const paymentMethods = [
PAID_ACTION_PAYMENT_METHODS.FEE_CREDIT,
PAID_ACTION_PAYMENT_METHODS.PESSIMISTIC
]

export async function getCost ({ sats }) {
return satsToMsats(sats)
Expand Down
10 changes: 7 additions & 3 deletions api/paidAction/downZap.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { PAID_ACTION_PAYMENT_METHODS } from '@/lib/constants'
import { msatsToSats, satsToMsats } from '@/lib/format'

export const anonable = false
export const supportsPessimism = false
export const supportsOptimism = true

export const paymentMethods = [
PAID_ACTION_PAYMENT_METHODS.FEE_CREDIT,
PAID_ACTION_PAYMENT_METHODS.OPTIMISTIC
]

export async function getCost ({ sats }) {
return satsToMsats(sats)
Expand Down Expand Up @@ -74,6 +78,6 @@ export async function onFail ({ invoice }, { tx }) {
await tx.itemAct.updateMany({ where: { invoiceId: invoice.id }, data: { invoiceActionState: 'FAILED' } })
}

export async function describe ({ itemId, sats }, { cost, actionId }) {
export async function describe ({ id: itemId, sats }, { cost, actionId }) {
return `SN: downzap of ${sats ?? msatsToSats(cost)} sats to #${itemId ?? actionId}`
}
Loading

0 comments on commit dcb3755

Please sign in to comment.