@solana/web3.js 1.39.0 → 1.39.1

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.
@@ -2391,6 +2391,26 @@ class TransactionInstruction {
2391
2391
  this.data = opts.data;
2392
2392
  }
2393
2393
  }
2394
+ /**
2395
+ * @internal
2396
+ */
2397
+
2398
+
2399
+ toJSON() {
2400
+ return {
2401
+ keys: this.keys.map(({
2402
+ pubkey,
2403
+ isSigner,
2404
+ isWritable
2405
+ }) => ({
2406
+ pubkey: pubkey.toJSON(),
2407
+ isSigner,
2408
+ isWritable
2409
+ })),
2410
+ programId: this.programId.toJSON(),
2411
+ data: [...this.data]
2412
+ };
2413
+ }
2394
2414
 
2395
2415
  }
2396
2416
  /**
@@ -2430,8 +2450,33 @@ class Transaction {
2430
2450
  this.instructions = [];
2431
2451
  this.recentBlockhash = void 0;
2432
2452
  this.nonceInfo = void 0;
2453
+ this._message = void 0;
2454
+ this._json = void 0;
2433
2455
  opts && Object.assign(this, opts);
2434
2456
  }
2457
+ /**
2458
+ * @internal
2459
+ */
2460
+
2461
+
2462
+ toJSON() {
2463
+ return {
2464
+ recentBlockhash: this.recentBlockhash || null,
2465
+ feePayer: this.feePayer ? this.feePayer.toJSON() : null,
2466
+ nonceInfo: this.nonceInfo ? {
2467
+ nonce: this.nonceInfo.nonce,
2468
+ nonceInstruction: this.nonceInfo.nonceInstruction.toJSON()
2469
+ } : null,
2470
+ instructions: this.instructions.map(instruction => instruction.toJSON()),
2471
+ signatures: this.signatures.map(({
2472
+ publicKey,
2473
+ signature
2474
+ }) => ({
2475
+ publicKey: publicKey.toJSON(),
2476
+ signature: signature ? [...signature] : null
2477
+ }))
2478
+ };
2479
+ }
2435
2480
  /**
2436
2481
  * Add one or more instructions to this Transaction
2437
2482
  */
@@ -2459,6 +2504,14 @@ class Transaction {
2459
2504
 
2460
2505
 
2461
2506
  compileMessage() {
2507
+ if (this._message) {
2508
+ if (JSON.stringify(this.toJSON()) !== JSON.stringify(this._json)) {
2509
+ throw new Error('Transaction mutated after being populated from Message');
2510
+ }
2511
+
2512
+ return this._message;
2513
+ }
2514
+
2462
2515
  const {
2463
2516
  nonceInfo
2464
2517
  } = this;
@@ -2980,6 +3033,8 @@ class Transaction {
2980
3033
  data: bs58__default["default"].decode(instruction.data)
2981
3034
  }));
2982
3035
  });
3036
+ transaction._message = message;
3037
+ transaction._json = transaction.toJSON();
2983
3038
  return transaction;
2984
3039
  }
2985
3040
 
@@ -7262,7 +7317,9 @@ class Connection {
7262
7317
  });
7263
7318
  transaction.instructions = transactionOrMessage.instructions;
7264
7319
  } else {
7265
- transaction = Transaction.populate(transactionOrMessage);
7320
+ transaction = Transaction.populate(transactionOrMessage); // HACK: this function relies on mutating the populated transaction
7321
+
7322
+ transaction._message = transaction._json = undefined;
7266
7323
  }
7267
7324
 
7268
7325
  if (transaction.nonceInfo && signers) {