@solana/web3.js 1.44.0 → 1.44.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solana/web3.js",
3
- "version": "1.44.0",
3
+ "version": "1.44.3",
4
4
  "description": "Solana Javascript API",
5
5
  "keywords": [
6
6
  "api",
package/src/connection.ts CHANGED
@@ -191,9 +191,9 @@ type Subscription = BaseSubscription &
191
191
  StatefulSubscription &
192
192
  DistributiveOmit<SubscriptionConfig, 'callback'>;
193
193
 
194
- type RpcRequest = (methodName: string, args: Array<any>) => any;
194
+ type RpcRequest = (methodName: string, args: Array<any>) => Promise<any>;
195
195
 
196
- type RpcBatchRequest = (requests: RpcParams[]) => any;
196
+ type RpcBatchRequest = (requests: RpcParams[]) => Promise<any[]>;
197
197
 
198
198
  /**
199
199
  * @internal
@@ -3566,7 +3566,16 @@ export class Connection {
3566
3566
  if ('error' in res) {
3567
3567
  throw new Error('failed to get transactions: ' + res.error.message);
3568
3568
  }
3569
- return res.result;
3569
+ const result = res.result;
3570
+ if (!result) return result;
3571
+
3572
+ return {
3573
+ ...result,
3574
+ transaction: {
3575
+ ...result.transaction,
3576
+ message: new Message(result.transaction.message),
3577
+ },
3578
+ };
3570
3579
  });
3571
3580
 
3572
3581
  return res;
package/src/index.ts CHANGED
@@ -25,6 +25,7 @@ export * from './errors';
25
25
  export * from './util/borsh-schema';
26
26
  export * from './util/send-and-confirm-transaction';
27
27
  export * from './util/send-and-confirm-raw-transaction';
28
+ export * from './util/tx-expiry-custom-errors';
28
29
  export * from './util/cluster';
29
30
 
30
31
  /**
@@ -327,17 +327,24 @@ export class Transaction {
327
327
  return this._message;
328
328
  }
329
329
 
330
- const {nonceInfo} = this;
331
- if (nonceInfo && this.instructions[0] != nonceInfo.nonceInstruction) {
332
- this.recentBlockhash = nonceInfo.nonce;
333
- this.instructions.unshift(nonceInfo.nonceInstruction);
330
+ let recentBlockhash;
331
+ let instructions: TransactionInstruction[];
332
+ if (this.nonceInfo) {
333
+ recentBlockhash = this.nonceInfo.nonce;
334
+ if (this.instructions[0] != this.nonceInfo.nonceInstruction) {
335
+ instructions = [this.nonceInfo.nonceInstruction, ...this.instructions];
336
+ } else {
337
+ instructions = this.instructions;
338
+ }
339
+ } else {
340
+ recentBlockhash = this.recentBlockhash;
341
+ instructions = this.instructions;
334
342
  }
335
- const {recentBlockhash} = this;
336
343
  if (!recentBlockhash) {
337
344
  throw new Error('Transaction recentBlockhash required');
338
345
  }
339
346
 
340
- if (this.instructions.length < 1) {
347
+ if (instructions.length < 1) {
341
348
  console.warn('No instructions provided');
342
349
  }
343
350
 
@@ -351,8 +358,8 @@ export class Transaction {
351
358
  throw new Error('Transaction fee payer required');
352
359
  }
353
360
 
354
- for (let i = 0; i < this.instructions.length; i++) {
355
- if (this.instructions[i].programId === undefined) {
361
+ for (let i = 0; i < instructions.length; i++) {
362
+ if (instructions[i].programId === undefined) {
356
363
  throw new Error(
357
364
  `Transaction instruction index ${i} has undefined program id`,
358
365
  );
@@ -361,7 +368,7 @@ export class Transaction {
361
368
 
362
369
  const programIds: string[] = [];
363
370
  const accountMetas: AccountMeta[] = [];
364
- this.instructions.forEach(instruction => {
371
+ instructions.forEach(instruction => {
365
372
  instruction.keys.forEach(accountMeta => {
366
373
  accountMetas.push({...accountMeta});
367
374
  });
@@ -471,7 +478,7 @@ export class Transaction {
471
478
  });
472
479
 
473
480
  const accountKeys = signedKeys.concat(unsignedKeys);
474
- const instructions: CompiledInstruction[] = this.instructions.map(
481
+ const compiledInstructions: CompiledInstruction[] = instructions.map(
475
482
  instruction => {
476
483
  const {data, programId} = instruction;
477
484
  return {
@@ -484,7 +491,7 @@ export class Transaction {
484
491
  },
485
492
  );
486
493
 
487
- instructions.forEach(instruction => {
494
+ compiledInstructions.forEach(instruction => {
488
495
  invariant(instruction.programIdIndex >= 0);
489
496
  instruction.accounts.forEach(keyIndex => invariant(keyIndex >= 0));
490
497
  });
@@ -497,7 +504,7 @@ export class Transaction {
497
504
  },
498
505
  accountKeys,
499
506
  recentBlockhash,
500
- instructions,
507
+ instructions: compiledInstructions,
501
508
  });
502
509
  }
503
510