Skip to content

Commit

Permalink
Merge branch 'develop' into jl/reset-streams-on-bfcache-pageshow
Browse files Browse the repository at this point in the history
  • Loading branch information
jiexi committed Jun 13, 2024
2 parents fecc52b + 04642d2 commit 9856738
Show file tree
Hide file tree
Showing 20 changed files with 2,765 additions and 112 deletions.
2,630 changes: 2,630 additions & 0 deletions .yarn/patches/@metamask-gas-fee-controller-npm-15.1.2-db4d2976aa.patch

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions app/manifest/v3/_base.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,8 @@
"webRequest",
"offscreen"
],
"sandbox": {
"pages": ["snaps/index.html"]
},
"short_name": "__MSG_appName__"
}
3 changes: 2 additions & 1 deletion app/manifest/v3/chrome.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"content_security_policy": {
"extension_pages": "script-src 'self' 'wasm-unsafe-eval'; object-src 'none'; frame-ancestors 'none';"
"extension_pages": "script-src 'self' 'wasm-unsafe-eval'; object-src 'none'; frame-ancestors 'none';",
"sandbox": "sandbox allow-scripts; script-src 'self' 'unsafe-inline' 'unsafe-eval'; object-src 'none'; default-src 'none'; connect-src *;"
},
"externally_connectable": {
"matches": ["https://metamask.io/*"],
Expand Down
13 changes: 11 additions & 2 deletions app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,11 @@ import { toChecksumHexAddress } from '../../shared/modules/hexstring-utils';
///: END:ONLY_INCLUDE_IF

import { AssetType, TokenStandard } from '../../shared/constants/transaction';
import { SWAPS_CLIENT_ID } from '../../shared/constants/swaps';
import {
GAS_API_BASE_URL,
GAS_DEV_API_BASE_URL,
SWAPS_CLIENT_ID,
} from '../../shared/constants/swaps';
import {
CHAIN_IDS,
NETWORK_TYPES,
Expand Down Expand Up @@ -776,6 +780,10 @@ export default class MetamaskController extends EventEmitter {
allowedEvents: ['NetworkController:stateChange'],
});

const gasApiBaseUrl = process.env.SWAPS_USE_DEV_APIS
? GAS_DEV_API_BASE_URL
: GAS_API_BASE_URL;

this.gasFeeController = new GasFeeController({
state: initState.GasFeeController,
interval: 10000,
Expand All @@ -795,12 +803,13 @@ export default class MetamaskController extends EventEmitter {
),
getCurrentAccountEIP1559Compatibility:
this.getCurrentAccountEIP1559Compatibility.bind(this),
legacyAPIEndpoint: `${gasApiBaseUrl}/networks/<chain_id>/gasPrices`,
EIP1559APIEndpoint: `${gasApiBaseUrl}/networks/<chain_id>/suggestedGasFees`,
getCurrentNetworkLegacyGasAPICompatibility: () => {
const { chainId } = this.networkController.state.providerConfig;
return chainId === CHAIN_IDS.BSC;
},
getChainId: () => this.networkController.state.providerConfig.chainId,
infuraAPIKey: opts.infuraProjectId,
});

this.appStateController = new AppStateController({
Expand Down
21 changes: 21 additions & 0 deletions development/build/static.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,27 @@ function getCopyTargets(
pattern: `*.html`,
dest: '',
},
...(process.env.ENABLE_MV3 === 'true' ||
process.env.ENABLE_MV3 === undefined
? [
{
src: getPathInsideNodeModules(
'@metamask/snaps-execution-environments',
'dist/browserify/iframe/index.html',
),
dest: `snaps/index.html`,
pattern: '',
},
{
src: getPathInsideNodeModules(
'@metamask/snaps-execution-environments',
'dist/browserify/iframe/bundle.js',
),
dest: `snaps/bundle.js`,
pattern: '',
},
]
: []),
];

if (activeFeatures.includes('blockaid')) {
Expand Down
1 change: 0 additions & 1 deletion lavamoat/browserify/beta/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -1466,7 +1466,6 @@
"@metamask/eth-query": true,
"@metamask/gas-fee-controller>@metamask/controller-utils": true,
"bn.js": true,
"browserify>buffer": true,
"uuid": true
}
},
Expand Down
1 change: 0 additions & 1 deletion lavamoat/browserify/flask/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -1466,7 +1466,6 @@
"@metamask/eth-query": true,
"@metamask/gas-fee-controller>@metamask/controller-utils": true,
"bn.js": true,
"browserify>buffer": true,
"uuid": true
}
},
Expand Down
1 change: 0 additions & 1 deletion lavamoat/browserify/main/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -1466,7 +1466,6 @@
"@metamask/eth-query": true,
"@metamask/gas-fee-controller>@metamask/controller-utils": true,
"bn.js": true,
"browserify>buffer": true,
"uuid": true
}
},
Expand Down
1 change: 0 additions & 1 deletion lavamoat/browserify/mmi/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -1751,7 +1751,6 @@
"@metamask/eth-query": true,
"@metamask/gas-fee-controller>@metamask/controller-utils": true,
"bn.js": true,
"browserify>buffer": true,
"uuid": true
}
},
Expand Down
2 changes: 1 addition & 1 deletion offscreen/scripts/offscreen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ const parentStream = new BrowserRuntimePostMessageStream({
target: 'parent',
});

