* WIP: Account switching
* Fix empty USER query
ANON_USER_ID was undefined and thus the query for @anon had no variables.
* Apply multiAuthMiddleware in /api/graphql
* Fix 'you must be logged in' query error on switch to anon
* Add smart 'switch account' button
"smart" means that it only shows if there are accounts to which one can switch
* Fix multiAuth not set in backend
* Comment fixes, minor changes
* Use fw-bold instead of 'selected'
* Close dropdown and offcanvas
Inside a dropdown, we can rely on autoClose but need to wrap the buttons with <Dropdown.Item> for that to work.
For the offcanvas, we need to pass down handleClose.
* Use button to add account
* Some pages require hard reload on account switch
* Reinit settings form on account switch
* Also don't refetch WalletHistory
* Formatting
* Use width: fit-content for standalone SignUpButton
* Remove unused className
* Use fw-bold and text-underline on selected
* Fix inconsistent padding of login buttons
* Fix duplicate redirect from /settings on anon switch
* Never throw during refetch
* Throw errors which extend GraphQLError
* Only use meAnonSats if logged out
* Use reactive variable for meAnonSats
The previous commit broke the UI update after anon zaps because we actually updated item.meSats in the cache and not item.meAnonSats.
Updating item.meAnonSats was not possible because it's a local field. For that, one needs to use reactive variables.
We do this now and thus also don't need the useEffect hack in item-info.js anymore.
* Switch to new user
* Fix missing cleanup during logout
If we logged in but never switched to any other account, the 'multi_auth.user-id' cookie was not set.
This meant that during logout, the other 'multi_auth.*' cookies were not deleted.
This broke the account switch modal.
This is fixed by setting the 'multi_auth.user-id' cookie on login.
Additionally, we now cleanup if cookie pointer OR session is set (instead of only if both are set).
* Fix comments in middleware
* Remove unnecessary effect dependencies
setState is stable and thus only noise in effect dependencies
* Show but disable unavailable auth methods
* make signup button consistent with others
* Always reload page on switch
* refine account switch styling
* logout barrier
---------
Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
Co-authored-by: k00b <k00b@stacker.news>
* Add NWC receives
* Refactor sendPayment+createInvoice with nwcCall function
* Update badge
* Add method support checks
* Add timeout to NWC test invoice
* Fix NWC isConfigured state
All NWC fields are marked as optional but NWC should only be considered configured if one of them is set.
* Fix relay.fetch() throws 'crypto is not defined' in node
nip04.encrypt() was failing in worker because 'crypto is not defined'. Updating to nostr-tools v2.7.2 fixed that.
However, now crypto.randomUUID() in relay.fetch() was throwing 'crypto is not defined'. Importing crypto from 'crypto' fixed that.
However, with the import, randomUUID() does not work so I switched to randomBytes().
Running relay.fetch() now works in browser and node.
* recv must not support pay_invoice
* Fix Relay connection check
* this.url was undefined
* error was an object
* Fix additional isConfigured check runs always
It was meant to only catch false positives, not turn negatives into false positives.
* Rename testConnectServer to testCreateInvoice
* Rename testConnectClient to testSendPayment
* Only run testSendPayment if send is configured
The return value of testSendPayment was used before but it only returned something for LNC.
And for LNC, we only wanted to save the transformation during validation, so it was not needed.
* Always use withTimeout in NWC test functions
* Fix fragment name
* Use get_info command exclusively
* Check permissions more efficiently
* Log NWC request-response flow
* Fix variable name
* Call ws.send after listener is added
* Fix websocket not closed after timeout
* Also check that pay_keysend etc. are not supported
* fix lnc session key save
---------
Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
Co-authored-by: k00b <k00b@stacker.news>
* Use custom relay API
Relay from nostr-tools was cumbersome to use. This custom abstraction over window.WebSocket makes interacting with nostr relays easier.
* Use variables for nostr message parts
* Fix NWC save
* Use try/finally
* Refactor crossposting code
* use custom replay API
* simplify callWithTimeout
* Use isomorphic-ws for nip57 zap receipts
* Use async map
* Reject with timeout error
* Move time functions into lib/time
* Remove outdated comment regarding relay.close()
* not-custodial zap scaffolding
* invoice forward state machine
* small refinements to state machine
* make wrap invoice work
* get state machine working end to end
* untested logic layout for paidAction invoice wraps
* perform pessimisitic actions before outgoing payment
* working end to end
* remove unneeded params from wallets/server/createInvoice
* fix cltv relative/absolute confusion + cancelling forwards
* small refinements
* add p2p wrap info to paidAction docs
* fallback to SN invoice when wrap fails
* fix paidAction retry description
* consistent naming scheme for state machine
* refinements
* have sn pay bounded outbound fee
* remove debug logging
* reenable lnc permissions checks
* don't p2p zap on item forward splits
* make createInvoice params json encodeable
* direct -> p2p badge on notifications
* allow no tls in dev for core lightning
* fix autowithdraw to create invoice with msats
* fix autowithdraw msats/sats inconsitency
* label p2p zaps properly in satistics
* add fees to autowithdrawal notifications
* add RETRYING as terminal paid action state
* Update api/paidAction/README.md
Co-authored-by: ekzyis <ek@stacker.news>
* Update api/paidAction/README.md
Co-authored-by: ekzyis <ek@stacker.news>
* Update api/lnd/index.js
Co-authored-by: ekzyis <ek@stacker.news>
* ek suggestions
* add bugetable to nwc card
* get paranoid with numbers
* better finalize retries and better max timeout height
* refine forward failure transitions
* more accurate satistics p2p status
* make sure paidaction cancel in state machine only
* dont drop bolt11s unless status is not null
* only allow PENDING_HELD to transition to FORWARDING
* add mermaid state machine diagrams to paid action doc
* fix cancel transition name
* cleanup readme
* move forwarding outside of transition
* refine testServerConnect and make sure ensureB64 transforms
* remove unused params from testServerConnect
---------
Co-authored-by: ekzyis <ek@stacker.news>
Co-authored-by: k00b <k00b@stacker.news>
* wip backend optimism
* another inch
* make action state transitions only happen once
* another inch
* almost ready for testing
* use interactive txs
* another inch
* ready for basic testing
* lint fix
* inches
* wip item update
* get item update to work
* donate and downzap
* inchy inch
* fix territory paid actions
* wip usePaidMutation
* usePaidMutation error handling
* PENDING_HELD and HELD transitions, gql paidAction return types
* mostly working pessimism
* make sure invoice field is present in optimisticResponse
* inches
* show optimistic values to current me
* first pass at notifications and payment status reporting
* fix migration to have withdrawal hash
* reverse optimism on payment failure
* Revert "Optimistic updates via pending sats in item context (#1229)"
This reverts commit 93713b33df.
* add onCompleted to usePaidMutation
* onPaid and onPayError for new comments
* use 'IS DISTINCT FROM' for NULL invoiceActionState columns
* make usePaidMutation easier to read
* enhance invoice qr
* prevent actions on unpaid items
* allow navigation to action's invoice
* retry create item
* start edit window after item is paid for
* fix ux of retries from notifications
* refine retries
* fix optimistic downzaps
* remember item updates can't be retried
* store reference to action item in invoice
* remove invoice modal layout shift
* fix destructuring
* fix zap undos
* make sure ItemAct is paid in aggregate queries
* dont toast on long press zap undo
* fix delete and remindme bots
* optimistic poll votes with retries
* fix retry notifications and invoice item context
* fix pessimisitic typo
* item mentions and mention notifications
* dont show payment retry on item popover
* make bios work
* refactor paidAction transitions
* remove stray console.log
* restore docker compose nwc settings
* add new todos
* persist qr modal on post submission + unify item form submission
* fix post edit threshold
* make bounty payments work
* make job posting work
* remove more store procedure usage ... document serialization concerns
* dont use dynamic imports for paid action modules
* inline comment denormalization
* create item starts with median votes
* fix potential of serialization anomalies in zaps
* dont trigger notification indicator on successful paid action invoices
* ignore invoiceId on territory actions and add optimistic concurrency control
* begin docs for paid actions
* better error toasts and fix apollo cache warnings
* small documentation enhancements
* improve paid action docs
* optimistic concurrency control for territory updates
* use satsToMsats and msatsToSats helpers
* explictly type raw query template parameters
* improve consistency of nested relation names
* complete paid action docs
* useEffect for canEdit on payment
* make sure invoiceId is provided when required
* don't return null when expecting array
* remove buy credits
* move verifyPayment to paidAction
* fix comments invoicePaidAt time zone
* close nwc connections once
* grouped logs for paid actions
* stop invoiceWaitUntilPaid if not attempting to pay
* allow actionState to transition directly from HELD to PAID
* make paid mutation wait until pessimistic are fully paid
* change button text when form submits/pays
* pulsing form submit button
* ignore me in notification indicator for territory subscription
* filter unpaid items from more queries
* fix donation stike timing
* fix pending poll vote
* fix recent item notifcation padding
* no default form submitting button text
* don't show paying on submit button on free edits
* fix territory autorenew with fee credits
* reorg readme
* allow jobs to be editted forever
* fix image uploads
* more filter fixes for aggregate views
* finalize paid action invoice expirations
* remove unnecessary async
* keep clientside cache normal/consistent
* add more detail to paid action doc
* improve paid action table
* remove actionType guard
* fix top territories
* typo api/paidAction/README.md
Co-authored-by: ekzyis <ek@stacker.news>
* typo components/use-paid-mutation.js
Co-authored-by: ekzyis <ek@stacker.news>
* Apply suggestions from code review
Co-authored-by: ekzyis <ek@stacker.news>
* encorporate ek feeback
* more ek suggestions
* fix 'cost to post' hover on items
* Apply suggestions from code review
Co-authored-by: ekzyis <ek@stacker.news>
---------
Co-authored-by: ekzyis <ek@stacker.news>
* Fix first zap when modal closed (#771)
- Extract handlers
- Remove unnecessary async keyword from callback
- Assign a new key to force remounting of LongPressable component when modal is closed from long press
- Remove hover state when closing modal, otherwise it stays colored
* Replace LongPressable with custom component
* Remove yarn.lock
* Add LNbits card
* Save LNbits Provider in WebLN context
* Check LNbits connection on save
* refactor: put LNbitsProvider into own file
* Pay invoices using WebLN provider from context
* Remove deprecated FIXME
* Try WebLN provider first
* Fix unhandled promise rejection
* Fix this in sendPayment
* Be optimistic regarding WebLN zaps
This wraps the WebLN payment promise with Apollo cache updates.
We will be optimistics and assume that the payment will succeed and update the cache accordingly.
When we notice that the payment failed, we undo this update.
* Bold strike on WebLN zap
If lightning strike animation is disabled, toaster will be used.
* Rename undo variable to amount
* Fix zap undo
* Add NWC card
* Attempt to check NWC connection using info event
* Fix NaN on zap
Third argument of update is reserved for context
* Fix TypeError in catch of QR code
* Add basic NWC payments
* Wrap LNbits getInfo with try/catch
* EOSE is enough to check NWC connection
* refactor: Wrap WebLN providers into own context
I should have done this earlier
* Show red indicator on error
* Fix useEffect return value
* Fix wrong usage of pubkey
The event pubkey is derived from the secret. Doesn't make sense to manually set it. It's also the wrong pubkey: we're not the wallet service.
* Use p tag in NWC request
* Add comment about required filter field
* Aesthetic changes to NWC sendPayment
* Add TODO about receipt verification
* Fix WebLN attempted again after error
* Fix undefined name
* Add code to mock NWC relay
* Revert "Bold strike on WebLN zap"
This reverts commit a9eb27daec0cd2ef30b56294b05e0056fb5b4184.
* Fix update undo
* Fix lightning strike before payment
* WIP: Wrap WebLN payments with toasts
* add toasts for pending, error, success
* while pending, invoice can be canceled
* there are still some race conditions between payiny the invoice / error on payment and invoice cancellation
* Fix invoice poll using stale value from cache
* Remove unnecessary if
* Make sure that pay_invoice is declared as supported
* Check if WebLN provider is enabled before calling sendPayment
* Fix bad retry
If WebLN payments failed due to insufficient balances, the promise resolved and thus the action was retried but failed immediately since the invoice (still) wasn't paid.
* Fix cache undo update
* Fix no cache update after QR payment
* refactor: Use fragments to undo cache updates
* Remove console.log
* Small changes to NWC relay mocking
* Return SendPaymentResponse
See https://www.webln.guide/building-lightning-apps/webln-reference/webln.sendpayment
* Also undo cache update on retry failure
* Disable NWC mocking
* Fix initialValue not set
But following warning is now shown in console:
"""
Warning: A component is changing a controlled input to be uncontrolled.
This is likely caused by the value changing from a defined to undefined, which should not happen.
Decide between using a controlled or uncontrolled input element for the lifetime of the component. More info: https://reactjs.org/link/controlled-components
"""
* Remove comment since only relevant for blastr (mutiny relay)
* Remove TODO
* Fix duplicate cache update
* Fix QR modal not closed after payment
* Ignore lnbits variable unused
* Use single relay connection for all NWC events
* Fix missing timer and subscription cleanup
* Remove TODO
Confirmed that nostr-tools verifies events and filters for us.
See https://github.com/nbd-wtf/nostr-tools/blob/master/abstract-relay.ts#L161
* Fix switch from controlled to uncontrolled input
* Show 'configure' on error
* Use budgetable instead of async
* Remove EOSE listener
Only nostr.mutinywallet.com didn't respond with info events due to implementation-specific reasons. This is no longer the case.
* Use invoice expiry for NWC timeout
I don't think there was a specific reason why I used 60 seconds initially.
* Validate LNbits config on save
* Validate NWC config on save
* Also show unattach if configuration is invalid
If unattach is only shown if configuration is valid, resetting the configuration is not possible while it's invalid. So we're stuck with a red wallet indicator.
* Fix detection of WebLN payment
It depended on a Apollo cache update function being available. But that is not the case for every WebLN payment.
* Fix formik bag lost
* Use payment instead of zap in toast
* autoscale capture svc by response time
* docs and changes for testing lnbits locally
* Rename configJSON to config
Naming of config object was inconsistent with saveConfig function which was annoying.
Also fixed other inconsistencies between LNbits and NWC provider.
* Allow setting of default payment provider
* Update TODO comment about provider priority
The list 'paymentMethods' is not used yet but is already implemented for future iterations.
* Add wallet security disclaimer
* Update labels
---------
Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
Co-authored-by: keyan <keyan.kousha+huumn@gmail.com>
* uber rough first pass at mention autocompletes
* support custom limit on topUsers query
* hot keys for selecting user suggestion in markdown input
* query top stackers for mentions with no search query
* refactor UserSuggestion to help with reusability
textarea-caret for placing the user suggest dropdown appropriately
other various code cleanup items to make it easier to use
off by one errors are fun!
various code cleanup and reuse the UserSuggest component in InputUserSuggest to reduce duplication
* change default users to week query
---------
Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
Co-authored-by: keyan <keyan.kousha+huumn@gmail.com>
* Add diagnostics settings & endpoint
Stackers can now help us to identify and fix bugs by enabling diagnostics.
This will send anonymized data to us.
For now, this is only used to send events around push notifications.
* Send diagnostics to slack
* Detect OS
* Diagnostics data is only pseudonymous, not anonymous
It's only pseudonymous since with additional knowledge (which stacker uses which fancy name), we could trace the events back to individual stackers.
Data is only anonymous if this is not possible - it must be irreversible.
* Check if window.navigator is defined
* Use Slack SDK
* Catch errors of slack requests
---------
Co-authored-by: ekzyis <ek@stacker.news>
Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>