From 01a4d0f1aa981723d249ceba8456ab5a1b2cf832 Mon Sep 17 00:00:00 2001 From: Chris Troutner Date: Fri, 2 Jun 2023 15:03:25 -0700 Subject: [PATCH 1/2] Adding integration-test-pearson.sh to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index b992c25..3007c9e 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ wallet.json integration-test-sweet.sh integration-test-ss.sh integration-test-bitfinex.sh +integration-test-pearson.sh docs/ coverage/ From b34040cd08fb7a322361b9bc673dd1c6fe6ebcc7 Mon Sep 17 00:00:00 2001 From: Chris Troutner Date: Tue, 3 Sep 2024 19:28:22 -0700 Subject: [PATCH 2/2] feat(getPsffppPrice): New endpoint to get PSFFPP pin price --- src/price.js | 36 ++++++++++++++++++++++++++++++++++++ test/integration/price.js | 9 +++++++++ 2 files changed, 45 insertions(+) diff --git a/src/price.js b/src/price.js index d8ef010..c06c2be 100644 --- a/src/price.js +++ b/src/price.js @@ -230,6 +230,42 @@ class Price { 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 diff --git a/test/integration/price.js b/test/integration/price.js index d535232..dbbca42 100644 --- a/test/integration/price.js +++ b/test/integration/price.js @@ -52,6 +52,15 @@ describe('#price', () => { 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) {