mirror of
https://github.com/Permissionless-Software-Foundation/bch-js.git
synced 2026-09-21 16:51:59 -07:00
fix(tokenUtxoDetails): porting fix from slp-sdk to Utils.tokenUtxoDetails
This commit is contained in:
+6
-2
@@ -1141,13 +1141,17 @@ class Utils {
|
||||
const thisUtxo = utxos[i]
|
||||
// console.log(`thisUtxo: ${JSON.stringify(thisUtxo, null, 2)}`)
|
||||
|
||||
const thisValidation = validations.filter(x => x.txid === thisUtxo.txid)
|
||||
const thisValidation = validations.filter(x => {
|
||||
if (x !== null) return x.txid === thisUtxo.txid
|
||||
|
||||
return false
|
||||
})
|
||||
// console.log(
|
||||
// `thisValidation: ${JSON.stringify(thisValidation, null, 2)}`
|
||||
// )
|
||||
|
||||
// If the utxo is not SLP, then skip the loop.
|
||||
if (!thisValidation[0].valid) {
|
||||
if (!thisValidation[0] || !thisValidation[0].valid) {
|
||||
outAry[i] = false
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -1166,6 +1166,42 @@ describe("#SLP Utils", () => {
|
||||
assert2.equal(result.length, 2)
|
||||
assert2.equal(result[0], false)
|
||||
})
|
||||
|
||||
it("should return false for BCH-only UTXOs", async () => {
|
||||
// Mock the call to REST API
|
||||
if (process.env.TEST === "unit") {
|
||||
// Stub the call to validateTxid
|
||||
sandbox.stub(slp.Utils, "validateTxid").resolves([null, null])
|
||||
}
|
||||
|
||||
const utxos = [
|
||||
{
|
||||
txid:
|
||||
"a937f792c7c9eb23b4f344ce5c233d1ac0909217d0a504d71e6b1e4efb864a3b",
|
||||
vout: 0,
|
||||
amount: 0.00001,
|
||||
satoshis: 1000,
|
||||
confirmations: 0,
|
||||
ts: 1578424704
|
||||
},
|
||||
{
|
||||
txid:
|
||||
"53fd141c2e999e080a5860887441a2c45e9cbe262027e2bd2ac998fc76e43c44",
|
||||
vout: 0,
|
||||
amount: 0.00001,
|
||||
satoshis: 1000,
|
||||
confirmations: 0,
|
||||
ts: 1578424634
|
||||
}
|
||||
]
|
||||
|
||||
const data = await slp.Utils.tokenUtxoDetails(utxos)
|
||||
// console.log(`data: ${JSON.stringify(data, null, 2)}`)
|
||||
|
||||
assert2.isArray(data)
|
||||
assert2.equal(false, data[0])
|
||||
assert2.equal(false, data[1])
|
||||
})
|
||||
})
|
||||
|
||||
describe("#txDetails", () => {
|
||||
|
||||
Reference in New Issue
Block a user