1- import { Connection , TransactionError } from './connection' ;
1+ import { Connection } from './connection' ;
22import { TransactionSignature } from './transaction' ;
33
44export class SendTransactionError extends Error {
5- #signature: TransactionSignature ;
6- #transactionError: TransactionError ;
7- #resolvedLogs: string [ ] | Promise < string [ ] > | undefined ;
5+ private signature : TransactionSignature ;
6+ private transactionMessage : string ;
7+ private transactionLogs ?: string [ ] ;
8+ private resolvedLogs : string [ ] | Promise < string [ ] > | undefined ;
89
910 constructor ( {
1011 action,
1112 signature,
12- transactionError,
13+ transactionMessage,
14+ transactionLogs,
1315 } : {
1416 action : 'send' | 'simulate' ;
1517 signature : TransactionSignature ;
16- transactionError : TransactionError ;
18+ transactionMessage : string ;
19+ transactionLogs ?: string [ ] ;
1720 } ) {
1821 let message : string ;
1922
2023 switch ( action ) {
2124 case 'send' :
2225 message =
2326 `Transaction ${ signature } resulted in an error. \n` +
24- `${ transactionError . message } . ` +
25- ( transactionError . data ?. logs
26- ? `Logs: \n${ JSON . stringify ( transactionError . data . logs . slice ( - 10 ) , null , 2 ) } . `
27+ `${ transactionMessage } . ` +
28+ ( transactionLogs
29+ ? `Logs: \n${ JSON . stringify ( transactionLogs . slice ( - 10 ) , null , 2 ) } . `
2730 : '' ) +
2831 '\nCatch the SendTransactionError and call `getLogs()` on it for full details.' ;
2932 break ;
3033 case 'simulate' :
3134 message =
32- `Simulation failed. \nMessage: ${ transactionError . message } . \n` +
33- ( transactionError . data ?. logs
34- ? `Logs: \n${ JSON . stringify ( transactionError . data . logs . slice ( - 10 ) , null , 2 ) } . `
35+ `Simulation failed. \nMessage: ${ transactionMessage } . \n` +
36+ ( transactionLogs
37+ ? `Logs: \n${ JSON . stringify ( transactionLogs . slice ( - 10 ) , null , 2 ) } . `
3538 : '' ) +
3639 '\nCatch the SendTransactionError and call `getLogs()` on it for full details.' ;
3740 break ;
@@ -40,26 +43,26 @@ export class SendTransactionError extends Error {
4043 }
4144 super ( message ) ;
4245
43- this . #signature = signature ;
44- this . #transactionError = transactionError ;
45- this . #resolvedLogs = transactionError . data ?. logs
46- ? transactionError . data . logs
47- : undefined ;
46+ this . signature = signature ;
47+ this . transactionMessage = transactionMessage ;
48+ this . transactionLogs = transactionLogs ;
49+ this . resolvedLogs = transactionLogs ? transactionLogs : undefined ;
4850 }
4951
50- get transactionError ( ) : TransactionError {
51- return this . #transactionError ;
52+ get transactionError ( ) : { message : string ; logs ?: string [ ] } {
53+ return { message : this . transactionMessage , logs : this . transactionLogs } ;
5254 }
5355
5456 async getLogs ( connection : Connection ) : Promise < string [ ] > {
55- if ( this . # resolvedLogs === undefined ) {
56- this . # resolvedLogs = new Promise ( ( resolve , reject ) => {
57+ if ( this . resolvedLogs === undefined ) {
58+ this . resolvedLogs = new Promise ( ( resolve , reject ) => {
5759 connection
58- . getTransaction ( this . # signature)
60+ . getTransaction ( this . signature )
5961 . then ( tx => {
6062 if ( tx && tx . meta && tx . meta . logMessages ) {
6163 const logs = tx . meta . logMessages ;
62- this . #resolvedLogs = logs ;
64+ this . resolvedLogs = logs ;
65+ this . transactionLogs = logs ;
6366 resolve ( logs ) ;
6467 } else {
6568 reject ( new Error ( 'Log messages not found' ) ) ;
@@ -68,7 +71,7 @@ export class SendTransactionError extends Error {
6871 . catch ( reject ) ;
6972 } ) ;
7073 }
71- return await this . # resolvedLogs;
74+ return await this . resolvedLogs ;
7275 }
7376}
7477
0 commit comments