Skip to content

Commit 09c01e5

Browse files
authored
Merge branch 'master' into live_comments
2 parents 450f7bc + d89a4a4 commit 09c01e5

File tree

230 files changed

+8947
-5728
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

230 files changed

+8947
-5728
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ docker-compose.*.yml
5353
*.sql
5454
!/prisma/migrations/*/*.sql
5555
!/docker/db/seed.sql
56+
!/docker/db/wallet-seed.sql
5657

5758
# nostr wallet connect
5859
scripts/nwc-keys.json

api/paidAction/index.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ async function performP2PAction (actionType, args, incomingContext) {
227227
await assertBelowMaxPendingInvoices(incomingContext)
228228

229229
const description = await paidActions[actionType].describe(args, incomingContext)
230-
const { invoice, wrappedInvoice, wallet, maxFee } = await createWrappedInvoice(userId, {
230+
const { invoice, wrappedInvoice, protocol, maxFee } = await createWrappedInvoice(userId, {
231231
msats: cost,
232232
feePercent: sybilFeePercent,
233233
description,
@@ -239,7 +239,7 @@ async function performP2PAction (actionType, args, incomingContext) {
239239
invoiceArgs: {
240240
bolt11: invoice,
241241
wrappedBolt11: wrappedInvoice,
242-
wallet,
242+
protocol,
243243
maxFee
244244
}
245245
}
@@ -269,7 +269,7 @@ async function performDirectAction (actionType, args, incomingContext) {
269269

270270
const description = actionDescription ?? await paidActions[actionType].describe(args, incomingContext)
271271

272-
for await (const { invoice, logger, wallet } of createUserInvoice(userId, {
272+
for await (const { invoice, logger, protocol } of createUserInvoice(userId, {
273273
msats: cost,
274274
description,
275275
expiry: INVOICE_EXPIRE_SECS
@@ -293,7 +293,7 @@ async function performDirectAction (actionType, args, incomingContext) {
293293
bolt11: invoice,
294294
msats: cost,
295295
hash,
296-
walletId: wallet.id,
296+
protocolId: protocol.id,
297297
receiverId: userId
298298
}
299299
}),
@@ -346,22 +346,26 @@ export async function retryPaidAction (actionType, args, incomingContext) {
346346
invoiceId: failedInvoice.id
347347
},
348348
include: {
349-
wallet: true
349+
protocol: {
350+
include: {
351+
wallet: true
352+
}
353+
}
350354
}
351355
})
352356

353357
if (invoiceForward) {
354358
// this is a wrapped invoice, we need to retry it with receiver fallbacks
355359
try {
356-
const { userId } = invoiceForward.wallet
360+
const { userId } = invoiceForward.protocol.wallet
357361
// this will return an invoice from the first receiver wallet that didn't fail yet and throw if none is available
358-
const { invoice: bolt11, wrappedInvoice: wrappedBolt11, wallet, maxFee } = await createWrappedInvoice(userId, {
362+
const { invoice: bolt11, wrappedInvoice: wrappedBolt11, protocol, maxFee } = await createWrappedInvoice(userId, {
359363
msats: failedInvoice.msatsRequested,
360364
feePercent: await action.getSybilFeePercent?.(actionArgs, retryContext),
361365
description: await action.describe?.(actionArgs, retryContext),
362366
expiry: INVOICE_EXPIRE_SECS
363367
}, retryContext)
364-
invoiceArgs = { bolt11, wrappedBolt11, wallet, maxFee }
368+
invoiceArgs = { bolt11, wrappedBolt11, protocol, maxFee }
365369
} catch (err) {
366370
console.log('failed to retry wrapped invoice, falling back to SN:', err)
367371
}
@@ -429,7 +433,7 @@ async function createSNInvoice (actionType, args, context) {
429433

430434
async function createDbInvoice (actionType, args, context) {
431435
const { me, models, tx, cost, optimistic, actionId, invoiceArgs, paymentAttempt, predecessorId } = context
432-
const { bolt11, wrappedBolt11, preimage, wallet, maxFee } = invoiceArgs
436+
const { bolt11, wrappedBolt11, preimage, protocol, maxFee } = invoiceArgs
433437

434438
const db = tx ?? models
435439

@@ -468,9 +472,9 @@ async function createDbInvoice (actionType, args, context) {
468472
invoice: {
469473
create: invoiceData
470474
},
471-
wallet: {
475+
protocol: {
472476
connect: {
473-
id: wallet.id
477+
id: protocol.id
474478
}
475479
}
476480
}

api/paidAction/zap.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ export async function getInvoiceablePeer ({ id, sats, hasSendWallet }, { models,
3939
return null
4040
}
4141

42-
const wallets = await getInvoiceableWallets(item.userId, { models })
42+
const protocols = await getInvoiceableWallets(item.userId, { models })
4343

4444
// request peer invoice if they have an attached wallet and have not forwarded the item
4545
// and the receiver doesn't want to receive credits
46-
if (wallets.length > 0 &&
46+
if (protocols.length > 0 &&
4747
item.itemForwards.length === 0 &&
4848
sats >= item.user.receiveCreditsBelowSats) {
4949
return item.userId

api/payingAction/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import { parsePaymentRequest, payViaPaymentRequest } from 'ln-service'
66
// paying actions are completely distinct from paid actions
77
// and there's only one paying action: send
88
// ... still we want the api to at least be similar
9-
export default async function performPayingAction ({ bolt11, maxFee, walletId }, { me, models, lnd }) {
9+
export default async function performPayingAction ({ bolt11, maxFee, protocolId }, { me, models, lnd }) {
1010
try {
11-
console.group('performPayingAction', `${bolt11.slice(0, 10)}...`, maxFee, walletId)
11+
console.group('performPayingAction', `${bolt11.slice(0, 10)}...`, maxFee, protocolId)
1212

1313
if (!me) {
1414
throw new Error('You must be logged in to perform this action')
@@ -34,8 +34,8 @@ export default async function performPayingAction ({ bolt11, maxFee, walletId },
3434
msatsPaying: toPositiveBigInt(decoded.mtokens),
3535
msatsFeePaying: satsToMsats(maxFee),
3636
userId: me.id,
37-
walletId,
38-
autoWithdraw: !!walletId
37+
protocolId,
38+
autoWithdraw: !!protocolId
3939
}
4040
})
4141
}, { isolationLevel: Prisma.TransactionIsolationLevel.ReadCommitted })

api/resolvers/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import user from './user'
22
import message from './message'
33
import item from './item'
4-
import wallet from './wallet'
4+
import walletV1 from './wallet'
5+
import walletV2 from '@/wallets/server/resolvers'
56
import lnurl from './lnurl'
67
import notifications from './notifications'
78
import invite from './invite'
@@ -19,7 +20,6 @@ import chainFee from './chainFee'
1920
import { GraphQLScalarType, Kind } from 'graphql'
2021
import { createIntScalar } from 'graphql-scalar'
2122
import paidAction from './paidAction'
22-
import vault from './vault'
2323

2424
const date = new GraphQLScalarType({
2525
name: 'Date',
@@ -54,6 +54,6 @@ const limit = createIntScalar({
5454
maximum: 1000
5555
})
5656

57-
export default [user, item, message, wallet, lnurl, notifications, invite, sub,
57+
export default [user, item, message, walletV1, walletV2, lnurl, notifications, invite, sub,
5858
upload, search, growth, rewards, referrals, price, admin, blockHeight, chainFee,
59-
{ JSONObject }, { Date: date }, { Limit: limit }, paidAction, vault]
59+
{ JSONObject }, { Date: date }, { Limit: limit }, paidAction]

api/resolvers/notifications.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { decodeCursor, LIMIT, nextNoteCursorEncoded } from '@/lib/cursor'
22
import { getItem, filterClause, whereClause, muteClause, activeOrMine } from './item'
33
import { getInvoice, getWithdrawl } from './wallet'
44
import { pushSubscriptionSchema, validateSchema } from '@/lib/validate'
5-
import { replyToSubscription } from '@/lib/webPush'
5+
import { sendPushSubscriptionReply } from '@/lib/webPush'
66
import { getSub } from './sub'
77
import { GqlAuthenticationError, GqlInputError } from '@/lib/error'
88
import { WALLET_MAX_RETRIES, WALLET_RETRY_BEFORE_MS } from '@/lib/constants'
@@ -439,7 +439,7 @@ export default {
439439
console.log(`[webPush] created subscription for user ${me.id}: endpoint=${endpoint}`)
440440
}
441441

442-
await replyToSubscription(dbPushSubscription.id, { title: 'Stacker News notifications are now active' })
442+
await sendPushSubscriptionReply(dbPushSubscription)
443443

444444
return dbPushSubscription
445445
},

api/resolvers/vault.js

Lines changed: 0 additions & 53 deletions
This file was deleted.

0 commit comments

Comments
 (0)