Merge branch 'master' into edit-ux
This commit is contained in:
commit
11a5bb5367
@ -258,8 +258,10 @@ export async function createLightningInvoice (actionType, args, context) {
|
|||||||
expiry: INVOICE_EXPIRE_SECS
|
expiry: INVOICE_EXPIRE_SECS
|
||||||
}, { models })
|
}, { models })
|
||||||
|
|
||||||
|
// the sender (me) decides if the wrapped invoice has a description
|
||||||
|
// whereas the recipient decides if their invoice has a description
|
||||||
const { invoice: wrappedInvoice, maxFee } = await wrapInvoice(
|
const { invoice: wrappedInvoice, maxFee } = await wrapInvoice(
|
||||||
bolt11, { msats: cost, description }, { lnd })
|
bolt11, { msats: cost, description }, { me, lnd })
|
||||||
|
|
||||||
return {
|
return {
|
||||||
bolt11,
|
bolt11,
|
||||||
|
@ -17,6 +17,7 @@ import ItemPopover from './item-popover'
|
|||||||
import classNames from 'classnames'
|
import classNames from 'classnames'
|
||||||
import { CarouselProvider, useCarousel } from './carousel'
|
import { CarouselProvider, useCarousel } from './carousel'
|
||||||
import rehypeSN from '@/lib/rehype-sn'
|
import rehypeSN from '@/lib/rehype-sn'
|
||||||
|
import remarkUnicode from '@/lib/remark-unicode'
|
||||||
import Embed from './embed'
|
import Embed from './embed'
|
||||||
import remarkMath from 'remark-math'
|
import remarkMath from 'remark-math'
|
||||||
import rehypeMathjax from 'rehype-mathjax'
|
import rehypeMathjax from 'rehype-mathjax'
|
||||||
@ -33,7 +34,7 @@ const rehypeSNStyled = () => rehypeSN({
|
|||||||
}]
|
}]
|
||||||
})
|
})
|
||||||
|
|
||||||
const remarkPlugins = [gfm, [remarkMath, { singleDollarTextMath: false }]]
|
const remarkPlugins = [gfm, remarkUnicode, [remarkMath, { singleDollarTextMath: false }]]
|
||||||
const rehypePlugins = [rehypeSNStyled, rehypeMathjax]
|
const rehypePlugins = [rehypeSNStyled, rehypeMathjax]
|
||||||
|
|
||||||
export function SearchText ({ text }) {
|
export function SearchText ({ text }) {
|
||||||
|
@ -51,10 +51,18 @@ export default function WalletCard ({ wallet, draggable, onDragStart, onDragEnte
|
|||||||
<Card.Title>{title}</Card.Title>
|
<Card.Title>{title}</Card.Title>
|
||||||
<Card.Subtitle className='mt-2'>
|
<Card.Subtitle className='mt-2'>
|
||||||
{badges?.map(
|
{badges?.map(
|
||||||
badge =>
|
badge => {
|
||||||
<Badge className={styles.badge} key={badge} bg={null}>
|
let style = ''
|
||||||
|
switch (badge) {
|
||||||
|
case 'receive': style = styles.receive; break
|
||||||
|
case 'send': style = styles.send; break
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<Badge className={`${styles.badge} ${style}`} key={badge} bg={null}>
|
||||||
{badge}
|
{badge}
|
||||||
</Badge>)}
|
</Badge>
|
||||||
|
)
|
||||||
|
})}
|
||||||
</Card.Subtitle>
|
</Card.Subtitle>
|
||||||
</Card.Body>
|
</Card.Body>
|
||||||
<Link href={`/settings/wallets/${wallet.name}`}>
|
<Link href={`/settings/wallets/${wallet.name}`}>
|
||||||
|
31
lib/remark-unicode.js
Normal file
31
lib/remark-unicode.js
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
import { visit } from 'unist-util-visit'
|
||||||
|
|
||||||
|
export default function remarkFilterUnicode () {
|
||||||
|
return (tree) => {
|
||||||
|
try {
|
||||||
|
visit(tree, 'paragraph', (node) => {
|
||||||
|
node.children = node.children.map(child => {
|
||||||
|
if (child.type !== 'inlineMath') return child
|
||||||
|
|
||||||
|
// if inline math contains currency symbols, rehypeMathjax will throw
|
||||||
|
// see https://github.com/stackernews/stacker.news/issues/1525
|
||||||
|
// and https://github.com/stackernews/stacker.news/pull/1526
|
||||||
|
|
||||||
|
let { hChildren } = child.data
|
||||||
|
hChildren = hChildren.map(child2 => {
|
||||||
|
return { ...child2, value: filterUnicode(child2.value) }
|
||||||
|
})
|
||||||
|
child.data.hChildren = hChildren
|
||||||
|
|
||||||
|
return { ...child, value: filterUnicode(child.value) }
|
||||||
|
})
|
||||||
|
})
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function filterUnicode (text) {
|
||||||
|
return text.replace(/\p{Sc}/u, '')
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
-- fix revenue for users who have multiple revenue entries for the same day
|
||||||
|
WITH revenue_days AS (
|
||||||
|
SELECT coalesce(sum(msats), 0) as revenue_msats, "userId", created_at
|
||||||
|
FROM "SubAct"
|
||||||
|
WHERE type = 'REVENUE'
|
||||||
|
GROUP BY "userId", created_at
|
||||||
|
HAVING COUNT(*) > 1
|
||||||
|
),
|
||||||
|
revenue_total AS (
|
||||||
|
SELECT coalesce(sum(revenue_msats), 0) as revenue_msats, "userId"
|
||||||
|
FROM revenue_days
|
||||||
|
GROUP BY "userId"
|
||||||
|
)
|
||||||
|
UPDATE users SET msats = users.msats + revenue_total.revenue_msats
|
||||||
|
FROM revenue_total
|
||||||
|
WHERE users.id = revenue_total."userId";
|
||||||
|
|
||||||
|
-- fix stacked msats for users who have territory revenue
|
||||||
|
-- prior to this, we were not updating stacked msats for territory revenue
|
||||||
|
WITH territory_revenue AS (
|
||||||
|
SELECT coalesce(sum(msats), 0) as revenue_msats, "userId"
|
||||||
|
FROM "SubAct"
|
||||||
|
WHERE type = 'REVENUE'
|
||||||
|
GROUP BY "userId"
|
||||||
|
)
|
||||||
|
UPDATE users SET "stackedMsats" = users."stackedMsats" + territory_revenue.revenue_msats
|
||||||
|
FROM territory_revenue
|
||||||
|
WHERE users.id = territory_revenue."userId";
|
@ -40,6 +40,14 @@
|
|||||||
margin-right: 0.2rem;
|
margin-right: 0.2rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.receive {
|
||||||
|
color: #20c997 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.send {
|
||||||
|
color: var(--bs-primary) !important;
|
||||||
|
}
|
||||||
|
|
||||||
.attach {
|
.attach {
|
||||||
color: var(--bs-body-color) !important;
|
color: var(--bs-body-color) !important;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
@ -28,7 +28,7 @@ export const fields = [
|
|||||||
export const card = {
|
export const card = {
|
||||||
title: 'Blink',
|
title: 'Blink',
|
||||||
subtitle: 'use [Blink](https://blink.sv/) for payments',
|
subtitle: 'use [Blink](https://blink.sv/) for payments',
|
||||||
badges: ['send only']
|
badges: ['send']
|
||||||
}
|
}
|
||||||
|
|
||||||
export const fieldValidation = blinkSchema
|
export const fieldValidation = blinkSchema
|
||||||
|
@ -36,7 +36,7 @@ export const fields = [
|
|||||||
export const card = {
|
export const card = {
|
||||||
title: 'CLN',
|
title: 'CLN',
|
||||||
subtitle: 'autowithdraw to your Core Lightning node via [CLNRest](https://docs.corelightning.org/docs/rest)',
|
subtitle: 'autowithdraw to your Core Lightning node via [CLNRest](https://docs.corelightning.org/docs/rest)',
|
||||||
badges: ['receive only']
|
badges: ['receive']
|
||||||
}
|
}
|
||||||
|
|
||||||
export const fieldValidation = CLNAutowithdrawSchema
|
export const fieldValidation = CLNAutowithdrawSchema
|
||||||
|
@ -15,7 +15,7 @@ export const fields = [
|
|||||||
export const card = {
|
export const card = {
|
||||||
title: 'lightning address',
|
title: 'lightning address',
|
||||||
subtitle: 'autowithdraw to a lightning address',
|
subtitle: 'autowithdraw to a lightning address',
|
||||||
badges: ['receive only']
|
badges: ['receive']
|
||||||
}
|
}
|
||||||
|
|
||||||
export const fieldValidation = lnAddrAutowithdrawSchema
|
export const fieldValidation = lnAddrAutowithdrawSchema
|
||||||
|
@ -29,7 +29,7 @@ export const fields = [
|
|||||||
export const card = {
|
export const card = {
|
||||||
title: 'LNbits',
|
title: 'LNbits',
|
||||||
subtitle: 'use [LNbits](https://lnbits.com/) for payments',
|
subtitle: 'use [LNbits](https://lnbits.com/) for payments',
|
||||||
badges: ['send & receive']
|
badges: ['send', 'receive']
|
||||||
}
|
}
|
||||||
|
|
||||||
export const fieldValidation = lnbitsSchema
|
export const fieldValidation = lnbitsSchema
|
||||||
|
@ -33,7 +33,7 @@ export const fields = [
|
|||||||
export const card = {
|
export const card = {
|
||||||
title: 'LNC',
|
title: 'LNC',
|
||||||
subtitle: 'use Lightning Node Connect for LND payments',
|
subtitle: 'use Lightning Node Connect for LND payments',
|
||||||
badges: ['send only', 'budgetable']
|
badges: ['send', 'budgetable']
|
||||||
}
|
}
|
||||||
|
|
||||||
export const fieldValidation = lncSchema
|
export const fieldValidation = lncSchema
|
||||||
|
@ -37,7 +37,7 @@ export const fields = [
|
|||||||
export const card = {
|
export const card = {
|
||||||
title: 'LND',
|
title: 'LND',
|
||||||
subtitle: 'autowithdraw to your Lightning Labs node',
|
subtitle: 'autowithdraw to your Lightning Labs node',
|
||||||
badges: ['receive only']
|
badges: ['receive']
|
||||||
}
|
}
|
||||||
|
|
||||||
export const fieldValidation = LNDAutowithdrawSchema
|
export const fieldValidation = LNDAutowithdrawSchema
|
||||||
|
@ -27,7 +27,7 @@ export const fields = [
|
|||||||
export const card = {
|
export const card = {
|
||||||
title: 'NWC',
|
title: 'NWC',
|
||||||
subtitle: 'use Nostr Wallet Connect for payments',
|
subtitle: 'use Nostr Wallet Connect for payments',
|
||||||
badges: ['send & receive', 'budgetable']
|
badges: ['send', 'receive', 'budgetable']
|
||||||
}
|
}
|
||||||
|
|
||||||
export const fieldValidation = nwcSchema
|
export const fieldValidation = nwcSchema
|
||||||
|
@ -33,7 +33,7 @@ export const fields = [
|
|||||||
export const card = {
|
export const card = {
|
||||||
title: 'phoenixd',
|
title: 'phoenixd',
|
||||||
subtitle: 'use [phoenixd](https://phoenix.acinq.co/server) for payments',
|
subtitle: 'use [phoenixd](https://phoenix.acinq.co/server) for payments',
|
||||||
badges: ['send & receive']
|
badges: ['send', 'receive']
|
||||||
}
|
}
|
||||||
|
|
||||||
// phoenixd::TODO
|
// phoenixd::TODO
|
||||||
|
@ -20,7 +20,7 @@ export const fieldValidation = ({ enabled }) => {
|
|||||||
export const card = {
|
export const card = {
|
||||||
title: 'WebLN',
|
title: 'WebLN',
|
||||||
subtitle: 'use a [WebLN provider](https://www.webln.guide/ressources/webln-providers) for payments',
|
subtitle: 'use a [WebLN provider](https://www.webln.guide/ressources/webln-providers) for payments',
|
||||||
badges: ['send only']
|
badges: ['send']
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function WebLnProvider ({ children }) {
|
export default function WebLnProvider ({ children }) {
|
||||||
|
@ -22,7 +22,7 @@ const ZAP_SYBIL_FEE_MULT = 10 / 7 // the fee for the zap sybil service
|
|||||||
maxFee: number
|
maxFee: number
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
export default async function wrapInvoice (bolt11, { msats, description, descriptionHash }, { lnd }) {
|
export default async function wrapInvoice (bolt11, { msats, description, descriptionHash }, { me, lnd }) {
|
||||||
try {
|
try {
|
||||||
console.group('wrapInvoice', description)
|
console.group('wrapInvoice', description)
|
||||||
|
|
||||||
@ -112,6 +112,11 @@ export default async function wrapInvoice (bolt11, { msats, description, descrip
|
|||||||
wrapped.description = inv.description
|
wrapped.description = inv.description
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (me?.hideInvoiceDesc) {
|
||||||
|
wrapped.description = undefined
|
||||||
|
wrapped.description_hash = undefined
|
||||||
|
}
|
||||||
|
|
||||||
// validate the expiration
|
// validate the expiration
|
||||||
if (new Date(inv.expires_at) < new Date(Date.now() + INCOMING_EXPIRATION_BUFFER_MSECS)) {
|
if (new Date(inv.expires_at) < new Date(Date.now() + INCOMING_EXPIRATION_BUFFER_MSECS)) {
|
||||||
throw new Error('Invoice expiration is too soon')
|
throw new Error('Invoice expiration is too soon')
|
||||||
|
@ -72,10 +72,17 @@ export async function territoryRevenue ({ models }) {
|
|||||||
FROM revenue
|
FROM revenue
|
||||||
WHERE revenue > 1000
|
WHERE revenue > 1000
|
||||||
RETURNING *
|
RETURNING *
|
||||||
)
|
),
|
||||||
UPDATE users SET msats = users.msats + "SubActResult".msats
|
"SubActResultTotal" AS (
|
||||||
|
SELECT coalesce(sum(msats), 0) as total_msats, "userId"
|
||||||
FROM "SubActResult"
|
FROM "SubActResult"
|
||||||
WHERE users.id = "SubActResult"."userId"`,
|
GROUP BY "userId"
|
||||||
|
)
|
||||||
|
UPDATE users
|
||||||
|
SET msats = users.msats + "SubActResultTotal".total_msats,
|
||||||
|
"stackedMsats" = users."stackedMsats" + "SubActResultTotal".total_msats
|
||||||
|
FROM "SubActResultTotal"
|
||||||
|
WHERE users.id = "SubActResultTotal"."userId"`,
|
||||||
{ models }
|
{ models }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user