Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: basic fee settings #522

Merged
merged 50 commits into from
Oct 4, 2022
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
1108112
feat: add refreshConfigValues to ServiceConfigContext
theborakompanioni Sep 26, 2022
badc227
chore: add api method to post config values
theborakompanioni Sep 27, 2022
7a86eed
feat: add updateConfigValues to ServiceConfigContext
theborakompanioni Sep 27, 2022
a50401e
feat(fees): ability to update fee specific config vars
theborakompanioni Sep 27, 2022
2e3d0ce
chore(fees): display error message on update failure
theborakompanioni Sep 27, 2022
22e207b
chore(fees): add block sprite and adapt description
theborakompanioni Sep 27, 2022
0a4ebee
ui(fee): wrap form sections in accordion
theborakompanioni Sep 27, 2022
85f3c2b
feat(fees): add ability to set fee randomization factor
theborakompanioni Sep 27, 2022
b8c174c
ui(fees): use placeholder instead of loading spinner
theborakompanioni Sep 27, 2022
6253f8f
fix(fees): proper error messages depending on fee value unit
theborakompanioni Sep 28, 2022
ef2128a
fix(fees): dont decline zero as input value
theborakompanioni Sep 28, 2022
3706459
chore(fees): wording
theborakompanioni Sep 28, 2022
2558d43
fix(fees): sats/vbyte mininum is exclusive
theborakompanioni Sep 28, 2022
ca1ab97
refactor: move percentage/factor functions to utils
theborakompanioni Sep 28, 2022
9dcc429
fix(i18n): number strings
dergigi Sep 28, 2022
944f34c
feat(fees): improve wording
dergigi Sep 28, 2022
d5e3e85
fix(i18n): title case for title
dergigi Sep 28, 2022
20937ae
feat(fees): remove superfluous label
dergigi Sep 28, 2022
92ee21a
feat(fees): improve wording
dergigi Sep 28, 2022
4eb8de9
feat(fees): more realistic example
dergigi Sep 28, 2022
3f269e3
fix(fees): consistency; vbyte -> vByte
dergigi Sep 28, 2022
a1e3a3c
fix(fees): consistency; satoshi -> sats
dergigi Sep 28, 2022
c553680
feat(i18n): better verb
dergigi Sep 28, 2022
f77c8be
feat(fees): maker -> collaborator
dergigi Sep 28, 2022
8b5edf6
Revert "feat(fees): remove superfluous label"
dergigi Sep 28, 2022
6bbc50e
feat(fees): improve wording around base fee and block target
dergigi Sep 28, 2022
e4ba689
fix(fees): parse max_cj_fee_abs as integer
theborakompanioni Sep 29, 2022
0b7c7d3
fix(fees): min/max value for absolute fee
theborakompanioni Sep 29, 2022
863b33f
fix(fees): parse block target as integer
theborakompanioni Sep 29, 2022
8ef4956
fix(fees): allow 0% maximum relative fee
theborakompanioni Sep 29, 2022
893a074
fix(fees): use 'absurd_fee_per_kb' as upper level for fee
theborakompanioni Sep 29, 2022
d6cd73e
chore(fees): lower max relative fee val from 50% to 20%
theborakompanioni Sep 29, 2022
025d0db
fix(fees): let users specify 1sat/vbyte as fee
theborakompanioni Sep 29, 2022
4a37f2c
fix(fees): add language attribute on form element
theborakompanioni Sep 29, 2022
b4fb840
feat(fees): improve wording & remove fee from label
dergigi Sep 29, 2022
f578474
feat(fees): better fee randomization wording
dergigi Sep 29, 2022
e45d5f1
feat(fees): better fee label wording
dergigi Sep 29, 2022
8530cf9
feat(fees): use smaller numbers in example
dergigi Sep 29, 2022
fb2cc20
feat(fees): improve wording
dergigi Sep 29, 2022
49044d3
feat(fees): improve wording
dergigi Sep 29, 2022
95843b5
feat(fees): improve base fee wording
dergigi Sep 29, 2022
10831a4
Merge branch 'master' into fees
theborakompanioni Oct 2, 2022
20f4311
chore(fees): remove dead code
theborakompanioni Oct 2, 2022
d1175f1
ui(fees): colorize accordion header on form errors
theborakompanioni Oct 2, 2022
5f7b96e
ui(fees): add info icon to cj fee description text
theborakompanioni Oct 2, 2022
bca8c48
fix(fees): wording
dergigi Oct 3, 2022
3d109ba
docs(fees): fix typo
dergigi Oct 3, 2022
da21a2f
chore: fix comment
theborakompanioni Oct 3, 2022
67641f9
review(fees): lower max valid form value for absolute fee
theborakompanioni Oct 3, 2022
817db95
review(fees): lower max valid form value for relative fee
theborakompanioni Oct 3, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions public/sprite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 1 addition & 14 deletions src/components/Earn.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import * as Api from '../libs/JmWalletApi'
import styles from './Earn.module.css'
import { OrderbookOverlay } from './Orderbook'
import Balance from './Balance'
import { factorToPercentage, percentageToFactor } from '../utils'

