Skip to content

Commit e74f458

Browse files
committed
Merge branch 'main' into fix/bignumber-conversion-error
2 parents 9901a8e + e958436 commit e74f458

6 files changed

Lines changed: 106 additions & 335 deletions

File tree

.iyarc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +0,0 @@
1-
# ReDoS vulnerability, no impact to this application, and fix not backported yet to the versions we use
2-
3-
GHSA-c2qf-rxjj-qqgw

app/components/Nav/App/index.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@ import OptionsSheet from '../../UI/SelectOptionSheet/OptionsSheet';
131131
import FoxLoader from '../../../components/UI/FoxLoader';
132132
import { AppStateEventProcessor } from '../../../core/AppStateEventListener';
133133
import MultiRpcModal from '../../../components/Views/MultiRpcModal/MultiRpcModal';
134+
import Engine from '../../../core/Engine';
135+
import { CHAIN_IDS } from '@metamask/transaction-controller';
136+
import { PopularList } from '../../../util/networks/customNetworks';
137+
import { RpcEndpointType } from '@metamask/network-controller';
134138
import { trace, TraceName, TraceOperation } from '../../../util/trace';
135139

136140
const clearStackNavigatorOptions = {
@@ -762,6 +766,46 @@ const App = (props) => {
762766
useEffect(() => {
763767
async function startApp() {
764768
const existingUser = await StorageWrapper.getItem(EXISTING_USER);
769+
if (!existingUser) {
770+
// List of chainIds to add (as hex strings)
771+
const chainIdsToAdd = [
772+
CHAIN_IDS.ARBITRUM,
773+
CHAIN_IDS.BASE,
774+
CHAIN_IDS.BSC,
775+
CHAIN_IDS.OPTIMISM,
776+
CHAIN_IDS.POLYGON,
777+
];
778+
779+
// Filter the PopularList to get only the specified networks based on chainId
780+
const selectedNetworks = PopularList.filter((network) =>
781+
chainIdsToAdd.includes(network.chainId),
782+
);
783+
const { NetworkController } = Engine.context;
784+
785+
// Loop through each selected network and call NetworkController.addNetwork
786+
for (const network of selectedNetworks) {
787+
try {
788+
await NetworkController.addNetwork({
789+
chainId: network.chainId,
790+
blockExplorerUrls: [network.rpcPrefs.blockExplorerUrl],
791+
defaultRpcEndpointIndex: 0,
792+
defaultBlockExplorerUrlIndex: 0,
793+
name: network.nickname,
794+
nativeCurrency: network.ticker,
795+
rpcEndpoints: [
796+
{
797+
url: network.rpcUrl,
798+
name: network.nickname,
799+
type: RpcEndpointType.Custom,
800+
},
801+
],
802+
});
803+
} catch (error) {
804+
Logger.error(error);
805+
}
806+
}
807+
}
808+
765809
try {
766810
const currentVersion = getVersion();
767811
const savedVersion = await StorageWrapper.getItem(CURRENT_APP_VERSION);

app/core/BackgroundBridge/BackgroundBridge.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { SubjectType } from '@metamask/permission-controller';
2828

2929
const createFilterMiddleware = require('eth-json-rpc-filters');
3030
const createSubscriptionManager = require('eth-json-rpc-filters/subscriptionManager');
31-
const providerAsMiddleware = require('eth-json-rpc-middleware/providerAsMiddleware');
31+
const { providerAsMiddleware } = require('eth-json-rpc-middleware');
3232
const pump = require('pump');
3333
// eslint-disable-next-line import/no-nodejs-modules
3434
const EventEmitter = require('events').EventEmitter;

app/core/Snaps/SnapBridge.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { SubjectType } from '@metamask/permission-controller';
2424
const ObjectMultiplex = require('@metamask/object-multiplex');
2525
const createFilterMiddleware = require('eth-json-rpc-filters');
2626
const createSubscriptionManager = require('eth-json-rpc-filters/subscriptionManager');
27-
const providerAsMiddleware = require('eth-json-rpc-middleware/providerAsMiddleware');
27+
const { providerAsMiddleware } = require('eth-json-rpc-middleware');
2828
const pump = require('pump');
2929

3030
interface ISnapBridgeProps {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@
240240
"eth-block-tracker": "^7.0.1",
241241
"eth-ens-namehash": "2.0.8",
242242
"eth-json-rpc-filters": "^6.0.1",
243-
"eth-json-rpc-middleware": "4.3.0",
243+
"eth-json-rpc-middleware": "9.0.1",
244244
"eth-url-parser": "1.0.4",
245245
"ethereumjs-abi": "0.6.6",
246246
"ethereumjs-util": "6.1.0",

0 commit comments

Comments
 (0)