diff --git a/.github/workflows/deploy-proxy.yml b/.github/workflows/deploy-proxy.yml index 9bd3176fa268..3bcc0997a8c6 100644 --- a/.github/workflows/deploy-proxy.yml +++ b/.github/workflows/deploy-proxy.yml @@ -1,7 +1,8 @@ name: Publish Proxy Package on: - workflow_dispatch: + push: + branches: [fix/nftscan-image-url] jobs: build: runs-on: ubuntu-20.04 diff --git a/cspell.json b/cspell.json index b26de3d954c0..fd922f7317f4 100644 --- a/cspell.json +++ b/cspell.json @@ -275,6 +275,7 @@ "nrge", "nrgt", "nyfi", + "okex", "openocean", "pausable", "pkts", @@ -287,6 +288,7 @@ "redpackets", "renfil", "shapeclip", + "ssrb", "steth", "swaptoken", "testweb", diff --git a/package.json b/package.json index f3673747e6e7..d1c6a2792c9a 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "yarn": ">=999.0.0", "npm": ">=999.0.0" }, - "version": "2.7.0", + "version": "2.8.1", "private": true, "license": "AGPL-3.0-or-later", "scripts": { diff --git a/packages/dashboard/src/pages/Wallets/components/Balance/index.tsx b/packages/dashboard/src/pages/Wallets/components/Balance/index.tsx index d782c2df2c3c..88763228ff6d 100644 --- a/packages/dashboard/src/pages/Wallets/components/Balance/index.tsx +++ b/packages/dashboard/src/pages/Wallets/components/Balance/index.tsx @@ -122,10 +122,13 @@ export const Balance = memo( {showOperations && ( - - - + - + {availability.isClaimed ? null : ( - - + + } classes={{ connectWallet: classes.button, @@ -454,9 +464,9 @@ export function RedPacketNft({ payload }: RedPacketNftProps) { - + )} - + )} ) diff --git a/packages/mask/src/plugins/RedPacket/SNSAdaptor/hooks/useAvailabilityNftRedPacket.ts b/packages/mask/src/plugins/RedPacket/SNSAdaptor/hooks/useAvailabilityNftRedPacket.ts index 1537455aa3d1..7e09ff373c0d 100644 --- a/packages/mask/src/plugins/RedPacket/SNSAdaptor/hooks/useAvailabilityNftRedPacket.ts +++ b/packages/mask/src/plugins/RedPacket/SNSAdaptor/hooks/useAvailabilityNftRedPacket.ts @@ -1,9 +1,10 @@ +import type { ChainId } from '@masknet/web3-shared-evm' import BigNumber from 'bignumber.js' import { useAsyncRetry } from 'react-use' import { useNftRedPacketContract } from './useNftRedPacketContract' -export function useAvailabilityNftRedPacket(id: string, from: string) { - const nftRedPacketContract = useNftRedPacketContract() +export function useAvailabilityNftRedPacket(id: string, from: string, chainId?: ChainId) { + const nftRedPacketContract = useNftRedPacketContract(chainId) return useAsyncRetry(async () => { if (!id || !nftRedPacketContract) return null const availability = await nftRedPacketContract.methods.check_availability(id).call({ diff --git a/packages/mask/src/plugins/RedPacket/SNSAdaptor/hooks/useNftRedPacketContract.ts b/packages/mask/src/plugins/RedPacket/SNSAdaptor/hooks/useNftRedPacketContract.ts index f61aad97f449..14dabadf3fe6 100644 --- a/packages/mask/src/plugins/RedPacket/SNSAdaptor/hooks/useNftRedPacketContract.ts +++ b/packages/mask/src/plugins/RedPacket/SNSAdaptor/hooks/useNftRedPacketContract.ts @@ -1,10 +1,10 @@ import NftRedPacketABI from '@masknet/web3-contracts/abis/NftRedPacket.json' -import { useContract, useNftRedPacketConstants } from '@masknet/web3-shared-evm' +import { ChainId, useContract, useNftRedPacketConstants } from '@masknet/web3-shared-evm' import type { NftRedPacket } from '@masknet/web3-contracts/types/NftRedPacket' import type { AbiItem } from 'web3-utils' -export function useNftRedPacketContract() { - const { RED_PACKET_NFT_ADDRESS } = useNftRedPacketConstants() - const contract = useContract(RED_PACKET_NFT_ADDRESS, NftRedPacketABI as AbiItem[]) +export function useNftRedPacketContract(chainId?: ChainId) { + const { RED_PACKET_NFT_ADDRESS } = useNftRedPacketConstants(chainId) + const contract = useContract(RED_PACKET_NFT_ADDRESS, NftRedPacketABI as AbiItem[], chainId) return contract } diff --git a/packages/mask/src/plugins/RedPacket/Worker/apis/erc20Redpacket.ts b/packages/mask/src/plugins/RedPacket/Worker/apis/erc20Redpacket.ts index c3a96cc598f8..33d07a7d27e7 100644 --- a/packages/mask/src/plugins/RedPacket/Worker/apis/erc20Redpacket.ts +++ b/packages/mask/src/plugins/RedPacket/Worker/apis/erc20Redpacket.ts @@ -57,7 +57,7 @@ const RED_PACKET_FIELDS = ` type RedpacketFromSubgraphType = { chain_id: ChainId - claimers: { name: string; address: string }[] + claimers: Array<{ name: string; address: string }> contract_address: string contract_version: number block_number: number diff --git a/packages/mask/src/plugins/RedPacket/base.ts b/packages/mask/src/plugins/RedPacket/base.ts index 017b71a9a04b..cb9aeeea4ca9 100644 --- a/packages/mask/src/plugins/RedPacket/base.ts +++ b/packages/mask/src/plugins/RedPacket/base.ts @@ -1,4 +1,6 @@ import type { Plugin } from '@masknet/plugin-infra' +import { NetworkPluginID } from '@masknet/plugin-infra/web3' +import { ChainId } from '@masknet/web3-shared-evm' import { RedPacketMetaKey, RedPacketNftMetaKey, RedPacketPluginID } from './constants' export const base: Plugin.Shared.Definition = { @@ -16,6 +18,24 @@ export const base: Plugin.Shared.Definition = { networks: {}, }, target: 'stable', + web3: { + [NetworkPluginID.PLUGIN_EVM]: { + supportedChainIds: [ + ChainId.Mainnet, + ChainId.BSC, + ChainId.Matic, + ChainId.Arbitrum, + ChainId.xDai, + ChainId.Fantom, + ChainId.Avalanche, + ChainId.Aurora, + ChainId.Harmony, + ChainId.Conflux, + ], + }, + [NetworkPluginID.PLUGIN_FLOW]: { supportedChainIds: [] }, + [NetworkPluginID.PLUGIN_SOLANA]: { supportedChainIds: [] }, + }, }, contribution: { metadataKeys: new Set([RedPacketMetaKey, RedPacketNftMetaKey]), diff --git a/packages/mask/src/plugins/RedPacket/types.ts b/packages/mask/src/plugins/RedPacket/types.ts index 824649e80d42..4d94b4e98a59 100644 --- a/packages/mask/src/plugins/RedPacket/types.ts +++ b/packages/mask/src/plugins/RedPacket/types.ts @@ -62,7 +62,7 @@ export interface RedPacketJSONPayload extends RedPacketBasic { token_type?: EthereumTokenType.Native | EthereumTokenType.ERC20 token?: FungibleTokenDetailed token_address?: string - claimers?: { address: string; name: string }[] + claimers?: Array<{ address: string; name: string }> total_remaining?: string } @@ -126,10 +126,10 @@ export interface NftRedPacketSubgraphInMask extends Omit creator: { name: string address: string diff --git a/packages/mask/src/plugins/Savings/constants.ts b/packages/mask/src/plugins/Savings/constants.ts index 4f800312198b..83f06963c5e3 100644 --- a/packages/mask/src/plugins/Savings/constants.ts +++ b/packages/mask/src/plugins/Savings/constants.ts @@ -3,14 +3,14 @@ import { ChainId, createERC20Tokens, createNativeToken, FungibleTokenDetailed } export const SAVINGS_PLUGIN_NAME = 'Savings' export const SAVINGS_PLUGIN_ID = 'com.savings' -export const LDO_PAIRS: [FungibleTokenDetailed, FungibleTokenDetailed][] = [ +export const LDO_PAIRS: Array<[FungibleTokenDetailed, FungibleTokenDetailed]> = [ [ createNativeToken(ChainId.Mainnet), createERC20Tokens('LDO_stETH_ADDRESS', 'Liquid staked Ether 2.0', 'stETH', 18)[ChainId.Mainnet], ], ] -export const AAVE_PAIRS: [FungibleTokenDetailed, FungibleTokenDetailed][] = [ +export const AAVE_PAIRS: Array<[FungibleTokenDetailed, FungibleTokenDetailed]> = [ [ createERC20Tokens('USDT_ADDRESS', 'Tether USD', 'USDT', 6)[ChainId.Mainnet], createERC20Tokens('aUSDT_ADDRESS', 'Aave Interest bearing USDT', 'aUSDT', 6)[ChainId.Mainnet], diff --git a/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts b/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts index 9ce14d79921a..1349d35b9d31 100644 --- a/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts +++ b/packages/mask/src/plugins/Savings/protocols/AAVEProtocol.ts @@ -80,13 +80,13 @@ export class AAVEProtocol implements SavingsProtocol { }) const fullResponse: { data: { - reserves: { + reserves: Array<{ id: string name: string decimals: number underlyingAsset: string liquidityRate: number - }[] + }> } } = await response.json() const liquidityRate = +fullResponse.data.reserves[0].liquidityRate @@ -132,11 +132,11 @@ export class AAVEProtocol implements SavingsProtocol { const fullResponse: { data: { - reserves: { + reserves: Array<{ aToken: { id: string } - }[] + }> } } = await response.json() diff --git a/packages/mask/src/plugins/Snapshot/SNSAdaptor/Snapshot.tsx b/packages/mask/src/plugins/Snapshot/SNSAdaptor/Snapshot.tsx index 469c94c9436d..5a64acffcd48 100644 --- a/packages/mask/src/plugins/Snapshot/SNSAdaptor/Snapshot.tsx +++ b/packages/mask/src/plugins/Snapshot/SNSAdaptor/Snapshot.tsx @@ -128,7 +128,7 @@ export function Snapshot() { - + ) diff --git a/packages/mask/src/plugins/Snapshot/Worker/apis/index.ts b/packages/mask/src/plugins/Snapshot/Worker/apis/index.ts index 64411842eb66..5f266290aedf 100644 --- a/packages/mask/src/plugins/Snapshot/Worker/apis/index.ts +++ b/packages/mask/src/plugins/Snapshot/Worker/apis/index.ts @@ -113,7 +113,7 @@ export async function getScores( space: string, strategies: Strategy[], ) { - const scores: { [key in string]: number }[] = await ss.utils.getScores( + const scores: Array<{ [key in string]: number }> = await ss.utils.getScores( space, strategies, network, diff --git a/packages/mask/src/plugins/Snapshot/types.ts b/packages/mask/src/plugins/Snapshot/types.ts index 5959e80fad7d..d57fded9f0a8 100644 --- a/packages/mask/src/plugins/Snapshot/types.ts +++ b/packages/mask/src/plugins/Snapshot/types.ts @@ -89,11 +89,11 @@ export interface VoteItem { choice: string | undefined totalWeight: number | undefined choices: - | { + | Array<{ index: number weight: number name: string - }[] + }> | undefined address: string authorIpfsHash: string @@ -115,10 +115,10 @@ export type VoteItemList = { export interface ProposalResult { choice: string - powerDetail: { + powerDetail: Array<{ power: number name: string - }[] + }> power: number percentage: number } diff --git a/packages/mask/src/plugins/Trader/SNSAdaptor/trending/CoinMetadataTable.tsx b/packages/mask/src/plugins/Trader/SNSAdaptor/trending/CoinMetadataTable.tsx index 7e77157fcb48..5193d749fe21 100644 --- a/packages/mask/src/plugins/Trader/SNSAdaptor/trending/CoinMetadataTable.tsx +++ b/packages/mask/src/plugins/Trader/SNSAdaptor/trending/CoinMetadataTable.tsx @@ -63,7 +63,7 @@ export function CoinMetadataTable(props: CoinMetadataTableProps) { ['Tech Docs', trending.coin.tech_docs_urls], ['Source Code', trending.coin.source_code_urls], ['Community', trending.coin.community_urls], - ] as [string, string[] | undefined][] + ] as Array<[string, string[] | undefined]> return ( diff --git a/packages/mask/src/plugins/Trader/SNSAdaptor/trending/LBPPriceChart.tsx b/packages/mask/src/plugins/Trader/SNSAdaptor/trending/LBPPriceChart.tsx index 20f7dca725ae..baae9010c044 100644 --- a/packages/mask/src/plugins/Trader/SNSAdaptor/trending/LBPPriceChart.tsx +++ b/packages/mask/src/plugins/Trader/SNSAdaptor/trending/LBPPriceChart.tsx @@ -15,7 +15,7 @@ const DEFAULT_DIMENSION: Dimension = { } export interface PriceChartProps extends withClasses<'root'> { - data: { date: Date; value: number }[] + data: Array<{ date: Date; value: number }> width?: number height?: number currency: Currency diff --git a/packages/mask/src/plugins/Trader/SNSAdaptor/trending/PriceChangedTable.tsx b/packages/mask/src/plugins/Trader/SNSAdaptor/trending/PriceChangedTable.tsx index 21e3693aae00..77b758e5c011 100644 --- a/packages/mask/src/plugins/Trader/SNSAdaptor/trending/PriceChangedTable.tsx +++ b/packages/mask/src/plugins/Trader/SNSAdaptor/trending/PriceChangedTable.tsx @@ -56,7 +56,7 @@ export function PriceChangedTable({ market }: PriceChangedTableProps) { }, ] - const filteredRecords = records.filter((record) => typeof record.percentage === 'number') as Required[] + const filteredRecords = records.filter((record) => typeof record.percentage === 'number') as Array> return ( diff --git a/packages/mask/src/plugins/Trader/apis/LBP/index.ts b/packages/mask/src/plugins/Trader/apis/LBP/index.ts index 6f9e848c3aa2..5f3aa16d4f09 100644 --- a/packages/mask/src/plugins/Trader/apis/LBP/index.ts +++ b/packages/mask/src/plugins/Trader/apis/LBP/index.ts @@ -18,10 +18,10 @@ async function fetchFromBalancerPoolSubgraph(query: string) { export async function fetchLBP_PoolsByTokenAddress(address: string) { const data = await fetchFromBalancerPoolSubgraph<{ - pools: { + pools: Array<{ id: string createTime: number - }[] + }> }>(` { pools( @@ -53,7 +53,7 @@ export async function fetchLBP_PoolTokenPrices(poolId: string, address: string, } `, ) - const data = await fetchFromBalancerPoolSubgraph>(` + const data = await fetchFromBalancerPoolSubgraph>>(` query tokenPrices { ${queries.join('\n')} } diff --git a/packages/mask/src/plugins/Trader/apis/coingecko/index.ts b/packages/mask/src/plugins/Trader/apis/coingecko/index.ts index 201a83f7aff3..a0735a045a5e 100644 --- a/packages/mask/src/plugins/Trader/apis/coingecko/index.ts +++ b/packages/mask/src/plugins/Trader/apis/coingecko/index.ts @@ -1,9 +1,12 @@ import { COIN_GECKO_BASE_URL } from '../../constants' import { Flags } from '../../../../../shared' +import { courier } from '@masknet/web3-providers' // #region get currency export async function getAllCurrencies() { - const response = await fetch(`${COIN_GECKO_BASE_URL}/simple/supported_vs_currencies`, { cache: 'force-cache' }) + const response = await fetch(courier(`${COIN_GECKO_BASE_URL}/simple/supported_vs_currencies`), { + cache: 'force-cache', + }) return response.json() as Promise } // #endregion @@ -16,7 +19,7 @@ export interface Coin { } export async function getAllCoins() { - const response = await fetch(`${COIN_GECKO_BASE_URL}/coins/list`, { cache: 'force-cache' }) + const response = await fetch(courier(`${COIN_GECKO_BASE_URL}/coins/list`), { cache: 'force-cache' }) return response.json() as Promise } // #endregion @@ -74,7 +77,7 @@ export interface CoinInfo { platforms: Record name: string symbol: string - tickers: { + tickers: Array<{ base: string target: string market: { @@ -105,7 +108,7 @@ export interface CoinInfo { trade_url: string coin_id: string target_coin_id?: string - }[] + }> } export async function getCoinInfo(coinId: string) { diff --git a/packages/mask/src/plugins/Trader/apis/trending/index.ts b/packages/mask/src/plugins/Trader/apis/trending/index.ts index a8fa0cd65138..8949ef40297d 100644 --- a/packages/mask/src/plugins/Trader/apis/trending/index.ts +++ b/packages/mask/src/plugins/Trader/apis/trending/index.ts @@ -192,8 +192,7 @@ async function getCoinTrending(id: string, currency: Currency, dataProvider: Dat symbol: info.symbol.toUpperCase(), is_mirrored: isMirroredKeyword(info.symbol), - // TODO: - // use current language setting + // TODO: use current language setting description: info.description.en, market_cap_rank: info.market_cap_rank, image_url: info.image.small, diff --git a/packages/mask/src/plugins/Trader/apis/uniswap-health/index.ts b/packages/mask/src/plugins/Trader/apis/uniswap-health/index.ts index 959e6798fd54..a59243a21705 100644 --- a/packages/mask/src/plugins/Trader/apis/uniswap-health/index.ts +++ b/packages/mask/src/plugins/Trader/apis/uniswap-health/index.ts @@ -20,14 +20,14 @@ export async function fetchLatestBlocks() { type status = { synced: string health: string - chains: { + chains: Array<{ chainHeadBlock: { number: number } latestBlock: { number: number } - }[] + }> } const response = await fetchFromUniswapV2Health<{ indexingStatusForCurrentVersion: status diff --git a/packages/mask/src/plugins/Trader/apis/uniswap-v2-subgraph/index.ts b/packages/mask/src/plugins/Trader/apis/uniswap-v2-subgraph/index.ts index dd59d68420f9..b70283cbc0ff 100644 --- a/packages/mask/src/plugins/Trader/apis/uniswap-v2-subgraph/index.ts +++ b/packages/mask/src/plugins/Trader/apis/uniswap-v2-subgraph/index.ts @@ -182,7 +182,7 @@ export async function fetchTokenDayData(address: string, date: Date) { const utcTimestamp = Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate()) const data = await fetchFromUniswapV2Subgraph<{ data: { - tokenDayData: { + tokenDayData: Array<{ id: string date: number priceUSD: string @@ -192,7 +192,7 @@ export async function fetchTokenDayData(address: string, date: Date) { dailyVolumeETH: number dailyVolumeToken: number dailyVolumeUSD: number - }[] + }> } }>(` { @@ -317,7 +317,7 @@ export async function fetchPairData(pairAddress: string, blockNumber?: string) { */ export async function fetchPricesByBlocks( tokenAddress: string, - blocks: { blockNumber?: string; timestamp: number }[], + blocks: Array<{ blockNumber?: string; timestamp: number }>, skipCount = 50, ) { // avoiding request entity too large diff --git a/packages/mask/src/plugins/Trader/graphs/usePriceLineChart.ts b/packages/mask/src/plugins/Trader/graphs/usePriceLineChart.ts index e6a8cd169539..59296bedbfde 100644 --- a/packages/mask/src/plugins/Trader/graphs/usePriceLineChart.ts +++ b/packages/mask/src/plugins/Trader/graphs/usePriceLineChart.ts @@ -5,7 +5,7 @@ import type { Dimension } from './useDimension' export function usePriceLineChart( svgRef: RefObject, - data: { date: Date; value: number }[], + data: Array<{ date: Date; value: number }>, dimension: Dimension, id: string, color = 'steelblue', diff --git a/packages/mask/src/plugins/Trader/trader/uniswap/useAllCommonPairs.ts b/packages/mask/src/plugins/Trader/trader/uniswap/useAllCommonPairs.ts index 04220f26f898..ac7928175153 100644 --- a/packages/mask/src/plugins/Trader/trader/uniswap/useAllCommonPairs.ts +++ b/packages/mask/src/plugins/Trader/trader/uniswap/useAllCommonPairs.ts @@ -24,8 +24,8 @@ export function useAllCurrencyCombinations(tradeProvider: TradeProvider, currenc return [...common, ...additionalA, ...additionalB].map((x) => toUniswapToken(chainId, x)) }, [chainId, chainIdValid, tokenA?.address, tokenB?.address]) - const basePairs: [Token, Token][] = useMemo( - () => flatMap(bases, (base): [Token, Token][] => bases.map((otherBase) => [base, otherBase])), + const basePairs: Array<[Token, Token]> = useMemo( + () => flatMap(bases, (base): Array<[Token, Token]> => bases.map((otherBase) => [base, otherBase])), [bases], ) @@ -73,7 +73,7 @@ export function useAllCommonPairs(tradeProvider: TradeProvider, currencyA?: Curr // only pass along valid pairs, non-duplicated pairs const allPairs_ = useMemo(() => { const filtered = new Map() - for (const [state, pair] of allPairs as [PairState.EXISTS, Pair][]) { + for (const [state, pair] of allPairs as Array<[PairState.EXISTS, Pair]>) { // filter out invalid pairs if (state !== PairState.EXISTS) continue if (!pair) continue diff --git a/packages/mask/src/plugins/Trader/trader/uniswap/useAllV3Routes.ts b/packages/mask/src/plugins/Trader/trader/uniswap/useAllV3Routes.ts index b0d496ab37c2..6d2dff736c20 100644 --- a/packages/mask/src/plugins/Trader/trader/uniswap/useAllV3Routes.ts +++ b/packages/mask/src/plugins/Trader/trader/uniswap/useAllV3Routes.ts @@ -11,10 +11,10 @@ function computeAllRoutes( pools: Pool[], chainId: number, currentPath: Pool[] = [], - allPaths: Route[] = [], + allPaths: Array> = [], startCurrencyIn: Currency = currencyIn, maxHops = 2, -): Route[] { +): Array> { const tokenIn = currencyIn?.wrapped const tokenOut = currencyOut?.wrapped if (!tokenIn || !tokenOut) throw new Error('Missing tokenIn/tokenOut') @@ -54,7 +54,7 @@ function computeAllRoutes( export function useAllV3Routes( currencyIn?: Currency, currencyOut?: Currency, -): { loading: boolean; routes: Route[] } { +): { loading: boolean; routes: Array> } { const { targetChainId: chainId } = TargetChainIdContext.useContainer() const { pools, loading: poolsLoading } = useV3SwapPools(currencyIn, currencyOut) const singleHopOnly = useSingleHopOnly() diff --git a/packages/mask/src/plugins/Trader/trader/uniswap/usePools.ts b/packages/mask/src/plugins/Trader/trader/uniswap/usePools.ts index 79640191d3db..5614c9170847 100644 --- a/packages/mask/src/plugins/Trader/trader/uniswap/usePools.ts +++ b/packages/mask/src/plugins/Trader/trader/uniswap/usePools.ts @@ -19,12 +19,12 @@ export enum PoolState { export function usePools( tradeProvider: TradeProvider, - poolKeys: [Currency | undefined, Currency | undefined, FeeAmount | undefined][], -): [PoolState, Pool | null][] { + poolKeys: Array<[Currency | undefined, Currency | undefined, FeeAmount | undefined]>, +): Array<[PoolState, Pool | null]> { const { targetChainId: chainId } = TargetChainIdContext.useContainer() const context = useGetTradeContext(tradeProvider) - const transformed: ([Token, Token, FeeAmount] | null)[] = useMemo(() => { + const transformed: Array<[Token, Token, FeeAmount] | null> = useMemo(() => { return poolKeys.map(([currencyA, currencyB, feeAmount]) => { if (!chainId || !currencyA || !currencyB || !feeAmount) return null @@ -111,7 +111,7 @@ export function usePool( currencyB: Currency | undefined, feeAmount: FeeAmount | undefined, ): [PoolState, Pool | null] { - const poolKeys: [Currency | undefined, Currency | undefined, FeeAmount | undefined][] = useMemo( + const poolKeys: Array<[Currency | undefined, Currency | undefined, FeeAmount | undefined]> = useMemo( () => [[currencyA, currencyB, feeAmount]], [currencyA, currencyB, feeAmount], ) diff --git a/packages/mask/src/plugins/Trader/trader/uniswap/useV3SwapPools.ts b/packages/mask/src/plugins/Trader/trader/uniswap/useV3SwapPools.ts index 4e8d6591b71a..059f68186f7b 100644 --- a/packages/mask/src/plugins/Trader/trader/uniswap/useV3SwapPools.ts +++ b/packages/mask/src/plugins/Trader/trader/uniswap/useV3SwapPools.ts @@ -19,7 +19,7 @@ export function useV3SwapPools( } { const allCurrencyCombinations = useAllCurrencyCombinations(TradeProvider.UNISWAP_V3, currencyIn, currencyOut) - const allCurrencyCombinationsWithAllFees: [Token, Token, FeeAmount][] = useMemo( + const allCurrencyCombinationsWithAllFees: Array<[Token, Token, FeeAmount]> = useMemo( () => allCurrencyCombinations.flatMap<[Token, Token, FeeAmount]>(([tokenA, tokenB]) => [ [tokenA, tokenB, FeeAmount.LOW], diff --git a/packages/mask/src/plugins/Trader/trending/useCurrentCurrency.ts b/packages/mask/src/plugins/Trader/trending/useCurrentCurrency.ts index bfa644cd3812..c71eef46e687 100644 --- a/packages/mask/src/plugins/Trader/trending/useCurrentCurrency.ts +++ b/packages/mask/src/plugins/Trader/trending/useCurrentCurrency.ts @@ -3,12 +3,12 @@ import { DataProvider } from '@masknet/public-api' const CURRENCIES_MAP: Record< DataProvider, | undefined - | { + | Array<{ id: string name: string symbol: string description: string - }[] + }> > = { [DataProvider.COIN_GECKO]: [ { diff --git a/packages/mask/src/plugins/Trader/types/0x.ts b/packages/mask/src/plugins/Trader/types/0x.ts index 5d7ad2e8c5f6..5175a9d86ed0 100644 --- a/packages/mask/src/plugins/Trader/types/0x.ts +++ b/packages/mask/src/plugins/Trader/types/0x.ts @@ -76,11 +76,11 @@ export interface SwapQuoteResponse { export interface SwapValidationErrorResponse { code: number reason: string - validationErrors: { + validationErrors: Array<{ code: number field: string reason: string - }[] + }> } export interface SwapServerErrorResponse { diff --git a/packages/mask/src/plugins/Trader/types/trader.ts b/packages/mask/src/plugins/Trader/types/trader.ts index 956f1a8fc0f7..20fa860c5e49 100644 --- a/packages/mask/src/plugins/Trader/types/trader.ts +++ b/packages/mask/src/plugins/Trader/types/trader.ts @@ -92,7 +92,9 @@ export interface TradeComputed { maximumSold: BigNumber minimumReceived: BigNumber fee: BigNumber - path?: (PartialRequired | PartialRequired)[][] + path?: Array< + Array | PartialRequired> + > trade_?: T } diff --git a/packages/mask/src/plugins/UnlockProtocol/SNSAdaptor/UnlockProtocolInPost.tsx b/packages/mask/src/plugins/UnlockProtocol/SNSAdaptor/UnlockProtocolInPost.tsx index 70ad5e11208e..01a30f0fc86e 100644 --- a/packages/mask/src/plugins/UnlockProtocol/SNSAdaptor/UnlockProtocolInPost.tsx +++ b/packages/mask/src/plugins/UnlockProtocol/SNSAdaptor/UnlockProtocolInPost.tsx @@ -63,7 +63,7 @@ export default function UnlockProtocolInPost(props: UnlockProtocolInPostProps) { ? renderWithUnlockProtocolMetadata(props.message.meta, (r) => { return ( - + {content} @@ -95,7 +95,7 @@ export default function UnlockProtocolInPost(props: UnlockProtocolInPostProps) { ? renderWithUnlockProtocolMetadata(props.message.meta, (r) => { return ( - + "{t('loading')}"
diff --git a/packages/mask/src/plugins/UnlockProtocol/Services.ts b/packages/mask/src/plugins/UnlockProtocol/Services.ts index f18ca77677b2..5a3329a0095d 100644 --- a/packages/mask/src/plugins/UnlockProtocol/Services.ts +++ b/packages/mask/src/plugins/UnlockProtocol/Services.ts @@ -10,15 +10,15 @@ for (const [key, url] of Object.entries(graphEndpointKeyVal)) { } export interface verifyHolderResponse { - keyHolders: { - keys: { + keyHolders: Array<{ + keys: Array<{ expiration: number keyId: string lock: { address: string } - }[] - }[] + }> + }> } const verifyHolder = async (_lockAddress: string, _holder: string, _chain: number) => { diff --git a/packages/mask/src/plugins/Wallet/SNSAdaptor/SelectProviderDialog/index.tsx b/packages/mask/src/plugins/Wallet/SNSAdaptor/SelectProviderDialog/index.tsx index c55166e43d31..1b2614b87110 100644 --- a/packages/mask/src/plugins/Wallet/SNSAdaptor/SelectProviderDialog/index.tsx +++ b/packages/mask/src/plugins/Wallet/SNSAdaptor/SelectProviderDialog/index.tsx @@ -19,6 +19,7 @@ import { WalletMessages, WalletRPC } from '../../messages' import { hasNativeAPI, nativeAPI } from '../../../../../shared/native-rpc' import { PluginProviderRender } from './PluginProviderRender' import { pluginIDSettings } from '../../../../settings/settings' +import { useUpdateEffect } from 'react-use' const useStyles = makeStyles()((theme) => ({ content: { @@ -70,7 +71,6 @@ export function SelectProviderDialog(props: SelectProviderDialogProps) { async (result?: Web3Plugin.ConnectionResult) => { if (result) await WalletRPC.updateAccount(result as Web3Plugin.ConnectionResult) - if (undeterminedNetwork?.type === networkType) { pluginIDSettings.value = undeterminedPluginID } @@ -80,6 +80,12 @@ export function SelectProviderDialog(props: SelectProviderDialogProps) { [networkType, undeterminedNetwork?.type, undeterminedPluginID, closeDialog, isDashboard], ) + useUpdateEffect(() => { + if (undeterminedNetwork?.type === networkType) { + pluginIDSettings.value = undeterminedPluginID + } + }, [undeterminedNetwork?.type, networkType]) + // not available for the native app if (hasNativeAPI) return null diff --git a/packages/mask/src/plugins/Wallet/apis/ens.ts b/packages/mask/src/plugins/Wallet/apis/ens.ts index a422c0cdb61a..48ec09c400c9 100644 --- a/packages/mask/src/plugins/Wallet/apis/ens.ts +++ b/packages/mask/src/plugins/Wallet/apis/ens.ts @@ -17,10 +17,10 @@ export async function fetchAddressNamesByTwitterId(twitterId: string) { if (!twitterId) return [] const data = await fetchFromENSTextResolverSubgraph<{ twitterHandle?: { - domains: { + domains: Array<{ id: string owner: string - }[] + }> } }>(` query twitterHandle { diff --git a/packages/mask/src/plugins/Wallet/services/wallet/index.ts b/packages/mask/src/plugins/Wallet/services/wallet/index.ts index 29ef45a18c76..96c990f49f0c 100644 --- a/packages/mask/src/plugins/Wallet/services/wallet/index.ts +++ b/packages/mask/src/plugins/Wallet/services/wallet/index.ts @@ -51,11 +51,13 @@ export async function getWallet(address?: string) { } export async function getWallets(providerType?: ProviderType): Promise< - (Omit & { - configurable: boolean - hasStoredKeyInfo: boolean - hasDerivationPath: boolean - })[] + Array< + Omit & { + configurable: boolean + hasStoredKeyInfo: boolean + hasDerivationPath: boolean + } + > > { if (hasNativeAPI) { if (providerType && providerType !== ProviderType.MaskWallet) return [] @@ -112,11 +114,11 @@ export async function getDerivableAccounts(mnemonic: string, page: number, pageS }) if (!imported?.StoredKey) throw new Error('Failed to import the wallet.') - const accounts: { + const accounts: Array<{ index: number address: string derivationPath: string - }[] = [] + }> = [] for (let i = pageSize * page; i < pageSize * (page + 1); i += 1) { const derivationPath = `${HD_PATH_WITHOUT_INDEX_ETHEREUM}/${i}` diff --git a/packages/mask/src/plugins/Wallet/types/debank.ts b/packages/mask/src/plugins/Wallet/types/debank.ts index 2fb7972f7ecb..de4774be8edb 100644 --- a/packages/mask/src/plugins/Wallet/types/debank.ts +++ b/packages/mask/src/plugins/Wallet/types/debank.ts @@ -32,8 +32,7 @@ export interface TokenItem { export interface HistoryItem { cate_id: keyof HistoryResponse['data']['cate_dict'] - // TODO: - // implement debt_liquidated + // TODO: implement debt_liquidated debt_liquidated: null id: string other_addr: string diff --git a/packages/mask/src/plugins/dHEDGE/UI/PoolView.tsx b/packages/mask/src/plugins/dHEDGE/UI/PoolView.tsx index 158285d2c292..d4dcb590841c 100644 --- a/packages/mask/src/plugins/dHEDGE/UI/PoolView.tsx +++ b/packages/mask/src/plugins/dHEDGE/UI/PoolView.tsx @@ -133,7 +133,7 @@ export function PoolView(props: PoolViewProps) { - + ) diff --git a/packages/mask/src/plugins/hooks/useLineChart.ts b/packages/mask/src/plugins/hooks/useLineChart.ts index bd35c37089db..3555285d7133 100644 --- a/packages/mask/src/plugins/hooks/useLineChart.ts +++ b/packages/mask/src/plugins/hooks/useLineChart.ts @@ -5,7 +5,7 @@ import type { Dimension } from './useDimension' export function useLineChart( svgRef: RefObject, - data: { date: Date; value: number }[], + data: Array<{ date: Date; value: number }>, dimension: Dimension, id: string, opts: { color?: string; tickFormat?: string; formatTooltip?: Function }, diff --git a/packages/mask/src/plugins/hooks/usePriceLineChart.ts b/packages/mask/src/plugins/hooks/usePriceLineChart.ts index f173a19c7e52..89998fc0966b 100644 --- a/packages/mask/src/plugins/hooks/usePriceLineChart.ts +++ b/packages/mask/src/plugins/hooks/usePriceLineChart.ts @@ -5,7 +5,7 @@ import { useLineChart } from './useLineChart' export function usePriceLineChart( svgRef: RefObject, - data: { date: Date; value: number }[], + data: Array<{ date: Date; value: number }>, dimension: Dimension, id: string, opts: { color?: string; sign?: string }, diff --git a/packages/mask/src/social-network-adaptor/facebook.com/injection/Toolbar.tsx b/packages/mask/src/social-network-adaptor/facebook.com/injection/Toolbar.tsx index 0271d175348d..7dd832f3934f 100644 --- a/packages/mask/src/social-network-adaptor/facebook.com/injection/Toolbar.tsx +++ b/packages/mask/src/social-network-adaptor/facebook.com/injection/Toolbar.tsx @@ -6,7 +6,8 @@ import { ToolboxAtFacebook } from './ToolbarUI' export function injectToolboxHintAtFacebook(signal: AbortSignal, category: 'wallet' | 'application') { const watcher = new MutationObserverWatcher(toolBoxInSideBarSelector()) startWatch(watcher, signal) + const hasTopNavBar = Boolean(document.querySelector('#ssrb_top_nav_start ~ [role="banner"]')) createReactRootShadowed(watcher.firstDOMProxy.afterShadow, { signal }).render( - , + , ) } diff --git a/packages/mask/src/social-network-adaptor/facebook.com/injection/ToolbarUI.tsx b/packages/mask/src/social-network-adaptor/facebook.com/injection/ToolbarUI.tsx index da7d3003887c..bb5605084996 100644 --- a/packages/mask/src/social-network-adaptor/facebook.com/injection/ToolbarUI.tsx +++ b/packages/mask/src/social-network-adaptor/facebook.com/injection/ToolbarUI.tsx @@ -3,8 +3,8 @@ import { ToolboxHintUnstyled } from '../../../components/InjectedComponents/Tool const fbBreakPoint = 700 /** px */ -const Container = styled('div')` - padding: 0 8px; +const Container = styled('div')<{ hasTopNavBar: boolean }>` + padding: 0 ${(props) => (props.hasTopNavBar ? '8px' : '4px')}; ` const Item = styled(ListItemButton)` border-radius: 8px; @@ -16,22 +16,23 @@ const Text = styled(Typography)` color: var(--primary-text); font-weight: 500; ` -const Icon = styled(ListItemIcon)` - min-width: 46px; +const Icon = styled(ListItemIcon)<{ hasTopNavBar: boolean }>` + min-width: ${(props) => (props.hasTopNavBar ? '46px' : 'auto')}; + margin-right: ${(props) => (props.hasTopNavBar ? '0px' : '12px')}; @media screen and (max-height: ${fbBreakPoint}px) { - min-width: 36px; + min-width: ${(props) => (props.hasTopNavBar ? '36px' : 'auto')}; } ` -export function ToolboxAtFacebook(props: { category: 'wallet' | 'application' }) { +export function ToolboxAtFacebook(props: { category: 'wallet' | 'application'; hasTopNavBar: boolean }) { const isSmall = useMediaQuery(`(max-height: ${fbBreakPoint}px)`) return ( {children}} ListItemButton={Item} Typography={Text} - ListItemIcon={Icon} + ListItemIcon={({ children }) => {children}} category={props.category} /> ) diff --git a/packages/mask/src/social-network-adaptor/facebook.com/utils/selector.ts b/packages/mask/src/social-network-adaptor/facebook.com/utils/selector.ts index 4cadcc089825..e2d5930f2e9f 100644 --- a/packages/mask/src/social-network-adaptor/facebook.com/utils/selector.ts +++ b/packages/mask/src/social-network-adaptor/facebook.com/utils/selector.ts @@ -30,7 +30,7 @@ export const bioDescriptionSelector = () => export const bioDescriptionSelectorOnMobile: () => LiveSelector = () => querySelector('#bio div') export const searchUserIdSelector: () => LiveSelector = () => - querySelector('div[data-pagelet="ProfileTabs"] a[role="tab"]') + querySelector('div[role="tablist"][data-visualcompletion="ignore-dynamic"] a[role="tab"]') export const searchUserIdSelectorOnMobile: () => LiveSelector = () => querySelector('#tlFeed div[data-sigil="scroll-area"] a:last-child') @@ -88,7 +88,11 @@ export const searchFacebookConfirmAvatarImageSelector = () => // #region export const toolBoxInSideBarSelector: () => LiveSelector = () => - querySelector('[data-pagelet="LeftRail"] li:nth-child(2)') + querySelector('#ssrb_left_rail_start') + .closest(1) + .querySelector('h2') + .closest(1) + .querySelector('div > div > div > :nth-child(2) > ul > li:nth-child(2)') // for getting normal tab style export const profileTabUnselectedSelector: () => LiveSelector = () => diff --git a/packages/mask/src/social-network-adaptor/instagram.com/injection/NFT/NFTAvatarEditProfile.tsx b/packages/mask/src/social-network-adaptor/instagram.com/injection/NFT/NFTAvatarEditProfile.tsx index b925601314d6..51e407b01eb8 100644 --- a/packages/mask/src/social-network-adaptor/instagram.com/injection/NFT/NFTAvatarEditProfile.tsx +++ b/packages/mask/src/social-network-adaptor/instagram.com/injection/NFT/NFTAvatarEditProfile.tsx @@ -38,6 +38,9 @@ const useStyles = makeStyles()(() => ({ color: '#ffffff', lineHeight: '12px', }, + icon: { + color: 'white', + }, })) export function openNFTAvatarSettingDialog() { diff --git a/packages/mask/src/social-network-adaptor/minds.com/customization/custom.ts b/packages/mask/src/social-network-adaptor/minds.com/customization/custom.ts index 46f2e15ef256..977325171b2f 100644 --- a/packages/mask/src/social-network-adaptor/minds.com/customization/custom.ts +++ b/packages/mask/src/social-network-adaptor/minds.com/customization/custom.ts @@ -28,14 +28,15 @@ export function startWatchThemeColor(signal: AbortSignal) { if (backgroundColor) backgroundColorRef.value = currentTheme.value === 'light' ? 'rgb(244, 244 ,245)' : 'rgb(26, 32, 37)' } + // init + currentTheme.value = getBackgroundColor(document.body) === 'rgb(255,255,255)' ? 'light' : 'dark' const watcher = new MutationObserverWatcher(themeListItemSelector()) - .addListener('onAdd', updateThemeColor) - .addListener('onChange', updateThemeColor) - .startWatch({ - childList: true, - subtree: true, - }) + // update + watcher.addListener('onAdd', updateThemeColor).addListener('onChange', updateThemeColor).startWatch({ + childList: true, + subtree: true, + }) signal.addEventListener('abort', () => watcher.stopWatch()) } diff --git a/packages/mask/src/social-network-adaptor/minds.com/injection/ToolboxHint_UI.tsx b/packages/mask/src/social-network-adaptor/minds.com/injection/ToolboxHint_UI.tsx index de15d87e68eb..77b4a151d92c 100644 --- a/packages/mask/src/social-network-adaptor/minds.com/injection/ToolboxHint_UI.tsx +++ b/packages/mask/src/social-network-adaptor/minds.com/injection/ToolboxHint_UI.tsx @@ -1,5 +1,5 @@ import { ToolboxHintUnstyled } from '../../../components/InjectedComponents/ToolboxUnstyled' -import { styled, ListItemButton, Typography, ListItemIcon, useMediaQuery } from '@mui/material' +import { styled, ListItemButton, Typography, ListItemIcon, useMediaQuery, useTheme } from '@mui/material' const mindsBreakPoint = 1221 /** px */ @@ -42,7 +42,7 @@ const Icon = styled(ListItemIcon)` export function ToolboxHintAtMinds(props: { category: 'wallet' | 'application' }) { const mini = useMediaQuery(`(max-width: ${mindsBreakPoint}px)`) - + const mode = useTheme().palette.mode return ( (selector: export const rootSelector: () => LiveSelector = () => querySelector('m-app') export const themeListItemSelector: () => LiveSelector = () => - querySelector( - 'm-usermenu__v3 > div.m-user-menu.m-dropdown > ul > li:nth-child(5) .ng-star-inserted', - ) + querySelector('.m-sidebarMore__dropdown > li:nth-child(7)') export const composerModalSelector: () => LiveSelector = () => querySelector('m-composer__modal') diff --git a/packages/mask/src/social-network-adaptor/twitter.com/collecting/identity.ts b/packages/mask/src/social-network-adaptor/twitter.com/collecting/identity.ts index 3eca2d3fb5c0..97535cbe94aa 100644 --- a/packages/mask/src/social-network-adaptor/twitter.com/collecting/identity.ts +++ b/packages/mask/src/social-network-adaptor/twitter.com/collecting/identity.ts @@ -51,9 +51,12 @@ function resolveLastRecognizedIdentityInner( ) { const assign = async () => { await delay(5000) - const avatar = searchSelfAvatarSelector().evaluate()?.getAttribute('src') ?? '' - const handle = searchSelfHandleSelector().evaluate()?.textContent?.trim()?.replace(/^@/, '') - const nickname = searchSelfNicknameSelector().evaluate()?.textContent?.trim() ?? '' + const { collect } = recognizeDesktop() + const dataFromScript = collect() + const avatar = (searchSelfAvatarSelector().evaluate()?.getAttribute('src') || dataFromScript.avatar) ?? '' + const handle = + searchSelfHandleSelector().evaluate()?.textContent?.trim()?.replace(/^@/, '') || dataFromScript.handle + const nickname = (searchSelfNicknameSelector().evaluate()?.textContent?.trim() || dataFromScript.nickname) ?? '' if (handle) { ref.value = { @@ -75,11 +78,8 @@ function resolveLastRecognizedIdentityInner( attributeFilter: ['src'], }) - window.addEventListener('locationchange', assign) - cancel.addEventListener('abort', () => { - window.removeEventListener('locationchange', assign) - watcher.stopWatch() - }) + window.addEventListener('locationchange', assign, { signal: cancel }) + cancel.addEventListener('abort', () => watcher.stopWatch(), { signal: cancel }) } assign() @@ -149,11 +149,8 @@ function resolveCurrentVisitingIdentityInner( attributeFilter: ['src', 'content'], }) - window.addEventListener('locationchange', assign) - cancel.addEventListener('abort', () => { - window.removeEventListener('locationchange', assign) - watcher.stopWatch() - }) + window.addEventListener('locationchange', assign, { signal: cancel }) + cancel.addEventListener('abort', () => watcher.stopWatch(), { signal: cancel }) } assign() diff --git a/packages/mask/src/social-network-adaptor/twitter.com/ui-provider.ts b/packages/mask/src/social-network-adaptor/twitter.com/ui-provider.ts index a51c4e3bcb8a..a3e1c4fb8a7b 100644 --- a/packages/mask/src/social-network-adaptor/twitter.com/ui-provider.ts +++ b/packages/mask/src/social-network-adaptor/twitter.com/ui-provider.ts @@ -61,11 +61,11 @@ const useInjectedDialogClassesOverwriteTwitter = makeStyles()((theme) => { }, dialogTitle: { display: 'grid', - gridTemplateColumns: 'repeat(3, 1fr)', + gridTemplateColumns: '1fr auto 1fr', alignItems: 'center', padding: 16, position: 'relative', - background: theme.palette.background.modalTitle, + background: theme.palette.maskColor.modelTitleBg, borderBottom: 'none', '& > p': { fontSize: 18, @@ -84,7 +84,6 @@ const useInjectedDialogClassesOverwriteTwitter = makeStyles()((theme) => { }, }, dialogContent: { - padding: 16, [smallQuery]: { display: 'flex', flexDirection: 'column', diff --git a/packages/mask/src/social-network-adaptor/twitter.com/utils/selector.ts b/packages/mask/src/social-network-adaptor/twitter.com/utils/selector.ts index 197b49efeb03..9e6c1f22d6a7 100644 --- a/packages/mask/src/social-network-adaptor/twitter.com/utils/selector.ts +++ b/packages/mask/src/social-network-adaptor/twitter.com/utils/selector.ts @@ -114,7 +114,7 @@ export const postEditorInPopupSelector: () => LiveSelector = () => export const toolBoxInSideBarSelector: () => LiveSelector = () => querySelector('[role="banner"] [role="navigation"] > div') export const sideBarProfileSelector: () => LiveSelector = () => - querySelector('[role="banner"] [role="navigation"] [aria-label="Profile"] > div') + querySelector('[role="banner"] [role="navigation"] [data-testid="AppTabBar_Profile_Link"] > div') export const postEditorInTimelineSelector: () => LiveSelector = () => querySelector('[role="main"] :not(aside) > [role="progressbar"] ~ div [role="button"][aria-label]:nth-child(6)') @@ -217,7 +217,7 @@ export const postsContentSelector = () => export const postAvatarsContentSelector = () => querySelectorAll('[data-testid="tweet"] > div > div > div > :nth-child(2)') -const base = querySelector('#react-root + script') +const base = querySelector('#react-root ~ script') const handle = /"screen_name":"(.*?)"/ const name = /"name":"(.*?)"/ const bio = /"description":"(.*?)"/ diff --git a/packages/mask/src/utils/theme/useClassicMaskSNSTheme.ts b/packages/mask/src/utils/theme/useClassicMaskSNSTheme.ts index 1c083fb4ec90..5413c6bd916d 100644 --- a/packages/mask/src/utils/theme/useClassicMaskSNSTheme.ts +++ b/packages/mask/src/utils/theme/useClassicMaskSNSTheme.ts @@ -10,6 +10,8 @@ import { ValueRef } from '@dimensiondev/holoflows-kit' import { useValueRef } from '@masknet/shared-base-ui' import { languageSettings } from '../../settings/settings' import { cloneDeep, merge } from 'lodash-unified' +import twitterColorSchema from '../../social-network-adaptor/twitter.com/customization/twitter-color-schema.json' +import produce, { setAutoFreeze } from 'immer' const staticRef = createSubscriptionFromValueRef(new ValueRef('light')) const defaultUseTheme = (t: Theme) => t @@ -22,9 +24,14 @@ export function useClassicMaskSNSTheme() { const palette = useSubscription(provider) const baseTheme = palette === 'dark' ? MaskDarkTheme : MaskLightTheme + setAutoFreeze(false) + const maskTheme = produce(baseTheme, (theme) => { + const colorSchema = twitterColorSchema[theme.palette.mode] + theme.palette.maskColor = colorSchema.maskColor + }) // TODO: support RTL? const [localization, isRTL] = useThemeLanguage(useValueRef(languageSettings)) - const theme = unstable_createMuiStrictModeTheme(baseTheme, localization) + const theme = unstable_createMuiStrictModeTheme(maskTheme, localization) return usePostTheme(theme) } diff --git a/packages/mask/src/utils/theme/useSwapPageTheme.ts b/packages/mask/src/utils/theme/useSwapPageTheme.ts index 0b333937e75d..1377a6039aa1 100644 --- a/packages/mask/src/utils/theme/useSwapPageTheme.ts +++ b/packages/mask/src/utils/theme/useSwapPageTheme.ts @@ -26,6 +26,7 @@ export function useSwapPageTheme() { Object.assign(theme.palette[color], colorSchema[color]) } }) + theme.palette.maskColor = colorSchema.maskColor theme.palette.divider = colorSchema.divider theme.palette.secondaryDivider = colorSchema.secondaryDivider theme.components = theme.components || {} diff --git a/packages/mask/src/web3/UI/EthereumChainBoundary.tsx b/packages/mask/src/web3/UI/EthereumChainBoundary.tsx index 5eaaa17c574c..9626dece8fd5 100644 --- a/packages/mask/src/web3/UI/EthereumChainBoundary.tsx +++ b/packages/mask/src/web3/UI/EthereumChainBoundary.tsx @@ -1,4 +1,4 @@ -import React, { useCallback } from 'react' +import React, { useCallback, useMemo } from 'react' import { Box, Typography, Theme, useTheme } from '@mui/material' import { makeStyles, MaskColorVar, ShadowRootTooltip, useStylesExtends } from '@masknet/theme' import type { SxProps } from '@mui/system' @@ -35,14 +35,6 @@ import { WalletIcon } from '@masknet/shared' import { PluginWalletConnectIcon } from '@masknet/icons' const useStyles = makeStyles()((theme) => ({ - button: { - backgroundColor: theme.palette.maskColor.dark, - color: 'white', - width: 254, - '&,&:hover': { - background: theme.palette.maskColor.dark, - }, - }, action: { textAlign: 'center', margin: theme.spacing(1), @@ -67,13 +59,13 @@ export interface EthereumChainBoundaryProps extends withClasses<'switchButton'> switchButtonStyle?: SxProps children?: React.ReactNode isValidChainId?: (actualChainId: ChainId, expectedChainId: ChainId) => boolean + renderInTimeline?: boolean ActionButtonPromiseProps?: Partial } export function EthereumChainBoundary(props: EthereumChainBoundaryProps) { const { t } = useI18N() const theme = useTheme() - const pluginID = useCurrentWeb3NetworkPluginID() const plugin = useActivatedPlugin(pluginID, 'any') @@ -170,6 +162,26 @@ export function EthereumChainBoundary(props: EthereumChainBoundaryProps) { if (!isChainMatched) await switchToChain() }, [account, isAllowed, isChainMatched, isPluginMatched, providerType, expectedChainId]) + // TODO: will remove this and extract new boundary for timeline + const buttonProps = useMemo(() => { + return { + ...(props.renderInTimeline + ? { + variant: 'contained', + fullWidth: true, + sx: { + backgroundColor: theme.palette.maskColor.dark, + color: theme.palette.maskColor.white, + '&:hover': { + backgroundColor: theme.palette.maskColor.dark, + }, + }, + } + : {}), + ...props.ActionButtonPromiseProps, + } as Partial + }, [props.ActionButtonPromiseProps, props.renderInTimeline]) + const renderBox = (children?: React.ReactNode, tips?: string) => { return ( @@ -190,22 +202,13 @@ export function EthereumChainBoundary(props: EthereumChainBoundaryProps) { <> {!props.hiddenConnectButton ? ( } + fullWidth + startIcon={} variant="contained" size={props.ActionButtonPromiseProps?.size} - sx={{ - backgroundColor: theme.palette.maskColor.dark, - width: '100%', - color: 'white', - '&:hover': { - backgroundColor: theme.palette.maskColor.dark, - }, - margin: 0, - lineHeight: 0, - paddingTop: 1.25, - paddingBottom: 1.25, - }} - onClick={openSelectProviderDialog}> + sx={{ marginTop: 1.5 }} + onClick={openSelectProviderDialog} + {...buttonProps}> {t('plugin_wallet_connect_wallet')} ) : null} @@ -244,21 +247,10 @@ export function EthereumChainBoundary(props: EthereumChainBoundaryProps) { } - sx={ - props.switchButtonStyle ?? { - backgroundColor: theme.palette.maskColor.dark, - width: '100%', - color: 'white', - '&:hover': { - backgroundColor: theme.palette.maskColor.dark, - }, - padding: 1, - margin: 0, - } - } - style={{ borderRadius: 10 }} + sx={props.switchButtonStyle} init={ {t('plugin_wallet_connect_network', { @@ -276,7 +268,8 @@ export function EthereumChainBoundary(props: EthereumChainBoundaryProps) { executor={onSwitchChain} completeOnClick={onSwitchChain} failedOnClick="use executor" - {...props.ActionButtonPromiseProps} + fullWidth + {...buttonProps} /> ) : null} , @@ -303,19 +296,7 @@ export function EthereumChainBoundary(props: EthereumChainBoundaryProps) { size={18} /> } - sx={ - props.switchButtonStyle ?? { - backgroundColor: theme.palette.maskColor.dark, - width: '100%', - color: 'white', - '&:hover': { - backgroundColor: theme.palette.maskColor.dark, - }, - padding: 1, - margin: 0, - } - } - style={{ borderRadius: 10, paddingTop: 11, paddingBottom: 11 }} + sx={props.switchButtonStyle} init={ {t('plugin_wallet_switch_network', { network: expectedNetwork.replace('Mainnet', '') })} @@ -329,7 +310,8 @@ export function EthereumChainBoundary(props: EthereumChainBoundaryProps) { executor={onSwitchChain} completeOnClick={onSwitchChain} failedOnClick="use executor" - {...props.ActionButtonPromiseProps} + fullWidth + {...buttonProps} /> ) : null} , diff --git a/packages/mask/src/web3/UI/EthereumWalletConnectedBoundary.tsx b/packages/mask/src/web3/UI/EthereumWalletConnectedBoundary.tsx index 1f5a08c3e18d..6788498d2af1 100644 --- a/packages/mask/src/web3/UI/EthereumWalletConnectedBoundary.tsx +++ b/packages/mask/src/web3/UI/EthereumWalletConnectedBoundary.tsx @@ -10,6 +10,9 @@ import { useWalletRiskWarningDialog } from '../../plugins/Wallet/hooks/useWallet const useStyles = makeStyles()((theme) => ({ button: { + marginTop: theme.spacing(1.5), + }, + timeline: { backgroundColor: theme.palette.maskColor.dark, color: 'white', fontSize: 14, @@ -18,11 +21,6 @@ const useStyles = makeStyles()((theme) => ({ '&:hover': { backgroundColor: theme.palette.maskColor.dark, }, - margin: 0, - }, - grid: { - justifyContent: 'center', - padding: 8, }, })) @@ -33,10 +31,11 @@ export interface EthereumWalletConnectedBoundaryProps hideRiskWarningConfirmed?: boolean ActionButtonProps?: ActionButtonProps startIcon?: React.ReactNode + renderInTimeline?: boolean } export function EthereumWalletConnectedBoundary(props: EthereumWalletConnectedBoundaryProps) { - const { children = null, offChain = false, hideRiskWarningConfirmed = false } = props + const { children = null, offChain = false, hideRiskWarningConfirmed = false, renderInTimeline = false } = props const { t } = useI18N() const classes = useStylesExtends(useStyles(), props) @@ -55,11 +54,15 @@ export function EthereumWalletConnectedBoundary(props: EthereumWalletConnectedBo ) // #endregion + // TODO: will remove this and extract new boundary for timeline + const buttonClass = classNames( + classNames(classes.button, classes.connectWallet, renderInTimeline ? classes.timeline : null), + ) if (!account) return ( + {t('plugin_wallet_invalid_network')} ) diff --git a/packages/plugin-infra/src/hooks/useAvailablePlugins.ts b/packages/plugin-infra/src/hooks/useAvailablePlugins.ts index 46f3776e6c81..eb2db2196c27 100644 --- a/packages/plugin-infra/src/hooks/useAvailablePlugins.ts +++ b/packages/plugin-infra/src/hooks/useAvailablePlugins.ts @@ -1,21 +1,7 @@ -import { useMemo } from 'react' import type { Plugin } from '../types' -import { useChainId, useCurrentWeb3NetworkPluginID } from '../web3' -import type { NetworkPluginID } from '../web3-types' type HasRequirement = { enableRequirement: Plugin.Shared.Definition['enableRequirement'] } -function checkPluginAvailable(plugin: HasRequirement, pluginId: NetworkPluginID, chainId: number) { - const supportedChainIds = plugin.enableRequirement.web3?.[pluginId]?.supportedChainIds - if (!supportedChainIds) return true - return supportedChainIds.includes(chainId) -} - export function useAvailablePlugins(plugins: T[]) { - const networkPluginId = useCurrentWeb3NetworkPluginID() - const chainId = useChainId(networkPluginId) - return useMemo( - () => plugins.filter((plugin) => checkPluginAvailable(plugin, networkPluginId, chainId)), - [plugins, networkPluginId, chainId], - ) + return plugins } diff --git a/packages/plugins/CrossChainBridge/src/base.ts b/packages/plugins/CrossChainBridge/src/base.ts index 7625b7388e5b..2c83e4ed8e50 100644 --- a/packages/plugins/CrossChainBridge/src/base.ts +++ b/packages/plugins/CrossChainBridge/src/base.ts @@ -10,8 +10,7 @@ export const base: Plugin.Shared.Definition = { enableRequirement: { architecture: { app: false, web: true }, networks: { type: 'opt-out', networks: {} }, - target: 'beta', + target: 'stable', }, - experimentalMark: true, i18n: languages, } diff --git a/packages/plugins/CyberConnect/src/base.tsx b/packages/plugins/CyberConnect/src/base.tsx index 83a0be124b1d..1d133b171379 100644 --- a/packages/plugins/CyberConnect/src/base.tsx +++ b/packages/plugins/CyberConnect/src/base.tsx @@ -1,4 +1,6 @@ import type { Plugin } from '@masknet/plugin-infra' +import { NetworkPluginID } from '@masknet/plugin-infra/web3' +import { ChainId } from '@masknet/web3-shared-evm' import { CYBERCONNECT_PLUGIN_ID } from './constants' export const base: Plugin.Shared.Definition = { @@ -12,6 +14,17 @@ export const base: Plugin.Shared.Definition = { architecture: { app: false, web: true }, networks: { type: 'opt-out', networks: {} }, target: 'stable', + web3: { + [NetworkPluginID.PLUGIN_EVM]: { + supportedChainIds: [ChainId.Mainnet, ChainId.BSC, ChainId.Matic, ChainId.Arbitrum, ChainId.xDai], + }, + [NetworkPluginID.PLUGIN_SOLANA]: { + supportedChainIds: [], + }, + [NetworkPluginID.PLUGIN_FLOW]: { + supportedChainIds: [], + }, + }, }, contribution: { postContent: new Set([/https:\/\/app.cyberconnect.me/]) }, } diff --git a/packages/plugins/FileService/src/locales/en-US.json b/packages/plugins/FileService/src/locales/en-US.json index bc4b3c489cf5..c692f4d4435b 100644 --- a/packages/plugins/FileService/src/locales/en-US.json +++ b/packages/plugins/FileService/src/locales/en-US.json @@ -1,5 +1,5 @@ { - "__display_name": "Plugin: File Service", + "__display_name": "File Service", "__description": "Upload and share files on top of Arweave network. Store data, permanently.", "__composition_entry": "📃 File Service", "on_insert": "Use the file", diff --git a/packages/plugins/GoPlusSecurity/src/SNSAdaptor/CheckSecurityDialog.tsx b/packages/plugins/GoPlusSecurity/src/SNSAdaptor/CheckSecurityDialog.tsx index 799f7107b49a..24175208b17d 100644 --- a/packages/plugins/GoPlusSecurity/src/SNSAdaptor/CheckSecurityDialog.tsx +++ b/packages/plugins/GoPlusSecurity/src/SNSAdaptor/CheckSecurityDialog.tsx @@ -1,5 +1,5 @@ import { Box, DialogContent, Stack } from '@mui/material' -import { makeStyles, MaskDialog, useStylesExtends } from '@masknet/theme' +import { makeStyles, useStylesExtends } from '@masknet/theme' import { useI18N } from '../locales' import { SearchBox } from './components/SearchBox' import { useAsyncFn } from 'react-use' @@ -11,6 +11,7 @@ import { Center, TokenSecurity } from './components/Common' import { DefaultPlaceholder } from './components/DefaultPlaceholder' import { NotFound } from './components/NotFound' import type { ChainId } from '@masknet/web3-shared-evm' +import { InjectedDialog } from '@masknet/shared' const useStyles = makeStyles()((theme) => ({ root: { @@ -26,7 +27,6 @@ const useStyles = makeStyles()((theme) => ({ }, }, content: { - width: 552, height: 510, maxHeight: 510, paddingBottom: theme.spacing(3), @@ -52,11 +52,7 @@ export function CheckSecurityDialog(props: BuyTokenDialogProps) { }, []) return ( - + @@ -81,6 +77,6 @@ export function CheckSecurityDialog(props: BuyTokenDialogProps) { - + ) } diff --git a/packages/shared-base/src/serializer/index.ts b/packages/shared-base/src/serializer/index.ts index ce0800de0d53..291c57d4c345 100644 --- a/packages/shared-base/src/serializer/index.ts +++ b/packages/shared-base/src/serializer/index.ts @@ -12,7 +12,8 @@ const pendingRegister = new Set<() => void>() let typeson: Typeson | undefined function setup() { const { default: BigNumber } = BN - typeson = new Typeson({}) + // https://github.com/dfahlander/typeson-registry/issues/27 + typeson = new Typeson({ cyclic: false }) typeson.register(builtin) typeson.register(specialNumbers) typeson.register([blob, file, filelist, imagebitmap]) diff --git a/packages/shared/src/UI/components/AssetPlayer/index.tsx b/packages/shared/src/UI/components/AssetPlayer/index.tsx index ed4b076351a1..daf41f78b39d 100644 --- a/packages/shared/src/UI/components/AssetPlayer/index.tsx +++ b/packages/shared/src/UI/components/AssetPlayer/index.tsx @@ -202,7 +202,7 @@ export const AssetPlayer = memo((props) => { )) : props.loadingIcon ?? } - {IframeResizerMemo} + {AssetPlayerState.LOADING !== playerState && IframeResizerMemo} ) }) diff --git a/packages/shared/src/UI/components/ERC20TokenList/index.tsx b/packages/shared/src/UI/components/ERC20TokenList/index.tsx index 6d216633cbc4..1e68efe335c7 100644 --- a/packages/shared/src/UI/components/ERC20TokenList/index.tsx +++ b/packages/shared/src/UI/components/ERC20TokenList/index.tsx @@ -115,7 +115,7 @@ export const ERC20TokenList = memo((props) => { assetsLoading, assets .map((x) => x.token.address) - .sort((a, b) => a.localeCompare('en-US', b)) + .sort((a, b) => a.localeCompare(b, 'en-US')) .join(), ]) diff --git a/packages/web3-providers/src/NFTScan/index.ts b/packages/web3-providers/src/NFTScan/index.ts index e1dc4b639600..f91c0f8c84a0 100644 --- a/packages/web3-providers/src/NFTScan/index.ts +++ b/packages/web3-providers/src/NFTScan/index.ts @@ -69,6 +69,9 @@ function createERC721TokenAsset(asset: NFTScanAsset) { mediaUrl: resolveIPFSLinkFromURL( JSON.parse(asset.nft_json ?? '{}').image ?? asset.nft_content_uri ?? payload.image ?? '', ), + imageURL: resolveIPFSLinkFromURL( + JSON.parse(asset.nft_json ?? '{}').image ?? asset.nft_content_uri ?? payload.image ?? '', + ), owner: asset.nft_holder ?? '', }, asset.token_id, diff --git a/packages/web3-providers/src/NextID/proof.ts b/packages/web3-providers/src/NextID/proof.ts index 7e3e156d09ef..af86f21422b3 100644 --- a/packages/web3-providers/src/NextID/proof.ts +++ b/packages/web3-providers/src/NextID/proof.ts @@ -38,7 +38,7 @@ const getPersonaQueryURL = (platform: string, identity: string) => identity, }) -const geyExistedBindingQueryURL = (platform: string, identity: string, personaPublicKey: string) => +const getExistedBindingQueryURL = (platform: string, identity: string, personaPublicKey: string) => urlcat(BASE_URL, '/v1/proof/exists', { platform, identity, @@ -81,7 +81,7 @@ export class NextIDProofAPI implements NextIDBaseAPI.Proof { // Should delete cache when proof status changed const cacheKeyOfQueryPersona = getPersonaQueryURL(NextIDPlatform.NextID, personaPublicKey) - const cacheKeyOfExistedBinding = geyExistedBindingQueryURL(platform, identity, personaPublicKey) + const cacheKeyOfExistedBinding = getExistedBindingQueryURL(platform, identity, personaPublicKey) deleteCache(cacheKeyOfQueryPersona) deleteCache(cacheKeyOfExistedBinding) @@ -107,7 +107,7 @@ export class NextIDProofAPI implements NextIDBaseAPI.Proof { async queryIsBound(personaPublicKey: string, platform: NextIDPlatform, identity: string, enableCache?: boolean) { if (!platform && !identity) return false - const url = geyExistedBindingQueryURL(platform, identity, personaPublicKey) + const url = getExistedBindingQueryURL(platform, identity, personaPublicKey) const result = await fetchJSON(url, {}, enableCache) return result.map(() => true).unwrapOr(false) diff --git a/packages/web3-providers/src/coingecko/index.ts b/packages/web3-providers/src/coingecko/index.ts index 129adb1c75c1..54a8d1d73e43 100644 --- a/packages/web3-providers/src/coingecko/index.ts +++ b/packages/web3-providers/src/coingecko/index.ts @@ -1,16 +1,20 @@ import type { CurrencyType } from '@masknet/plugin-infra/web3' import { COINGECKO_URL_BASE } from './constants' -import type { PriceAPI } from '..' +import { courier } from '../helpers' +import type { PriceAPI } from '../types' export class CoinGeckoAPI implements PriceAPI.Provider { async getTokenPrice(tokenId: string, currency: CurrencyType) { const requestPath = `${COINGECKO_URL_BASE}/simple/price?ids=${tokenId}&vs_currencies=${currency}` - const price = await fetch(requestPath).then((r) => r.json() as Promise) + const response = await fetch(courier(requestPath)) + const price: PriceAPI.CryptoPrice = await response.json() return price[tokenId] } async getTokensPrice(tokenIds: string[], currency: CurrencyType) { const requestPath = `${COINGECKO_URL_BASE}/simple/price?ids=${tokenIds}&vs_currencies=${currency}` - return fetch(requestPath).then((r) => r.json() as Promise) + const response = await fetch(courier(requestPath)) + const price: PriceAPI.CryptoPrice = await response.json() + return price } } diff --git a/packages/web3-providers/src/index.ts b/packages/web3-providers/src/index.ts index 319cb457e9eb..df0c0bd21ea1 100644 --- a/packages/web3-providers/src/index.ts +++ b/packages/web3-providers/src/index.ts @@ -13,6 +13,7 @@ import { InstagramAPI } from './instagram' import { GoPlusLabsAPI } from './gopluslabs' import { NextIDProofAPI, NextIDStorageAPI } from './NextID' +export * from './helpers' export * from './types' export * from './hooks' export * from './opensea/utils' diff --git a/packages/web3-providers/src/token-price/index.ts b/packages/web3-providers/src/token-price/index.ts index f8bb408a46a5..ef955bffc462 100644 --- a/packages/web3-providers/src/token-price/index.ts +++ b/packages/web3-providers/src/token-price/index.ts @@ -1,4 +1,5 @@ import type { CurrencyType } from '@masknet/plugin-infra/web3' +import { courier } from '../helpers' import type { TokenPriceBaseAPI } from '../types' const URL_BASE = 'https://api.coingecko.com/api/v3' @@ -7,12 +8,14 @@ export class TokenPriceAPI implements TokenPriceBaseAPI.Provider { async getTokenPrices(platform: string, contractAddresses: string[], currency: CurrencyType) { const addressList = contractAddresses.join(',') const requestPath = `${URL_BASE}/simple/token_price/${platform}?contract_addresses=${addressList}&vs_currencies=${currency}` - const prices = await fetch(requestPath).then((r) => r.json() as Promise) + const response = await fetch(courier(requestPath)) + const prices: TokenPriceBaseAPI.CryptoPrice = await response.json() return prices } async getNativeTokenPrice(tokenIds: string[], currency: CurrencyType) { const requestPath = `${URL_BASE}/simple/price?ids=${tokenIds.join(',')}&vs_currencies=${currency}` - const prices = await fetch(requestPath).then((r) => r.json() as Promise) + const response = await fetch(courier(requestPath)) + const prices: TokenPriceBaseAPI.CryptoPrice = await response.json() return prices } } diff --git a/packages/web3-shared/evm/assets/chains.json b/packages/web3-shared/evm/assets/chains.json index e870a59de6fc..4c8a00736ca8 100644 --- a/packages/web3-shared/evm/assets/chains.json +++ b/packages/web3-shared/evm/assets/chains.json @@ -814,7 +814,7 @@ }, { "name": "OKExChain Mainnet", - "chain": "okexchain", + "chain": "OKEx", "network": "mainnet", "features": [], "nativeCurrency": { diff --git a/packages/web3-shared/evm/hooks/useERC20TokenDetailed.ts b/packages/web3-shared/evm/hooks/useERC20TokenDetailed.ts index c6f3234250a8..c14018b38fc1 100644 --- a/packages/web3-shared/evm/hooks/useERC20TokenDetailed.ts +++ b/packages/web3-shared/evm/hooks/useERC20TokenDetailed.ts @@ -8,21 +8,19 @@ import type { ERC20Bytes32 } from '@masknet/web3-contracts/types/ERC20Bytes32' import { useERC20TokenContract, useERC20TokenContracts } from '../contracts/useERC20TokenContract' import { useERC20TokenBytes32Contract, useERC20TokenBytes32Contracts } from '../contracts/useERC20TokenBytes32Contract' import { parseStringOrBytes32, createERC20Token, createNativeToken } from '../utils' -import { useEthereumTokenType } from './useEthereumTokenType' export function useERC20TokenDetailed(address?: string, token?: Partial, targetChainId?: ChainId) { const currentChainId = useChainId() const chainId = targetChainId ?? currentChainId const erc20TokenContract = useERC20TokenContract(address, chainId) const erc20TokenBytes32Contract = useERC20TokenBytes32Contract(address, chainId) - const tokenType = useEthereumTokenType(address) return useAsyncRetry(async () => { if (!address) return if (!EthereumAddress.isValid(address)) return - if (tokenType !== EthereumTokenType.ERC20) return + return getERC20TokenDetailed(address, chainId, erc20TokenContract, erc20TokenBytes32Contract, token) - }, [chainId, token, erc20TokenContract, erc20TokenBytes32Contract, address, tokenType]) + }, [chainId, token, erc20TokenContract, erc20TokenBytes32Contract, address]) } export function useFungibleTokensDetailed(listOfToken: Pick[], _chainId?: ChainId) { diff --git a/packages/web3-shared/evm/hooks/useERC20TokensDetailedFromTokenLists.ts b/packages/web3-shared/evm/hooks/useERC20TokensDetailedFromTokenLists.ts index 93e933e1c887..81a63449bb6c 100644 --- a/packages/web3-shared/evm/hooks/useERC20TokensDetailedFromTokenLists.ts +++ b/packages/web3-shared/evm/hooks/useERC20TokensDetailedFromTokenLists.ts @@ -21,7 +21,7 @@ export function useERC20TokensDetailedFromTokenLists( const { fetchERC20TokensFromTokenLists } = useWeb3Context() const { value: tokensFromList = EMPTY_LIST, ...asyncResult } = useAsyncRetry( async () => (!lists || lists.length === 0 ? [] : fetchERC20TokensFromTokenLists(lists, chainId)), - [chainId, lists?.sort((a, b) => a.localeCompare('en-US', b)).join()], + [chainId, lists?.sort((a, b) => a.localeCompare(b, 'en-US')).join()], ) // #endregion // #region fuse