File tree Expand file tree Collapse file tree 1 file changed +17
-6
lines changed
Expand file tree Collapse file tree 1 file changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -52,10 +52,21 @@ export const parseLogs = (input: unknown): readonly Log[] => {
5252 * @param input transaction log (for tx returned by the client you can use tx.result.log)
5353 */
5454export const parseRawLogs = ( input = '[]' ) : readonly Log [ ] => {
55- const logsToParse = JSON . parse ( input ) . map ( ( { events } : { events : readonly unknown [ ] } , i : number ) => ( {
56- msg_index : i ,
57- events,
58- log : '' ,
59- } ) ) ;
60- return parseLogs ( logsToParse ) ;
55+ try {
56+ const logsToParse = JSON . parse ( input ) . map ( ( { events } : { events : readonly unknown [ ] } , i : number ) => ( {
57+ msg_index : i ,
58+ events,
59+ log : '' ,
60+ } ) ) ;
61+ return parseLogs ( logsToParse ) ;
62+ } catch ( e ) {
63+ // Transactions that failed only contain a string error message in the logs
64+ return [
65+ {
66+ msg_index : 0 ,
67+ events : [ ] ,
68+ log : input ,
69+ } ,
70+ ] ;
71+ }
6172} ;
You can’t perform that action at this time.
0 commit comments