psffpp 1.1.5 → 1.1.7

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/LICENSE.md CHANGED
@@ -1,5 +1,5 @@
1
1
  The MIT License (MIT)
2
- Copyright (c) 2023 Chris Troutner <chris.troutner@gmail.com>
2
+ Copyright (c) 2023-2024 Chris Troutner <chris.troutner@gmail.com>
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5
5
 
package/index.js CHANGED
@@ -153,6 +153,12 @@ class PSFFPP {
153
153
  // const WRITE_PRICE = 0.08335233 // Cost in PSF tokens to pin 1MB
154
154
  const PSF_TOKEN_ID = '38e97c5d7d3585a2cbf3f9580c82ca33985f9cb0845d4dcce220cb709f9538b0'
155
155
 
156
+ // Get info and libraries from the wallet.
157
+ const addr = this.wallet.walletInfo.address
158
+ targetAddr = addr
159
+ const bchjs = this.wallet.bchjs
160
+ const wif = this.wallet.walletInfo.privateKey
161
+
156
162
  // Calculate the write cost
157
163
  const dataCost = writePrice * fileSizeInMegabytes
158
164
  const minCost = writePrice
@@ -161,13 +167,10 @@ class PSFFPP {
161
167
  console.log(`Burning ${actualCost} PSF tokens for ${fileSizeInMegabytes} MB of data.`)
162
168
 
163
169
  const pobTxid = await this.wallet.burnTokens(actualCost, PSF_TOKEN_ID)
164
- // console.log(`Proof-of-burn TX: ${pobTxid}`)
170
+ // console.log(`Proof-of-burn TX: ${pobT xid}`)
165
171
 
166
- // Get info and libraries from the wallet.
167
- const addr = this.wallet.walletInfo.address
168
- targetAddr = addr
169
- const bchjs = this.wallet.bchjs
170
- const wif = this.wallet.walletInfo.privateKey
172
+ // Wait for the indexer to update before get utxos.
173
+ await this.bchjs.Util.sleep(4000)
171
174
 
172
175
  // Get a UTXO to spend to generate the pin claim TX.
173
176
  let utxos = await this.wallet.getUtxos()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "psffpp",
3
- "version": "1.1.5",
3
+ "version": "1.1.7",
4
4
  "description": "PS010 PSF File Pinning Protocol",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -110,6 +110,7 @@ describe('#PSFFPP-index.js', () => {
110
110
 
111
111
  // Mock dependencies and force desired code path
112
112
  sandbox.stub(uut, 'getMcWritePrice').resolves(0.08335233)
113
+ sandbox.stub(uut.bchjs.Util, 'sleep').resolves(true)
113
114
 
114
115
  const inObj = {
115
116
  cid: 'bafkreih7eeixbkyvabqdde4g5mdourjidxpsgf6bgz6f7ouxqr24stg6f4',