ProxySnapExecutor.initialize(parentStream);
ProxySnapExecutor.initialize(parentStream, './snaps/index.html');
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,8 @@
"@expo/config-plugins/glob": "^10.3.10",
"@metamask/network-controller": "patch:@metamask/network-controller@npm%3A19.0.0#~/.yarn/patches/@metamask-network-controller-npm-19.0.0-a5e0d1fe14.patch",
"@solana/web3.js/rpc-websockets": "^8.0.1",
"@metamask/network-controller@npm:^19.0.0": "patch:@metamask/network-controller@npm%3A19.0.0#~/.yarn/patches/@metamask-network-controller-npm-19.0.0-a5e0d1fe14.patch"
"@metamask/network-controller@npm:^19.0.0": "patch:@metamask/network-controller@npm%3A19.0.0#~/.yarn/patches/@metamask-network-controller-npm-19.0.0-a5e0d1fe14.patch",
"@metamask/gas-fee-controller@npm:^15.1.1": "patch:@metamask/gas-fee-controller@npm%3A15.1.2#~/.yarn/patches/@metamask-gas-fee-controller-npm-15.1.2-db4d2976aa.patch"
},
"dependencies": {
"@babel/runtime": "patch:@babel/runtime@npm%3A7.24.0#~/.yarn/patches/@babel-runtime-npm-7.24.0-7eb1dd11a2.patch",
Expand Down Expand Up @@ -305,7 +306,7 @@
"@metamask/ethjs": "^0.6.0",
"@metamask/ethjs-contract": "^0.4.1",
"@metamask/ethjs-query": "^0.7.1",
"@metamask/gas-fee-controller": "^15.1.2",
"@metamask/gas-fee-controller": "patch:@metamask/gas-fee-controller@npm%3A15.1.2#~/.yarn/patches/@metamask-gas-fee-controller-npm-15.1.2-db4d2976aa.patch",
"@metamask/jazzicon": "^2.0.0",
"@metamask/keyring-api": "^8.0.0",
"@metamask/keyring-controller": "patch:@metamask/keyring-controller@npm%3A15.0.0#~/.yarn/patches/@metamask-keyring-controller-npm-15.0.0-fa070ce311.patch",
Expand Down
2 changes: 1 addition & 1 deletion privacy-snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"etherscan.io",
"execution.metamask.io",
"fonts.gstatic.com",
"gas.api.infura.io",
"gas.api.cx.metamask.io",
"github.com",
"goerli.infura.io",
"localhost:8000",
Expand Down
2 changes: 1 addition & 1 deletion shared/constants/swaps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ const SWAPS_TESTNET_CHAIN_ID = '0x539';
export const SWAPS_API_V2_BASE_URL = 'https://swap.api.cx.metamask.io';
export const SWAPS_DEV_API_V2_BASE_URL = 'https://swap.dev-api.cx.metamask.io';
export const TOKEN_API_BASE_URL = 'https://tokens.api.cx.metamask.io';
export const GAS_API_BASE_URL = 'https://gas.api.infura.io';
export const GAS_API_BASE_URL = 'https://gas.api.cx.metamask.io';
export const GAS_DEV_API_BASE_URL = 'https://gas.uat-api.cx.metamask.io';

const BSC_DEFAULT_BLOCK_EXPLORER_URL = 'https://bscscan.com/';
Expand Down
3 changes: 2 additions & 1 deletion shared/lib/swaps-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import log from 'loglevel';
import { CHAIN_IDS } from '../constants/network';
import {
GAS_API_BASE_URL,
GAS_DEV_API_BASE_URL,
SWAPS_API_V2_BASE_URL,
SWAPS_CHAINID_DEFAULT_TOKEN_MAP,
SWAPS_CLIENT_ID,
Expand Down Expand Up @@ -130,7 +131,7 @@ const getBaseUrlForNewSwapsApi = (type, chainId) => {
const v2ApiBaseUrl = useDevApis
? SWAPS_DEV_API_V2_BASE_URL
: SWAPS_API_V2_BASE_URL;
const gasApiBaseUrl = GAS_API_BASE_URL;
const gasApiBaseUrl = useDevApis ? GAS_DEV_API_BASE_URL : GAS_API_BASE_URL;
const tokenApiBaseUrl = TOKEN_API_BASE_URL;
const noNetworkSpecificTypes = ['refreshTime']; // These types don't need network info in the URL.
if (noNetworkSpecificTypes.includes(type)) {
Expand Down
97 changes: 45 additions & 52 deletions test/e2e/mock-e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,60 +191,18 @@ async function setupMocking(
};
});

const gasPricesCallbackMock = () => ({
statusCode: 200,
json: {
SafeGasPrice: '1',
ProposeGasPrice: '2',
FastGasPrice: '3',
},
});
const suggestedGasFeesCallbackMock = () => ({
statusCode: 200,
json: {
low: {
suggestedMaxPriorityFeePerGas: '1',
suggestedMaxFeePerGas: '20.44436136',
minWaitTimeEstimate: 15000,
maxWaitTimeEstimate: 30000,
},
medium: {
suggestedMaxPriorityFeePerGas: '1.5',
suggestedMaxFeePerGas: '25.80554517',
minWaitTimeEstimate: 15000,
maxWaitTimeEstimate: 45000,
},
high: {
suggestedMaxPriorityFeePerGas: '2',
suggestedMaxFeePerGas: '27.277766977',
minWaitTimeEstimate: 15000,
maxWaitTimeEstimate: 60000,
},
estimatedBaseFee: '19.444436136',
networkCongestion: 0.14685,
latestPriorityFeeRange: ['0.378818859', '6.555563864'],
historicalPriorityFeeRange: ['0.1', '248.262969261'],
historicalBaseFeeRange: ['14.146999781', '28.825256275'],
priorityFeeTrend: 'down',
baseFeeTrend: 'up',
},
});

await server
.forGet(`${GAS_API_BASE_URL}/networks/${chainId}/gasPrices`)
.thenCallback(gasPricesCallbackMock);

await server
.forGet(`${GAS_API_BASE_URL}/networks/1/gasPrices`)
.thenCallback(gasPricesCallbackMock);

await server
.forGet(`${GAS_API_BASE_URL}/networks/1/suggestedGasFees`)
.thenCallback(suggestedGasFeesCallbackMock);

await server
.forGet(`${GAS_API_BASE_URL}/networks/${chainId}/suggestedGasFees`)
.thenCallback(suggestedGasFeesCallbackMock);
.thenCallback(() => {
return {
statusCode: 200,
json: {
SafeGasPrice: '1',
ProposeGasPrice: '2',
FastGasPrice: '3',
},
};
});

await server
.forGet(`${SWAPS_API_V2_BASE_URL}/networks/1/token`)
Expand All @@ -263,6 +221,41 @@ async function setupMocking(
};
});

