Skip to content

Commit

Permalink
fix: remove lodash chain for extension launch (#6383)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lanttcat authored May 30, 2022
1 parent 70da94b commit 6d9aaa4
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions packages/web3-shared/base/src/utils/token.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { keyBy, mapValues } from 'lodash-unified'
import {
FungibleToken,
NonFungibleToken,
Expand All @@ -7,7 +8,6 @@ import {
TokenType,
} from '../specs'
import type { Constants } from './types'
import { chain } from 'lodash-unified'

export function createFungibleToken<ChainId, SchemaType>(
chainId: ChainId,
Expand Down Expand Up @@ -118,22 +118,20 @@ export function createFungibleTokensFromConstants<T extends Constants<string>, C
symbol: string | ((chainId: ChainId) => string),
decimals: number | ((chainId: ChainId) => number),
) => {
return chain(chainIds)
.keyBy('value')
.mapValues<FungibleToken<ChainId, SchemaType>>(({ key: chainName, value: chainId }) => {
const evaluator = <R>(f: ((chainId: ChainId) => R) | R): R =>
// @ts-ignore
typeof f === 'function' ? f(chainId as ChainId) : f
const chainIdGroup = keyBy(chainIds, 'value')
return mapValues(chainIdGroup, ({ key: chainName, value: chainId }) => {
const evaluator = <R>(f: ((chainId: ChainId) => R) | R): R =>
// @ts-ignore
typeof f === 'function' ? f(chainId as ChainId) : f

return createFungibleToken<ChainId, SchemaType>(
chainId,
schema,
constants[key][chainName as 'Mainnet'] ?? '',
evaluator(name),
evaluator(symbol),
evaluator(decimals),
)
})
.value()
return createFungibleToken<ChainId, SchemaType>(
chainId,
schema,
constants[key][chainName as 'Mainnet'] ?? '',
evaluator(name),
evaluator(symbol),
evaluator(decimals),
)
})
}
}

0 comments on commit 6d9aaa4

Please sign in to comment.