mirror of
https://github.com/Permissionless-Software-Foundation/bch-dex.git
synced 2026-09-21 16:52:00 -07:00
fix(createOffer()): Prevening duplicate Offers from being created
This commit is contained in:
@@ -77,7 +77,7 @@ class Adapters {
|
||||
|
||||
// Open the wallet file
|
||||
const walletData = await this.wallet.openWallet()
|
||||
console.log('walletData: ', walletData)
|
||||
// console.log('walletData: ', walletData)
|
||||
|
||||
// Instance the wallet.
|
||||
await this.wallet.instanceWallet(walletData, this.bchjs)
|
||||
|
||||
@@ -46,6 +46,14 @@ class OfferUseCases {
|
||||
try {
|
||||
console.log('Use Case createOffer(offerObj): ', offerObj)
|
||||
|
||||
// Return if Offer already exists in database with the same P2WDB CID.
|
||||
try {
|
||||
await this.findOfferByHash(offerObj.hash)
|
||||
|
||||
console.log('Offer already found in local database.')
|
||||
return false
|
||||
} catch (err) { /* exit quietly */ }
|
||||
|
||||
// console.log('this.adapters.bchjs: ', this.adapters.bchjs)
|
||||
|
||||
// Input Validation
|
||||
|
||||
@@ -35,11 +35,15 @@ class OrderLib {
|
||||
console.log('entryObj.makerAddr: ', entryObj.makerAddr)
|
||||
|
||||
// Get Ticker for token ID.
|
||||
// TODO: Move this below the orderEntity.validate() call.
|
||||
const tokenData = await this.adapters.wallet.bchWallet.getTxData([entryObj.tokenId])
|
||||
// console.log(`tokenData: ${JSON.stringify(tokenData, null, 2)}`)
|
||||
entryObj.ticker = tokenData[0].tokenTicker
|
||||
|
||||
// Input Validation
|
||||
// TODO: Remove ticker from validation.
|
||||
// TODO: Rename validate() to inputValidate(). Create fullValidate() that
|
||||
// validates a fully hydrated Order entity.
|
||||
const orderEntity = this.orderEntity.validate(entryObj)
|
||||
console.log('orderEntity: ', orderEntity)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user