Skip to content

Commit

Permalink
Merge branch 'master' into fallbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
riccardobl authored Oct 26, 2024
2 parents ec3662c + 1856520 commit 71f197d
Show file tree
Hide file tree
Showing 30 changed files with 242 additions and 146 deletions.
35 changes: 0 additions & 35 deletions .github/ISSUE_TEMPLATE/bug_report.md

This file was deleted.

65 changes: 65 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: 🐞 Bug report
description: Create a bug report to help us fix it
title: "bug report"
labels: [bug]
body:
- type: checkboxes
attributes:
label: Is there an existing issue for this?
description: Please search to see if an issue already exists for the bug you encountered.
options:
- label: I have searched the existing issues
required: true
- type: textarea
attributes:
label: Describe the bug
description: A clear and concise description of what the bug is. Include images if relevant.
placeholder: I accidentally deleted the internet. Here's my story ...
validations:
required: true
- type: textarea
attributes:
label: Screenshots
description: |
Add screenshots to help explain your problem. You can also add a video here.
Tip: You can attach images or video files by clicking this area to highlight it and then dragging files in.
validations:
required: false
- type: textarea
attributes:
label: Steps To Reproduce
description: Steps to reproduce the bug.
placeholder: |
1. Go to '...'
2. Click on '...'
3. Scroll to '...'
4. See error
validations:
required: true
- type: textarea
attributes:
label: Expected behavior
description: A clear and concise description of what you expected to happen
validations:
required: true
- type: textarea
attributes:
label: Logs
description: If applicable, add your browser's console logs here
- type: textarea
attributes:
label: Device information
placeholder: |
- OS: [e.g. Windows]
- Browser: [e.g. chrome, safari, firefox]
- Browser Version: [e.g. 22]
validations:
required: false
- type: textarea
attributes:
label: Additional context
description: |
Do you have links to discussions about this on SN or other references?
validations:
required: false
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
blank_issues_enabled: true
contact_links:
- name: Questions
url: https://stacker.news/~meta
about: If you simply have a question, you can ask it in ~meta or the saloon.
20 changes: 0 additions & 20 deletions .github/ISSUE_TEMPLATE/feature_request.md

This file was deleted.

32 changes: 32 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: ✨ Feature request
description: Request a feature you'd like to see in SN!
title: "feature request"
labels: [feature]
body:
- type: markdown
attributes:
value: |
We're always looking for suggestions on how we could improve SN!
- type: textarea
attributes:
label: Describe the problem you're trying to solve
description: |
Is your feature request related to a problem? Add a clear and concise description of what the problem is.
validations:
required: true
- type: textarea
attributes:
label: Describe the solution you'd like
description: A clear and concise description of what you want to happen.
validations:
required: true
- type: textarea
attributes:
label: Describe alternatives you've considered
description: |
A clear and concise description of any alternative solutions or features you have considered.
- type: textarea
attributes:
label: Additional context
description: |
Add any other additional context or screenshots about the feature request here.
27 changes: 2 additions & 25 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,22 @@
## Description

<!--
A clear and concise description of what you changed and why.
Don't forget to mention which tickets this closes (if any).
Use following syntax to close them automatically on merge: closes #<number>
-->
_A clear and concise description of what you changed and why._

## Screenshots

<!--
If your changes are user facing, please add screenshots of the new UI.
You can also create a video to showcase your changes (useful to show UX).
-->

## Additional Context

<!--
You can mention here anything that you think is relevant for this PR. Some examples:
* You encountered something that you didn't understand while working on this PR
* You were not sure about something you did but did not find a better way
* You initially had a different approach but went with a different approach for some reason
-->
_Was anything unclear during your work on this PR? Anything we should definitely take a closer look at?_

## Checklist

**Are your changes backwards compatible? Please answer below:**

<!-- put your answer about backwards compatibility here -->

<!--
If your PR is not ready for review yet, please mark your PR as a draft.
If changes were requested, request a new review when you incorporated the feedback.
-->
**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:**

<!-- put your answer about QA here -->

**For frontend changes: Tested on mobile? Please answer below:**

<!-- put your answer about mobile QA here -->

