@solana/web3.js 1.92.0 → 1.92.2

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.
@@ -2154,42 +2154,52 @@ class SendTransactionError extends Error {
2154
2154
  action,
2155
2155
  signature,
2156
2156
  transactionMessage,
2157
- transactionLogs
2157
+ logs
2158
2158
  }) {
2159
+ const maybeLogsOutput = logs ? `Logs: \n${JSON.stringify(logs.slice(-10), null, 2)}. ` : '';
2160
+ const guideText = '\nCatch the `SendTransactionError` and call `getLogs()` on it for full details.';
2159
2161
  let message;
2160
2162
  switch (action) {
2161
2163
  case 'send':
2162
- message = `Transaction ${signature} resulted in an error. \n` + `${transactionMessage}. ` + (transactionLogs ? `Logs: \n${JSON.stringify(transactionLogs.slice(-10), null, 2)}. ` : '') + '\nCatch the SendTransactionError and call `getLogs()` on it for full details.';
2164
+ message = `Transaction ${signature} resulted in an error. \n` + `${transactionMessage}. ` + maybeLogsOutput + guideText;
2163
2165
  break;
2164
2166
  case 'simulate':
2165
- message = `Simulation failed. \nMessage: ${transactionMessage}. \n` + (transactionLogs ? `Logs: \n${JSON.stringify(transactionLogs.slice(-10), null, 2)}. ` : '') + '\nCatch the SendTransactionError and call `getLogs()` on it for full details.';
2167
+ message = `Simulation failed. \nMessage: ${transactionMessage}. \n` + maybeLogsOutput + guideText;
2166
2168
  break;
2167
2169
  default:
2168
- message = 'Unknown action';
2170
+ {
2171
+ message = `Unknown action '${(a => a)(action)}'`;
2172
+ }
2169
2173
  }
2170
2174
  super(message);
2171
2175
  this.signature = void 0;
2172
2176
  this.transactionMessage = void 0;
2173
2177
  this.transactionLogs = void 0;
2174
- this.resolvedLogs = void 0;
2175
2178
  this.signature = signature;
2176
2179
  this.transactionMessage = transactionMessage;
2177
- this.transactionLogs = transactionLogs;
2178
- this.resolvedLogs = transactionLogs ? transactionLogs : undefined;
2180
+ this.transactionLogs = logs ? logs : undefined;
2179
2181
  }
2180
2182
  get transactionError() {
2181
2183
  return {
2182
2184
  message: this.transactionMessage,
2183
- logs: this.transactionLogs
2185
+ logs: Array.isArray(this.transactionLogs) ? this.transactionLogs : undefined
2184
2186
  };
2185
2187
  }
2188
+
2189
+ /* @deprecated Use `await getLogs()` instead */
2190
+ get logs() {
2191
+ const cachedLogs = this.transactionLogs;
2192
+ if (cachedLogs != null && typeof cachedLogs === 'object' && 'then' in cachedLogs) {
2193
+ return undefined;
2194
+ }
2195
+ return cachedLogs;
2196
+ }
2186
2197
  async getLogs(connection) {
2187
- if (this.resolvedLogs === undefined) {
2188
- this.resolvedLogs = new Promise((resolve, reject) => {
2198
+ if (!Array.isArray(this.transactionLogs)) {
2199
+ this.transactionLogs = new Promise((resolve, reject) => {
2189
2200
  connection.getTransaction(this.signature).then(tx => {
2190
2201
  if (tx && tx.meta && tx.meta.logMessages) {
2191
2202
  const logs = tx.meta.logMessages;
2192
- this.resolvedLogs = logs;
2193
2203
  this.transactionLogs = logs;
2194
2204
  resolve(logs);
2195
2205
  } else {
@@ -2198,7 +2208,7 @@ class SendTransactionError extends Error {
2198
2208
  }).catch(reject);
2199
2209
  });
2200
2210
  }
2201
- return await this.resolvedLogs;
2211
+ return await this.transactionLogs;
2202
2212
  }
2203
2213
  }
2204
2214
 
@@ -7301,7 +7311,7 @@ class Connection {
7301
7311
  action: 'simulate',
7302
7312
  signature: '',
7303
7313
  transactionMessage: res.error.message,
7304
- transactionLogs: logs
7314
+ logs: logs
7305
7315
  });
7306
7316
  }
7307
7317
  return res.result;
@@ -7411,7 +7421,7 @@ class Connection {
7411
7421
  action: skipPreflight ? 'send' : 'simulate',
7412
7422
  signature: '',
7413
7423
  transactionMessage: res.error.message,
7414
- transactionLogs: logs
7424
+ logs: logs
7415
7425
  });
7416
7426
  }
7417
7427
  return res.result;