-
Notifications
You must be signed in to change notification settings - Fork 306
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add new token selector and show balance (#3482)
* feat: add searchable list component in theme package * fix: token icon not show on BSC (#3383) * fix: change asset base url of binance token icon * fix: fetch token icon uri from mask.json * fix: perfect token icon map for missing in trust wallet and logoURI 404 * refactor: use isSameAddress to compare addresses in TokenIcon * chore: move special icon list to json file (#3402) * fix: typo error * fix: should use incoming chainId when get token asset base uri Co-authored-by: Septs <[email protected]> (cherry picked from commit 976f5f4) * feat: add token list component in dashboard package * chore: migrate useERC20TokensDetailedFromTokenLists to web3-shared * chore: @DimensionDev to @masknet * chore: fix pr comments * fix: rename TokenIconSpeialIconList to TokenIconSpecialIconList * fix: remove invalid style * fix: use currySameAddress in token icon to compare token address * chore: move TokenList and TokenIcon to share * chore: remove unused useImageFailOver hook * chore: move ErrorBoundary / QRCode / locales / useSnackbarCallback to shared from them * fix: work around for cannot be named without a reference * chore: remove unused package * refactor: use deconstruction for getTokenAssetBaseURLConstants in token icon * refactor: add interface NetworkSettings in setting * fix: fix prettier * refactor: use deconstruction for constant * refactor: rename token list props * fix: merge develop * refactor: add comment for token icon load * refactor: rename searchable list props to item keys to avoid react remove key * chore: remove useless code Co-authored-by: Jack Works <[email protected]>
- Loading branch information
1 parent
119ee53
commit 5376358
Showing
99 changed files
with
1,435 additions
and
863 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"TOKEN_ASSET_BASE_URI": { | ||
"Mainnet": [ | ||
"https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum", | ||
"https://rawcdn.githack.com/trustwallet/assets/master/blockchains/ethereum" | ||
], | ||
"Ropsten": [ | ||
"https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum", | ||
"https://rawcdn.githack.com/trustwallet/assets/master/blockchains/ethereum" | ||
], | ||
"Rinkeby": [ | ||
"https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum", | ||
"https://rawcdn.githack.com/trustwallet/assets/master/blockchains/ethereum" | ||
], | ||
"Kovan": [ | ||
"https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum", | ||
"https://rawcdn.githack.com/trustwallet/assets/master/blockchains/ethereum" | ||
], | ||
"Gorli": [ | ||
"https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum", | ||
"https://rawcdn.githack.com/trustwallet/assets/master/blockchains/ethereum" | ||
], | ||
"BSC": [ | ||
"https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/smartchain", | ||
"https://rawcdn.githack.com/trustwallet/assets/master/blockchains/smartchain" | ||
], | ||
"BSCT": [ | ||
"https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/smartchain", | ||
"https://rawcdn.githack.com/trustwallet/assets/master/blockchains/smartchain" | ||
], | ||
"Matic": [ | ||
"https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/polygon", | ||
"https://rawcdn.githack.com/trustwallet/assets/master/blockchains/polygon" | ||
], | ||
"Mumbai": [ | ||
"https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/polygon", | ||
"https://rawcdn.githack.com/trustwallet/assets/master/blockchains/polygon" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
packages/dashboard/src/pages/Wallets/components/AddCollectibleDialog/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/dashboard/src/pages/Wallets/components/AddTokenConfirmUI/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
packages/dashboard/src/pages/Wallets/components/AddTokenDialog/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
packages/dashboard/src/pages/Wallets/components/ReceiveDialog/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 0 additions & 70 deletions
70
packages/dashboard/src/pages/Wallets/components/TokenIcon/index.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
packages/dashboard/src/pages/Wallets/hooks/useERC20TokensDetailed.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { | ||
EthereumTokenType, | ||
isSameAddress, | ||
TokenListsState, | ||
useAssetsFromChain, | ||
useERC20TokensDetailedFromTokenLists, | ||
useEthereumConstants, | ||
useNativeTokenDetailed, | ||
useTokenConstants, | ||
} from '@masknet/web3-shared' | ||
import { uniqBy } from 'lodash-es' | ||
import { useMemo } from 'react' | ||
|
||
export function useERC20TokensDetailed() { | ||
const { ERC20_TOKEN_LISTS } = useEthereumConstants() | ||
const { value: nativeTokenDetailed } = useNativeTokenDetailed() | ||
const { state, tokensDetailed: erc20TokensDetailed } = useERC20TokensDetailedFromTokenLists(ERC20_TOKEN_LISTS) | ||
|
||
//#region mask token | ||
const { MASK_ADDRESS } = useTokenConstants() | ||
//#endregion | ||
|
||
const tokens = useMemo( | ||
() => | ||
uniqBy( | ||
nativeTokenDetailed ? [nativeTokenDetailed, ...erc20TokensDetailed] : [...erc20TokensDetailed], | ||
(x) => x.address.toLowerCase(), | ||
).sort((a, z) => { | ||
if (a.type === EthereumTokenType.Native) return -1 | ||
if (z.type === EthereumTokenType.Native) return 1 | ||
if (isSameAddress(a.address, MASK_ADDRESS)) return -1 | ||
if (isSameAddress(z.address, MASK_ADDRESS)) return 1 | ||
return 0 | ||
}), | ||
[nativeTokenDetailed, erc20TokensDetailed.length], | ||
) | ||
|
||
const { | ||
value: assetsDetailedChain = [], | ||
loading: assetsDetailedChainLoading, | ||
error: assetsDetailedChainError, | ||
} = useAssetsFromChain(tokens) | ||
|
||
return { | ||
value: assetsDetailedChain, | ||
loading: state !== TokenListsState.READY || assetsDetailedChainLoading, | ||
error: assetsDetailedChainError, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...me/stories/components/CrashUI.stories.tsx → ...ard/stories/components/Shared/CrashUI.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export { ErrorBoundary, withErrorBoundary } from '@masknet/theme' | ||
export { ErrorBoundary, withErrorBoundary } from '@masknet/shared' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.