@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.
@@ -2359,6 +2359,26 @@ class TransactionInstruction {
2359
2359
  this.data = opts.data;
2360
2360
  }
2361
2361
  }
2362
+ /**
2363
+ * @internal
2364
+ */
2365
+
2366
+
2367
+ toJSON() {
2368
+ return {
2369
+ keys: this.keys.map(({
2370
+ pubkey,
2371
+ isSigner,
2372
+ isWritable
2373
+ }) => ({
2374
+ pubkey: pubkey.toJSON(),
2375
+ isSigner,
2376
+ isWritable
2377
+ })),
2378
+ programId: this.programId.toJSON(),
2379
+ data: [...this.data]
2380
+ };
2381
+ }
2362
2382
 
2363
2383
  }
2364
2384
  /**
@@ -2398,8 +2418,33 @@ class Transaction {
2398
2418
  this.instructions = [];
2399
2419
  this.recentBlockhash = void 0;
2400
2420
  this.nonceInfo = void 0;
2421
+ this._message = void 0;
2422
+ this._json = void 0;
2401
2423
  opts && Object.assign(this, opts);
2402
2424
  }
2425
+ /**
2426
+ * @internal
2427
+ */
2428
+
2429
+
2430
+ toJSON() {
2431
+ return {
2432
+ recentBlockhash: this.recentBlockhash || null,
2433
+ feePayer: this.feePayer ? this.feePayer.toJSON() : null,
2434
+ nonceInfo: this.nonceInfo ? {
2435
+ nonce: this.nonceInfo.nonce,
2436
+ nonceInstruction: this.nonceInfo.nonceInstruction.toJSON()
2437
+ } : null,
2438
+ instructions: this.instructions.map(instruction => instruction.toJSON()),
2439
+ signatures: this.signatures.map(({
2440
+ publicKey,
2441
+ signature
2442
+ }) => ({
2443
+ publicKey: publicKey.toJSON(),
2444
+ signature: signature ? [...signature] : null
2445
+ }))
2446
+ };
2447
+ }
2403
2448
  /**
2404
2449
  * Add one or more instructions to this Transaction
2405
2450
  */
@@ -2427,6 +2472,14 @@ class Transaction {
2427
2472
 
2428
2473
 
2429
2474
  compileMessage() {
2475
+ if (this._message) {
2476
+ if (JSON.stringify(this.toJSON()) !== JSON.stringify(this._json)) {
2477
+ throw new Error('Transaction mutated after being populated from Message');
2478
+ }
2479
+
2480
+ return this._message;
2481
+ }
2482
+
2430
2483
  const {
2431
2484
  nonceInfo
2432
2485
  } = this;
@@ -2948,6 +3001,8 @@ class Transaction {
2948
3001
  data: bs58.decode(instruction.data)
2949
3002
  }));
2950
3003
  });
3004
+ transaction._message = message;
3005
+ transaction._json = transaction.toJSON();
2951
3006
  return transaction;
2952
3007
  }
2953
3008
 
@@ -7230,7 +7285,9 @@ class Connection {
7230
7285
  });
7231
7286
  transaction.instructions = transactionOrMessage.instructions;
7232
7287
  } else {
7233
- transaction = Transaction.populate(transactionOrMessage);
7288
+ transaction = Transaction.populate(transactionOrMessage); // HACK: this function relies on mutating the populated transaction
7289
+
7290
+ transaction._message = transaction._json = undefined;
7234
7291
  }
7235
7292
 
7236
7293
  if (transaction.nonceInfo && signers) {