mirror of
https://github.com/Permissionless-Software-Foundation/bch-js.git
synced 2026-09-21 16:51:59 -07:00
feat(getPsffppPrice): New endpoint to get PSFFPP pin price
This commit is contained in:
@@ -230,6 +230,42 @@ class Price {
|
|||||||
else throw err
|
else throw err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @api price.getPsffppPrice() getPsffppPrice()
|
||||||
|
* @apiName Price getPsffppPrice()
|
||||||
|
* @apiGroup Price
|
||||||
|
* @apiDescription Return the cost in PSF tokens to write 1MB of data to the PSFFPP
|
||||||
|
* Find out more at PSFFPP.com. This is a IPFS pinning service that can pin
|
||||||
|
* up to 100MB per transaction into its network. The cost is denominated in
|
||||||
|
* PSF SLP tokens. The endpoint returns the cost to pin 1MB of data to the
|
||||||
|
* PSFFPP network.
|
||||||
|
*
|
||||||
|
* @apiExample Example usage:
|
||||||
|
*(async () => {
|
||||||
|
* try {
|
||||||
|
* let current = await bchjs.Price.getPsffppPrice();
|
||||||
|
* console.log(current);
|
||||||
|
* } catch(err) {
|
||||||
|
* console.error(err)
|
||||||
|
* }
|
||||||
|
*})()
|
||||||
|
*
|
||||||
|
* // 0.08335233
|
||||||
|
*/
|
||||||
|
async getPsffppPrice () {
|
||||||
|
try {
|
||||||
|
const response = await this.axios.get(
|
||||||
|
`${this.restURL}price/psffpp`,
|
||||||
|
this.axiosOptions
|
||||||
|
)
|
||||||
|
|
||||||
|
return response.data.writePrice
|
||||||
|
} catch (err) {
|
||||||
|
if (err.response && err.response.data) throw err.response.data
|
||||||
|
else throw err
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Price
|
module.exports = Price
|
||||||
|
|||||||
@@ -52,6 +52,15 @@ describe('#price', () => {
|
|||||||
assert.property(result, 'CAD')
|
assert.property(result, 'CAD')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('#getPsffppPrice', () => {
|
||||||
|
it('should get the price of BCH in several currencies', async () => {
|
||||||
|
const result = await bchjs.Price.getPsffppPrice()
|
||||||
|
// console.log(result)
|
||||||
|
|
||||||
|
assert.isNumber(result)
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
function sleep (ms) {
|
function sleep (ms) {
|
||||||
|
|||||||
Reference in New Issue
Block a user