await server
.forGet(`${GAS_API_BASE_URL}/networks/${chainId}/suggestedGasFees`)
.thenCallback(() => {
return {
statusCode: 200,
json: {
low: {
suggestedMaxPriorityFeePerGas: '1',
suggestedMaxFeePerGas: '20.44436136',
minWaitTimeEstimate: 15000,
maxWaitTimeEstimate: 30000,
},
medium: {
suggestedMaxPriorityFeePerGas: '1.5',
suggestedMaxFeePerGas: '25.80554517',
minWaitTimeEstimate: 15000,
maxWaitTimeEstimate: 45000,
},
high: {
suggestedMaxPriorityFeePerGas: '2',
suggestedMaxFeePerGas: '27.277766977',
minWaitTimeEstimate: 15000,
maxWaitTimeEstimate: 60000,
},
estimatedBaseFee: '19.444436136',
networkCongestion: 0.14685,
latestPriorityFeeRange: ['0.378818859', '6.555563864'],
historicalPriorityFeeRange: ['0.1', '248.262969261'],
historicalBaseFeeRange: ['14.146999781', '28.825256275'],
priorityFeeTrend: 'down',
baseFeeTrend: 'up',
},
};
});

await server
.forGet(`${SWAPS_API_V2_BASE_URL}/featureFlags`)
.thenCallback(() => {
Expand Down
2 changes: 1 addition & 1 deletion test/jest/constants.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export const METASWAP_BASE_URL = 'https://swap.api.cx.metamask.io';
export const GAS_API_URL = 'https://gas.api.infura.io';
export const GAS_API_URL = 'https://gas.api.cx.metamask.io';
23 changes: 10 additions & 13 deletions ui/pages/onboarding-flow/recovery-phrase/confirm-recovery-phrase.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import { debounce } from 'lodash';
import PropTypes from 'prop-types';
import Box from '../../../components/ui/box';
import Button from '../../../components/ui/button';
import Typography from '../../../components/ui/typography';
import { Text } from '../../../components/component-library';
import {
TEXT_ALIGN,
TypographyVariant,
TextAlign,
TextVariant,
JustifyContent,
FONT_WEIGHT,
FontWeight,
} from '../../../helpers/constants/design-system';
import {
ThreeStepProgressBar,
Expand Down Expand Up @@ -73,24 +73,21 @@ export default function ConfirmRecoveryPhrase({ secretRecoveryPhrase = '' }) {
/>
<Box
justifyContent={JustifyContent.center}
textAlign={TEXT_ALIGN.CENTER}
textAlign={TextAlign.Center}
marginBottom={4}
>
<Typography
variant={TypographyVariant.H2}
fontWeight={FONT_WEIGHT.BOLD}
>
<Text variant={TextVariant.headingLg} fontWeight={FontWeight.Bold}>
{t('seedPhraseConfirm')}
</Typography>
</Text>
</Box>
<Box
justifyContent={JustifyContent.center}
textAlign={TEXT_ALIGN.CENTER}
textAlign={TextAlign.Center}
marginBottom={4}
>
<Typography variant={TypographyVariant.H4}>
<Text variant={TextVariant.headingSm} fontWeight={FontWeight.Normal}>
{t('seedPhraseEnterMissingWords')}
</Typography>
</Text>
</Box>
<RecoveryPhraseChips
secretRecoveryPhrase={splitSecretRecoveryPhrase}
Expand Down
Loading

0 comments on commit 9856738

Please sign in to comment.