privacycash 1.0.7 → 1.0.12

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.
@@ -1,67 +1,55 @@
1
- # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2
- # For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
3
-
4
- name: Publish to npm
1
+ name: Publish to npm when version changes
5
2
 
6
3
  on:
7
4
  push:
8
5
  branches:
9
6
  - main
7
+ - master
8
+ paths:
9
+ - "package.json"
10
+
11
+ permissions:
12
+ id-token: write
13
+ contents: read
10
14
 
11
15
  jobs:
12
16
  publish:
13
17
  runs-on: ubuntu-latest
18
+
14
19
  steps:
15
20
  - name: Checkout repository
16
- uses: actions/checkout@v3
17
- with:
18
- fetch-depth: 0
21
+ uses: actions/checkout@v4
19
22
 
20
23
  - name: Setup Node.js
21
24
  uses: actions/setup-node@v4
22
25
  with:
23
- node-version: "20"
24
- registry-url: "https://registry.npmjs.org"
25
- cache: "npm"
26
+ node-version: 24
27
+ registry-url: https://registry.npmjs.org/
26
28
 
27
- # Get previous version from the last commit in origin/main
28
- - name: Get previous package.json version
29
- run: |
30
- PREV=$(git show origin/main~1:package.json | jq -r .version)
31
- echo "Previous version: $PREV"
32
- echo "PREV_VERSION=$PREV" >> $GITHUB_ENV
33
-
34
- # Get current version from package.json
35
- - name: Get current package.json version
36
- run: |
37
- CURR=$(jq -r .version package.json)
38
- echo "CURR_VERSION=$CURR"
39
- echo "CURR_VERSION=$CURR" >> $GITHUB_ENV
29
+ - name: Get current package version
30
+ id: pkg
31
+ run: echo "version=$(node -p 'require(\"./package.json\").version')" >> $GITHUB_OUTPUT
40
32
 
41
- # Compare previous and current versions
42
- - name: Compare versions
33
+ - name: Check if version already exists on npm
34
+ id: check
43
35
  run: |
44
- if [ "$PREV_VERSION" = "$CURR_VERSION" ]; then
45
- echo "Version unchanged, skip publish"
46
- echo "SHOULD_PUBLISH=false" >> $GITHUB_ENV
36
+ PKG_NAME=$(node -p 'require("./package.json").name')
37
+ PUBLISHED=$(npm view $PKG_NAME versions --json | grep -o "\"${{ steps.pkg.outputs.version }}\"" || true)
38
+ if [ -n "$PUBLISHED" ]; then
39
+ echo "exists=true" >> $GITHUB_OUTPUT
40
+ echo "Version ${{ steps.pkg.outputs.version }} already exists on npm. Skipping publish."
47
41
  else
48
- echo "Version changed, will publish"
49
- echo "SHOULD_PUBLISH=true" >> $GITHUB_ENV
42
+ echo "exists=false" >> $GITHUB_OUTPUT
50
43
  fi
51
44
 
52
- # Install dependencies only if publish is needed
53
45
  - name: Install dependencies
54
- if: env.SHOULD_PUBLISH == 'true'
55
- run: npm ci
46
+ run: npm install
56
47
 
57
- # Run build script before publishing
58
- - name: Build project
59
- if: env.SHOULD_PUBLISH == 'true'
60
- run: npm run build
48
+ - name: Build source
49
+ run: npm run build || echo "No build script defined."
61
50
 
62
- # Publish to npm
63
51
  - name: Publish to npm
