File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,22 @@ type EIP1559Fee = {
2929 others ?: Array < EIP1559Price > ;
3030} ;
3131
32+ function decodeStringCallResult ( hexResult : string ) : string {
33+ if ( hexResult . length <= 2 ) {
34+ throw new Error ( 'Invalid hex result.' ) ;
35+ }
36+ try {
37+ return defaultAbiCoder . decode ( [ 'string' ] , hexResult ) [ 0 ] ;
38+ } catch ( e ) {
39+ console . error ( e ) ;
40+ // Non-standard name or symbol, type of bytes32.
41+ // See 0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2
42+ return Buffer . from ( hexResult . slice ( 2 ) , 'hex' )
43+ . toString ( )
44+ . replace ( / \0 + $ / , '' ) ;
45+ }
46+ }
47+
3248class Geth extends BaseClient {
3349 static readonly __LAST_BLOCK__ = 'latest' ;
3450 private _mmFee ! : MmFee ;
@@ -215,8 +231,8 @@ class Geth extends BaseClient {
215231 }
216232
217233 try {
218- const [ symbol ] = defaultAbiCoder . decode ( [ 'string' ] , symbolHex ) ;
219- const [ name ] = defaultAbiCoder . decode ( [ 'string' ] , nameHex ) ;
234+ const symbol = decodeStringCallResult ( symbolHex ) ;
235+ const name = decodeStringCallResult ( nameHex ) ;
220236 const decimals = parseInt ( decimalsHex , 16 ) ;
221237 check ( ! isNaN ( decimals ) ) ;
222238
You can’t perform that action at this time.
0 commit comments