@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.
package/lib/index.iife.js CHANGED
@@ -13357,42 +13357,52 @@ var solanaWeb3 = (function (exports) {
13357
13357
  action,
13358
13358
  signature,
13359
13359
  transactionMessage,
13360
- transactionLogs
13360
+ logs
13361
13361
  }) {
13362
+ const maybeLogsOutput = logs ? `Logs: \n${JSON.stringify(logs.slice(-10), null, 2)}. ` : '';
13363
+ const guideText = '\nCatch the `SendTransactionError` and call `getLogs()` on it for full details.';
13362
13364
  let message;
13363
13365
  switch (action) {
13364
13366
  case 'send':
13365
- 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.';
13367
+ message = `Transaction ${signature} resulted in an error. \n` + `${transactionMessage}. ` + maybeLogsOutput + guideText;
13366
13368
  break;
13367
13369
  case 'simulate':
13368
- 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.';
13370
+ message = `Simulation failed. \nMessage: ${transactionMessage}. \n` + maybeLogsOutput + guideText;
13369
13371
  break;
13370
13372
  default:
13371
- message = 'Unknown action';
13373
+ {
13374
+ message = `Unknown action '${(a => a)(action)}'`;
13375
+ }
13372
13376
  }
13373
13377
  super(message);
13374
13378
  this.signature = void 0;
13375
13379
  this.transactionMessage = void 0;
13376
13380
  this.transactionLogs = void 0;
13377
- this.resolvedLogs = void 0;
13378
13381
  this.signature = signature;
13379
13382
  this.transactionMessage = transactionMessage;
13380
- this.transactionLogs = transactionLogs;
13381
- this.resolvedLogs = transactionLogs ? transactionLogs : undefined;
13383
+ this.transactionLogs = logs ? logs : undefined;
13382
13384
  }
13383
13385
  get transactionError() {
13384
13386
  return {
13385
13387
  message: this.transactionMessage,
13386
- logs: this.transactionLogs
13388
+ logs: Array.isArray(this.transactionLogs) ? this.transactionLogs : undefined
13387
13389
  };
13388
13390
  }
13391
+
13392
+ /* @deprecated Use `await getLogs()` instead */
13393
+ get logs() {
13394
+ const cachedLogs = this.transactionLogs;
13395
+ if (cachedLogs != null && typeof cachedLogs === 'object' && 'then' in cachedLogs) {
13396
+ return undefined;
13397
+ }
13398
+ return cachedLogs;
13399
+ }
13389
13400
  async getLogs(connection) {
13390
- if (this.resolvedLogs === undefined) {
13391
- this.resolvedLogs = new Promise((resolve, reject) => {
13401
+ if (!Array.isArray(this.transactionLogs)) {
13402
+ this.transactionLogs = new Promise((resolve, reject) => {
13392
13403
  connection.getTransaction(this.signature).then(tx => {
13393
13404
  if (tx && tx.meta && tx.meta.logMessages) {
13394
13405
  const logs = tx.meta.logMessages;
13395
- this.resolvedLogs = logs;
13396
13406
  this.transactionLogs = logs;
13397
13407
  resolve(logs);
13398
13408
  } else {
@@ -13401,7 +13411,7 @@ var solanaWeb3 = (function (exports) {
13401
13411
  }).catch(reject);
13402
13412
  });
13403
13413
  }
13404
- return await this.resolvedLogs;
13414
+ return await this.transactionLogs;
13405
13415
  }
13406
13416
  }
13407
13417
 
@@ -20698,7 +20708,7 @@ var solanaWeb3 = (function (exports) {
20698
20708
  action: 'simulate',
20699
20709
  signature: '',
20700
20710
  transactionMessage: res.error.message,
20701
- transactionLogs: logs
20711
+ logs: logs
20702
20712
  });
20703
20713
  }
20704
20714
  return res.result;
@@ -20808,7 +20818,7 @@ var solanaWeb3 = (function (exports) {
20808
20818
  action: skipPreflight ? 'send' : 'simulate',
20809
20819
  signature: '',
20810
20820
  transactionMessage: res.error.message,
20811
- transactionLogs: logs
20821
+ logs: logs
20812
20822
  });
20813
20823
  }
20814
20824
  return res.result;