mirror of
https://github.com/Permissionless-Software-Foundation/bch-dex.git
synced 2026-09-22 01:02:00 -07:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8c17645479 | ||
|
|
fa18daa103 | ||
|
|
b2f7ca3e44 | ||
|
|
3912db4c8d | ||
|
|
9f3d1f866e | ||
|
|
0811024030 | ||
|
|
737d35463d |
Vendored
+1
-1
@@ -80,7 +80,7 @@ export default {
|
|||||||
? (
|
? (
|
||||||
process.env.APISERVER
|
process.env.APISERVER
|
||||||
? process.env.APISERVER
|
? process.env.APISERVER
|
||||||
: 'https://api.fullstack.cash/v5/'
|
: 'https://bch.fullstack.cash/v6/'
|
||||||
)
|
)
|
||||||
: 'https://free-bch.fullstack.cash/',
|
: 'https://free-bch.fullstack.cash/',
|
||||||
|
|
||||||
|
|||||||
Generated
+847
-113
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -74,7 +74,7 @@
|
|||||||
"koa2-ratelimit": "0.9.1",
|
"koa2-ratelimit": "0.9.1",
|
||||||
"libp2p": "2.7.2",
|
"libp2p": "2.7.2",
|
||||||
"line-reader": "0.4.0",
|
"line-reader": "0.4.0",
|
||||||
"minimal-slp-wallet": "5.13.2",
|
"minimal-slp-wallet": "7.1.5",
|
||||||
"mongoose": "5.13.14",
|
"mongoose": "5.13.14",
|
||||||
"node-fetch": "npm:@achingbrain/node-fetch@2.6.7",
|
"node-fetch": "npm:@achingbrain/node-fetch@2.6.7",
|
||||||
"nodemailer": "6.7.5",
|
"nodemailer": "6.7.5",
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ const Offer = new mongoose.Schema({
|
|||||||
immutableDataCid: { type: String, default: null },
|
immutableDataCid: { type: String, default: null },
|
||||||
mutableDataCid: { type: String, default: null },
|
mutableDataCid: { type: String, default: null },
|
||||||
tokenIconUrl: { type: String, default: null },
|
tokenIconUrl: { type: String, default: null },
|
||||||
|
tokenData: { type: Object },
|
||||||
tokenCategories: { type: Array, default: [] },
|
tokenCategories: { type: Array, default: [] },
|
||||||
tokenTags: { type: Array, default: [] },
|
tokenTags: { type: Array, default: [] },
|
||||||
userDataStr: { type: String }, // Token user data
|
userDataStr: { type: String }, // Token user data
|
||||||
|
|||||||
@@ -468,8 +468,9 @@ class WalletAdapter {
|
|||||||
}
|
}
|
||||||
// Ensure the URL points at FullStack.cash, since the web 3 infra does not
|
// Ensure the URL points at FullStack.cash, since the web 3 infra does not
|
||||||
// yet support this call.
|
// yet support this call.
|
||||||
|
// TODO: Remove this once the web 3 infra supports this call.
|
||||||
const oldUrl = this.bchWallet.bchjs.RawTransactions.restURL
|
const oldUrl = this.bchWallet.bchjs.RawTransactions.restURL
|
||||||
this.bchWallet.bchjs.RawTransactions.restURL = 'https://api.fullstack.cash/v5/'
|
this.bchWallet.bchjs.RawTransactions.restURL = 'https://bch.fullstack.cash/v6/'
|
||||||
|
|
||||||
// Use a full node to deserialize the transaction.
|
// Use a full node to deserialize the transaction.
|
||||||
const txObj2 = await this.bchWallet.bchjs.RawTransactions.decodeRawTransaction(txHex)
|
const txObj2 = await this.bchWallet.bchjs.RawTransactions.decodeRawTransaction(txHex)
|
||||||
@@ -480,7 +481,7 @@ class WalletAdapter {
|
|||||||
|
|
||||||
return txObj2
|
return txObj2
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Error in wallet.js/deserializeTx()')
|
console.error('Error in wallet.js/deserializeTx(): ', err)
|
||||||
throw err
|
throw err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -148,6 +148,7 @@ class OfferUseCases {
|
|||||||
const immutableDataCid = tokenData.immutableData
|
const immutableDataCid = tokenData.immutableData
|
||||||
offerEntity.mutableDataCid = mutableDataCid
|
offerEntity.mutableDataCid = mutableDataCid
|
||||||
offerEntity.immutableDataCid = immutableDataCid
|
offerEntity.immutableDataCid = immutableDataCid
|
||||||
|
offerEntity.tokenData = tokenData
|
||||||
|
|
||||||
// Get the mutable data from the cid if it exists.
|
// Get the mutable data from the cid if it exists.
|
||||||
if (mutableDataCid && typeof mutableDataCid === 'string') {
|
if (mutableDataCid && typeof mutableDataCid === 'string') {
|
||||||
@@ -1000,6 +1001,7 @@ class OfferUseCases {
|
|||||||
const immutableDataCid = tokenData.immutableData
|
const immutableDataCid = tokenData.immutableData
|
||||||
offer.mutableDataCid = mutableDataCid
|
offer.mutableDataCid = mutableDataCid
|
||||||
offer.immutableDataCid = immutableDataCid
|
offer.immutableDataCid = immutableDataCid
|
||||||
|
offer.tokenData = tokenData
|
||||||
|
|
||||||
// Get the mutable data from the cid if it exists.
|
// Get the mutable data from the cid if it exists.
|
||||||
if (mutableDataCid && typeof mutableDataCid === 'string') {
|
if (mutableDataCid && typeof mutableDataCid === 'string') {
|
||||||
|
|||||||
@@ -107,14 +107,14 @@ describe('#offer-use-case', () => {
|
|||||||
const result = await uut.createOffer(offerObj)
|
const result = await uut.createOffer(offerObj)
|
||||||
assert.isFalse(result)
|
assert.isFalse(result)
|
||||||
})
|
})
|
||||||
|
it('should create offer with token data', async () => {
|
||||||
it('should create offer with mutable data', async () => {
|
|
||||||
const tokenDataMock = mockData.nftTokenData01
|
const tokenDataMock = mockData.nftTokenData01
|
||||||
const offerObj = mockData.offerMockData
|
const offerObj = mockData.offerMockData
|
||||||
const mutableDataMock = mockData.mutableDataMock
|
const mutableDataMock = mockData.mutableDataMock
|
||||||
|
const offerEntityMock = Object.assign({}, mockData.offerMockData.data)
|
||||||
|
|
||||||
// Mock dependencies
|
// Mock dependencies
|
||||||
// sandbox.stub(uut.adapters.wallet.bchWallet, 'utxoIsValid').resolves(false)
|
sandbox.stub(uut.offerEntity, 'validate').returns(offerEntityMock)
|
||||||
sandbox.stub(uut, 'findOfferByTxid').throws(new Error('offer not found'))
|
sandbox.stub(uut, 'findOfferByTxid').throws(new Error('offer not found'))
|
||||||
sandbox.stub(uut.retryQueue, 'addToQueue')
|
sandbox.stub(uut.retryQueue, 'addToQueue')
|
||||||
.onCall(0).resolves({}) // Utxo Status call
|
.onCall(0).resolves({}) // Utxo Status call
|
||||||
@@ -123,6 +123,31 @@ describe('#offer-use-case', () => {
|
|||||||
|
|
||||||
const result = await uut.createOffer(offerObj)
|
const result = await uut.createOffer(offerObj)
|
||||||
assert.isTrue(result)
|
assert.isTrue(result)
|
||||||
|
console.log('offerEntityMock', offerEntityMock)
|
||||||
|
assert.property(offerEntityMock, 'tokenData')
|
||||||
|
})
|
||||||
|
it('should create offer with mutable data', async () => {
|
||||||
|
const tokenDataMock = mockData.nftTokenData01
|
||||||
|
const offerObj = mockData.offerMockData
|
||||||
|
const mutableDataMock = mockData.mutableDataMock
|
||||||
|
const offerEntityMock = Object.assign({}, mockData.offerMockData.data)
|
||||||
|
|
||||||
|
// Mock dependencies
|
||||||
|
sandbox.stub(uut.offerEntity, 'validate').returns(offerEntityMock)
|
||||||
|
sandbox.stub(uut, 'findOfferByTxid').throws(new Error('offer not found'))
|
||||||
|
sandbox.stub(uut.retryQueue, 'addToQueue')
|
||||||
|
.onCall(0).resolves({}) // Utxo Status call
|
||||||
|
.onCall(1).resolves(tokenDataMock) // Token Data call
|
||||||
|
.onCall(2).resolves(mutableDataMock)
|
||||||
|
|
||||||
|
const result = await uut.createOffer(offerObj)
|
||||||
|
assert.isTrue(result)
|
||||||
|
console.log('offerEntityMock', offerEntityMock)
|
||||||
|
|
||||||
|
assert.property(offerEntityMock, 'tokenIconUrl')
|
||||||
|
assert.property(offerEntityMock, 'tokenCategories')
|
||||||
|
assert.property(offerEntityMock, 'tokenTags')
|
||||||
|
assert.property(offerEntityMock, 'lastUpdatedTokenData')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should skip userData stringify error', async () => {
|
it('should skip userData stringify error', async () => {
|
||||||
@@ -1106,6 +1131,12 @@ describe('#offer-use-case', () => {
|
|||||||
const offer = await uut.syncOfferMutableData('tokenId')
|
const offer = await uut.syncOfferMutableData('tokenId')
|
||||||
assert.isObject(offer)
|
assert.isObject(offer)
|
||||||
assert.isNumber(offer.lastUpdatedTokenData)
|
assert.isNumber(offer.lastUpdatedTokenData)
|
||||||
|
|
||||||
|
assert.property(offer, 'tokenData')
|
||||||
|
assert.property(offer, 'tokenIconUrl')
|
||||||
|
assert.property(offer, 'tokenCategories')
|
||||||
|
assert.property(offer, 'tokenTags')
|
||||||
|
assert.property(offer, 'lastUpdatedTokenData')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should skip userData stringify error', async () => {
|
it('should skip userData stringify error', async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user