64
- if: env.SHOULD_PUBLISH == 'true'
65
- run: npm publish
66
- env:
67
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
52
+ if: steps.check.outputs.exists == 'false'
53
+ run: |
54
+ echo "Publishing version ${{ steps.pkg.outputs.version }}..."
55
+ npm publish --access public
package/dist/getUtxos.js CHANGED
@@ -60,6 +60,7 @@ export async function getUtxos({ publicKey, connection, encryptionService, stora
60
60
  const spentFlags = await areUtxosSpent(connection, nonZeroUtxos);
61
61
  for (let i = 0; i < nonZeroUtxos.length; i++) {
62
62
  if (!spentFlags[i]) {
63
+ logger.debug(`found unspent encrypted_output ${nonZeroEncrypted[i]}`);
63
64
  am += nonZeroUtxos[i].amount.toNumber();
64
65
  valid_utxos.push(nonZeroUtxos[i]);
65
66
  valid_strings.push(nonZeroEncrypted[i]);
@@ -80,7 +81,9 @@ export async function getUtxos({ publicKey, connection, encryptionService, stora
80
81
  getMyUtxosPromise = null;
81
82
  }
82
83
  // store valid strings
84
+ logger.debug(`valid_strings len before set: ${valid_strings.length}`);
83
85
  valid_strings = [...new Set(valid_strings)];
86
+ logger.debug(`valid_strings len after set: ${valid_strings.length}`);
84
87
  storage.setItem(LSK_ENCRYPTED_OUTPUTS + localstorageKey(publicKey), JSON.stringify(valid_strings));
85
88
  return valid_utxos;
86
89
  })();
package/dist/withdraw.js CHANGED
@@ -74,6 +74,8 @@ export async function withdraw({ recipient, lightWasm, storage, publicKey, conne
74
74
  amount: '0'
75
75
  });
76
76
  const inputs = [firstInput, secondInput];
77
+ logger.debug(`firstInput index: ${firstInput.index}, commitment: ${firstInput.getCommitment()}`);
78
+ logger.debug(`secondInput index: ${secondInput.index}, commitment: ${secondInput.getCommitment()}`);
77
79
  const totalInputAmount = firstInput.amount.add(secondInput.amount);
78
80
  logger.debug(`Using UTXO with amount: ${firstInput.amount.toString()} and ${secondInput.amount.gt(new BN(0)) ? 'second UTXO with amount: ' + secondInput.amount.toString() : 'dummy UTXO'}`);
79
81
  if (totalInputAmount.toNumber() === 0) {
@@ -146,6 +148,8 @@ export async function withdraw({ recipient, lightWasm, storage, publicKey, conne
146
148
  await outputs[0].log();
147
149
  logger.debug(`\nOutput[1] (empty):`);
148
150
  await outputs[1].log();
151
+ logger.debug(`Encrypted output 1: ${encryptedOutput1.toString('hex')}`);
152
+ logger.debug(`Encrypted output 2: ${encryptedOutput2.toString('hex')}`);
149
153
  logger.debug(`\nEncrypted output 1 size: ${encryptedOutput1.length} bytes`);
150
154
  logger.debug(`Encrypted output 2 size: ${encryptedOutput2.length} bytes`);
151
155
  logger.debug(`Total encrypted outputs size: ${encryptedOutput1.length + encryptedOutput2.length} bytes`);
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "privacycash",
3
- "version": "1.0.7",
3
+ "version": "1.0.12",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
+ "repository": "https://github.com/Privacy-Cash/privacy-cash-sdk",
6
7
  "exports": {
7
8
  ".": "./dist/index.js",
8
9
  "./utils": "./dist/exportUtils.js"
package/src/getUtxos.ts CHANGED
@@ -90,6 +90,7 @@ export async function getUtxos({ publicKey, connection, encryptionService, stora
90
90
  const spentFlags = await areUtxosSpent(connection, nonZeroUtxos);
91
91
  for (let i = 0; i < nonZeroUtxos.length; i++) {
92
92
  if (!spentFlags[i]) {
93
+ logger.debug(`found unspent encrypted_output ${nonZeroEncrypted[i]}`)
93
94
  am += nonZeroUtxos[i].amount.toNumber();
94
95
  valid_utxos.push(nonZeroUtxos[i]);
95
96
  valid_strings.push(nonZeroEncrypted[i]);
@@ -108,7 +109,9 @@ export async function getUtxos({ publicKey, connection, encryptionService, stora
108
109
  getMyUtxosPromise = null
109
110
  }
110
111
  // store valid strings
112
+ logger.debug(`valid_strings len before set: ${valid_strings.length}`)
111
113
  valid_strings = [...new Set(valid_strings)];
114
+ logger.debug(`valid_strings len after set: ${valid_strings.length}`)
112
115
  storage.setItem(LSK_ENCRYPTED_OUTPUTS + localstorageKey(publicKey), JSON.stringify(valid_strings))
113
116
  return valid_utxos
114
117
  })()
package/src/withdraw.ts CHANGED
@@ -107,6 +107,8 @@ export async function withdraw({ recipient, lightWasm, storage, publicKey, conne
107
107
  });
108
108
 
109
109
  const inputs = [firstInput, secondInput];
110
+ logger.debug(`firstInput index: ${firstInput.index}, commitment: ${firstInput.getCommitment()}`)
111
+ logger.debug(`secondInput index: ${secondInput.index}, commitment: ${secondInput.getCommitment()}`)
110
112
  const totalInputAmount = firstInput.amount.add(secondInput.amount);
111
113
  logger.debug(`Using UTXO with amount: ${firstInput.amount.toString()} and ${secondInput.amount.gt(new BN(0)) ? 'second UTXO with amount: ' + secondInput.amount.toString() : 'dummy UTXO'}`);
112
114
  if (totalInputAmount.toNumber() === 0) {
@@ -192,7 +194,8 @@ export async function withdraw({ recipient, lightWasm, storage, publicKey, conne
192
194
  await outputs[0].log();
193
195
  logger.debug(`\nOutput[1] (empty):`);
194
196
  await outputs[1].log();
195
-
197
+ logger.debug(`Encrypted output 1: ${encryptedOutput1.toString('hex')}`)
198
+ logger.debug(`Encrypted output 2: ${encryptedOutput2.toString('hex')}`)
196
199
  logger.debug(`\nEncrypted output 1 size: ${encryptedOutput1.length} bytes`);
197
200
  logger.debug(`Encrypted output 2 size: ${encryptedOutput2.length} bytes`);
198
201
  logger.debug(`Total encrypted outputs size: ${encryptedOutput1.length + encryptedOutput2.length} bytes`);