privacycash 1.1.13 → 1.1.15

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 CHANGED
@@ -327,6 +327,21 @@ export async function deposit({ lightWasm, storage, keyBasePath, publicKey, conn
327
327
  instructions: [modifyComputeUnits, prioritizeCompute, depositInstruction],
328
328
  }).compileToV0Message([lookupTableAccount.value]);
329
329
  let versionedTransaction = new VersionedTransaction(messageV0);
330
+ // check tx size
331
+ const txSize = versionedTransaction.serialize().length;
332
+ logger.debug(`Initial transaction size: ${txSize} bytes`);
333
+ if (txSize > 1232) {
334
+ logger.debug(`Transaction size ${txSize} exceeds limit. Cannot proceed.`);
335
+ logger.debug('Removing prioritize compute instruction to reduce size and retrying...');
336
+ // Remove prioritize compute instruction and recreate transaction
337
+ const messageV0NoPrioritize = new TransactionMessage({
338
+ payerKey: signer, // User pays for their own deposit
339
+ recentBlockhash: recentBlockhash.blockhash,
340
+ instructions: [modifyComputeUnits, depositInstruction],
341
+ }).compileToV0Message([lookupTableAccount.value]);
342
+ // Recreate versioned transaction without prioritize instruction
343
+ versionedTransaction = new VersionedTransaction(messageV0NoPrioritize);
344
+ }
330
345
  // sign tx
331
346
  versionedTransaction = await transactionSigner(versionedTransaction);
332
347
  logger.debug('Transaction signed by user');
@@ -380,6 +380,21 @@ export async function depositSPL({ lightWasm, storage, keyBasePath, publicKey, c
380
380
  instructions: [modifyComputeUnits, prioritizeCompute, depositInstruction],
381
381
  }).compileToV0Message([lookupTableAccount.value]);
382
382
  let versionedTransaction = new VersionedTransaction(messageV0);
383
+ // check tx size
384
+ const txSize = versionedTransaction.serialize().length;
385
+ logger.debug(`Serialized transaction size: ${txSize} bytes`);
386
+ if (txSize > 1232) {
387
+ logger.debug(`Transaction size ${txSize} exceeds limit. Cannot proceed.`);
388
+ logger.debug('Removing prioritize compute instruction to reduce size and retrying...');
389
+ // Remove prioritize compute instruction and recreate transaction
390
+ const messageV0NoPrioritize = new TransactionMessage({
391
+ payerKey: signer, // User pays for their own deposit
392
+ recentBlockhash: recentBlockhash.blockhash,
393
+ instructions: [modifyComputeUnits, depositInstruction],
394
+ }).compileToV0Message([lookupTableAccount.value]);
395
+ // Recreate versioned transaction without prioritize instruction
396
+ versionedTransaction = new VersionedTransaction(messageV0NoPrioritize);
397
+ }
383
398
  // sign tx
384
399
  versionedTransaction = await transactionSigner(versionedTransaction);
385
400
  logger.debug('Transaction signed by user');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "privacycash",
3
- "version": "1.1.13",
3
+ "version": "1.1.15",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "repository": "https://github.com/Privacy-Cash/privacy-cash-sdk",
package/src/deposit.ts CHANGED
@@ -405,6 +405,22 @@ export async function deposit({ lightWasm, storage, keyBasePath, publicKey, conn
405
405
 
406
406
  let versionedTransaction = new VersionedTransaction(messageV0);
407
407
 
408
+ // check tx size
409
+ const txSize = versionedTransaction.serialize().length;
410
+ logger.debug(`Initial transaction size: ${txSize} bytes`);
411
+ if (txSize > 1232) {
412
+ logger.debug(`Transaction size ${txSize} exceeds limit. Cannot proceed.`);
413
+ logger.debug('Removing prioritize compute instruction to reduce size and retrying...');
414
+ // Remove prioritize compute instruction and recreate transaction
415
+ const messageV0NoPrioritize = new TransactionMessage({
416
+ payerKey: signer, // User pays for their own deposit
417
+ recentBlockhash: recentBlockhash.blockhash,
418
+ instructions: [modifyComputeUnits, depositInstruction],
419
+ }).compileToV0Message([lookupTableAccount.value]);
420
+ // Recreate versioned transaction without prioritize instruction
421
+ versionedTransaction = new VersionedTransaction(messageV0NoPrioritize);
422
+ }
423
+
408
424
  // sign tx
409
425
  versionedTransaction = await transactionSigner(versionedTransaction)
410
426
 
package/src/depositSPL.ts CHANGED
@@ -490,6 +490,22 @@ export async function depositSPL({ lightWasm, storage, keyBasePath, publicKey, c
490
490
 
491
491
  let versionedTransaction = new VersionedTransaction(messageV0);
492
492
 
493
+ // check tx size
494
+ const txSize = versionedTransaction.serialize().length
495
+ logger.debug(`Serialized transaction size: ${txSize} bytes`);
496
+ if (txSize > 1232) {
497
+ logger.debug(`Transaction size ${txSize} exceeds limit. Cannot proceed.`);
498
+ logger.debug('Removing prioritize compute instruction to reduce size and retrying...');
499
+ // Remove prioritize compute instruction and recreate transaction
500
+ const messageV0NoPrioritize = new TransactionMessage({
501
+ payerKey: signer, // User pays for their own deposit
502
+ recentBlockhash: recentBlockhash.blockhash,
503
+ instructions: [modifyComputeUnits, depositInstruction],
504
+ }).compileToV0Message([lookupTableAccount.value]);
505
+ // Recreate versioned transaction without prioritize instruction
506
+ versionedTransaction = new VersionedTransaction(messageV0NoPrioritize);
507
+ }
508
+
493
509
  // sign tx
494
510
  versionedTransaction = await transactionSigner(versionedTransaction)
495
511