refactor: replace custom field function with const and move update trade logic inside a function

This commit is contained in:
José Oliveira 2021-06-10 22:25:14 +01:00 committed by Josh Harvey
parent f45c783876
commit 8567b7887c
6 changed files with 25 additions and 19 deletions

View file

@ -19,7 +19,8 @@ function fetchExchange (settings, cryptoCode) {
})
}
function buy (settings, cryptoAtoms, fiatCode, cryptoCode, tradeId) {
function buy (settings, tradeEntry, tradeId) {
const { cryptoAtoms, fiatCode, cryptoCode } = tradeEntry
return fetchExchange(settings, cryptoCode)
.then(r => {
if (r.exchangeName === 'mock-exchange') {
@ -29,7 +30,8 @@ function buy (settings, cryptoAtoms, fiatCode, cryptoCode, tradeId) {
})
}
function sell (settings, cryptoAtoms, fiatCode, cryptoCode, tradeId) {
function sell (settings, tradeEntry, tradeId) {
const { cryptoAtoms, fiatCode, cryptoCode } = tradeEntry
return fetchExchange(settings, cryptoCode)
.then(r => {
if (r.exchangeName === 'mock-exchange') {