File tree Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -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
Original file line number Diff line number Diff line change @@ -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 ) {
You can’t perform that action at this time.
0 commit comments