@psf/bch-js 6.7.4 → 6.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/price.js +36 -0
- package/test/integration/price.js +9 -0
package/package.json
CHANGED
package/src/price.js
CHANGED
|
@@ -230,6 +230,42 @@ class Price {
|
|
|
230
230
|
else throw err
|
|
231
231
|
}
|
|
232
232
|
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* @api price.getPsffppPrice() getPsffppPrice()
|
|
236
|
+
* @apiName Price getPsffppPrice()
|
|
237
|
+
* @apiGroup Price
|
|
238
|
+
* @apiDescription Return the cost in PSF tokens to write 1MB of data to the PSFFPP
|
|
239
|
+
* Find out more at PSFFPP.com. This is a IPFS pinning service that can pin
|
|
240
|
+
* up to 100MB per transaction into its network. The cost is denominated in
|
|
241
|
+
* PSF SLP tokens. The endpoint returns the cost to pin 1MB of data to the
|
|
242
|
+
* PSFFPP network.
|
|
243
|
+
*
|
|
244
|
+
* @apiExample Example usage:
|
|
245
|
+
*(async () => {
|
|
246
|
+
* try {
|
|
247
|
+
* let current = await bchjs.Price.getPsffppPrice();
|
|
248
|
+
* console.log(current);
|
|
249
|
+
* } catch(err) {
|
|
250
|
+
* console.error(err)
|
|
251
|
+
* }
|
|
252
|
+
*})()
|
|
253
|
+
*
|
|
254
|
+
* // 0.08335233
|
|
255
|
+
*/
|
|
256
|
+
async getPsffppPrice () {
|
|
257
|
+
try {
|
|
258
|
+
const response = await this.axios.get(
|
|
259
|
+
`${this.restURL}price/psffpp`,
|
|
260
|
+
this.axiosOptions
|
|
261
|
+
)
|
|
262
|
+
|
|
263
|
+
return response.data.writePrice
|
|
264
|
+
} catch (err) {
|
|
265
|
+
if (err.response && err.response.data) throw err.response.data
|
|
266
|
+
else throw err
|
|
267
|
+
}
|
|
268
|
+
}
|
|
233
269
|
}
|
|
234
270
|
|
|
235
271
|
module.exports = Price
|
|
@@ -52,6 +52,15 @@ describe('#price', () => {
|
|
|
52
52
|
assert.property(result, 'CAD')
|
|
53
53
|
})
|
|
54
54
|
})
|
|
55
|
+
|
|
56
|
+
describe('#getPsffppPrice', () => {
|
|
57
|
+
it('should get the price of BCH in several currencies', async () => {
|
|
58
|
+
const result = await bchjs.Price.getPsffppPrice()
|
|
59
|
+
// console.log(result)
|
|
60
|
+
|
|
61
|
+
assert.isNumber(result)
|
|
62
|
+
})
|
|
63
|
+
})
|
|
55
64
|
})
|
|
56
65
|
|
|
57
66
|
function sleep (ms) {
|