Skip to content

Commit ef9bdd9

Browse files
authored
Merge pull request #449 from owallet-io/feat/fix-arbitrum
refactor: clean up code style with trailing commas and remove unused …
2 parents 5e4a961 + 9f2e405 commit ef9bdd9

3 files changed

Lines changed: 23 additions & 35 deletions

File tree

apps

Submodule apps updated from 3679a17 to 6c2cbba

packages/stores-eth/src/queries/coingecko-token-info.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ export class ObservableQueryCoingeckoTokenInfoInner extends ObservableQuery<{
2424
coingeckoAPIBaseURL: string,
2525
coingeckoAPIURI: string,
2626
protected readonly coingeckoChainId: string,
27-
contractAddress: string
27+
contractAddress: string,
2828
) {
2929
super(
3030
sharedContext,
3131
coingeckoAPIBaseURL,
3232
coingeckoAPIURI
3333
.replace("{coingeckoChainId}", coingeckoChainId)
34-
.replace("{contractAddress}", contractAddress)
34+
.replace("{contractAddress}", contractAddress),
3535
);
3636

3737
makeObservable(this);
@@ -63,7 +63,7 @@ export class ObservableQueryCoingeckoTokenInfo extends HasMapStore<
6363
protected readonly chainId: string,
6464
protected readonly chainGetter: ChainGetter,
6565
protected readonly coingeckoAPIBaseURL: string,
66-
protected readonly coingeckoAPIURI: string
66+
protected readonly coingeckoAPIURI: string,
6767
) {
6868
const coingeckoChainId = coingeckoChainIdMap[chainId];
6969

@@ -74,14 +74,14 @@ export class ObservableQueryCoingeckoTokenInfo extends HasMapStore<
7474
coingeckoAPIBaseURL,
7575
coingeckoAPIURI,
7676
coingeckoChainId,
77-
contractAddress
77+
contractAddress,
7878
);
7979
}
8080
});
8181
}
8282

8383
getQueryContract(
84-
contractAddress: string
84+
contractAddress: string,
8585
): ObservableQueryCoingeckoTokenInfoInner | undefined {
8686
return this.get(contractAddress) as ObservableQueryCoingeckoTokenInfoInner;
8787
}
@@ -90,8 +90,4 @@ export class ObservableQueryCoingeckoTokenInfo extends HasMapStore<
9090
const coingeckoChainIdMap: Record<string, string> = {
9191
"eip155:1": Network.ETHEREUM,
9292
"eip155:56": Network.BINANCE_SMART_CHAIN,
93-
"eip155:10": "optimistic-ethereum",
94-
"eip155:137": "polygon-pos",
95-
"eip155:8453": "base",
96-
"eip155:42161": "arbitrum-one",
9793
};

packages/stores-eth/src/queries/erc20-balances.ts

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ import { ObservableQuery } from "@owallet/stores";
1717
const 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

Comments
 (0)