fix(marketplace): honor configured fees and validate result text
Display the fee supplied by the marketplace service. Use the unconfirmed notice when the returned message is missing or invalid.
This commit is contained in:
1 parent
0678c3bf27
commit
7e8fd4788e
1 file changed
+3
-3
@@ -34,7 +34,7 @@ const t = (key, params) => WtoUi.tr(T, key, params);
|
|||||||
const $ = (id) => document.getElementById(id);
|
const $ = (id) => document.getElementById(id);
|
||||||
const wantedItem = WtoUi.query.get('n') || '';
|
const wantedItem = WtoUi.query.get('n') || '';
|
||||||
|
|
||||||
let state = { accounts: [], currentUserId: '', balance: { gjnCents: 0, goldenEagles: 0 }, sellFeeRate: 0.15, listings: [] };
|
let state = { accounts: [], currentUserId: '', balance: { gjnCents: 0, goldenEagles: 0 }, listings: [] };
|
||||||
const activeCats = new Set();
|
const activeCats = new Set();
|
||||||
let openedWanted = false;
|
let openedWanted = false;
|
||||||
let tradeNoticeId = 0;
|
let tradeNoticeId = 0;
|
||||||
@@ -165,7 +165,7 @@ function openDetail(listing) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function fillOrderColumns(detail, listing) {
|
function fillOrderColumns(detail, listing) {
|
||||||
const fee = Math.round((state.sellFeeRate || 0) * 100);
|
const fee = Math.round(state.sellFeeRate * 100);
|
||||||
const sellCol = detail.querySelector('.sell-col');
|
const sellCol = detail.querySelector('.sell-col');
|
||||||
const buyCol = detail.querySelector('.buy-col');
|
const buyCol = detail.querySelector('.buy-col');
|
||||||
const noAccount = !state.currentUserId;
|
const noAccount = !state.currentUserId;
|
||||||
@@ -206,7 +206,7 @@ async function trade(url, body, listing) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const message = WtoUi.text(result?.message);
|
const message = WtoUi.text(result?.message);
|
||||||
if (typeof result?.ok !== 'boolean' || !message) {
|
if (typeof result?.ok !== 'boolean' || typeof message !== 'string' || !message) {
|
||||||
showResult(t('tradeUnconfirmed'), false);
|
showResult(t('tradeUnconfirmed'), false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user