Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 2 additions & 15 deletions packages/mask/src/plugins/EVM/UI/Web3State/getAssetsFn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export const getFungibleAssetsFn =
async (address: string, providerType: string, network: Web3Plugin.NetworkDescriptor, pagination?: Pagination) => {
const chainId = context.chainId.getCurrentValue()
const wallet = context.wallets.getCurrentValue().find((x) => isSameAddress(x.address, address))
const socket = await context.providerSocket
const networks = PLUGIN_NETWORKS
const trustedTokens = uniqBy(
context.erc20Tokens
Expand All @@ -51,19 +50,7 @@ export const getFungibleAssetsFn =
createExternalProvider(context.request, context.getSendOverrides, context.getRequestOptions),
)
const { BALANCE_CHECKER_ADDRESS } = getEthereumConstants(chainId)
const socketId = `mask.fetchFungibleTokenAsset_${address}`
let dataFromProvider = await socket.sendAsync<Web3Plugin.Asset<Web3Plugin.FungibleToken>>({
id: socketId,
method: 'mask.fetchFungibleTokenAsset',
params: {
address: address,
pageSize: 10000,
},
})
if (!dataFromProvider.length) {
// @ts-ignore getAssetList Asset[]
dataFromProvider = await context.getAssetsList(address, FungibleAssetProvider.DEBANK)
}
const dataFromProvider = await context.getAssetsList(address, FungibleAssetProvider.DEBANK)
const assetsFromProvider: Web3Plugin.Asset<Web3Plugin.FungibleToken>[] = dataFromProvider.map((x) => ({
id: x.token.address,
chainId: x.token.chainId,
Expand Down Expand Up @@ -108,7 +95,7 @@ export const getFungibleAssetsFn =
const assetFromChain = balanceList.map(
(balance, idx): Web3Plugin.Asset<Web3Plugin.FungibleToken> => ({
id: trustedTokens[idx].address,
chainId: chainId,
chainId,
token: {
...trustedTokens[idx],
id: trustedTokens[idx].address,
Expand Down
7 changes: 6 additions & 1 deletion packages/mask/src/plugins/Wallet/apis/debank.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ export async function getAssetsList(address: string) {
`${DEBANK_OPEN_API}/v1/user/token_list?is_all=true&has_balance=true&id=${address.toLowerCase()}`,
)
try {
return ((await response.json()) ?? []) as WalletTokenRecord[]
const records = ((await response.json()) ?? []) as WalletTokenRecord[]
return records.map((x) => ({
...x,
id: x.id === 'bsc' ? 'bnb' : x.id,
chain: x.chain === 'bsc' ? 'bnb' : x.chain,
}))
} catch {
return []
}
Expand Down
1 change: 1 addition & 0 deletions packages/plugins/CyberConnect/src/base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Plugin, NetworkPluginID } from '@masknet/plugin-infra'
import { ChainId } from '@masknet/web3-shared-evm'
import { CYBERCONNECT_PLUGIN_ID } from './constants'
import { CyberConnectIcon } from './assets/CyberConnectIcon'

export const base: Plugin.Shared.Definition = {
ID: CYBERCONNECT_PLUGIN_ID,
icon: <CyberConnectIcon />,
Expand Down
8 changes: 7 additions & 1 deletion packages/web3-providers/src/debank/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ export async function getAssetListFromDebank(address: string) {
)
try {
const result = ((await response.json()) ?? []) as WalletTokenRecord[]
return formatAssets(result)
return formatAssets(
result.map((x) => ({
...x,
id: x.id === 'bsc' ? 'bnb' : x.id,
chain: x.chain === 'bsc' ? 'bnb' : x.chain,
})),
)
} catch {
return []
}
Expand Down
2 changes: 1 addition & 1 deletion packages/web3-shared/evm/assets/chains.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
"chainId": 97,
"fullName": "Binance",
"shortName": "bnbt",
"chain": "BSC",
"chain": "BNB Chain",
"network": "chapel",
"networkId": 97,
"nativeCurrency": {
Expand Down