@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.
@@ -2126,40 +2126,53 @@ class SendTransactionError extends Error {
2126
2126
  action,
2127
2127
  signature,
2128
2128
  transactionMessage,
2129
- logs: logs
2129
+ logs
2130
2130
  }) {
2131
+ const maybeLogsOutput = logs ? `Logs: \n${JSON.stringify(logs.slice(-10), null, 2)}. ` : '';
2132
+ const guideText = '\nCatch the `SendTransactionError` and call `getLogs()` on it for full details.';
2131
2133
  let message;
2132
2134
  switch (action) {
2133
2135
  case 'send':
2134
- 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.';
2136
+ message = `Transaction ${signature} resulted in an error. \n` + `${transactionMessage}. ` + maybeLogsOutput + guideText;
2135
2137
  break;
2136
2138
  case 'simulate':
2137
- 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.';
2139
+ message = `Simulation failed. \nMessage: ${transactionMessage}. \n` + maybeLogsOutput + guideText;
2138
2140
  break;
2139
2141
  default:
2140
- message = 'Unknown action';
2142
+ {
2143
+ message = `Unknown action '${(a => a)(action)}'`;
2144
+ }
2141
2145
  }
2142
2146
  super(message);
2143
2147
  this.signature = void 0;
2144
2148
  this.transactionMessage = void 0;
2145
- this.logs = void 0;
2149
+ this.transactionLogs = void 0;
2146
2150
  this.signature = signature;
2147
2151
  this.transactionMessage = transactionMessage;
2148
- this.logs = logs ? logs : undefined;
2152
+ this.transactionLogs = logs ? logs : undefined;
2149
2153
  }
2150
2154
  get transactionError() {
2151
2155
  return {
2152
2156
  message: this.transactionMessage,
2153
- logs: Array.isArray(this.logs) ? this.logs : undefined
2157
+ logs: Array.isArray(this.transactionLogs) ? this.transactionLogs : undefined
2154
2158
  };
2155
2159
  }
2160
+
2161
+ /* @deprecated Use `await getLogs()` instead */
2162
+ get logs() {
2163
+ const cachedLogs = this.transactionLogs;
2164
+ if (cachedLogs != null && typeof cachedLogs === 'object' && 'then' in cachedLogs) {
2165
+ return undefined;
2166
+ }
2167
+ return cachedLogs;
2168
+ }
2156
2169
  async getLogs(connection) {
2157
- if (!Array.isArray(this.logs)) {
2158
- this.logs = new Promise((resolve, reject) => {
2170
+ if (!Array.isArray(this.transactionLogs)) {
2171
+ this.transactionLogs = new Promise((resolve, reject) => {
2159
2172
  connection.getTransaction(this.signature).then(tx => {
2160
2173
  if (tx && tx.meta && tx.meta.logMessages) {
2161
2174
  const logs = tx.meta.logMessages;
2162
- this.logs = logs;
2175
+ this.transactionLogs = logs;
2163
2176
  resolve(logs);
2164
2177
  } else {
2165
2178
  reject(new Error('Log messages not found'));
@@ -2167,7 +2180,7 @@ class SendTransactionError extends Error {
2167
2180
  }).catch(reject);
2168
2181
  });
2169
2182
  }
2170
- return await this.logs;
2183
+ return await this.transactionLogs;
2171
2184
  }
2172
2185
  }
2173
2186