@@ -17,10 +17,6 @@ import { ObservableQuery } from "@owallet/stores";
1717const thirdparySupportedChainIdMap : Record < string , string > = {
1818 "eip155:1" : Network . ETHEREUM ,
1919 "eip155:56" : Network . BINANCE_SMART_CHAIN ,
20- "eip155:10" : "opt" ,
21- "eip155:137" : "polygon" ,
22- "eip155:8453" : "base" ,
23- "eip155:42161" : "arb" ,
2420} ;
2521
2622// interface ThirdpartyERC20TokenBalance {
@@ -47,12 +43,12 @@ export class ObservableQueryThirdpartyERC20BalancesImplParent extends Observable
4743 sharedContext : QuerySharedContext ,
4844 protected readonly chainId : string ,
4945 protected readonly chainGetter : ChainGetter ,
50- protected readonly ethereumHexAddress : string
46+ protected readonly ethereumHexAddress : string ,
5147 ) {
5248 super (
5349 sharedContext ,
5450 urlTxHistory ,
55- `raw-tx-history/all/balances?network=${ thirdparySupportedChainIdMap [ chainId ] } &address=${ ethereumHexAddress } `
51+ `raw-tx-history/all/balances?network=${ thirdparySupportedChainIdMap [ chainId ] } &address=${ ethereumHexAddress } ` ,
5652 ) ;
5753
5854 makeObservable ( this ) ;
@@ -67,7 +63,7 @@ export class ObservableQueryThirdpartyERC20BalancesImplParent extends Observable
6763 }
6864
6965 protected override onReceiveResponse (
70- response : Readonly < QueryResponse < ResBalanceEvm > >
66+ response : Readonly < QueryResponse < ResBalanceEvm > > ,
7167 ) {
7268 super . onReceiveResponse ( response ) ;
7369 const chainInfo = this . chainGetter . getChain ( this . chainId ) ;
@@ -77,14 +73,14 @@ export class ObservableQueryThirdpartyERC20BalancesImplParent extends Observable
7773 ( tokenBalance ) =>
7874 tokenBalance . balance != null &&
7975 Number ( tokenBalance . balance ) > 0 &&
80- tokenBalance . tokenAddress !== contractWeth
76+ tokenBalance . tokenAddress !== contractWeth ,
8177 ) ;
8278 if ( ! erc20Denoms ) return ;
8379
8480 const tokenAddresses = erc20Denoms
8581 . map (
8682 ( { tokenAddress } ) =>
87- `${ thirdparySupportedChainIdMap [ this . chainId ] } %2B${ tokenAddress } `
83+ `${ thirdparySupportedChainIdMap [ this . chainId ] } %2B${ tokenAddress } ` ,
8884 )
8985 . join ( "," ) ;
9086 if ( ! tokenAddresses ) return ;
@@ -95,7 +91,7 @@ export class ObservableQueryThirdpartyERC20BalancesImplParent extends Observable
9591 // 5. Map token metadata to currencies
9692 const currencyInfo = tokenInfos
9793 . filter (
98- ( { coingeckoId, denom } ) => coingeckoId !== null && denom !== null
94+ ( { coingeckoId, denom } ) => coingeckoId !== null && denom !== null ,
9995 )
10096 . map ( ( item ) => ( {
10197 coinImageUrl : item . imgUrl ,
@@ -112,14 +108,12 @@ export class ObservableQueryThirdpartyERC20BalancesImplParent extends Observable
112108 }
113109}
114110
115- export class ObservableQueryThirdpartyERC20BalancesImpl
116- implements IObservableQueryBalanceImpl
117- {
111+ export class ObservableQueryThirdpartyERC20BalancesImpl implements IObservableQueryBalanceImpl {
118112 constructor (
119113 protected readonly parent : ObservableQueryThirdpartyERC20BalancesImplParent ,
120114 protected readonly chainId : string ,
121115 protected readonly chainGetter : ChainGetter ,
122- protected readonly denomHelper : DenomHelper
116+ protected readonly denomHelper : DenomHelper ,
123117 ) {
124118 makeObservable ( this ) ;
125119 }
@@ -134,16 +128,16 @@ export class ObservableQueryThirdpartyERC20BalancesImpl
134128
135129 const contractAddress = this . denomHelper . denom . replace ( "erc20:" , "" ) ;
136130 const tokenBalance = this . response . data . result . find (
137- ( bal ) => bal . tokenAddress === contractAddress
131+ ( bal ) => bal . tokenAddress === contractAddress ,
138132 ) ;
139133 if ( tokenBalance ?. balance == null ) {
140134 return new CoinPretty ( currency , new Int ( 0 ) ) . ready ( false ) ;
141135 }
142136 return new CoinPretty (
143137 currency ,
144138 new Dec ( tokenBalance . balance ) . mul (
145- DecUtils . getTenExponentN ( currency . coinDecimals )
146- )
139+ DecUtils . getTenExponentN ( currency . coinDecimals ) ,
140+ ) ,
147141 ) ;
148142 }
149143
@@ -197,7 +191,7 @@ export class ObservableQueryThirdpartyERC20BalancesImpl
197191 reject ( e ) ;
198192 }
199193 } ) ( ) ;
200- }
194+ } ,
201195 ) ;
202196 return this . parent . duplicatedFetchResolver ;
203197 }
@@ -216,9 +210,7 @@ export class ObservableQueryThirdpartyERC20BalancesImpl
216210 }
217211}
218212
219- export class ObservableQueryThirdpartyERC20BalanceRegistry
220- implements BalanceRegistry
221- {
213+ export class ObservableQueryThirdpartyERC20BalanceRegistry implements BalanceRegistry {
222214 protected parentMap : Map <
223215 string ,
224216 ObservableQueryThirdpartyERC20BalancesImplParent
@@ -230,7 +222,7 @@ export class ObservableQueryThirdpartyERC20BalanceRegistry
230222 chainId : string ,
231223 chainGetter : ChainGetter ,
232224 address : string ,
233- minimalDenom : string
225+ minimalDenom : string ,
234226 ) : ObservableQueryThirdpartyERC20BalancesImpl | undefined {
235227 const denomHelper = new DenomHelper ( minimalDenom ) ;
236228 const chainInfo = chainGetter . getChain ( chainId ) ;
@@ -254,16 +246,16 @@ export class ObservableQueryThirdpartyERC20BalanceRegistry
254246 this . sharedContext ,
255247 chainId ,
256248 chainGetter ,
257- address
258- )
249+ address ,
250+ ) ,
259251 ) ;
260252 }
261253
262254 return new ObservableQueryThirdpartyERC20BalancesImpl (
263255 this . parentMap . get ( key ) ! ,
264256 chainId ,
265257 chainGetter ,
266- denomHelper
258+ denomHelper ,
267259 ) ;
268260 }
269261}
0 commit comments