@@ -62,7 +62,7 @@ Polymer({
62
62
value : false ,
63
63
} ,
64
64
65
- chainIdValue_ : String ,
65
+ chainIdValue_ : Number ,
66
66
invalidChainIdMessage_ : String ,
67
67
chainIdInvalid_ : {
68
68
type : Boolean ,
@@ -105,7 +105,7 @@ Polymer({
105
105
ready : function ( ) {
106
106
if ( Object . keys ( this . selected ) . length === 0 )
107
107
return
108
- this . chainIdValue_ = this . selected . chainId
108
+ this . chainIdValue_ = parseInt ( this . selected . chainId , 16 ) | 0
109
109
this . chainNameValue_ = this . selected . chainName
110
110
this . currencyNameValue_ = this . selected . nativeCurrency . name
111
111
this . currencySymbolValue_ = this . selected . nativeCurrency . symbol
@@ -135,20 +135,12 @@ Polymer({
135
135
136
136
return url . protocol === "http:" || url . protocol === "https:"
137
137
} ,
138
- isValidHexValue : function ( value ) {
139
- var parsed = parseInt ( value , 16 ) ;
140
- const processed = value . replace ( '0x' , '' ) . toLowerCase ( )
141
- return ( parsed . toString ( 16 ) === processed ) && value . startsWith ( '0x' ) ;
142
- } ,
143
138
/** @private */
144
139
chainIdChanged_ : function ( event ) {
145
140
const value = event . target . value
146
- this . chainIdInvalid_ = ! this . isValidHexValue ( value )
147
- const empty = value . trim ( ) === ''
141
+ this . chainIdInvalid_ = value <= 0
148
142
if ( this . chainIdInvalid_ ) {
149
- const text = empty ? this . i18n ( 'walletAddNetworkMandarotyFieldError' )
150
- : this . i18n ( 'walletAddNetworkInvalidChainId' )
151
- this . invalidChainIdMessage_ = text
143
+ this . invalidChainIdMessage_ = this . i18n ( 'walletAddNetworkInvalidChainId' )
152
144
}
153
145
this . updateSubmitButtonState_ ( )
154
146
} ,
@@ -198,7 +190,7 @@ Polymer({
198
190
return ;
199
191
}
200
192
}
201
- if ( this . chainIdValue_ === '' ) {
193
+ if ( this . chainIdValue_ <= 0 ) {
202
194
this . isSubmitButtonEnabled_ = false
203
195
return ;
204
196
}
@@ -287,9 +279,12 @@ Polymer({
287
279
}
288
280
} )
289
281
} ,
282
+ getHexNumber : function ( value ) {
283
+ return '0x' + Number ( this . chainIdValue_ ) . toString ( 16 )
284
+ } ,
290
285
onAddNetworkTap_ : function ( item ) {
291
286
let payload = Object ( {
292
- chainId : this . chainIdValue_ ,
287
+ chainId : this . getHexNumber ( ) ,
293
288
chainName : this . chainNameValue_ ,
294
289
} )
295
290
const nativeCurrency = Object ( {
0 commit comments