**Did you introduce any new environment variables? If so, call them out explicitly here:**

<!-- put your answer about env vars here -->
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,6 @@ docker-compose.*.yml

# nostr wallet connect
scripts/nwc-keys.json

# lnbits
docker/lnbits/data
2 changes: 1 addition & 1 deletion api/lnd/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export const getBlockHeight = cachedFetcher(async function fetchBlockHeight ({ l

export const getOurPubkey = cachedFetcher(async function fetchOurPubkey ({ lnd, ...args }) {
try {
const { identity } = await getIdentity({ lnd, ...args })
const identity = await getIdentity({ lnd, ...args })
return identity.public_key
} catch (err) {
throw new Error(`Unable to fetch identity: ${err.message}`)
Expand Down
2 changes: 1 addition & 1 deletion api/resolvers/sub.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ export default {

const { name } = data

await ssValidate(territorySchema, data, { models, me, sub: { name } })
await ssValidate(territorySchema, data, { models, me })

const oldSub = await models.sub.findUnique({ where: { name } })
if (!oldSub) {
Expand Down
17 changes: 12 additions & 5 deletions api/resolvers/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -482,12 +482,12 @@ const resolvers = {
FROM "Withdrawl"
WHERE "userId" = ${me.id}
AND id = ${Number(id)}
AND now() > created_at + interval '${retention}'
AND now() > created_at + ${retention}::INTERVAL
AND hash IS NOT NULL
AND status IS NOT NULL
), updated_rows AS (
UPDATE "Withdrawl"
SET hash = NULL, bolt11 = NULL
SET hash = NULL, bolt11 = NULL, preimage = NULL
FROM to_be_updated
WHERE "Withdrawl".id = to_be_updated.id)
SELECT * FROM to_be_updated;`
Expand All @@ -499,7 +499,7 @@ const resolvers = {
console.error(error)
await models.withdrawl.update({
where: { id: invoice.id },
data: { hash: invoice.hash, bolt11: invoice.bolt11 }
data: { hash: invoice.hash, bolt11: invoice.bolt11, preimage: invoice.preimage }
})
throw new GqlInputError('failed to drop bolt11 from lnd')
}
Expand Down Expand Up @@ -647,14 +647,21 @@ async function upsertWallet (
}

const { id, ...walletData } = data
const { autoWithdrawThreshold, autoWithdrawMaxFeePercent, enabled, priority } = settings
const {
autoWithdrawThreshold,
autoWithdrawMaxFeePercent,
autoWithdrawMaxFeeTotal,
enabled,
priority
} = settings

const txs = [
models.user.update({
where: { id: me.id },
data: {
autoWithdrawMaxFeePercent,
autoWithdrawThreshold
autoWithdrawThreshold,
autoWithdrawMaxFeeTotal
}
})
]
Expand Down
1 change: 1 addition & 0 deletions api/typeDefs/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ export default gql`
withdrawMaxFeeDefault: Int!
autoWithdrawThreshold: Int
autoWithdrawMaxFeePercent: Float
autoWithdrawMaxFeeTotal: Int
}
type UserOptional {
Expand Down
1 change: 1 addition & 0 deletions api/typeDefs/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ const typeDefs = `
input AutowithdrawSettings {
autoWithdrawThreshold: Int!
autoWithdrawMaxFeePercent: Float!
autoWithdrawMaxFeeTotal: Int!
priority: Int
enabled: Boolean
}
Expand Down
2 changes: 2 additions & 0 deletions awards.csv
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,5 @@ toyota-corolla0,pr,#1449,,good-first-issue,,,,20k,[email protected],2
toyota-corolla0,pr,#1455,#1437,good-first-issue,,,,20k,[email protected],2024-10-02
SouthKoreaLN,issue,#1436,,easy,,,,10k,[email protected],2024-10-02
TonyGiorgio,issue,#1462,,easy,urgent,,,30k,[email protected],2024-10-07
hkarani,issue,#1369,#1458,good-first-issue,,,,2k,[email protected],2024-10-21
toyota-corolla0,pr,#1369,#1458,good-first-issue,,,,20k,[email protected],2024-10-20
23 changes: 21 additions & 2 deletions components/autowithdraw-shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useMe } from './me'
import { useEffect, useState } from 'react'
import { isNumber } from '@/lib/validate'
import { useIsClient } from './use-client'
import Link from 'next/link'

function autoWithdrawThreshold ({ me }) {
return isNumber(me?.privates?.autoWithdrawThreshold) ? me?.privates?.autoWithdrawThreshold : 10000
Expand All @@ -12,7 +13,8 @@ function autoWithdrawThreshold ({ me }) {
export function autowithdrawInitial ({ me }) {
return {
autoWithdrawThreshold: autoWithdrawThreshold({ me }),
autoWithdrawMaxFeePercent: isNumber(me?.privates?.autoWithdrawMaxFeePercent) ? me?.privates?.autoWithdrawMaxFeePercent : 1
autoWithdrawMaxFeePercent: isNumber(me?.privates?.autoWithdrawMaxFeePercent) ? me?.privates?.autoWithdrawMaxFeePercent : 1,
autoWithdrawMaxFeeTotal: isNumber(me?.privates?.autoWithdrawMaxFeeTotal) ? me?.privates?.autoWithdrawMaxFeeTotal : 1
}
}

Expand Down Expand Up @@ -51,13 +53,30 @@ export function AutowithdrawSettings ({ wallet }) {
append={<InputGroup.Text className='text-monospace'>sats</InputGroup.Text>}
required
/>
<h3 className='text-center text-muted pt-3'>network fees</h3>
<h6 className='text-center pb-3'>
we'll use whichever setting is higher during{' '}
<Link
target='_blank'
href='https://docs.lightning.engineering/the-lightning-network/pathfinding'
rel='noreferrer'
>pathfinding
</Link>
</h6>
<Input
label='max fee'
label='max fee rate'
name='autoWithdrawMaxFeePercent'
hint='max fee as percent of withdrawal amount'
append={<InputGroup.Text>%</InputGroup.Text>}
required
/>
<Input
label='max fee total'
name='autoWithdrawMaxFeeTotal'
hint='max fee for any withdrawal amount'
append={<InputGroup.Text className='text-monospace'>sats</InputGroup.Text>}
required
/>
</div>
</div>
</>
Expand Down
13 changes: 7 additions & 6 deletions components/wallet-logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ import useIndexedDB from './use-indexeddb'
import { SSR } from '@/lib/constants'

export function WalletLogs ({ wallet, embedded }) {
const { logs, setLogs, hasMore, loadMore, loadLogs, loading } = useWalletLogs(wallet)
useEffect(() => {
loadLogs()
}, [loadLogs])
const { logs, setLogs, hasMore, loadMore, loading } = useWalletLogs(wallet)

const showModal = useShowModal()

Expand Down Expand Up @@ -46,7 +43,7 @@ export function WalletLogs ({ wallet, embedded }) {
? <div className='w-100 text-center'>loading...</div>
: logs.length === 0 && <div className='w-100 text-center'>empty</div>}
{hasMore
? <Button onClick={loadMore} size='sm' className='mt-3'>Load More</Button>
? <div className='w-100 text-center'><Button onClick={loadMore} size='sm' className='mt-3'>more</Button></div>
: <div className='w-100 text-center'>------ start of logs ------</div>}
</div>
</>
Expand Down Expand Up @@ -228,7 +225,7 @@ export function useWalletLogs (wallet, initialPage = 1, logsPerPage = 10) {
const loadMore = useCallback(async () => {
if (hasMore) {
setLoading(true)
const result = await loadLogsPage(page, logsPerPage, wallet)
const result = await loadLogsPage(page + 1, logsPerPage, wallet)
setLogs(prevLogs => [...prevLogs, ...result.data])
setHasMore(result.hasMore)
setTotal(result.total)
Expand All @@ -247,5 +244,9 @@ export function useWalletLogs (wallet, initialPage = 1, logsPerPage = 10) {
setLoading(false)
}, [wallet, loadLogsPage])

useEffect(() => {
loadLogs()
}, [wallet])

return { logs, hasMore, total, loadMore, loadLogs, setLogs, loading }
}
Loading

0 comments on commit 71f197d

Please sign in to comment.