Compare commits

..
1 Commits
Author SHA1 Message Date
Chris Troutner 94cfb4c785 Customizing for temp demo 2022-10-09 10:32:51 -07:00
8 changed files with 23 additions and 64 deletions
+8 -12
View File
@@ -38,7 +38,7 @@
"mongoose": "5.13.14",
"node-fetch": "npm:@achingbrain/node-fetch@2.6.7",
"nodemailer": "6.7.5",
"p2wdb-esm": "2.2.8",
"p2wdb-esm": "2.2.7",
"passport-local": "1.0.0",
"public-ip": "4.0.4",
"winston": "3.3.3",
@@ -8853,8 +8853,6 @@
"node_modules/node-fetch": {
"name": "@achingbrain/node-fetch",
"version": "2.6.7",
"resolved": "https://registry.npmjs.org/@achingbrain/node-fetch/-/node-fetch-2.6.7.tgz",
"integrity": "sha512-iTASGs+HTFK5E4ZqcMsHmeJ4zodyq8L38lZV33jwqcBJYoUt3HjN4+ot+O9/0b+ke8ddE7UgOtVuZN/OkV19/g==",
"license": "MIT",
"engines": {
"node": "4.x || >=6.0.0"
@@ -11867,9 +11865,9 @@
}
},
"node_modules/p2wdb-esm": {
"version": "2.2.8",
"resolved": "https://registry.npmjs.org/p2wdb-esm/-/p2wdb-esm-2.2.8.tgz",
"integrity": "sha512-wqTj6HaUdSMDFjp9a2lAGUembGtLxDxBH+PNUNnCHG1RSrLsrFrYFzMc48RlW9BGWybqypstrhORHrlZ30aygA==",
"version": "2.2.7",
"resolved": "https://registry.npmjs.org/p2wdb-esm/-/p2wdb-esm-2.2.7.tgz",
"integrity": "sha512-528nGjthkkAf8n4H7jSX52pCpsprKgRfZKB4emIYHkOFo9rHYOOZMLlbRkluYtAThjVxJd7w3fyplZFPEXzlyA==",
"dependencies": {
"@chris.troutner/retry-queue-commonjs": "1.0.8",
"axios": "0.24.0"
@@ -21601,9 +21599,7 @@
}
},
"node-fetch": {
"version": "npm:@achingbrain/node-fetch@2.6.7",
"resolved": "https://registry.npmjs.org/@achingbrain/node-fetch/-/node-fetch-2.6.7.tgz",
"integrity": "sha512-iTASGs+HTFK5E4ZqcMsHmeJ4zodyq8L38lZV33jwqcBJYoUt3HjN4+ot+O9/0b+ke8ddE7UgOtVuZN/OkV19/g=="
"version": "npm:@achingbrain/node-fetch@2.6.7"
},
"node-forge": {
"version": "1.3.1"
@@ -23630,9 +23626,9 @@
"dev": true
},
"p2wdb-esm": {
"version": "2.2.8",
"resolved": "https://registry.npmjs.org/p2wdb-esm/-/p2wdb-esm-2.2.8.tgz",
"integrity": "sha512-wqTj6HaUdSMDFjp9a2lAGUembGtLxDxBH+PNUNnCHG1RSrLsrFrYFzMc48RlW9BGWybqypstrhORHrlZ30aygA==",
"version": "2.2.7",
"resolved": "https://registry.npmjs.org/p2wdb-esm/-/p2wdb-esm-2.2.7.tgz",
"integrity": "sha512-528nGjthkkAf8n4H7jSX52pCpsprKgRfZKB4emIYHkOFo9rHYOOZMLlbRkluYtAThjVxJd7w3fyplZFPEXzlyA==",
"requires": {
"@chris.troutner/retry-queue-commonjs": "1.0.8",
"axios": "0.24.0"
+1 -1
View File
@@ -57,7 +57,7 @@
"mongoose": "5.13.14",
"node-fetch": "npm:@achingbrain/node-fetch@2.6.7",
"nodemailer": "6.7.5",
"p2wdb-esm": "2.2.8",
"p2wdb-esm": "2.2.7",
"passport-local": "1.0.0",
"public-ip": "4.0.4",
"winston": "3.3.3",
+1 -1
View File
@@ -53,7 +53,7 @@ RUN git clone https://github.com/Permissionless-Software-Foundation/bch-dex-ui-v
WORKDIR /home/safeuser/bch-dex-ui-v2
# For development: switch to unstable branch
RUN git checkout ct-unstable
RUN git checkout temp-demo
# Install dependencies
#RUN mkdir .ipfsdata
+8 -8
View File
@@ -70,10 +70,10 @@ services:
restart: always
bch-dex:
#build:
# context: ./bch-dex/
# dockerfile: Dockerfile
image: christroutner/bch-dex:v2.0.12
build:
context: ./bch-dex/
dockerfile: Dockerfile
#image: christroutner/bch-dex:v2.0.8
container_name: bch-dex
environment:
CONSUMER_URL: 'https://free-bch.fullstack.cash'
@@ -94,10 +94,10 @@ services:
restart: always
dex-ui:
#build:
# context: ./bch-dex-ui/
# dockerfile: Dockerfile
image: christroutner/bch-dex-ui:v1.2.4
build:
context: ./bch-dex-ui/
dockerfile: Dockerfile
#image: christroutner/bch-dex-ui:v1.2.4
container_name: dex-ui
environment:
SERVER: 'http://192.168.2.3'
@@ -47,21 +47,6 @@ class OrderRESTControllerLib {
}
}
// curl -X GET http://localhost:5700/order/list/all/0
async listOrders (ctx) {
try {
let page = ctx.params.page
if (!page) page = 0
const offers = await _this.useCases.order.listOrders(page)
ctx.body = offers
} catch (err) {
console.log('Error in listOrders REST API handler: ', err)
_this.handleError(ctx, err)
}
}
// DRY error handler
handleError (ctx, err) {
console.log('err', err)
-1
View File
@@ -50,7 +50,6 @@ class OrderRouter {
// Define the routes and attach the controller.
this.router.post('/', _this.orderRESTController.createOrder)
this.router.get('/list/all/:page', _this.orderRESTController.listOrders)
// Attach the Controller routes to the Koa app.
app.use(_this.router.routes())
+4 -5
View File
@@ -306,7 +306,7 @@ class OfferUseCases {
console.log(`utxos: ${JSON.stringify(utxos, null, 2)}`)
// Calculate amount of sats to generate a counter offer.
let satsToMove = Math.ceil(offerInfo.numTokens * parseInt(offerInfo.rateInBaseUnit))
let satsToMove = offerInfo.numTokens * parseInt(offerInfo.rateInBaseUnit)
if (isNaN(satsToMove)) {
throw new Error('Could not calculate the amount of BCH to generate counter offer')
}
@@ -385,7 +385,7 @@ class OfferUseCases {
// Sell Offer
// Calculate the sats needed
const satsNeeded = Math.ceil(offerEntity.numTokens * parseInt(offerEntity.rateInBaseUnit))
const satsNeeded = offerEntity.numTokens * parseInt(offerEntity.rateInBaseUnit)
if (isNaN(satsNeeded)) {
throw new Error('Could not calculate sats needed!')
}
@@ -467,7 +467,7 @@ class OfferUseCases {
console.log(`txObj: ${JSON.stringify(txObj, null, 2)}`)
// Ensure the 3rd output (vout=2) contains the required amount of BCH.
const satsToReceive = Math.ceil(orderData.numTokens * parseInt(orderData.rateInBaseUnit))
const satsToReceive = orderData.numTokens * parseInt(orderData.rateInBaseUnit)
if (isNaN(satsToReceive)) {
throw new Error('Could not calculate the amount of BCH offered in the Counter Offer')
}
@@ -579,8 +579,7 @@ class OfferUseCases {
}
// If the Offer UTXO is spent, delete the Offer model.
if (utxoStatus === false) {
console.log('utxoStatus: ', utxoStatus)
if (!utxoStatus) {
console.log(`Spent UTXO detected. Deleting this Offer: ${JSON.stringify(thisOffer, null, 2)}`)
await thisOffer.remove()
}
+1 -21
View File
@@ -10,8 +10,6 @@ import wlogger from '../adapters/wlogger.js'
import OrderEntity from '../entities/order.js'
import config from '../../config/index.js'
const DEFAULT_ENTRIES_PER_PAGE = 20
class OrderLib {
constructor (localConfig = {}) {
// console.log('User localConfig: ', localConfig)
@@ -237,8 +235,7 @@ class OrderLib {
}
// If the Order UTXO is spent, delete the Order model.
if (utxoStatus === false) {
console.log('utxoStatus: ', utxoStatus)
if (!utxoStatus) {
console.log(`Spent UTXO detected. Deleting this Order: ${JSON.stringify(thisOrder, null, 2)}`)
await thisOrder.remove()
}
@@ -248,23 +245,6 @@ class OrderLib {
throw err
}
}
async listOrders (page = 0) {
try {
const data = await this.OrderModel.find({})
// Sort entries so newest entries show first.
.sort('-timestamp')
// Skip to the start of the selected page.
.skip(page * DEFAULT_ENTRIES_PER_PAGE)
// Only return 20 results.
.limit(DEFAULT_ENTRIES_PER_PAGE)
return data
} catch (error) {
console.error('Error in use-cases/order/listOrders()')
throw error
}
}
}
export default OrderLib