Skip to content

Commit

Permalink
Merge branch 'develop' into feature/17670-recovery-phrase-reminder
Browse files Browse the repository at this point in the history
  • Loading branch information
brad-decker authored Apr 27, 2023
2 parents bec02d1 + e339afc commit 819f368
Show file tree
Hide file tree
Showing 34 changed files with 387 additions and 100 deletions.
1 change: 1 addition & 0 deletions app/scripts/lockdown-run.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ try {
errorTaming: 'unsafe',
mathTaming: 'unsafe',
dateTaming: 'unsafe',
domainTaming: 'unsafe',
overrideTaming: 'severe',
});
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@
"redux-thunk": "^2.3.0",
"remove-trailing-slash": "^0.1.1",
"reselect": "^3.0.1",
"ses": "^0.12.4",
"ses": "^0.18.4",
"single-call-balance-checker-abi": "^1.0.0",
"unicode-confusables": "^0.1.1",
"uuid": "^8.3.2",
Expand Down
13 changes: 13 additions & 0 deletions shared/constants/metametrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ export enum MetaMetricsEventName {
AppInstalled = 'App Installed',
AppUnlocked = 'App Unlocked',
AppUnlockedFailed = 'App Unlocked Failed',
AppLocked = 'App Locked',
AppWindowExpanded = 'App Window Expanded',
BridgeLinkClicked = 'Bridge Link Clicked',
DecryptionApproved = 'Decryption Approved',
Expand Down Expand Up @@ -541,6 +542,17 @@ export enum MetaMetricsEventName {
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
UserClickedDeepLink = 'User clicked deeplink',
///: END:ONLY_INCLUDE_IN
AccountDetailMenuOpened = 'Account Details Menu Opened',
BlockExplorerLinkClicked = 'Block Explorer Clicked',
AccountRemoved = 'Account Removed',
TestNetworksDisplayed = 'Test Networks Displayed',
AddNetworkButtonClick = 'Add Network Button Clicked',
CustomNetworkAdded = 'Custom Network Added',
TokenDetailsOpened = 'Token Details Opened',
NftScreenOpened = 'NFT Screen Opened',
ActivityScreenOpened = 'Activity Screen Opened',
WhatsNewViewed = `What's New Viewed`,
WhatsNewClicked = `What's New Link Clicked`,
}

export enum MetaMetricsEventAccountType {
Expand Down Expand Up @@ -583,6 +595,7 @@ export enum MetaMetricsEventCategory {
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
MMI = 'Institutional',
///: END:ONLY_INCLUDE_IN
Tokens = 'Tokens',
}

export enum MetaMetricsEventLinkType {
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/tests/portfolio-site.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('Portfolio site', function () {
// Verify site
assert.equal(
await driver.getCurrentUrl(),
'http://127.0.0.1:8080/?metamaskEntry=ext',
'http://127.0.0.1:8080/?metamaskEntry=ext&metametricsId=null',
);
},
);
Expand Down
4 changes: 0 additions & 4 deletions test/helpers/protect-intrinsics-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,10 @@ module.exports = {
function getGlobalProperties() {
const comp = new Compartment().globalThis;

// These are Agoric inventions, and we don't care about them.
const ignoreList = new Set([
'Compartment',
'HandledPromise',
'StaticModuleRecord',
...Object.getOwnPropertySymbols(comp),
]);

const namedIntrinsics = Reflect.ownKeys(comp);

return new Set(
Expand Down
2 changes: 1 addition & 1 deletion test/unit-global/protect-intrinsics.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'ses/lockdown';
import 'ses';
import '../../app/scripts/lockdown-run';
import '../../app/scripts/lockdown-more';
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import classNames from 'classnames';
import Box from '../../../ui/box/box';
import Button from '../../../ui/button';
import { useI18nContext } from '../../../../hooks/useI18nContext';
import { getDetectedTokensInCurrentNetwork } from '../../../../selectors';
import {
getCurrentChainId,
getDetectedTokensInCurrentNetwork,
} from '../../../../selectors';
import { MetaMetricsContext } from '../../../../contexts/metametrics';
import {
MetaMetricsEventCategory,
Expand All @@ -23,13 +26,16 @@ const DetectedTokensLink = ({ className = '', setShowDetectedTokens }) => {
({ address, symbol }) => `${symbol} - ${address}`,
);

const chainId = useSelector(getCurrentChainId);

const onClick = () => {
setShowDetectedTokens(true);
trackEvent({
event: MetaMetricsEventName.TokenImportClicked,
category: MetaMetricsEventCategory.Wallet,
properties: {
source: MetaMetricsTokenEventSource.Detected,
source_connection_method: MetaMetricsTokenEventSource.Detected,
chain_id: chainId,
tokens: detectedTokensDetails,
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { TypographyVariant } from '../../../../helpers/constants/design-system';

import SecurityProviderBannerMessage from '../../security-provider-banner-message/security-provider-banner-message';
import { SECURITY_PROVIDER_MESSAGE_SEVERITIES } from '../../security-provider-banner-message/security-provider-banner-message.constants';
import { getPortfolioUrl } from '../../../../helpers/utils/portfolio';
import { ConfirmPageContainerSummary, ConfirmPageContainerWarning } from '.';

export default class ConfirmPageContainerContent extends Component {
Expand Down Expand Up @@ -54,6 +55,7 @@ export default class ConfirmPageContainerContent extends Component {
transactionType: PropTypes.string,
isBuyableChain: PropTypes.bool,
txData: PropTypes.object,
metaMetricsId: PropTypes.string,
};

renderContent() {
Expand Down Expand Up @@ -159,6 +161,7 @@ export default class ConfirmPageContainerContent extends Component {
transactionType,
isBuyableChain,
txData,
metaMetricsId,
} = this.props;

const { t } = this.context;
Expand Down Expand Up @@ -222,9 +225,12 @@ export default class ConfirmPageContainerContent extends Component {
type="inline"
className="confirm-page-container-content__link"
onClick={() => {
const portfolioUrl = process.env.PORTFOLIO_URL;
global.platform.openTab({
url: `${portfolioUrl}/buy?metamaskEntry=ext_buy_button`,
url: getPortfolioUrl(
'buy',
'ext_buy_button',
metaMetricsId,
),
});
}}
key={`${nativeCurrency}-buy-button`}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import {
getIsBuyableChain,
getMetadataContractName,
getMetaMaskIdentities,
getMetaMetricsId,
getNetworkIdentifier,
getSwapsDefaultToken,
} from '../../../selectors';
Expand Down Expand Up @@ -116,6 +117,8 @@ const ConfirmPageContainer = (props) => {
getMetadataContractName(state, toAddress),
);

const metaMetricsId = useSelector(getMetaMetricsId);

// TODO: Move useRamps hook to the confirm-transaction-base parent component.
// TODO: openBuyCryptoInPdapp should be passed to this component as a custom prop.
// We try to keep this component for layout purpose only, we need to move this hook to the confirm-transaction-base parent
Expand Down Expand Up @@ -198,6 +201,7 @@ const ConfirmPageContainer = (props) => {
)}
{contentComponent || (
<ConfirmPageContainerContent
metaMetricsId={metaMetricsId}
action={action}
title={title}
image={image}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import {
MetaMetricsEventName,
MetaMetricsTokenEventSource,
} from '../../../../../shared/constants/metametrics';
import { getDetectedTokensInCurrentNetwork } from '../../../../selectors';
import {
getCurrentChainId,
getDetectedTokensInCurrentNetwork,
} from '../../../../selectors';

import Popover from '../../../ui/popover';
import Box from '../../../ui/box';
Expand All @@ -27,6 +30,8 @@ const DetectedTokenSelectionPopover = ({
const t = useI18nContext();
const trackEvent = useContext(MetaMetricsContext);

const chainId = useSelector(getCurrentChainId);

const detectedTokens = useSelector(getDetectedTokensInCurrentNetwork);
const { selected: selectedTokens = [] } =
sortingBasedOnTokenSelection(tokensListDetected);
Expand All @@ -44,7 +49,8 @@ const DetectedTokenSelectionPopover = ({
event: MetaMetricsEventName.TokenImportCanceled,
category: MetaMetricsEventCategory.Wallet,
properties: {
source: MetaMetricsTokenEventSource.Detected,
source_connection_method: MetaMetricsTokenEventSource.Detected,
chain_id: chainId,
tokens: eventTokensDetails,
},
});
Expand Down
10 changes: 8 additions & 2 deletions ui/components/app/detected-token/detected-token.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import {
ignoreTokens,
setNewTokensImported,
} from '../../../store/actions';
import { getDetectedTokensInCurrentNetwork } from '../../../selectors';
import {
getCurrentChainId,
getDetectedTokensInCurrentNetwork,
} from '../../../selectors';
import { MetaMetricsContext } from '../../../contexts/metametrics';

import {
Expand Down Expand Up @@ -47,6 +50,7 @@ const DetectedToken = ({ setShowDetectedTokens }) => {
const dispatch = useDispatch();
const trackEvent = useContext(MetaMetricsContext);

const chainId = useSelector(getCurrentChainId);
const detectedTokens = useSelector(getDetectedTokensInCurrentNetwork);

const [tokensListDetected, setTokensListDetected] = useState(() =>
Expand All @@ -69,9 +73,11 @@ const DetectedToken = ({ setShowDetectedTokens }) => {
token_symbol: importedToken.symbol,
token_contract_address: importedToken.address,
token_decimal_precision: importedToken.decimals,
source: MetaMetricsTokenEventSource.Detected,
source_connection_method: MetaMetricsTokenEventSource.Detected,
token_standard: TokenStandard.ERC20,
asset_type: AssetType.token,
token_added_type: 'detected',
chain_id: chainId,
},
});
});
Expand Down
28 changes: 23 additions & 5 deletions ui/components/app/wallet-overview/eth-overview.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import {
getIsBuyableChain,
getNativeCurrencyImage,
getSelectedAccountCachedBalance,
getCurrentChainId,
getMetaMetricsId,
} from '../../../selectors';
import { setSwapsFromToken } from '../../../ducks/swaps/swaps';
import IconButton from '../../ui/icon-button';
Expand All @@ -52,6 +54,7 @@ import {
} from '../../component-library';
import { IconColor } from '../../../helpers/constants/design-system';
import useRamps from '../../../hooks/experiences/useRamps';
import { getPortfolioUrl } from '../../../helpers/utils/portfolio';
import WalletOverview from './wallet-overview';

const EthOverview = ({ className }) => {
Expand All @@ -70,6 +73,8 @@ const EthOverview = ({ className }) => {
const isBuyableChain = useSelector(getIsBuyableChain);
const primaryTokenImage = useSelector(getNativeCurrencyImage);
const defaultSwapsToken = useSelector(getSwapsDefaultToken);
const chainId = useSelector(getCurrentChainId);
const metaMetricsId = useSelector(getMetaMetricsId);

///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
const mmiPortfolioEnabled = useSelector(getMmiPortfolioEnabled);
Expand Down Expand Up @@ -166,9 +171,13 @@ const EthOverview = ({ className }) => {
ariaLabel={t('portfolio')}
size={ButtonIconSize.Lg}
onClick={() => {
const portfolioUrl = process.env.PORTFOLIO_URL;
const portfolioUrl = getPortfolioUrl(
'',
'ext',
metaMetricsId,
);
global.platform.openTab({
url: `${portfolioUrl}?metamaskEntry=ext`,
url: portfolioUrl,
});
trackEvent(
{
Expand Down Expand Up @@ -226,6 +235,8 @@ const EthOverview = ({ className }) => {
properties: {
location: 'Home',
text: 'Buy',
chain_id: chainId,
token_symbol: defaultSwapsToken,
},
});
}}
Expand Down Expand Up @@ -257,6 +268,7 @@ const EthOverview = ({ className }) => {
token_symbol: 'ETH',
location: 'Home',
text: 'Send',
chain_id: chainId,
},
});
dispatch(
Expand Down Expand Up @@ -284,6 +296,7 @@ const EthOverview = ({ className }) => {
token_symbol: 'ETH',
location: MetaMetricsSwapsEventSource.MainView,
text: 'Swap',
chain_id: chainId,
},
});
dispatch(setSwapsFromToken(defaultSwapsToken));
Expand Down Expand Up @@ -320,10 +333,13 @@ const EthOverview = ({ className }) => {
label={t('bridge')}
onClick={() => {
if (isBridgeChain) {
const portfolioUrl = process.env.PORTFOLIO_URL;
const bridgeUrl = `${portfolioUrl}/bridge`;
const portfolioUrl = getPortfolioUrl(
'bridge',
'ext_bridge_button',
metaMetricsId,
);
global.platform.openTab({
url: `${bridgeUrl}?metamaskEntry=ext_bridge_button${
url: `${portfolioUrl}${
location.pathname.includes('asset') ? '&token=native' : ''
}`,
});
Expand All @@ -333,6 +349,8 @@ const EthOverview = ({ className }) => {
properties: {
location: 'Home',
text: 'Bridge',
chain_id: chainId,
token_symbol: 'ETH',
},
});
}
Expand Down
Loading

0 comments on commit 819f368

Please sign in to comment.