File tree Expand file tree Collapse file tree 3 files changed +12
-21
lines changed
packages/thirdweb/src/rpc Expand file tree Collapse file tree 3 files changed +12
-21
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " thirdweb " : patch
3
+ ---
4
+
5
+ Simplify RPC request handling
Original file line number Diff line number Diff line change @@ -78,16 +78,7 @@ export async function fetchRpc(
78
78
) ;
79
79
}
80
80
81
- if ( response . headers . get ( "Content-Type" ) ?. startsWith ( "application/json" ) ) {
82
- return await response . json ( ) ;
83
- }
84
- const text = await response . text ( ) ;
85
- try {
86
- return JSON . parse ( text ) ;
87
- } catch ( err ) {
88
- console . error ( "Error parsing response" , err , text ) ;
89
- throw err ;
90
- }
81
+ return await response . json ( ) ;
91
82
}
92
83
93
84
type FetchSingleRpcOptions = {
@@ -121,14 +112,5 @@ export async function fetchSingleRpc(
121
112
`RPC request failed with status ${ response . status } - ${ response . statusText } : ${ error || "unknown error" } ` ,
122
113
) ;
123
114
}
124
- if ( response . headers . get ( "Content-Type" ) ?. startsWith ( "application/json" ) ) {
125
- return await response . json ( ) ;
126
- }
127
- const text = await response . text ( ) ;
128
- try {
129
- return JSON . parse ( text ) ;
130
- } catch ( err ) {
131
- console . error ( "Error parsing response" , err , text ) ;
132
- throw err ;
133
- }
115
+ return await response . json ( ) ;
134
116
}
Original file line number Diff line number Diff line change @@ -144,7 +144,11 @@ export function getRpcClient(
144
144
145
145
// No response.
146
146
if ( ! response ) {
147
- inflight . reject ( new Error ( "No response" ) ) ;
147
+ inflight . reject (
148
+ new Error (
149
+ `No response for index ${ index } - all responses: ${ stringify ( responses ) } ` ,
150
+ ) ,
151
+ ) ;
148
152
}
149
153
// Response is an error or error string.
150
154
else if ( response instanceof Error ) {
You can’t perform that action at this time.
0 commit comments