Skip to content

Commit

Permalink
Merge branch 'develop' into feat_array_split_safety
Browse files Browse the repository at this point in the history
  • Loading branch information
gomesalexandre authored May 6, 2024
2 parents 4476eab + daac3b4 commit 512cde4
Show file tree
Hide file tree
Showing 28 changed files with 9,556 additions and 9,510 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/sentry.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: New Sentry Release
on:
pull_request:
branches: [main]

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout release
- uses: actions/checkout@v3
with:
ref: release
- name: Sentry Release
uses: getsentry/[email protected]
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
with:
environment: production
# uses the release PR title as a version
version: ${{ github.event.pull_request.title }}
ignore_missing: true

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

102 changes: 39 additions & 63 deletions scripts/generateAssetData/colorMap/color-map.json

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion src/components/StakingVaults/hooks/useFetchOpportunities.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ export const useFetchOpportunities = () => {
const portfolioAccounts = useSelector(selectPortfolioAccounts)
const DynamicLpAssets = useFeatureFlag('DynamicLpAssets')

const { isLoading: isZapperAppsBalancesOutputLoading } = useGetZapperAppsBalancesOutputQuery()
const { isLoading: isZapperAppsBalancesOutputLoading } = useGetZapperAppsBalancesOutputQuery(
undefined,
{
skip: !requestedAccountIds.length,
},
)
const { isLoading: isZapperUniV2PoolAssetIdsLoading } = useGetZapperUniV2PoolAssetIdsQuery(
undefined,
{ skip: !DynamicLpAssets },
Expand Down
6 changes: 2 additions & 4 deletions src/context/WalletProvider/Coinbase/components/Connect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import type { ActionTypes } from 'context/WalletProvider/actions'
import { WalletActions } from 'context/WalletProvider/actions'
import { KeyManager } from 'context/WalletProvider/KeyManager'
import { useLocalWallet } from 'context/WalletProvider/local-wallet'
import { removeAccountsAndChainListeners } from 'context/WalletProvider/WalletProvider'
import { useWallet } from 'hooks/useWallet/useWallet'
import { getEthersProvider } from 'lib/ethersProviderSingleton'

import { ConnectModal } from '../../components/ConnectModal'
import type { LocationState } from '../../NativeWallet/types'
Expand Down Expand Up @@ -40,9 +40,7 @@ export const CoinbaseConnect = ({ history }: CoinbaseSetupProps) => {
if (adapter) {
try {
// Remove all provider event listeners from previously connected wallets
const ethersProvider = getEthersProvider()
ethersProvider.removeAllListeners('accountsChanged')
ethersProvider.removeAllListeners('chainChanged')
await removeAccountsAndChainListeners()

const wallet = await adapter.pairDevice()
if (!wallet) {
Expand Down
6 changes: 2 additions & 4 deletions src/context/WalletProvider/KeepKey/components/Connect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import { Text } from 'components/Text'
import { WalletActions } from 'context/WalletProvider/actions'
import { KeyManager } from 'context/WalletProvider/KeyManager'
import { useLocalWallet } from 'context/WalletProvider/local-wallet'
import { removeAccountsAndChainListeners } from 'context/WalletProvider/WalletProvider'
import { useWallet } from 'hooks/useWallet/useWallet'
import { getEthersProvider } from 'lib/ethersProviderSingleton'

import { KeepKeyConfig } from '../config'
import { FailureType, MessageType } from '../KeepKeyTypes'
Expand Down Expand Up @@ -60,9 +60,7 @@ export const KeepKeyConnect = () => {
const wallet = await (async () => {
try {
// Remove all provider event listeners from previously connected wallets
const ethersProvider = getEthersProvider()
ethersProvider.removeAllListeners('accountsChanged')
ethersProvider.removeAllListeners('chainChanged')
await removeAccountsAndChainListeners()

const sdk = await setupKeepKeySDK()

Expand Down
6 changes: 2 additions & 4 deletions src/context/WalletProvider/Keplr/components/Connect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import type { ActionTypes } from 'context/WalletProvider/actions'
import { WalletActions } from 'context/WalletProvider/actions'
import { KeyManager } from 'context/WalletProvider/KeyManager'
import { useLocalWallet } from 'context/WalletProvider/local-wallet'
import { removeAccountsAndChainListeners } from 'context/WalletProvider/WalletProvider'
import { useWallet } from 'hooks/useWallet/useWallet'
import { getEthersProvider } from 'lib/ethersProviderSingleton'

import { ConnectModal } from '../../components/ConnectModal'
import { KeplrConfig } from '../config'
Expand Down Expand Up @@ -33,9 +33,7 @@ export const KeplrConnect = ({ history }: KeplrSetupProps) => {
const adapter = await getAdapter(KeyManager.Keplr)
if (adapter) {
// Remove all provider event listeners from previously connected wallets
const ethersProvider = getEthersProvider()
ethersProvider.removeAllListeners('accountsChanged')
ethersProvider.removeAllListeners('chainChanged')
await removeAccountsAndChainListeners()

const wallet = await adapter.pairDevice()
if (!wallet) {
Expand Down
6 changes: 2 additions & 4 deletions src/context/WalletProvider/Ledger/components/Connect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import type { ActionTypes } from 'context/WalletProvider/actions'
import { WalletActions } from 'context/WalletProvider/actions'
import { KeyManager } from 'context/WalletProvider/KeyManager'
import { useLocalWallet } from 'context/WalletProvider/local-wallet'
import { removeAccountsAndChainListeners } from 'context/WalletProvider/WalletProvider'
import { useWallet } from 'hooks/useWallet/useWallet'
import { getEthersProvider } from 'lib/ethersProviderSingleton'

import { ConnectModal } from '../../components/ConnectModal'
import { LedgerConfig } from '../config'
Expand Down Expand Up @@ -37,9 +37,7 @@ export const LedgerConnect = ({ history }: LedgerSetupProps) => {
if (adapter) {
try {
// Remove all provider event listeners from previously connected wallets
const ethersProvider = getEthersProvider()
ethersProvider.removeAllListeners('accountsChanged')
ethersProvider.removeAllListeners('chainChanged')
await removeAccountsAndChainListeners()

const wallet = await adapter.pairDevice()

Expand Down
8 changes: 3 additions & 5 deletions src/context/WalletProvider/MetaMask/components/Connect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type { ActionTypes } from 'context/WalletProvider/actions'
import { WalletActions } from 'context/WalletProvider/actions'
import { KeyManager } from 'context/WalletProvider/KeyManager'
import { useLocalWallet } from 'context/WalletProvider/local-wallet'
import { removeAccountsAndChainListeners } from 'context/WalletProvider/WalletProvider'
import { useFeatureFlag } from 'hooks/useFeatureFlag/useFeatureFlag'
import {
checkIsMetaMaskDesktop,
Expand All @@ -14,7 +15,6 @@ import {
checkIsSnapInstalled,
} from 'hooks/useIsSnapInstalled/useIsSnapInstalled'
import { useWallet } from 'hooks/useWallet/useWallet'
import { getEthersProvider } from 'lib/ethersProviderSingleton'
import { selectShowSnapsModal } from 'state/slices/selectors'

import { ConnectModal } from '../../components/ConnectModal'
Expand Down Expand Up @@ -52,10 +52,8 @@ export const MetaMaskConnect = ({ history }: MetaMaskSetupProps) => {

const adapter = await getAdapter(KeyManager.MetaMask)
if (adapter) {
const ethersProvider = getEthersProvider()
ethersProvider.removeAllListeners('accountsChanged')
ethersProvider.removeAllListeners('chainChanged')

// Remove all provider event listeners from previously connected wallets
await removeAccountsAndChainListeners()
const wallet = await adapter.pairDevice()
if (!wallet) {
setErrorLoading('walletProvider.errors.walletNotFound')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import { RawText, Text } from 'components/Text'
import { WalletActions } from 'context/WalletProvider/actions'
import { KeyManager } from 'context/WalletProvider/KeyManager'
import { useLocalWallet } from 'context/WalletProvider/local-wallet'
import { removeAccountsAndChainListeners } from 'context/WalletProvider/WalletProvider'
import { useWallet } from 'hooks/useWallet/useWallet'
import { getEthersProvider } from 'lib/ethersProviderSingleton'

import { MobileConfig } from '../config'
import { deleteWallet, getWallet, listWallets } from '../mobileMessageHandlers'
Expand Down Expand Up @@ -149,10 +149,8 @@ export const MobileLoad = ({ history }: RouteComponentProps) => {
if (!revoker?.mnemonic) throw new Error(`Mobile wallet not found: ${deviceId}`)
if (!revoker?.id) throw new Error(`Revoker ID not found: ${deviceId}`)

// remove all provider event listeners from previously connected wallets
const ethersProvider = getEthersProvider()
ethersProvider.removeAllListeners('accountsChanged')
ethersProvider.removeAllListeners('chainChanged')
// Remove all provider event listeners from previously connected wallets
await removeAccountsAndChainListeners()

const wallet = await adapter.pairDevice(revoker.id)
await wallet?.loadDevice({ mnemonic: revoker.mnemonic })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { Text } from 'components/Text'
import { WalletActions } from 'context/WalletProvider/actions'
import { KeyManager } from 'context/WalletProvider/KeyManager'
import { useLocalWallet } from 'context/WalletProvider/local-wallet'
import { removeAccountsAndChainListeners } from 'context/WalletProvider/WalletProvider'
import { useStateIfMounted } from 'hooks/useStateIfMounted/useStateIfMounted'
import { useWallet } from 'hooks/useWallet/useWallet'
import { getEthersProvider } from 'lib/ethersProviderSingleton'
import { preferences } from 'state/slices/preferencesSlice/preferencesSlice'
import { useAppDispatch } from 'state/store'

Expand All @@ -28,10 +28,8 @@ export const MobileSuccess = ({ location }: MobileSetupProps) => {
const adapter = await getAdapter(KeyManager.Mobile)
if (!adapter) throw new Error('Native adapter not found')
try {
// remove all provider event listeners from previously connected wallets
const ethersProvider = getEthersProvider()
ethersProvider.removeAllListeners('accountsChanged')
ethersProvider.removeAllListeners('chainChanged')
// Remove all provider event listeners from previously connected wallets
await removeAccountsAndChainListeners()

const deviceId = vault.id ?? ''
const wallet = (await adapter.pairDevice(deviceId)) as NativeHDWallet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import { RawText, Text } from 'components/Text'
import { WalletActions } from 'context/WalletProvider/actions'
import { KeyManager } from 'context/WalletProvider/KeyManager'
import { useLocalWallet } from 'context/WalletProvider/local-wallet'
import { removeAccountsAndChainListeners } from 'context/WalletProvider/WalletProvider'
import { useWallet } from 'hooks/useWallet/useWallet'
import { getEthersProvider } from 'lib/ethersProviderSingleton'

import { NativeConfig } from '../config'

Expand Down Expand Up @@ -81,10 +81,8 @@ export const NativeLoad = ({ history }: RouteComponentProps) => {
if (adapter) {
const { name, icon } = NativeConfig
try {
// remove all provider event listeners from previously connected wallets
const ethersProvider = getEthersProvider()
ethersProvider.removeAllListeners('accountsChanged')
ethersProvider.removeAllListeners('chainChanged')
// Remove all provider event listeners from previously connected wallets
await removeAccountsAndChainListeners()

const wallet = await adapter.pairDevice(deviceId)
if (!(await wallet?.isInitialized())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { useEffect } from 'react'
import { WalletActions } from 'context/WalletProvider/actions'
import { KeyManager } from 'context/WalletProvider/KeyManager'
import { useLocalWallet } from 'context/WalletProvider/local-wallet'
import { removeAccountsAndChainListeners } from 'context/WalletProvider/WalletProvider'
import { useStateIfMounted } from 'hooks/useStateIfMounted/useStateIfMounted'
import { useWallet } from 'hooks/useWallet/useWallet'
import { getEthersProvider } from 'lib/ethersProviderSingleton'
import { preferences } from 'state/slices/preferencesSlice/preferencesSlice'
import { useAppDispatch } from 'state/store'

Expand All @@ -26,10 +26,8 @@ export const useNativeSuccess = ({ vault }: UseNativeSuccessPropTypes) => {
const adapter = await getAdapter(KeyManager.Native)
if (!adapter) throw new Error('Native adapter not found')
try {
// remove all provider event listeners from previously connected wallets
const ethersProvider = getEthersProvider()
ethersProvider.removeAllListeners('accountsChanged')
ethersProvider.removeAllListeners('chainChanged')
// Remove all provider event listeners from previously connected wallets
await removeAccountsAndChainListeners()

await new Promise(resolve => setTimeout(resolve, 250))
await Promise.all([navigator.storage?.persist?.(), vault.save()])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { KeyManager } from 'context/WalletProvider/KeyManager'
import { useLocalWallet } from 'context/WalletProvider/local-wallet'
import { WalletConnectV2Config } from 'context/WalletProvider/WalletConnectV2/config'
import { WalletNotFoundError } from 'context/WalletProvider/WalletConnectV2/Error'
import { removeAccountsAndChainListeners } from 'context/WalletProvider/WalletProvider'
import { useWallet } from 'hooks/useWallet/useWallet'
import { getEthersProvider } from 'lib/ethersProviderSingleton'
import { isWalletConnectWallet } from 'lib/utils'

import type { LocationState } from '../../NativeWallet/types'
Expand Down Expand Up @@ -38,9 +38,7 @@ export const WalletConnectV2Connect = ({ history }: WalletConnectSetupProps) =>
if (adapter) {
if (!state.wallet || !isWalletConnectWallet(state.wallet)) {
// Remove all provider event listeners from previously connected wallets
const ethersProvider = getEthersProvider()
ethersProvider.removeAllListeners('accountsChanged')
ethersProvider.removeAllListeners('chainChanged')
await removeAccountsAndChainListeners()

setLoading(true)

Expand Down
13 changes: 13 additions & 0 deletions src/context/WalletProvider/WalletProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { MobileConfig } from 'context/WalletProvider/MobileWallet/config'
import { getWallet } from 'context/WalletProvider/MobileWallet/mobileMessageHandlers'
import { KeepKeyRoutes } from 'context/WalletProvider/routes'
import { useWalletConnectV2EventHandler } from 'context/WalletProvider/WalletConnectV2/useWalletConnectV2EventHandler'
import { isSome } from 'lib/utils'
import { localWalletSlice } from 'state/slices/localWalletSlice/localWalletSlice'
import { selectWalletDeviceId, selectWalletType } from 'state/slices/localWalletSlice/selectors'
import { portfolio } from 'state/slices/portfolioSlice/portfolioSlice'
Expand Down Expand Up @@ -137,6 +138,18 @@ export const isKeyManagerWithProvider = (
].includes(keyManager),
)

export const removeAccountsAndChainListeners = async () => {
const providers = Object.values(KeyManager).filter(isKeyManagerWithProvider)
const maybeProviders = (
await Promise.all(providers.map(keyManager => getMaybeProvider(keyManager)))
).filter(isSome) as BrowserProvider[]

maybeProviders.forEach(maybeProvider => {
maybeProvider.removeAllListeners('accountsChanged')
maybeProvider.removeAllListeners('chainChanged')
})
}

export const getMaybeProvider = async (
localWalletType: KeyManager | null,
): Promise<InitialState['provider']> => {
Expand Down
6 changes: 2 additions & 4 deletions src/context/WalletProvider/XDEFI/components/Connect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import type { ActionTypes } from 'context/WalletProvider/actions'
import { WalletActions } from 'context/WalletProvider/actions'
import { KeyManager } from 'context/WalletProvider/KeyManager'
import { useLocalWallet } from 'context/WalletProvider/local-wallet'
import { removeAccountsAndChainListeners } from 'context/WalletProvider/WalletProvider'
import { useWallet } from 'hooks/useWallet/useWallet'
import { getEthersProvider } from 'lib/ethersProviderSingleton'

import { ConnectModal } from '../../components/ConnectModal'
import type { LocationState } from '../../NativeWallet/types'
Expand Down Expand Up @@ -38,9 +38,7 @@ export const XDEFIConnect = ({ history }: XDEFISetupProps) => {
if (adapter) {
try {
// Remove all provider event listeners from previously connected wallets
const ethersProvider = getEthersProvider()
ethersProvider.removeAllListeners('accountsChanged')
ethersProvider.removeAllListeners('chainChanged')
await removeAccountsAndChainListeners()

const wallet = (await adapter.pairDevice()) as XDEFIHDWallet | undefined
if (!wallet) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ export const Deposit: React.FC<DepositProps> = ({
const isApprovalRequired = await (async () => {
// Router contract address is only set in case we're depositting a token, not a native asset
if (!inboundAddress) return false
// Do not try to get allowance for native assets, including non-EVM ones.
if (!isTokenDeposit) return false

const allowanceOnChainCryptoBaseUnit = await getErc20Allowance({
address: fromAssetId(assetId).assetReference,
Expand All @@ -211,7 +213,15 @@ export const Deposit: React.FC<DepositProps> = ({
})()
setIsApprovalRequired(isApprovalRequired)
})()
}, [accountId, asset.chainId, asset.precision, assetId, inputValues, inboundAddress])
}, [
accountId,
asset.chainId,
asset.precision,
assetId,
inputValues,
inboundAddress,
isTokenDeposit,
])

// TODO(gomes): this will work for UTXO but is invalid for tokens since they use diff. denoms
// the current workaround is to not do fee deduction for non-UTXO chains,
Expand Down
Loading

0 comments on commit 512cde4

Please sign in to comment.