* wip: Use uniform interface for wallets
* Fix import error
* Update wallet logging + other stuff
* add canPay and canSend to wallet definition
* rename 'default payment method' to 'enabled' and add enable + disable method
* Set canPay, canReceive in useWallet
* Enable wallet if just configured
* Don't pass logger to sendPayment
* Add logging to attach & detach
* Add schema to wallet def
* Add NWC wallet
* Fix unused isDefault saved in config
* Fix enableWallet
* wrong storage key was used
* broke if wallets with no configs existed
* Run validation during save
* Use INFO level for 'wallet disabled' message
* Pass config with spread operator
* Support help, optional, hint in wallet fields
* wip: Add LNC
* Fix 20s page load for /settings/wallets.json?nodata=true
For some reason, if nodata is passed (which is the case if going back), the page takes 20s to load.
* Fix extremely slow page load for LNC import
I noticed that the combination of
```
import { Form, PasswordInput, SubmitButton } from '@/components/form'
```
in components/wallet/lnc.js and the dynamic import via `await import` in components/wallet/index.js caused extremely slow page loads.
* Use normal imports
* Revert "Fix 20s page load for /settings/wallets.json?nodata=true"
This reverts commit deb476b3a966569fefcfdf4082d6b64f90fbd0a2.
Not using the dynamic import for LNC fixed the slow page load with ?nodata=true.
* Remove follow and show recent logs first
* Fix position of log start marker
* Add FIXMEs for LNC
I can't get LNC to connect. It just hangs forever on lnc.connect(). See FIXMEs.
* Remove logger.error since already handled in useWallet
* Don't require destructuring to pass props to input
* wip: Add LND autowithdrawals
* receiving wallets need to export 'server' object field
* don't print macaroon error stack
* fix missing wallet logs order update
* mark autowithdrawl settings as required
* fix server wallet logs deletion
* remove canPay and canReceive since it was confusing where it is available
TODO
* also use numeric priority for sending wallets to be consistent with how status for receiving wallets is determined
* define createInvoice function in wallet definition
* consistent wallet logs: sending wallets use 'wallet attached'+'wallet enabled/disabled' whereas receiving wallets use 'wallet created/updated'
* see FIXMEs
* Fix TypeError
* Fix sendPayment called with empty config
* removed useEffect such that config is available on first render
* fix hydration error using dynamic import without SSR
* Fix confusing UX around enabled
* Remove FIXMEs
Rebase on master seemed to have fixed these, weird
* Use same error format in toast and wallet log
* Fix usage of conditional hooks in useConfig
* Fix isConfigured
* Fix delete wallet logs on server
* Fix wallet logs refetch
onError does not exist on client.mutate
* Fix TypeError in isConfigured if no enabled wallet found
* Only include local/server config if required
* Fix another hydration error
* Fix server config not updated after save or detach
* Also use 'enabled' for server wallets
* Fix wallet logs not updated after server delete
* Consistent logs between local and server wallets
* 'wallet attached' on create
* 'wallet updated' on config updates
* 'wallet enabled' and 'wallet disabled' if checkbox changed
* 'wallet detached' on delete
* Also enable server wallets on create
* Disable checkbox if not configured yet
* Move all validation schema into lib/validate
* Implement drag & drop w/o persistence
* Use dynamic import for WalletCard
This fixes a lot of issues with hydration
* Save order as priority
* Fix autowithdrawSettings not applied
Form requires config in flat format but mutation requires autowithdraw settings in a separate 'settings' field.
I have decided that config will be in flat form format. It will be transformed into mutation format during save.
* Save dedicated enabled flag for server wallets
* wallet table now contains boolean column 'enabled'
* 'priority' is now a number everywhere
* use consistent order between how autowithdrawals are attempted and server wallets cards
* Fix onCanceled missing
* Fix typo
* Fix noisy changes in lib/validate
I moved the schema for lnbits, nwc and lnc out of lib/validate only to put them back in there later.
This commit should make the changeset cleaner by removing noise.
* Split arguments into [value,] config, context
* Run lnbits url.replace in validate and sendPayment
* Remove unnecessary WALLETS_QUERY
* Generate wallet mutation from fields
* Generate wallet resolver from fields
* Fix import inconsistency between app and worker
* Use wallet.createInvoice for autowithdrawals
* Fix success autowithdrawal log
* Fix wallet security banner shown for server wallets
* Add autowithdrawal to lightning address
* Add optional wallet short name for logging
* Fix draggable
* Fix autowithdraw loop
* Add missing hints
* Add CLN autowithdrawal
* Detach wallets and delete logs on logout
* Remove Wallet in lib/constants
* Use inject function for resolvers and typeDefs
* Fix priority ignored when fetching enabled wallet
* Fix draggable false on first page load due to SSR
* Use touches instead of dnd on mobile
Browsers don't support drag events for touch devices.
To have a consistent implementation for desktop and mobile, we would need to use mousedown/touchstart, mouseup/touchend and mousemove/touchmove.
For now, this commit makes changing the order possible on touch devices with simple touches.
* Fix duplicate CLN error
* Fix autowithdraw priority order
* Fix error per invalid bip39 word
* Update LNC code
* remove LNC FIXMEs
Mhh, I guess the TURN server was down or something? It now magically works. Or maybe it only works once per mnemonic?
* also removed the lnc.lnd.lightning.getInfo() call since we don't ask and need permission for this RPC for payments.
* setting a password does not work though. It fails with 'The password provided is not valid' which is triggered at https://github.com/lightninglabs/lnc-web/blob/main/lib/util/credentialStore.ts#L81.
* Fix order if wallet with no priority exists
* Use common sort
* Add link to lnbits.com
* Add example wallet def
* Remove TODOs
TODO in components/wallet-logger.js was handled.
I don't see a need for the TODO in lib/wallet.js anymore. This function will only be called with the wallet of type LIGHTNING_ADDRESS anyway.
* Remove console.log
* Toast priority save errors
* Fix leaking relay connections
* Remove 'tor or clearnet' hint for LN addresses
* Remove React dependency from wallet definitions
* Generate resolver name from walletField
* Move wallets into top level directory wallet/
* Put wallets into own folder
* Fix generateMutation
* remove resolverName property from wallet defs
* move function into lib/wallet
* use function in generateMutation on client to fix wrongly generated mutation
* Separate client and server imports by files
* wallets now consist of an index.js, a client.js and a server.js file
* client.js is imported on the client and contains the client portion
* server.js is imported on the server and contains the server porition
* both reexport index.js so everything in index.js can be shared by client and server
* every wallet contains a client.js file since they are all imported on the client to show the cards
* client.js of every wallet is reexported as an array in wallets/client.js
* server.js of every wallet is reexported as an array in wallets/server.js
FIXME: for some reason, worker does not properly import the default export of wallets/server.js
* Fix worker import of wallets/server
* Fix wallet.server usage
* I removed wallet.server in a previous commit
* the client couldn't determine which wallet was stored on the server since all server specific fields were set in server.js
* walletType and walletField are now set in index.js
* walletType is now used to determine if a wallet is stored on the server
* also included some formatting changes
* Fix w.default usage
Since package.json with { "type": "module" } was added, this is no longer needed.
* Fix id access in walletPrioritySort
* Fix autowithdrawal error log
* Generate validation schema for LNbits
* Generate validation schema for NWC
* Rename to torAllowed
* Generate validation schema for LNC
* Generate validation schema for LND
* Generate validation schema for LnAddr
* Remove stringTypes
* Generate validation schema for CLN
* Make clear that message belongs to test
* validate.message was used in tandem with validate.test
* it might be confused as the message if the validation for validate.type failed
* now validate.test can be a function or an object of { test, message } shape which matches Yup.test
* Remove validate.schema as a trap door
* make lnc work
* Return null if no wallet was found
* Revert code around schema generation
* Transform autowithdrawSchemaMembers into an object
* Rename schema to yupSchema
* Fix missing required for LNbits adminKey
* Support formik form-level validation
* Fix missing addWalletLog import
* Fix missing space after =
* fix merge conflict resolution mistake
* remove non-custodial* badges
* create guides for attaching wallets in sndev
* Use built-in formik validation or Yup schema but not both
* Rename: validate -> testConnectClient, testConnect -> testConnectServer
* make lnaddr autowithdraw work in dev
* move ATTACH docs to ./wallets and add lnaddr doc
* Fix missing rename: yupSchema -> fieldValidation
* Remove unused context
* Add documentation how to add wallets
---------
Co-authored-by: keyan <keyan.kousha+huumn@gmail.com>
Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
144 lines
6.8 KiB
JavaScript
144 lines
6.8 KiB
JavaScript
// XXX this is temporary until we have so many subs they have
|
|
// to be loaded from the server
|
|
export const DEFAULT_SUBS = ['bitcoin', 'nostr', 'tech', 'meta', 'jobs']
|
|
export const DEFAULT_SUBS_NO_JOBS = DEFAULT_SUBS.filter(s => s !== 'jobs')
|
|
|
|
export const NOFOLLOW_LIMIT = 1000
|
|
export const UNKNOWN_LINK_REL = 'noreferrer nofollow noopener'
|
|
export const BOOST_MULT = 5000
|
|
export const BOOST_MIN = BOOST_MULT * 10
|
|
export const UPLOAD_SIZE_MAX = 25 * 1024 * 1024
|
|
export const UPLOAD_SIZE_MAX_AVATAR = 5 * 1024 * 1024
|
|
export const IMAGE_PIXELS_MAX = 35000000
|
|
// backwards compatibile with old media domain env var and precedence for docker url if set
|
|
export const MEDIA_URL = process.env.MEDIA_URL_DOCKER || process.env.NEXT_PUBLIC_MEDIA_URL || `https://${process.env.NEXT_PUBLIC_MEDIA_DOMAIN}`
|
|
export const AWS_S3_URL_REGEXP = new RegExp(`${process.env.NEXT_PUBLIC_MEDIA_URL || `https://${process.env.NEXT_PUBLIC_MEDIA_DOMAIN}`}/([0-9]+)`, 'g')
|
|
export const UPLOAD_TYPES_ALLOW = [
|
|
'image/gif',
|
|
'image/heic',
|
|
'image/png',
|
|
'image/jpeg',
|
|
'image/webp'
|
|
]
|
|
export const INVOICE_ACTION_NOTIFICATION_TYPES = ['ITEM_CREATE', 'ZAP', 'DOWN_ZAP', 'POLL_VOTE']
|
|
export const BOUNTY_MIN = 1000
|
|
export const BOUNTY_MAX = 10000000
|
|
export const POST_TYPES = ['LINK', 'DISCUSSION', 'BOUNTY', 'POLL']
|
|
export const TERRITORY_BILLING_TYPES = ['MONTHLY', 'YEARLY', 'ONCE']
|
|
export const TERRITORY_GRACE_DAYS = 5
|
|
export const COMMENT_DEPTH_LIMIT = 8
|
|
export const MAX_TITLE_LENGTH = 80
|
|
export const MIN_TITLE_LENGTH = 5
|
|
export const MAX_POST_TEXT_LENGTH = 100000 // 100k
|
|
export const MAX_COMMENT_TEXT_LENGTH = 10000 // 10k
|
|
export const MAX_TERRITORY_DESC_LENGTH = 1000 // 1k
|
|
export const MAX_POLL_CHOICE_LENGTH = 40
|
|
export const ITEM_SPAM_INTERVAL = '10m'
|
|
export const ANON_ITEM_SPAM_INTERVAL = '0'
|
|
export const INV_PENDING_LIMIT = 100
|
|
export const BALANCE_LIMIT_MSATS = 100000000 // 100k sat
|
|
export const USER_ID = {
|
|
k00b: 616,
|
|
ek: 6030,
|
|
sn: 4502,
|
|
anon: 27,
|
|
ad: 9,
|
|
delete: 106,
|
|
saloon: 17226
|
|
}
|
|
export const SN_USER_IDS = [USER_ID.k00b, USER_ID.ek, USER_ID.sn]
|
|
export const SN_NO_REWARDS_IDS = [USER_ID.anon, USER_ID.sn, USER_ID.saloon]
|
|
export const ANON_INV_PENDING_LIMIT = 1000
|
|
export const ANON_BALANCE_LIMIT_MSATS = 0 // disable
|
|
export const MAX_POLL_NUM_CHOICES = 10
|
|
export const MIN_POLL_NUM_CHOICES = 2
|
|
export const POLL_COST = 1
|
|
export const ITEM_FILTER_THRESHOLD = 1.2
|
|
export const DONT_LIKE_THIS_COST = 1
|
|
export const COMMENT_TYPE_QUERY = ['comments', 'freebies', 'outlawed', 'borderland', 'all', 'bookmarks']
|
|
export const USER_SORTS = ['value', 'stacking', 'spending', 'comments', 'posts', 'referrals']
|
|
export const ITEM_SORTS = ['zaprank', 'comments', 'sats']
|
|
export const SUB_SORTS = ['stacking', 'revenue', 'spending', 'posts', 'comments']
|
|
export const WHENS = ['day', 'week', 'month', 'year', 'forever', 'custom']
|
|
export const ITEM_TYPES_USER = ['all', 'posts', 'comments', 'bounties', 'links', 'discussions', 'polls', 'freebies', 'jobs', 'bookmarks']
|
|
export const ITEM_TYPES = ['all', 'posts', 'comments', 'bounties', 'links', 'discussions', 'polls', 'freebies', 'bios', 'jobs']
|
|
export const ITEM_TYPES_UNIVERSAL = ['all', 'posts', 'comments', 'freebies']
|
|
export const OLD_ITEM_DAYS = 3
|
|
export const ANON_FEE_MULTIPLIER = 100
|
|
export const SSR = typeof window === 'undefined'
|
|
export const MAX_FORWARDS = 5
|
|
export const LNURLP_COMMENT_MAX_LENGTH = 1000
|
|
export const RESERVED_MAX_USER_ID = 615
|
|
export const GLOBAL_SEED = USER_ID.k00b
|
|
export const FREEBIE_BASE_COST_THRESHOLD = 10
|
|
export const USER_IDS_BALANCE_NO_LIMIT = [...SN_USER_IDS, USER_ID.anon, USER_ID.ad]
|
|
|
|
// WIP ultimately subject to this list: https://ofac.treasury.gov/sanctions-programs-and-country-information
|
|
// From lawyers: north korea, cuba, iran, ukraine, syria
|
|
export const SANCTIONED_COUNTRY_CODES = ['KP', 'CU', 'IR', 'UA', 'SY']
|
|
|
|
export const TERRITORY_COST_MONTHLY = 100000
|
|
export const TERRITORY_COST_YEARLY = 1000000
|
|
export const TERRITORY_COST_ONCE = 3000000
|
|
|
|
export const TERRITORY_BILLING_OPTIONS = (labelPrefix) => ({
|
|
monthly: {
|
|
term: '+ 100k',
|
|
label: `${labelPrefix} month`,
|
|
modifier: cost => cost + TERRITORY_COST_MONTHLY
|
|
},
|
|
yearly: {
|
|
term: '+ 1m',
|
|
label: `${labelPrefix} year`,
|
|
modifier: cost => cost + TERRITORY_COST_YEARLY
|
|
},
|
|
once: {
|
|
term: '+ 3m',
|
|
label: 'one time',
|
|
modifier: cost => cost + TERRITORY_COST_ONCE
|
|
}
|
|
})
|
|
|
|
export const TERRITORY_PERIOD_COST = (billingType) => {
|
|
switch (billingType.toUpperCase()) {
|
|
case 'MONTHLY':
|
|
return TERRITORY_COST_MONTHLY
|
|
case 'YEARLY':
|
|
return TERRITORY_COST_YEARLY
|
|
case 'ONCE':
|
|
return TERRITORY_COST_ONCE
|
|
}
|
|
}
|
|
|
|
export const FOUND_BLURBS = [
|
|
'The harsh frontier is no place for the unprepared. This hat will protect you from the sun, dust, and other elements Mother Nature throws your way.',
|
|
'A cowboy is nothing without a cowboy hat. Take good care of it, and it will protect you from the sun, dust, and other elements on your journey.',
|
|
"This is not just a hat, it's a matter of survival. Take care of this essential tool, and it will shield you from the scorching sun and the elements.",
|
|
"A cowboy hat isn't just a fashion statement. It's your last defense against the unforgiving elements of the Wild West. Hang onto it tight.",
|
|
"A good cowboy hat is worth its weight in gold, shielding you from the sun, wind, and dust of the western frontier. Don't lose it.",
|
|
'Your cowboy hat is the key to your survival in the wild west. Treat it with respect and it will protect you from the elements.'
|
|
]
|
|
export const LOST_BLURBS = [
|
|
'your cowboy hat was taken by the wind storm that blew in from the west. No worries, a true cowboy always finds another hat.',
|
|
"you left your trusty cowboy hat in the saloon before leaving town. You'll need a replacement for the long journey west.",
|
|
'you lost your cowboy hat in a wild shoot-out on the outskirts of town. Tough luck, tIme to start searching for another one.',
|
|
'you ran out of food and had to trade your hat for supplies. Better start looking for another hat.',
|
|
"your hat was stolen by a mischievous prairie dog. You won't catch the dog, but you can always find another hat.",
|
|
'you lost your hat while crossing the river on your journey west. Maybe you can find a replacement hat in the next town.'
|
|
]
|
|
|
|
export const ITEM_ALLOW_EDITS = [
|
|
// FAQ, old privacy policy, changelog, content guidelines, tos, new privacy policy, copyright policy
|
|
349, 76894, 78763, 81862, 338393, 338369, 338453
|
|
]
|
|
|
|
export const INVOICE_RETENTION_DAYS = 7
|
|
export const JIT_INVOICE_TIMEOUT_MS = 180_000
|
|
|
|
export const FAST_POLL_INTERVAL = Number(process.env.NEXT_PUBLIC_FAST_POLL_INTERVAL)
|
|
export const NORMAL_POLL_INTERVAL = Number(process.env.NEXT_PUBLIC_NORMAL_POLL_INTERVAL)
|
|
export const LONG_POLL_INTERVAL = Number(process.env.NEXT_PUBLIC_LONG_POLL_INTERVAL)
|
|
export const EXTRA_LONG_POLL_INTERVAL = Number(process.env.NEXT_PUBLIC_EXTRA_LONG_POLL_INTERVAL)
|
|
|
|
export const ZAP_UNDO_DELAY_MS = 5_000
|