mirror of
https://github.com/joinmarket-webui/jam.git
synced 2026-08-19 13:18:30 +02:00
chore: add type AmountSats
This commit is contained in:
parent
ac836e1c4c
commit
b027b22262
3 changed files with 22 additions and 19 deletions
|
|
@ -13,6 +13,7 @@ import { Tabs, TabsContent } from '@/components/ui/tabs'
|
|||
import * as JAM from '@/constants/jam'
|
||||
import type { OfferType } from '@/constants/jm'
|
||||
import { cn, factorToPercentage } from '@/lib/utils'
|
||||
import type { AmountSats } from '@/types/global'
|
||||
import { SatSymbol } from '../CurrencySymbol'
|
||||
|
||||
const FieldPrefixSatSymbol = (
|
||||
|
|
@ -30,9 +31,9 @@ const OFFERTYPE_REL: OfferType = 'sw0reloffer'
|
|||
|
||||
export interface EarnFormValues {
|
||||
offerType: OfferType
|
||||
offerAbsoluteFee?: number
|
||||
offerAbsoluteFee?: AmountSats
|
||||
offerRelativeFeeInPercent?: number
|
||||
offerMinAmount: number
|
||||
offerMinAmount: AmountSats
|
||||
}
|
||||
|
||||
const FORM_INPUT_DEFAULT_VALUES: Required<EarnFormValues> = {
|
||||
|
|
@ -99,7 +100,7 @@ interface EarnFormProps {
|
|||
isWaitingMakerStart: boolean
|
||||
onSubmit: SubmitHandler<EarnFormValues>
|
||||
/* TODO: make offerMinsizeMax mandatory */
|
||||
offerMinsizeMax?: number
|
||||
offerMinsizeMax?: AmountSats
|
||||
disabled?: boolean
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { percentageToFactor } from '@/lib/utils'
|
||||
import type { AmountSats, Milliseconds } from '@/types/global'
|
||||
import { JM_API_AUTH_TOKEN_EXPIRY, JM_DUST_THRESHOLD } from './jm'
|
||||
|
||||
export const TX_FEES_FACTOR_MIN = 0 // 0%
|
||||
|
|
@ -10,8 +11,8 @@ export const TX_FEES_FACTOR_MIN = 0 // 0%
|
|||
* Once resolved, this can be set to 100% again.
|
||||
*/
|
||||
export const TX_FEES_FACTOR_MAX = percentageToFactor(50) // 50%
|
||||
export const CJ_FEE_ABS_MIN = 1
|
||||
export const CJ_FEE_ABS_MAX = 1_000_000 // 0.01 BTC - no enforcement by JM - this should be a "sane" max value
|
||||
export const CJ_FEE_ABS_MIN: AmountSats = 1
|
||||
export const CJ_FEE_ABS_MAX: AmountSats = 1_000_000 // 0.01 BTC - no enforcement by JM - this should be a "sane" max value
|
||||
export const CJ_FEE_REL_MIN = percentageToFactor(0.0001)
|
||||
export const CJ_FEE_REL_MAX = percentageToFactor(5) // no enforcement by JM - this should be a "sane" max value
|
||||
export const MAX_SWEEP_FEE_CHANGE_MIN = percentageToFactor(50)
|
||||
|
|
@ -22,30 +23,30 @@ export const OFFER_FEE_REL_MAX = percentageToFactor(10)
|
|||
export const OFFER_FEE_REL_STEP = percentageToFactor(0.0001)
|
||||
export const OFFER_FEE_REL_DEFAULT = percentageToFactor(0.0021)
|
||||
|
||||
export const OFFER_FEE_ABS_MIN = 0
|
||||
export const OFFER_FEE_ABS_DEFAULT = 21
|
||||
export const OFFER_FEE_ABS_MIN: AmountSats = 0
|
||||
export const OFFER_FEE_ABS_DEFAULT: AmountSats = 21
|
||||
|
||||
export const OFFER_MINSIZE_MIN = JM_DUST_THRESHOLD
|
||||
export const OFFER_MINSIZE_DEFAULT = 100_000
|
||||
export const OFFER_MINSIZE_MIN: AmountSats = JM_DUST_THRESHOLD
|
||||
export const OFFER_MINSIZE_DEFAULT: AmountSats = 100_000
|
||||
|
||||
export const JAM_JM_SESSION_REFRESH_MIN_INTERVAL = 5_000
|
||||
export const JAM_JM_SESSION_REFRESH_DEFAULT_INTERVAL = 30_000
|
||||
export const JAM_JM_SESSION_REFRESH_INTERVAL = Math.max(
|
||||
export const JAM_JM_SESSION_REFRESH_MIN_INTERVAL: Milliseconds = 5_000
|
||||
export const JAM_JM_SESSION_REFRESH_DEFAULT_INTERVAL: Milliseconds = 30_000
|
||||
export const JAM_JM_SESSION_REFRESH_INTERVAL: Milliseconds = Math.max(
|
||||
import.meta.env.VITE_JAM_JM_SESSION_REFRESH_INTERVAL ?? JAM_JM_SESSION_REFRESH_DEFAULT_INTERVAL,
|
||||
JAM_JM_SESSION_REFRESH_MIN_INTERVAL,
|
||||
)
|
||||
export const JAM_API_AUTH_TOKEN_RENEW_INTERVAL = Math.round(JM_API_AUTH_TOKEN_EXPIRY * 0.75)
|
||||
export const JAM_API_AUTH_TOKEN_RENEW_INTERVAL: Milliseconds = Math.round(JM_API_AUTH_TOKEN_EXPIRY * 0.75)
|
||||
|
||||
export const JAM_RESCAN_PROGRESS_MIN_INTERVAL = 5_000
|
||||
export const JAM_RESCAN_PROGRESS_DEFAULT_INTERVAL = 21_000
|
||||
export const JAM_RESCAN_PROGRESS_INTERVAL = Math.max(
|
||||
export const JAM_RESCAN_PROGRESS_MIN_INTERVAL: Milliseconds = 5_000
|
||||
export const JAM_RESCAN_PROGRESS_DEFAULT_INTERVAL: Milliseconds = 21_000
|
||||
export const JAM_RESCAN_PROGRESS_INTERVAL: Milliseconds = Math.max(
|
||||
import.meta.env.VITE_JAM_RESCAN_PROGRESS_INTERVAL ?? JAM_RESCAN_PROGRESS_DEFAULT_INTERVAL,
|
||||
JAM_RESCAN_PROGRESS_MIN_INTERVAL,
|
||||
)
|
||||
|
||||
const JAM_SEED_MODAL_MIN_TIMEOUT = 5_000
|
||||
const JAM_SEED_MODAL_DEFAULT_TIMEOUT = 21_000
|
||||
export const JAM_SEED_MODAL_TIMEOUT = Math.max(
|
||||
const JAM_SEED_MODAL_MIN_TIMEOUT: Milliseconds = 5_000
|
||||
const JAM_SEED_MODAL_DEFAULT_TIMEOUT: Milliseconds = 21_000
|
||||
export const JAM_SEED_MODAL_TIMEOUT: Milliseconds = Math.max(
|
||||
import.meta.env.VITE_JAM_SEED_MODAL_TIMEOUT ?? JAM_SEED_MODAL_DEFAULT_TIMEOUT,
|
||||
JAM_SEED_MODAL_MIN_TIMEOUT,
|
||||
)
|
||||
|
|
|
|||
1
src/types/global.d.ts
vendored
1
src/types/global.d.ts
vendored
|
|
@ -1,4 +1,5 @@
|
|||
export type Currency = 'sats' | 'btc'
|
||||
export type AmountSats = number
|
||||
|
||||
export type Milliseconds = number
|
||||
export type Seconds = number
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue