privacycash 1.1.17 → 1.1.18
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/dist/deposit.js +5 -4
- package/dist/depositSPL.js +5 -4
- package/dist/withdraw.js +5 -4
- package/dist/withdrawSPL.js +5 -4
- package/package.json +1 -1
- package/src/deposit.ts +6 -6
- package/src/depositSPL.ts +6 -6
- package/src/withdraw.ts +6 -5
- package/src/withdrawSPL.ts +6 -5
package/dist/deposit.js
CHANGED
|
@@ -68,10 +68,6 @@ export async function deposit({ lightWasm, storage, keyBasePath, publicKey, conn
|
|
|
68
68
|
const { treeAccount, treeTokenAccount, globalConfigAccount } = getProgramAccounts();
|
|
69
69
|
// Create the merkle tree with the pre-initialized poseidon hash
|
|
70
70
|
const tree = new MerkleTree(MERKLE_TREE_DEPTH, lightWasm);
|
|
71
|
-
// Initialize root and nextIndex variables
|
|
72
|
-
const { root, nextIndex: currentNextIndex } = await queryRemoteTreeState();
|
|
73
|
-
logger.debug(`Using tree root: ${root}`);
|
|
74
|
-
logger.debug(`New UTXOs will be inserted at indices: ${currentNextIndex} and ${currentNextIndex + 1}`);
|
|
75
71
|
// Generate a deterministic private key derived from the wallet keypair
|
|
76
72
|
// const utxoPrivateKey = encryptionService.deriveUtxoPrivateKey();
|
|
77
73
|
const utxoPrivateKey = encryptionService.getUtxoPrivateKeyV2();
|
|
@@ -92,6 +88,10 @@ export async function deposit({ lightWasm, storage, keyBasePath, publicKey, conn
|
|
|
92
88
|
let extData;
|
|
93
89
|
let encryptedOutput1;
|
|
94
90
|
let getProve = async () => {
|
|
91
|
+
// Initialize root and nextIndex variables
|
|
92
|
+
const { root, nextIndex: currentNextIndex } = await queryRemoteTreeState();
|
|
93
|
+
logger.debug(`Using tree root: ${root}`);
|
|
94
|
+
logger.debug(`New UTXOs will be inserted at indices: ${currentNextIndex} and ${currentNextIndex + 1}`);
|
|
95
95
|
if (existingUnspentUtxos.length === 0) {
|
|
96
96
|
// Scenario 1: Fresh deposit with dummy inputs - add new funds to the system
|
|
97
97
|
extAmount = amount_in_lamports;
|
|
@@ -275,6 +275,7 @@ export async function deposit({ lightWasm, storage, keyBasePath, publicKey, conn
|
|
|
275
275
|
if (getProveRetryCount >= 2) {
|
|
276
276
|
throw new Error('Proof generation failed after 2 attempts. Please try again later.');
|
|
277
277
|
}
|
|
278
|
+
await new Promise(resolve => setTimeout(resolve, 500));
|
|
278
279
|
}
|
|
279
280
|
}
|
|
280
281
|
const { proof, publicSignals } = getProveResult;
|
package/dist/depositSPL.js
CHANGED
|
@@ -106,10 +106,6 @@ export async function depositSPL({ lightWasm, storage, keyBasePath, publicKey, c
|
|
|
106
106
|
const { globalConfigAccount } = getProgramAccounts();
|
|
107
107
|
// Create the merkle tree with the pre-initialized poseidon hash
|
|
108
108
|
const tree = new MerkleTree(MERKLE_TREE_DEPTH, lightWasm);
|
|
109
|
-
// Initialize root and nextIndex variables
|
|
110
|
-
const { root, nextIndex: currentNextIndex } = await queryRemoteTreeState(token.name);
|
|
111
|
-
logger.debug(`Using tree root: ${root}`);
|
|
112
|
-
logger.debug(`New UTXOs will be inserted at indices: ${currentNextIndex} and ${currentNextIndex + 1}`);
|
|
113
109
|
// Generate a deterministic private key derived from the wallet keypair
|
|
114
110
|
// const utxoPrivateKey = encryptionService.deriveUtxoPrivateKey();
|
|
115
111
|
const utxoPrivateKey = encryptionService.getUtxoPrivateKeyV2();
|
|
@@ -130,6 +126,10 @@ export async function depositSPL({ lightWasm, storage, keyBasePath, publicKey, c
|
|
|
130
126
|
let extData;
|
|
131
127
|
let encryptedOutput1;
|
|
132
128
|
let getProve = async () => {
|
|
129
|
+
// Initialize root and nextIndex variables
|
|
130
|
+
const { root, nextIndex: currentNextIndex } = await queryRemoteTreeState(token.name);
|
|
131
|
+
logger.debug(`Using tree root: ${root}`);
|
|
132
|
+
logger.debug(`New UTXOs will be inserted at indices: ${currentNextIndex} and ${currentNextIndex + 1}`);
|
|
133
133
|
if (mintUtxos.length === 0) {
|
|
134
134
|
// Scenario 1: Fresh deposit with dummy inputs - add new funds to the system
|
|
135
135
|
extAmount = base_units;
|
|
@@ -316,6 +316,7 @@ export async function depositSPL({ lightWasm, storage, keyBasePath, publicKey, c
|
|
|
316
316
|
if (getProveRetryCount >= 2) {
|
|
317
317
|
throw new Error('Proof generation failed after 2 attempts. Please try again later.');
|
|
318
318
|
}
|
|
319
|
+
await new Promise(resolve => setTimeout(resolve, 500));
|
|
319
320
|
}
|
|
320
321
|
}
|
|
321
322
|
const { proof, publicSignals } = getProveResult;
|
package/dist/withdraw.js
CHANGED
|
@@ -41,10 +41,6 @@ export async function withdraw({ recipient, lightWasm, storage, publicKey, conne
|
|
|
41
41
|
let isPartial = false;
|
|
42
42
|
logger.debug('Encryption key generated from user keypair');
|
|
43
43
|
const { treeAccount, treeTokenAccount, globalConfigAccount } = getProgramAccounts();
|
|
44
|
-
// Get current tree state
|
|
45
|
-
const { root, nextIndex: currentNextIndex } = await queryRemoteTreeState();
|
|
46
|
-
logger.debug(`Using tree root: ${root}`);
|
|
47
|
-
logger.debug(`New UTXOs will be inserted at indices: ${currentNextIndex} and ${currentNextIndex + 1}`);
|
|
48
44
|
// Generate a deterministic private key derived from the wallet keypair
|
|
49
45
|
const utxoPrivateKey = encryptionService.deriveUtxoPrivateKey();
|
|
50
46
|
// Create a UTXO keypair that will be used for all inputs and outputs
|
|
@@ -95,6 +91,10 @@ export async function withdraw({ recipient, lightWasm, storage, publicKey, conne
|
|
|
95
91
|
let encryptedOutput1;
|
|
96
92
|
let encryptedOutput2;
|
|
97
93
|
let getProve = async () => {
|
|
94
|
+
// Get current tree state
|
|
95
|
+
const { root, nextIndex: currentNextIndex } = await queryRemoteTreeState();
|
|
96
|
+
logger.debug(`Using tree root: ${root}`);
|
|
97
|
+
logger.debug(`New UTXOs will be inserted at indices: ${currentNextIndex} and ${currentNextIndex + 1}`);
|
|
98
98
|
// Get Merkle proofs for both input UTXOs
|
|
99
99
|
const inputMerkleProofs = await Promise.all(inputs.map(async (utxo, index) => {
|
|
100
100
|
// For dummy UTXO (amount is 0), use a zero-filled proof
|
|
@@ -214,6 +214,7 @@ export async function withdraw({ recipient, lightWasm, storage, publicKey, conne
|
|
|
214
214
|
if (getProveRetryCount >= 2) {
|
|
215
215
|
throw new Error('Proof generation failed after 2 attempts. Please try again later.');
|
|
216
216
|
}
|
|
217
|
+
await new Promise(resolve => setTimeout(resolve, 500));
|
|
217
218
|
}
|
|
218
219
|
}
|
|
219
220
|
const { proof, publicSignals } = getProveResult;
|
package/dist/withdrawSPL.js
CHANGED
|
@@ -71,10 +71,6 @@ export async function withdrawSPL({ recipient, lightWasm, storage, publicKey, co
|
|
|
71
71
|
// Derive tree account PDA with mint address for SPL (different from SOL version)
|
|
72
72
|
const [treeAccount] = PublicKey.findProgramAddressSync([Buffer.from('merkle_tree'), token.pubkey.toBuffer()], PROGRAM_ID);
|
|
73
73
|
const { globalConfigAccount, treeTokenAccount } = getProgramAccounts();
|
|
74
|
-
// Get current tree state
|
|
75
|
-
const { root, nextIndex: currentNextIndex } = await queryRemoteTreeState(token.name);
|
|
76
|
-
logger.debug(`Using tree root: ${root}`);
|
|
77
|
-
logger.debug(`New UTXOs will be inserted at indices: ${currentNextIndex} and ${currentNextIndex + 1}`);
|
|
78
74
|
// Generate a deterministic private key derived from the wallet keypair
|
|
79
75
|
const utxoPrivateKey = encryptionService.deriveUtxoPrivateKey();
|
|
80
76
|
// Create a UTXO keypair that will be used for all inputs and outputs
|
|
@@ -125,6 +121,10 @@ export async function withdrawSPL({ recipient, lightWasm, storage, publicKey, co
|
|
|
125
121
|
let extData;
|
|
126
122
|
let encryptedOutput1;
|
|
127
123
|
let getProve = async () => {
|
|
124
|
+
// Get current tree state
|
|
125
|
+
const { root, nextIndex: currentNextIndex } = await queryRemoteTreeState(token.name);
|
|
126
|
+
logger.debug(`Using tree root: ${root}`);
|
|
127
|
+
logger.debug(`New UTXOs will be inserted at indices: ${currentNextIndex} and ${currentNextIndex + 1}`);
|
|
128
128
|
// Get Merkle proofs for both input UTXOs
|
|
129
129
|
const inputMerkleProofs = await Promise.all(inputs.map(async (utxo, index) => {
|
|
130
130
|
// For dummy UTXO (amount is 0), use a zero-filled proof
|
|
@@ -245,6 +245,7 @@ export async function withdrawSPL({ recipient, lightWasm, storage, publicKey, co
|
|
|
245
245
|
if (getProveRetryCount >= 2) {
|
|
246
246
|
throw new Error('Proof generation failed after 2 attempts. Please try again later.');
|
|
247
247
|
}
|
|
248
|
+
await new Promise(resolve => setTimeout(resolve, 500));
|
|
248
249
|
}
|
|
249
250
|
}
|
|
250
251
|
const { proof, publicSignals } = getProveResult;
|
package/package.json
CHANGED
package/src/deposit.ts
CHANGED
|
@@ -97,12 +97,6 @@ export async function deposit({ lightWasm, storage, keyBasePath, publicKey, conn
|
|
|
97
97
|
// Create the merkle tree with the pre-initialized poseidon hash
|
|
98
98
|
const tree = new MerkleTree(MERKLE_TREE_DEPTH, lightWasm);
|
|
99
99
|
|
|
100
|
-
// Initialize root and nextIndex variables
|
|
101
|
-
const { root, nextIndex: currentNextIndex } = await queryRemoteTreeState();
|
|
102
|
-
|
|
103
|
-
logger.debug(`Using tree root: ${root}`);
|
|
104
|
-
logger.debug(`New UTXOs will be inserted at indices: ${currentNextIndex} and ${currentNextIndex + 1}`);
|
|
105
|
-
|
|
106
100
|
// Generate a deterministic private key derived from the wallet keypair
|
|
107
101
|
// const utxoPrivateKey = encryptionService.deriveUtxoPrivateKey();
|
|
108
102
|
const utxoPrivateKey = encryptionService.getUtxoPrivateKeyV2();
|
|
@@ -128,6 +122,11 @@ export async function deposit({ lightWasm, storage, keyBasePath, publicKey, conn
|
|
|
128
122
|
let extData: any
|
|
129
123
|
let encryptedOutput1: any
|
|
130
124
|
let getProve = async () => {
|
|
125
|
+
// Initialize root and nextIndex variables
|
|
126
|
+
const { root, nextIndex: currentNextIndex } = await queryRemoteTreeState();
|
|
127
|
+
logger.debug(`Using tree root: ${root}`);
|
|
128
|
+
logger.debug(`New UTXOs will be inserted at indices: ${currentNextIndex} and ${currentNextIndex + 1}`);
|
|
129
|
+
|
|
131
130
|
if (existingUnspentUtxos.length === 0) {
|
|
132
131
|
// Scenario 1: Fresh deposit with dummy inputs - add new funds to the system
|
|
133
132
|
extAmount = amount_in_lamports;
|
|
@@ -340,6 +339,7 @@ export async function deposit({ lightWasm, storage, keyBasePath, publicKey, conn
|
|
|
340
339
|
if (getProveRetryCount >= 2) {
|
|
341
340
|
throw new Error('Proof generation failed after 2 attempts. Please try again later.');
|
|
342
341
|
}
|
|
342
|
+
await new Promise(resolve => setTimeout(resolve, 500));
|
|
343
343
|
}
|
|
344
344
|
}
|
|
345
345
|
|
package/src/depositSPL.ts
CHANGED
|
@@ -162,12 +162,6 @@ export async function depositSPL({ lightWasm, storage, keyBasePath, publicKey, c
|
|
|
162
162
|
// Create the merkle tree with the pre-initialized poseidon hash
|
|
163
163
|
const tree = new MerkleTree(MERKLE_TREE_DEPTH, lightWasm);
|
|
164
164
|
|
|
165
|
-
// Initialize root and nextIndex variables
|
|
166
|
-
const { root, nextIndex: currentNextIndex } = await queryRemoteTreeState(token.name);
|
|
167
|
-
|
|
168
|
-
logger.debug(`Using tree root: ${root}`);
|
|
169
|
-
logger.debug(`New UTXOs will be inserted at indices: ${currentNextIndex} and ${currentNextIndex + 1}`);
|
|
170
|
-
|
|
171
165
|
// Generate a deterministic private key derived from the wallet keypair
|
|
172
166
|
// const utxoPrivateKey = encryptionService.deriveUtxoPrivateKey();
|
|
173
167
|
const utxoPrivateKey = encryptionService.getUtxoPrivateKeyV2();
|
|
@@ -193,6 +187,11 @@ export async function depositSPL({ lightWasm, storage, keyBasePath, publicKey, c
|
|
|
193
187
|
let extData: any
|
|
194
188
|
let encryptedOutput1: any
|
|
195
189
|
let getProve = async () => {
|
|
190
|
+
// Initialize root and nextIndex variables
|
|
191
|
+
const { root, nextIndex: currentNextIndex } = await queryRemoteTreeState(token.name);
|
|
192
|
+
logger.debug(`Using tree root: ${root}`);
|
|
193
|
+
logger.debug(`New UTXOs will be inserted at indices: ${currentNextIndex} and ${currentNextIndex + 1}`);
|
|
194
|
+
|
|
196
195
|
if (mintUtxos.length === 0) {
|
|
197
196
|
// Scenario 1: Fresh deposit with dummy inputs - add new funds to the system
|
|
198
197
|
extAmount = base_units;
|
|
@@ -406,6 +405,7 @@ export async function depositSPL({ lightWasm, storage, keyBasePath, publicKey, c
|
|
|
406
405
|
if (getProveRetryCount >= 2) {
|
|
407
406
|
throw new Error('Proof generation failed after 2 attempts. Please try again later.');
|
|
408
407
|
}
|
|
408
|
+
await new Promise(resolve => setTimeout(resolve, 500));
|
|
409
409
|
}
|
|
410
410
|
}
|
|
411
411
|
const { proof, publicSignals } = getProveResult;
|
package/src/withdraw.ts
CHANGED
|
@@ -65,11 +65,6 @@ export async function withdraw({ recipient, lightWasm, storage, publicKey, conne
|
|
|
65
65
|
|
|
66
66
|
const { treeAccount, treeTokenAccount, globalConfigAccount } = getProgramAccounts()
|
|
67
67
|
|
|
68
|
-
// Get current tree state
|
|
69
|
-
const { root, nextIndex: currentNextIndex } = await queryRemoteTreeState();
|
|
70
|
-
logger.debug(`Using tree root: ${root}`);
|
|
71
|
-
logger.debug(`New UTXOs will be inserted at indices: ${currentNextIndex} and ${currentNextIndex + 1}`);
|
|
72
|
-
|
|
73
68
|
// Generate a deterministic private key derived from the wallet keypair
|
|
74
69
|
const utxoPrivateKey = encryptionService.deriveUtxoPrivateKey();
|
|
75
70
|
|
|
@@ -132,6 +127,11 @@ export async function withdraw({ recipient, lightWasm, storage, publicKey, conne
|
|
|
132
127
|
let encryptedOutput2: any
|
|
133
128
|
|
|
134
129
|
let getProve = async () => {
|
|
130
|
+
// Get current tree state
|
|
131
|
+
const { root, nextIndex: currentNextIndex } = await queryRemoteTreeState();
|
|
132
|
+
logger.debug(`Using tree root: ${root}`);
|
|
133
|
+
logger.debug(`New UTXOs will be inserted at indices: ${currentNextIndex} and ${currentNextIndex + 1}`);
|
|
134
|
+
|
|
135
135
|
// Get Merkle proofs for both input UTXOs
|
|
136
136
|
const inputMerkleProofs = await Promise.all(
|
|
137
137
|
inputs.map(async (utxo, index) => {
|
|
@@ -268,6 +268,7 @@ export async function withdraw({ recipient, lightWasm, storage, publicKey, conne
|
|
|
268
268
|
if (getProveRetryCount >= 2) {
|
|
269
269
|
throw new Error('Proof generation failed after 2 attempts. Please try again later.');
|
|
270
270
|
}
|
|
271
|
+
await new Promise(resolve => setTimeout(resolve, 500));
|
|
271
272
|
}
|
|
272
273
|
}
|
|
273
274
|
|
package/src/withdrawSPL.ts
CHANGED
|
@@ -120,11 +120,6 @@ export async function withdrawSPL({ recipient, lightWasm, storage, publicKey, co
|
|
|
120
120
|
|
|
121
121
|
const { globalConfigAccount, treeTokenAccount } = getProgramAccounts()
|
|
122
122
|
|
|
123
|
-
// Get current tree state
|
|
124
|
-
const { root, nextIndex: currentNextIndex } = await queryRemoteTreeState(token.name);
|
|
125
|
-
logger.debug(`Using tree root: ${root}`);
|
|
126
|
-
logger.debug(`New UTXOs will be inserted at indices: ${currentNextIndex} and ${currentNextIndex + 1}`);
|
|
127
|
-
|
|
128
123
|
// Generate a deterministic private key derived from the wallet keypair
|
|
129
124
|
const utxoPrivateKey = encryptionService.deriveUtxoPrivateKey();
|
|
130
125
|
|
|
@@ -188,6 +183,11 @@ export async function withdrawSPL({ recipient, lightWasm, storage, publicKey, co
|
|
|
188
183
|
let encryptedOutput1: any
|
|
189
184
|
|
|
190
185
|
let getProve = async () => {
|
|
186
|
+
// Get current tree state
|
|
187
|
+
const { root, nextIndex: currentNextIndex } = await queryRemoteTreeState(token.name);
|
|
188
|
+
logger.debug(`Using tree root: ${root}`);
|
|
189
|
+
logger.debug(`New UTXOs will be inserted at indices: ${currentNextIndex} and ${currentNextIndex + 1}`);
|
|
190
|
+
|
|
191
191
|
// Get Merkle proofs for both input UTXOs
|
|
192
192
|
const inputMerkleProofs = await Promise.all(
|
|
193
193
|
inputs.map(async (utxo, index) => {
|
|
@@ -325,6 +325,7 @@ export async function withdrawSPL({ recipient, lightWasm, storage, publicKey, co
|
|
|
325
325
|
if (getProveRetryCount >= 2) {
|
|
326
326
|
throw new Error('Proof generation failed after 2 attempts. Please try again later.');
|
|
327
327
|
}
|
|
328
|
+
await new Promise(resolve => setTimeout(resolve, 500));
|
|
328
329
|
}
|
|
329
330
|
}
|
|
330
331
|
|