jam/src/constants/debugFeatures.ts
Thebora Kompanioni c68e4c5c64
feat: basic fidelity bonds (#307)
* dev: add simple fidelity bond screen in advanced mode

* dev: add link to fidelity form page in CurrentWalletAdvanced

* dev: fix build errors and remove 'as' tag of translation elements

* refactor: move FidelityBondAdvanced component to own file

* ui: highlight expiry date of fidelity bond address

* dev: display Fidelity Bond create form regardless if FBs already exist

* dev: avoid flickering when loading new fb address

* fix: rename Locktime to Lockdate

* dev: add translation strings to section 'global'

* wip: FidelityBondSimple

* review: distinct simple and dev mode Fidelity Bond screens

* review: fix dev FB view in dark mode

* refactor: rename FidelityBondAdvanced to FidelityBondDevOnly

* dev: add link to default view to FidelityBondDevOnly

* dev: sort utxo by value

* dev: reset user confirmation on data change

* dev: create fidelity bond with collaborative transaction WIP

* dev: wait for collaborative transaction to finish

* dev: unfreeze utxos after creating sweep tx

* review: render whitespace only when necessary in FB alert

* review: do not provide time related values to Date.UTC for FB

* Update src/components/FidelityBondDevOnly.tsx

Co-authored-by: Daniel <10026790+dnlggr@users.noreply.github.com>

* review: do not duplicate 'initialLockdate' values

* dev: allow lockdates in the past in dev mode

* dev: display percentage of utxo to total value in account

* dev: style percentage bar

* dev: display percentage bar in account selector

* dev: i18n for 'time elapsed' phrase

* dev: externalize components UtxoSelector and UtxoCheckbox

* dev: externalize components AccountSelector and AccountCheckbox

* dev: externalize LockdateForm

* dev: externalize FidelityBondDetailsSetupForm

* dev: display all accounts by default in FB form

* refactor: remove unused vars and imports

* dev: fix comments and add todos

* dev: minimal i18n for FB form

* ui: remove account/utxo checkbox overlay

* dev: add checkbox-card component

* dev: show unit of funds according to settings in FB form

* dev: allow already expired lockdates in dev mode

* dev: use minimum makers to create fb

* refactor: combine FidelityBond and FidelityBondSimple

* dev: undo coin control setup on errors

* dev: perform coin control actions sequentially

* dev: use direct-send when renewing an expired fidelity bond

* review: improve code readability

* review: do not return value from function 'sweepToFidelityBond'

* dev: log timelocked address to console in dev mode

* review: remove FidelityBondDevOnly component

* review: use dropdowns in lockdate form

* Update src/components/FidelityBond.tsx

Co-authored-by: Daniel <10026790+dnlggr@users.noreply.github.com>

* dev: add debug feature 'allowCreatingExpiredFidelityBond'

* review: fix var naming

* review: fix comment

* Update src/components/FidelityBond.tsx

Co-authored-by: Daniel <10026790+dnlggr@users.noreply.github.com>

* Update src/components/FidelityBond.tsx

Co-authored-by: Daniel <10026790+dnlggr@users.noreply.github.com>

* dev: unfreeze sequentially after fidelity bond tx was created

* review: remove ability to select multiple jars

* review: add tests for fb utils

* review: remove coin control

* review: reflect missing coin control in account checkbox

* review: remove time elapsed string from fb summary

* dev: add taker started alert to FB screen

* dev: reset lockdate form if date is invalid

* dev: reload after taker operation

* dev: add calculated total balance to useBalanceSummary hook

* dev: handle expired timelocked funds in useBalanceSummary hook

* dev: use isLocked to detect if freeze/unfreeze is enabled

* dev: fix build

* refactor: proper var names

* dev: show success msg only if fb has been created successfully

* dev: do not wait for collaborative tx to finish

* dev: direct-send if renewing FB

* dev: utilize 'isLocked' in CurrentWalletAdvanced and Jam view

* dev: link to FB view in Cheatsheet

* dev: utilize 'calculatedTotalBalanceInSats' where possible

* Update src/components/FidelityBond.tsx

Co-authored-by: Daniel <10026790+dnlggr@users.noreply.github.com>

* review: adapt error handling style on FB sweep tx

sorry @dnlggr for letting this slip in _again_

* review: always show all accounts in FB form

* review: initial lockdate should be 3 month from now

* review: move YearsRange and initialLockdate to fb_utils

* review: display month names

* review: wrap rows in container

* review: remove unnecessary comment

* review: left-align confirmation toggle in FB form

* review: turn accountBalances from array to object

* Update src/i18n/locales/en/translation.json

Co-authored-by: Gigi <109058+dergigi@users.noreply.github.com>

* Update src/components/FidelityBond.tsx

Co-authored-by: Gigi <109058+dergigi@users.noreply.github.com>

* review: remove initializing flag

* review: show timelocked address in confirmation step

* test: add test for LockdateForm component

* test: add test for _minMonth

* test: add test for _selectableYears

* test: add test for _selectableMonths

* ui: fix table in light theme

Co-authored-by: Daniel <10026790+dnlggr@users.noreply.github.com>
Co-authored-by: Gigi <109058+dergigi@users.noreply.github.com>
2022-06-15 15:17:51 +02:00

26 lines
643 B
TypeScript

interface DebugFeatures {
insecureScheduleTesting: boolean
allowCreatingExpiredFidelityBond: boolean
}
const devMode = process.env.NODE_ENV === 'development'
const debugFeatures: DebugFeatures = {
insecureScheduleTesting: true,
allowCreatingExpiredFidelityBond: true,
}
type DebugFeature = keyof DebugFeatures
export const isDebugFeatureEnabled = (name: DebugFeature): boolean => {
if (!devMode) {
return false
}
return debugFeatures[name] || false
}
// only to be used in tests
export const __testSetDebugFeatureEnabled = (name: DebugFeature, enabled: boolean): boolean => {
return (debugFeatures[name] = enabled)
}