@solana/web3.js 1.92.1 → 1.92.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.
@@ -2154,40 +2154,53 @@ class SendTransactionError extends Error {
2154
2154
  action,
2155
2155
  signature,
2156
2156
  transactionMessage,
2157
- logs: logs
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}. ` + (logs ? `Logs: \n${JSON.stringify(logs.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` + (logs ? `Logs: \n${JSON.stringify(logs.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
- this.logs = void 0;
2177
+ this.transactionLogs = void 0;
2174
2178
  this.signature = signature;
2175
2179
  this.transactionMessage = transactionMessage;
2176
- this.logs = logs ? logs : undefined;
2180
+ this.transactionLogs = logs ? logs : undefined;
2177
2181
  }
2178
2182
  get transactionError() {
2179
2183
  return {
2180
2184
  message: this.transactionMessage,
2181
- logs: Array.isArray(this.logs) ? this.logs : undefined
2185
+ logs: Array.isArray(this.transactionLogs) ? this.transactionLogs : undefined
2182
2186
  };
2183
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
+ }
2184
2197
  async getLogs(connection) {
2185
- if (!Array.isArray(this.logs)) {
2186
- this.logs = new Promise((resolve, reject) => {
2198
+ if (!Array.isArray(this.transactionLogs)) {
2199
+ this.transactionLogs = new Promise((resolve, reject) => {
2187
2200
  connection.getTransaction(this.signature).then(tx => {
2188
2201
  if (tx && tx.meta && tx.meta.logMessages) {
2189
2202
  const logs = tx.meta.logMessages;
2190
- this.logs = logs;
2203
+ this.transactionLogs = logs;
2191
2204
  resolve(logs);
2192
2205
  } else {
2193
2206
  reject(new Error('Log messages not found'));
@@ -2195,7 +2208,7 @@ class SendTransactionError extends Error {
2195
2208
  }).catch(reject);
2196
2209
  });
2197
2210
  }
2198
- return await this.logs;
2211
+ return await this.transactionLogs;
2199
2212
  }
2200
2213
  }
2201
2214