// In order to prevent state mismatch, the 'maker stop' response is delayed shortly.
// Even though the API response suggests that the maker has started or stopped immediately, it seems that this is not always the case.
Expand Down Expand Up @@ -73,20 +74,6 @@ const initialFormValues = (settings) => ({
FORM_INPUT_DEFAULT_VALUES.minsize,
})

const percentageToFactor = (val, precision = 6) => {
// Value cannot just be divided
// e.g. ✗ 0.0027 / 100 == 0.000027000000000000002
// but: ✓ Number((0.0027 / 100).toFixed(6)) = 0.000027
return Number((val / 100).toFixed(precision))
}

const factorToPercentage = (val, precision = 6) => {
// Value cannot just be divided
// e.g. ✗ 0.000027 * 100 == 0.0026999999999999997
// but: ✓ Number((0.000027 * 100).toFixed(6)) = 0.0027
return Number((val * 100).toFixed(precision))
}

const renderOrderType = (val, t) => {
if (isAbsoluteOffer(val)) {
return <rb.Badge bg="info">{t('earn.current.text_offer_type_absolute')}</rb.Badge>
Expand Down
16 changes: 16 additions & 0 deletions src/components/Settings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { fetchFeatures } from '../libs/JamApi'
import { routes } from '../constants/routes'
import languages from '../i18n/languages'
import styles from './Settings.module.css'
import FeeConfigModal from './settings/FeeConfigModal'

function SeedModal({ show = false, onHide }) {
const { t } = useTranslation()
Expand Down Expand Up @@ -91,6 +92,7 @@ function SeedModal({ show = false, onHide }) {

export default function Settings({ stopWallet }) {
const [showingSeed, setShowingSeed] = useState(false)
const [showingFeeConfig, setShowingFeeConfig] = useState(false)
const [lockingWallet, setLockingWallet] = useState(false)
const [showConfirmLockModal, setShowConfirmLockModal] = useState(null)
const [showLogsEnabled, setShowLogsEnabled] = useState(false)
Expand Down Expand Up @@ -235,6 +237,20 @@ export default function Settings({ stopWallet }) {
</rb.Dropdown.Menu>
</rb.Dropdown>

{currentWallet && (
<>
<rb.Button
variant="outline-dark"
className={styles['settings-btn']}
onClick={(e) => setShowingFeeConfig(true)}
>
<Sprite symbol="coins" width="24" height="24" />
{t('settings.show_fee_config')}
</rb.Button>
{showingFeeConfig && <FeeConfigModal show={showingFeeConfig} onHide={() => setShowingFeeConfig(false)} />}
</>
)}

{currentWallet && showLogsEnabled && (
<>
<rb.Button variant="outline-dark" className={styles['settings-btn']} onClick={() => setShowingLogs(true)}>
Expand Down
40 changes: 40 additions & 0 deletions src/components/settings/FeeConfigModal.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
.feeConfigModal .accordionLoader {
height: 3.25rem;
margin: 1px 0;
}

.feeConfigModal form input:not([type='checkbox']) {
height: 3.5rem;
}

.feeConfigModal form :global .form-label {
margin-bottom: 0 !important;
}
.feeConfigModal form :global .form-label ~ .form-text {
display: block;
margin-top: 0 !important;
margin-bottom: 0.5rem !important;
}

.inputGroupText {
width: 5ch;
display: inline-flex;
justify-content: center;
align-items: center;
font-size: 1.2rem;
}

.modalFooter .buttonContainer {
width: 100%;
display: flex !important;
justify-content: center !important;
gap: 1rem;
background-color: transparent !important;
}

.modalFooter .buttonContainer :global .btn {
flex-grow: 1;
min-height: 2.8rem;
font-weight: 500;
border-color: none !important;
}
Loading