Skip to content

Commit

Permalink
Merge branch 'master' into v11.12.0-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
danjm committed Mar 13, 2024
2 parents 9faeede + a70a36f commit 7fc7f77
Show file tree
Hide file tree
Showing 28 changed files with 296 additions and 47 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4495,6 +4495,7 @@ Update styles and spacing on the critical error page ([#20350](https://github.c
[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v11.12.0...HEAD
[11.12.0]: https://github.com/MetaMask/metamask-extension/compare/v11.10.0...v11.12.0
[11.12.0]: https://github.com/MetaMask/metamask-extension/compare/v11.11.4...v11.12.0
[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v11.11.4...HEAD
[11.11.4]: https://github.com/MetaMask/metamask-extension/compare/v11.11.3...v11.11.4
[11.11.3]: https://github.com/MetaMask/metamask-extension/compare/v11.11.2...v11.11.3
[11.11.2]: https://github.com/MetaMask/metamask-extension/compare/v11.11.1...v11.11.2
Expand Down
Binary file added app/images/staking-light-mode-preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/images/velas.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/scripts/constants/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ export const SINGLE_CALL_BALANCES_ADDRESSES = {
[CHAIN_IDS.AVALANCHE]: '0xD023D153a0DFa485130ECFdE2FAA7e612EF94818',
[CHAIN_IDS.FANTOM]: '0x07f697424ABe762bB808c109860c04eA488ff92B',
[CHAIN_IDS.ARBITRUM]: '0x151E24A486D7258dd7C33Fb67E4bB01919B7B32c',
[CHAIN_IDS.BLAST]: '0xfd5730e96f9dffae40d99b77015bd42816280998',
};
28 changes: 28 additions & 0 deletions app/scripts/migrations/105.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ import { migrate } from './105';
const MOCK_ADDRESS = '0x0';
const MOCK_ADDRESS_2 = '0x1';

const sentryCaptureExceptionMock = jest.fn();

global.sentry = {
startSession: jest.fn(),
endSession: jest.fn(),
toggleSession: jest.fn(),
captureException: sentryCaptureExceptionMock,
};

function addressToUUID(address: string): string {
return uuid({
random: sha256FromString(address).slice(0, 16),
Expand Down Expand Up @@ -257,5 +266,24 @@ describe('migration #105', () => {
},
});
});

it('captures an exception if the selectedAddress state is invalid', async () => {
const oldData = {
PreferencesController: {
identities: {},
selectedAddress: undefined,
},
};
const oldStorage = {
meta: { version: 103 },
data: oldData,
};
await migrate(oldStorage);

expect(sentryCaptureExceptionMock).toHaveBeenCalledTimes(1);
expect(sentryCaptureExceptionMock).toHaveBeenCalledWith(
new Error(`state.PreferencesController?.selectedAddress is undefined`),
);
});
});
});
8 changes: 8 additions & 0 deletions app/scripts/migrations/105.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@ function createSelectedAccountForAccountsController(
) {
const selectedAddress = state.PreferencesController?.selectedAddress;

if (typeof selectedAddress !== 'string') {
global.sentry?.captureException?.(
new Error(
`state.PreferencesController?.selectedAddress is ${selectedAddress}`,
),
);
}

const selectedAccount = Object.values<InternalAccount>(
state.AccountsController.internalAccounts.accounts,
).find((account: InternalAccount) => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@
},
"dependencies": {
"@babel/runtime": "^7.23.2",
"@blockaid/ppom_release": "^1.4.1",
"@blockaid/ppom_release": "^1.4.4",
"@ensdomains/content-hash": "^2.5.7",
"@ethereumjs/common": "^3.1.1",
"@ethereumjs/tx": "^4.1.1",
Expand Down
38 changes: 38 additions & 0 deletions shared/constants/first-party-contracts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { Hex } from '@metamask/utils';
import { CHAIN_IDS } from './network';

/**
* A map of first-party contract names to their addresses on various chains.
*/
export const FIRST_PARTY_CONTRACT_NAMES: Record<string, Record<Hex, Hex>> = {
'MetaMask Validator Staking': {
[CHAIN_IDS.MAINNET]: '0xDc71aFFC862fceB6aD32BE58E098423A7727bEbd',
},
'MetaMask Pool Staking': {
[CHAIN_IDS.MAINNET]: '0x1f6692E78dDE07FF8da75769B6d7c716215bC7D0',
},
'MetaMask Pool Staking (v1)': {
[CHAIN_IDS.MAINNET]: '0xc7bE520a13dC023A1b34C03F4Abdab8A43653F7B',
},
'MetaMask Bridge': {
[CHAIN_IDS.MAINNET]: '0x0439e60F02a8900a951603950d8D4527f400C3f1',
[CHAIN_IDS.OPTIMISM]: '0xB90357f2b86dbfD59c3502215d4060f71DF8ca0e',
[CHAIN_IDS.BSC]: '0xaEc23140408534b378bf5832defc426dF8604B59',
[CHAIN_IDS.POLYGON]: '0x3A0b42cE6166abB05d30DdF12E726c95a83D7a16',
[CHAIN_IDS.ZKSYNC_ERA]: '0x357B5935482AD8a4A2e181e0132aBd1882E16520',
[CHAIN_IDS.BASE]: '0xa20ECbC821fB54064aa7B5C6aC81173b8b34Df71',
[CHAIN_IDS.ARBITRUM]: '0x23981fC34e69eeDFE2BD9a0a9fCb0719Fe09DbFC',
[CHAIN_IDS.AVALANCHE]: '0x29106d08382d3c73bF477A94333C61Db1142E1B6',
[CHAIN_IDS.LINEA_MAINNET]: '0xE3d0d2607182Af5B24f5C3C2E4990A053aDd64e3',
},
'MetaMask Swaps': {
[CHAIN_IDS.MAINNET]: '0x881D40237659C251811CEC9c364ef91dC08D300C',
[CHAIN_IDS.BSC]: '0x1a1ec25DC08e98e5E93F1104B5e5cdD298707d31',
[CHAIN_IDS.POLYGON]: '0x1a1ec25DC08e98e5E93F1104B5e5cdD298707d31',
[CHAIN_IDS.AVALANCHE]: '0x1a1ec25DC08e98e5E93F1104B5e5cdD298707d31',
[CHAIN_IDS.ARBITRUM]: '0x9dDA6Ef3D919c9bC8885D5560999A3640431e8e6',
[CHAIN_IDS.OPTIMISM]: '0x9dDA6Ef3D919c9bC8885D5560999A3640431e8e6',
[CHAIN_IDS.ZKSYNC_ERA]: '0xf504c1fe13d14DF615E66dcd0ABF39e60c697f34',
[CHAIN_IDS.LINEA_MAINNET]: '0x9dDA6Ef3D919c9bC8885D5560999A3640431e8e6',
},
};
11 changes: 11 additions & 0 deletions shared/constants/network.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { existsSync } from 'fs';
import { join } from 'path';
import { CHAIN_ID_TO_NETWORK_IMAGE_URL_MAP } from './network';

describe('NetworkConstants', () => {
it('has images files that exist for defined networks', () => {
Object.values(CHAIN_ID_TO_NETWORK_IMAGE_URL_MAP).forEach((image) =>
expect(existsSync(join('app', image))).toBe(true),
);
});
});
8 changes: 5 additions & 3 deletions shared/constants/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ export const CHAIN_IDS = {
ZKSYNC_ERA: '0x144',
TEST_ETH: '0x539',
ARBITRUM_GOERLI: '0x66eed',
BLAST: '0x13e31',
} as const;

const CHAINLIST_CHAIN_IDS_MAP = {
Expand Down Expand Up @@ -377,7 +378,7 @@ export const DEXALOT_SUBNET_IMAGE_URL = './images/dexalut-subnet.svg';
export const DFK_CHAIN_IMAGE_URL = './images/dfk.png';
export const DOGECHAIN_IMAGE_URL = './images/dogechain.jpeg';
export const ENDURANCE_SMART_CHAIN_MAINNET_IMAGE_URL =
'./images/endurance-smart-chain.png';
'./images/endurance-smart-chain-mainnet.png';
export const ETHEREUM_CLASSIC_MAINNET_IMAGE_URL = './images/eth_classic.svg';
export const EVMOS_IMAGE_URL = './images/evmos.svg';
export const FLARE_MAINNET_IMAGE_URL = './images/flare-mainnet.svg';
Expand All @@ -402,11 +403,11 @@ export const SHARDEUM_LIBERTY_2X_IMAGE_URL = './images/shardeum-2.svg';
export const SHARDEUM_SPHINX_1X_IMAGE_URL = './images/shardeum-1.svg';
export const SHIB_MAINNET_IMAGE_URL = './images/shiba.svg';
export const SONGBIRD_MAINNET_IMAGE_URL = './images/songbird.svg';
export const STEP_NETWORK_IMAGE_URL = './images/setp.svg';
export const STEP_NETWORK_IMAGE_URL = './images/step.svg';
export const TELOS_EVM_MAINNET_IMAGE_URL = './images/telos.svg';
export const TENET_MAINNET_IMAGE_URL = './images/tenet.svg';
export const VELAS_EVM_MAINNET_IMAGE_URL = './images/velas.svg';
export const ZKATANA_MAINNET_IMAGE_URL = './images/zkatana.svg';
export const ZKATANA_MAINNET_IMAGE_URL = './images/zkatana.png';
export const ZORA_MAINNET_IMAGE_URL = './images/zora.svg';

export const INFURA_PROVIDER_TYPES = [
Expand Down Expand Up @@ -855,6 +856,7 @@ export const BUYABLE_CHAINS_MAP: {
| typeof CHAIN_IDS.GNOSIS
| typeof CHAIN_IDS.AURORA
| typeof CHAIN_IDS.ARBITRUM_GOERLI
| typeof CHAIN_IDS.BLAST
>]: BuyableChainSettings;
} = {
[CHAIN_IDS.MAINNET]: {
Expand Down
1 change: 0 additions & 1 deletion shared/constants/permissions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ describe('EndowmentPermissions', () => {
expect(Object.keys(EndowmentPermissions).sort()).toStrictEqual(
[
'endowment:name-lookup',
'endowment:page-home',
'endowment:signature-insight',
...Object.keys(endowmentPermissionBuilders).filter(
(targetName) =>
Expand Down
4 changes: 1 addition & 3 deletions shared/constants/snaps/permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ export const EndowmentPermissions = Object.freeze({
'endowment:rpc': 'endowment:rpc',
'endowment:webassembly': 'endowment:webassembly',
'endowment:lifecycle-hooks': 'endowment:lifecycle-hooks',
///: BEGIN:ONLY_INCLUDE_IF(build-flask)
'endowment:page-home': 'endowment:page-home',
///: BEGIN:ONLY_INCLUDE_IF(build-flask)
'endowment:signature-insight': 'endowment:signature-insight',
'endowment:name-lookup': 'endowment:name-lookup',
///: END:ONLY_INCLUDE_IF
Expand All @@ -24,8 +24,6 @@ export const ExcludedSnapPermissions = Object.freeze({

export const ExcludedSnapEndowments = Object.freeze({
///: BEGIN:ONLY_INCLUDE_IF(build-main)
'endowment:page-home':
'This endowment is experimental and therefore not available.',
'endowment:name-lookup':
'This endowment is experimental and therefore not available.',
'endowment:signature-insight':
Expand Down
2 changes: 1 addition & 1 deletion shared/notifications/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const UI_NOTIFICATIONS = {
id: Number(NOTIFICATION_STAKING_PORTFOLIO),
date: null,
image: {
src: 'images/portfolio-stake-notification-light-mode.png',
src: 'images/staking-light-mode-preview.png',
width: '100%',
},
},
Expand Down
1 change: 0 additions & 1 deletion test/e2e/run-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const { loadBuildTypesConfig } = require('../../development/lib/build-type');
const FLASK_ONLY_TESTS = [
'test-snap-txinsights-v2.spec.js',
'test-snap-namelookup.spec.js',
'test-snap-homepage.spec.js',
];

const getTestPathsForTestDir = async (testDir) => {
Expand Down
2 changes: 2 additions & 0 deletions test/e2e/tests/account-token-list.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ describe('Settings', function () {
await logInWithBalanceValidation(driver, ganacheServer);

await driver.clickElement('[data-testid="home__asset-tab"]');

const tokenValue = '25 ETH';

const tokenListAmount = await driver.findElement(
'[data-testid="multichain-token-list-item-value"]',
);
Expand Down
22 changes: 11 additions & 11 deletions ui/components/app/asset-list/asset-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ const AssetList = ({ onClickAsset }) => {
const showFiat = useSelector(getShouldShowFiat);
const currentNetwork = useSelector(getCurrentNetwork);
const currentLocale = useSelector(getCurrentLocale);

const isMainnet = useSelector(getIsMainnet);
const { useNativeCurrencyAsPrimaryCurrency } = useSelector(getPreferences);
const { ticker, type } = useSelector(getProviderConfig);
Expand Down Expand Up @@ -93,13 +94,11 @@ const AssetList = ({ onClickAsset }) => {
numberOfDecimals: secondaryNumberOfDecimals,
} = useUserPreferencedCurrency(SECONDARY, { ethNumberOfDecimals: 4 });

const [, primaryCurrencyProperties] = useCurrencyDisplay(
selectedAccountBalance,
{
const [primaryCurrencyDisplay, primaryCurrencyProperties] =
useCurrencyDisplay(selectedAccountBalance, {
numberOfDecimals: primaryNumberOfDecimals,
currency: primaryCurrency,
},
);
});

const [secondaryCurrencyDisplay, secondaryCurrencyProperties] =
useCurrencyDisplay(selectedAccountBalance, {
Expand Down Expand Up @@ -226,14 +225,15 @@ const AssetList = ({ onClickAsset }) => {
<TokenListItem
onClick={() => onClickAsset(nativeCurrency)}
title={nativeCurrency}
// The primary and secondary currencies are subject to change based on the user's settings
// TODO: rename this primary/secondary concept here to be more intuitive, regardless of setting
primary={
showPrimaryCurrency(
showSecondaryCurrency(
isOriginalNativeSymbol,
useNativeCurrencyAsPrimaryCurrency,
)
? primaryCurrencyProperties.value ??
secondaryCurrencyProperties.value
: null
? secondaryCurrencyDisplay
: undefined
}
tokenSymbol={
useNativeCurrencyAsPrimaryCurrency
Expand All @@ -242,11 +242,11 @@ const AssetList = ({ onClickAsset }) => {
}
secondary={
showFiat &&
showSecondaryCurrency(
showPrimaryCurrency(
isOriginalNativeSymbol,
useNativeCurrencyAsPrimaryCurrency,
)
? secondaryCurrencyDisplay
? primaryCurrencyDisplay
: undefined
}
tokenImage={balanceIsLoading ? null : primaryTokenImage}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ exports[`Token Cell should match snapshot 1`] = `
5.000
TEST
</p>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ exports[`TokenListItem should render correctly 1`] = `
data-testid="multichain-token-list-item-value"
>
</p>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ export const TokenListItem = ({
variant={TextVariant.bodyMd}
textAlign={TextAlign.End}
>
{primary} {tokenSymbol}{' '}
{primary} {isNativeCurrency ? '' : tokenSymbol}
</Text>
</Box>
</Box>
Expand Down
Loading

0 comments on commit 7fc7f77

Please sign in to comment.