Merge pull request #198 from gerlofvanek/doge-fixes-3
Some checks failed
ci / ci (3.12) (push) Has been cancelled

Fix Swap Type + Set adaptor_sig default if both adaptor/secret as option.
This commit is contained in:
tecnovert 2025-01-07 19:19:42 +00:00 committed by GitHub
commit 878a145420
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -514,8 +514,8 @@ function set_swap_type_enabled(coin_from, coin_to, swap_type) {
'8', /* PART_ANON */
'7', /* PART_BLIND */
'13', /* FIRO */
'17', /* BCH */
'18' /* DOGE */
'18', /* DOGE */
'17' /* BCH */
];
const secret_hash_only_coins = [
'11', /* PIVX */
@ -524,12 +524,15 @@ function set_swap_type_enabled(coin_from, coin_to, swap_type) {
let make_hidden = false;
if (adaptor_sig_only_coins.includes(coin_from) || adaptor_sig_only_coins.includes(coin_to)) {
coin_from = String(coin_from);
coin_to = String(coin_to);
if (adaptor_sig_only_coins.indexOf(coin_from) !== -1 || adaptor_sig_only_coins.indexOf(coin_to) !== -1) {
swap_type.disabled = true;
swap_type.value = 'xmr_swap';
make_hidden = true;
swap_type.classList.add('select-disabled');
} else if (secret_hash_only_coins.includes(coin_from) && secret_hash_only_coins.includes(coin_to)) {
} else if (secret_hash_only_coins.indexOf(coin_from) !== -1 || secret_hash_only_coins.indexOf(coin_to) !== -1) {
swap_type.disabled = true;
swap_type.value = 'seller_first';
make_hidden = true;
@ -537,6 +540,7 @@ function set_swap_type_enabled(coin_from, coin_to, swap_type) {
} else {
swap_type.disabled = false;
swap_type.classList.remove('select-disabled');
swap_type.value = 'xmr_swap';
}
let swap_type_hidden = document.getElementById('swap_type_hidden');
@ -554,6 +558,23 @@ function set_swap_type_enabled(coin_from, coin_to, swap_type) {
}
}
document.addEventListener('DOMContentLoaded', function() {
const coin_from = document.getElementById('coin_from');
const coin_to = document.getElementById('coin_to');
if (coin_from && coin_to) {
coin_from.addEventListener('change', function() {
const swap_type = document.getElementById('swap_type');
set_swap_type_enabled(this.value, coin_to.value, swap_type);
});
coin_to.addEventListener('change', function() {
const swap_type = document.getElementById('swap_type');
set_swap_type_enabled(coin_from.value, this.value, swap_type);
});
}
});
function set_rate(value_changed) {
const coin_from = document.getElementById('coin_from').value;
const coin_to = document.getElementById('coin_to').value;