Skip to content

Commit 6e53ba0

Browse files
author
Lex Peterson
committed
fixup! Add loop fetch meta tokens from info server
1 parent 736153a commit 6e53ba0

File tree

2 files changed

+14
-26
lines changed

2 files changed

+14
-26
lines changed

src/ethereum/ethEngine.js

+3-20
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ import {
4646
type EthereumTxOtherParams,
4747
type EthereumWalletOtherData,
4848
type LastEstimatedGasLimit,
49-
type MetaToken,
5049
type MetaTokenMap,
5150
asEthereumFees,
5251
asMetaTokenMap
@@ -209,23 +208,7 @@ export class EthereumEngine extends CurrencyEngine {
209208
const valid = asMaybe(asMetaTokenMap)(jsonObj) != null
210209

211210
if (valid) {
212-
for (const contractAddress in jsonObj) {
213-
const { name, symbol, decimals, iconUrl }: MetaToken =
214-
jsonObj[contractAddress]
215-
216-
this.allTokens.push({
217-
currencyCode: symbol,
218-
currencyName: name,
219-
denominations: [
220-
{
221-
name: symbol,
222-
multiplier: Math.pow(10, decimals).toString()
223-
}
224-
],
225-
symbolImage: iconUrl,
226-
contractAddress
227-
})
228-
}
211+
this.allTokens.push(...jsonObj)
229212
} else {
230213
this.log.error(
231214
`Error: Fetched invalid metaTokens ${JSON.stringify(jsonObj)}`
@@ -244,13 +227,13 @@ export class EthereumEngine extends CurrencyEngine {
244227
245228
Formula:
246229
fee = baseMultiplier * baseFee + minPriorityFee
247-
230+
248231
Where:
249232
minPriorityFee = <minimum priority fee from info server>
250233
baseFee = <latest block's base fee>
251234
baseMultiplier = <multiplier from info server for low, standard, high, etc>
252235
253-
Reference analysis for choosing 2 gwei minimum priority fee:
236+
Reference analysis for choosing 2 gwei minimum priority fee:
254237
https://hackmd.io/@q8X_WM2nTfu6nuvAzqXiTQ/1559-wallets#:~:text=2%20gwei%20is%20probably%20a%20very%20good%20default
255238
*/
256239

src/ethereum/ethTypes.js

+11-6
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,21 @@ export const asEthereumFees = asObject<EthereumFee>(asEthereumFee)
7878
export type EthereumFees = $Call<typeof asEthereumFees>
7979

8080
export const asMetaToken = asObject({
81-
name: asString,
82-
symbol: asString,
83-
decimals: asNumber,
84-
tradable: asBoolean,
85-
iconUrl: asString
81+
currencyCode: asString,
82+
currencyName: asString,
83+
denominations: asArray(
84+
asObject({
85+
name: asString,
86+
multiplier: asString
87+
})
88+
),
89+
symbolImage: asOptional(asString),
90+
contractAddress: asOptional(asString)
8691
})
8792

8893
export type MetaToken = $Call<typeof asMetaToken>
8994

90-
export const asMetaTokenMap = asObject<MetaToken>(asMetaToken)
95+
export const asMetaTokenMap = asArray<MetaToken>(asMetaToken)
9196

9297
export type MetaTokenMap = $Call<typeof asMetaTokenMap>
9398

0 commit comments

Comments
 (0)