@solana/web3.js 1.20.3 → 1.21.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.
@@ -2423,6 +2423,17 @@ class EpochSchedule {
2423
2423
 
2424
2424
  }
2425
2425
 
2426
+ class SendTransactionError extends Error {
2427
+ constructor(message, logs) {
2428
+ super(message);
2429
+
2430
+ _defineProperty(this, "logs", void 0);
2431
+
2432
+ this.logs = logs;
2433
+ }
2434
+
2435
+ }
2436
+
2426
2437
  // TODO: These constants should be removed in favor of reading them out of a
2427
2438
  // Syscall account
2428
2439
 
@@ -4704,7 +4715,19 @@ class Connection {
4704
4715
  const res = create(unsafeRes, SimulatedTransactionResponseStruct);
4705
4716
 
4706
4717
  if ('error' in res) {
4707
- throw new Error('failed to simulate transaction: ' + res.error.message);
4718
+ let logs;
4719
+
4720
+ if ('data' in res.error) {
4721
+ logs = res.error.data.logs;
4722
+
4723
+ if (logs && Array.isArray(logs)) {
4724
+ const traceIndent = '\n ';
4725
+ const logTrace = traceIndent + logs.join(traceIndent);
4726
+ console.error(res.error.message, logTrace);
4727
+ }
4728
+ }
4729
+
4730
+ throw new SendTransactionError('failed to simulate transaction: ' + res.error.message, logs);
4708
4731
  }
4709
4732
 
4710
4733
  return res.result;
@@ -4786,8 +4809,10 @@ class Connection {
4786
4809
  const res = create(unsafeRes, SendTransactionRpcResult);
4787
4810
 
4788
4811
  if ('error' in res) {
4812
+ let logs;
4813
+
4789
4814
  if ('data' in res.error) {
4790
- const logs = res.error.data.logs;
4815
+ logs = res.error.data.logs;
4791
4816
 
4792
4817
  if (logs && Array.isArray(logs)) {
4793
4818
  const traceIndent = '\n ';
@@ -4796,7 +4821,7 @@ class Connection {
4796
4821
  }
4797
4822
  }
4798
4823
 
4799
- throw new Error('failed to send transaction: ' + res.error.message);
4824
+ throw new SendTransactionError('failed to send transaction: ' + res.error.message, logs);
4800
4825
  }
4801
4826
 
4802
4827
  return res.result;