@solana/web3.js 1.92.0 → 1.92.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solana/web3.js",
3
- "version": "1.92.0",
3
+ "version": "1.92.1",
4
4
  "description": "Solana Javascript API",
5
5
  "keywords": [
6
6
  "api",
package/src/connection.ts CHANGED
@@ -5787,7 +5787,7 @@ export class Connection {
5787
5787
  action: 'simulate',
5788
5788
  signature: '',
5789
5789
  transactionMessage: res.error.message,
5790
- transactionLogs: logs,
5790
+ logs: logs,
5791
5791
  });
5792
5792
  }
5793
5793
  return res.result;
@@ -5928,7 +5928,7 @@ export class Connection {
5928
5928
  action: skipPreflight ? 'send' : 'simulate',
5929
5929
  signature: '',
5930
5930
  transactionMessage: res.error.message,
5931
- transactionLogs: logs,
5931
+ logs: logs,
5932
5932
  });
5933
5933
  }
5934
5934
  return res.result;
package/src/errors.ts CHANGED
@@ -4,19 +4,18 @@ import {TransactionSignature} from './transaction';
4
4
  export class SendTransactionError extends Error {
5
5
  private signature: TransactionSignature;
6
6
  private transactionMessage: string;
7
- private transactionLogs?: string[];
8
- private resolvedLogs: string[] | Promise<string[]> | undefined;
7
+ private logs: string[] | Promise<string[]> | undefined;
9
8
 
10
9
  constructor({
11
10
  action,
12
11
  signature,
13
12
  transactionMessage,
14
- transactionLogs,
13
+ logs: logs,
15
14
  }: {
16
15
  action: 'send' | 'simulate';
17
16
  signature: TransactionSignature;
18
17
  transactionMessage: string;
19
- transactionLogs?: string[];
18
+ logs?: string[];
20
19
  }) {
21
20
  let message: string;
22
21
 
@@ -25,16 +24,16 @@ export class SendTransactionError extends Error {
25
24
  message =
26
25
  `Transaction ${signature} resulted in an error. \n` +
27
26
  `${transactionMessage}. ` +
28
- (transactionLogs
29
- ? `Logs: \n${JSON.stringify(transactionLogs.slice(-10), null, 2)}. `
27
+ (logs
28
+ ? `Logs: \n${JSON.stringify(logs.slice(-10), null, 2)}. `
30
29
  : '') +
31
30
  '\nCatch the SendTransactionError and call `getLogs()` on it for full details.';
32
31
  break;
33
32
  case 'simulate':
34
33
  message =
35
34
  `Simulation failed. \nMessage: ${transactionMessage}. \n` +
36
- (transactionLogs
37
- ? `Logs: \n${JSON.stringify(transactionLogs.slice(-10), null, 2)}. `
35
+ (logs
36
+ ? `Logs: \n${JSON.stringify(logs.slice(-10), null, 2)}. `
38
37
  : '') +
39
38
  '\nCatch the SendTransactionError and call `getLogs()` on it for full details.';
40
39
  break;
@@ -45,24 +44,25 @@ export class SendTransactionError extends Error {
45
44
 
46
45
  this.signature = signature;
47
46
  this.transactionMessage = transactionMessage;
48
- this.transactionLogs = transactionLogs;
49
- this.resolvedLogs = transactionLogs ? transactionLogs : undefined;
47
+ this.logs = logs ? logs : undefined;
50
48
  }
51
49
 
52
50
  get transactionError(): {message: string; logs?: string[]} {
53
- return {message: this.transactionMessage, logs: this.transactionLogs};
51
+ return {
52
+ message: this.transactionMessage,
53
+ logs: Array.isArray(this.logs) ? this.logs : undefined,
54
+ };
54
55
  }
55
56
 
56
57
  async getLogs(connection: Connection): Promise<string[]> {
57
- if (this.resolvedLogs === undefined) {
58
- this.resolvedLogs = new Promise((resolve, reject) => {
58
+ if (!Array.isArray(this.logs)) {
59
+ this.logs = new Promise((resolve, reject) => {
59
60
  connection
60
61
  .getTransaction(this.signature)
61
62
  .then(tx => {
62
63
  if (tx && tx.meta && tx.meta.logMessages) {
63
64
  const logs = tx.meta.logMessages;
64
- this.resolvedLogs = logs;
65
- this.transactionLogs = logs;
65
+ this.logs = logs;
66
66
  resolve(logs);
67
67
  } else {
68
68
  reject(new Error('Log messages not found'));
@@ -71,7 +71,7 @@ export class SendTransactionError extends Error {
71
71
  .catch(reject);
72
72
  });
73
73
  }
74
- return await this.resolvedLogs;
74
+ return await this.logs;
75
75
  }
76
76
  }
77
77