Skip to content

Commit

Permalink
Merge branch 'develop' into chore/mmassets-344_add-telemetry-currency…
Browse files Browse the repository at this point in the history
…-conversion
  • Loading branch information
gambinish authored Sep 6, 2024
2 parents ff30288 + c7e2b6e commit cebe1a7
Show file tree
Hide file tree
Showing 119 changed files with 1,581 additions and 1,180 deletions.
23 changes: 22 additions & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

* @MetaMask/extension-devs
development/ @MetaMask/extension-devs @kumavis
lavamoat/ @MetaMask/extension-devs @MetaMask/supply-chain @MetaMask/snaps-devs
lavamoat/ @MetaMask/extension-devs @MetaMask/supply-chain

# The offscreen.ts script file that is included in the offscreen document html
# file is responsible, at present, for loading the snaps execution environment
Expand Down Expand Up @@ -93,3 +93,24 @@ app/scripts/controllers/swaps @MetaMask/swaps-engineers
shared/constants/permissions.ts @MetaMask/snaps-devs
ui/helpers/utils/permission.js @MetaMask/snaps-devs
ui/hooks/useTransactionInsights.js @MetaMask/snaps-devs

# Wallet UX
ui/components/multichain @MetaMask/wallet-ux
ui/components/app/whats-new-popup @MetaMask/wallet-ux
ui/css @MetaMask/wallet-ux
ui/pages/home @MetaMask/wallet-ux
ui/pages/onboarding-flow @MetaMask/wallet-ux

# Assets
ui/components/app/add-network @MetaMask/metamask-assets
ui/components/app/auto-detect-nft @MetaMask/metamask-assets
ui/components/app/auto-detect-token @MetaMask/metamask-assets
ui/components/app/import-token @MetaMask/metamask-assets
ui/components/app/nft-default-image @MetaMask/metamask-assets
ui/components/app/nft-details @MetaMask/metamask-assets
ui/components/app/nft-options @MetaMask/metamask-assets
ui/components/app/nfts-detection-notice-import-nfts @MetaMask/metamask-assets
ui/components/app/nfts-items @MetaMask/metamask-assets
ui/components/app/nfts-tab @MetaMask/metamask-assets
ui/components/ui/deprecated-networks @MetaMask/metamask-assets
ui/components/ui/nft-collection-image @MetaMask/metamask-assets
8 changes: 7 additions & 1 deletion .storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,13 @@ const metamaskDecorator = (story, context) => {
<Provider store={store}>
<Router history={history}>
<MetaMetricsProviderStorybook>
<AlertMetricsProvider>
<AlertMetricsProvider
metrics={{
trackAlertActionClicked: () => undefined,
trackAlertRender: () => undefined,
trackInlineAlertClicked: () => undefined,
}}
>
<I18nProvider
currentLocale={currentLocale}
current={current}
Expand Down
6 changes: 6 additions & 0 deletions app/_locales/en/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 10 additions & 4 deletions app/scripts/lib/ppom/ppom-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ export async function validateRequestWithPPOM({

const ppomResponse = isSecurityAlertsAPIEnabled()
? await validateWithAPI(ppomController, chainId, normalizedRequest)
: await validateWithController(ppomController, normalizedRequest);
: await validateWithController(
ppomController,
normalizedRequest,
chainId,
);

return {
...ppomResponse,
Expand Down Expand Up @@ -207,9 +211,11 @@ async function findConfirmationBySecurityAlertId(
async function validateWithController(
ppomController: PPOMController,
request: SecurityAlertsAPIRequest | JsonRpcRequest,
chainId: string,
): Promise<SecurityAlertResponse> {
const response = (await ppomController.usePPOM((ppom: PPOM) =>
ppom.validateJsonRpc(request),
const response = (await ppomController.usePPOM(
(ppom: PPOM) => ppom.validateJsonRpc(request),
chainId,
)) as SecurityAlertResponse;

return {
Expand All @@ -232,6 +238,6 @@ async function validateWithAPI(
};
} catch (error: unknown) {
handlePPOMError(error, `Error validating request with security alerts API`);
return await validateWithController(ppomController, request);
return await validateWithController(ppomController, request, chainId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,35 @@ describe('addEthereumChainHandler', () => {
expect(mocks.setActiveNetwork).toHaveBeenCalledWith(123);
});

it('creates a new networkConfiguration when called without "blockExplorerUrls" property', async () => {
const mocks = makeMocks({
permissionsFeatureFlagIsActive: false,
});
await addEthereumChainHandler(
{
origin: 'example.com',
params: [
{
chainId: CHAIN_IDS.OPTIMISM,
chainName: 'Optimism Mainnet',
rpcUrls: ['https://optimism.llamarpc.com'],
nativeCurrency: {
symbol: 'ETH',
decimals: 18,
},
iconUrls: ['https://optimism.icon.com'],
},
],
},
{},
jest.fn(),
jest.fn(),
mocks,
);
expect(mocks.upsertNetworkConfiguration).toHaveBeenCalledTimes(1);
expect(mocks.setActiveNetwork).toHaveBeenCalledTimes(1);
});

describe('if a networkConfiguration for the given chainId already exists', () => {
it('creates a new network configuration for the given chainid and switches to it if proposed networkConfiguration has a different rpcUrl from all existing networkConfigurations', async () => {
const mocks = makeMocks({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,25 +119,18 @@ export function validateAddEthereumChainParams(params, end) {
};

const firstValidRPCUrl = rpcUrls.find((rpcUrl) => isLocalhostOrHttps(rpcUrl));
const firstValidBlockExplorerUrl =
blockExplorerUrls !== null && Array.isArray(blockExplorerUrls)
? blockExplorerUrls.find((blockExplorerUrl) =>
isLocalhostOrHttps(blockExplorerUrl),
)
: null;
const firstValidBlockExplorerUrl = Array.isArray(blockExplorerUrls)
? blockExplorerUrls.find((blockExplorerUrl) =>
isLocalhostOrHttps(blockExplorerUrl),
)
: null;

if (!firstValidRPCUrl) {
throw ethErrors.rpc.invalidParams({
message: `Expected an array with at least one valid string HTTPS url 'rpcUrls', Received:\n${rpcUrls}`,
});
}

if (blockExplorerUrls !== null && !firstValidBlockExplorerUrl) {
throw ethErrors.rpc.invalidParams({
message: `Expected null or array with at least one valid string HTTPS URL 'blockExplorerUrl'. Received: ${blockExplorerUrls}`,
});
}

if (typeof chainName !== 'string' || !chainName) {
throw ethErrors.rpc.invalidParams({
message: `Expected non-empty string 'chainName'. Received:\n${chainName}`,
Expand Down
5 changes: 4 additions & 1 deletion app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,10 @@ export default class MetamaskController extends EventEmitter {
this.ppomController = new PPOMController({
messenger: this.controllerMessenger.getRestricted({
name: 'PPOMController',
allowedEvents: ['NetworkController:stateChange'],
allowedEvents: [
'NetworkController:stateChange',
'NetworkController:networkDidChange',
],
allowedActions: ['NetworkController:getNetworkClientById'],
}),
storageBackend: new IndexedDBPPOMStorage('PPOMDB', 1),
Expand Down
21 changes: 11 additions & 10 deletions lavamoat/browserify/beta/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -1605,16 +1605,24 @@
},
"@metamask/message-manager": {
"packages": {
"@metamask/base-controller": true,
"@metamask/controller-utils": true,
"@metamask/eth-sig-util": true,
"@metamask/message-manager>@metamask/base-controller": true,
"@metamask/message-manager>jsonschema": true,
"@metamask/utils": true,
"browserify>buffer": true,
"uuid": true,
"webpack>events": true
}
},
"@metamask/message-manager>@metamask/base-controller": {
"globals": {
"setTimeout": true
},
"packages": {
"immer": true
}
},
"@metamask/message-manager>jsonschema": {
"packages": {
"browserify>url": true
Expand Down Expand Up @@ -2090,23 +2098,16 @@
"crypto": true
},
"packages": {
"@metamask/base-controller": true,
"@metamask/eth-query>json-rpc-random-id": true,
"@metamask/ppom-validator>@metamask/base-controller": true,
"@metamask/ppom-validator>@metamask/controller-utils": true,
"@metamask/ppom-validator>crypto-js": true,
"@metamask/ppom-validator>elliptic": true,
"@metamask/rpc-errors": true,
"await-semaphore": true,
"browserify>buffer": true
}
},
"@metamask/ppom-validator>@metamask/base-controller": {
"globals": {
"setTimeout": true
},
"packages": {
"immer": true
}
},
"@metamask/ppom-validator>@metamask/controller-utils": {
"globals": {
"URL": true,
Expand Down
21 changes: 11 additions & 10 deletions lavamoat/browserify/flask/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -1605,16 +1605,24 @@
},
"@metamask/message-manager": {
"packages": {
"@metamask/base-controller": true,
"@metamask/controller-utils": true,
"@metamask/eth-sig-util": true,
"@metamask/message-manager>@metamask/base-controller": true,
"@metamask/message-manager>jsonschema": true,
"@metamask/utils": true,
"browserify>buffer": true,
"uuid": true,
"webpack>events": true
}
},
"@metamask/message-manager>@metamask/base-controller": {
"globals": {
"setTimeout": true
},
"packages": {
"immer": true
}
},
"@metamask/message-manager>jsonschema": {
"packages": {
"browserify>url": true
Expand Down Expand Up @@ -2090,23 +2098,16 @@
"crypto": true
},
"packages": {
"@metamask/base-controller": true,
"@metamask/eth-query>json-rpc-random-id": true,
"@metamask/ppom-validator>@metamask/base-controller": true,
"@metamask/ppom-validator>@metamask/controller-utils": true,
"@metamask/ppom-validator>crypto-js": true,
"@metamask/ppom-validator>elliptic": true,
"@metamask/rpc-errors": true,
"await-semaphore": true,
"browserify>buffer": true
}
},
"@metamask/ppom-validator>@metamask/base-controller": {
"globals": {
"setTimeout": true
},
"packages": {
"immer": true
}
},
"@metamask/ppom-validator>@metamask/controller-utils": {
"globals": {
"URL": true,
Expand Down
21 changes: 11 additions & 10 deletions lavamoat/browserify/main/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -1605,16 +1605,24 @@
},
"@metamask/message-manager": {
"packages": {
"@metamask/base-controller": true,
"@metamask/controller-utils": true,
"@metamask/eth-sig-util": true,
"@metamask/message-manager>@metamask/base-controller": true,
"@metamask/message-manager>jsonschema": true,
"@metamask/utils": true,
"browserify>buffer": true,
"uuid": true,
"webpack>events": true
}
},
"@metamask/message-manager>@metamask/base-controller": {
"globals": {
"setTimeout": true
},
"packages": {
"immer": true
}
},
"@metamask/message-manager>jsonschema": {
"packages": {
"browserify>url": true
Expand Down Expand Up @@ -2090,23 +2098,16 @@
"crypto": true
},
"packages": {
"@metamask/base-controller": true,
"@metamask/eth-query>json-rpc-random-id": true,
"@metamask/ppom-validator>@metamask/base-controller": true,
"@metamask/ppom-validator>@metamask/controller-utils": true,
"@metamask/ppom-validator>crypto-js": true,
"@metamask/ppom-validator>elliptic": true,
"@metamask/rpc-errors": true,
"await-semaphore": true,
"browserify>buffer": true
}
},
"@metamask/ppom-validator>@metamask/base-controller": {
"globals": {
"setTimeout": true
},
"packages": {
"immer": true
}
},
"@metamask/ppom-validator>@metamask/controller-utils": {
"globals": {
"URL": true,
Expand Down
21 changes: 11 additions & 10 deletions lavamoat/browserify/mmi/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -1697,16 +1697,24 @@
},
"@metamask/message-manager": {
"packages": {
"@metamask/base-controller": true,
"@metamask/controller-utils": true,
"@metamask/eth-sig-util": true,
"@metamask/message-manager>@metamask/base-controller": true,
"@metamask/message-manager>jsonschema": true,
"@metamask/utils": true,
"browserify>buffer": true,
"uuid": true,
"webpack>events": true
}
},
"@metamask/message-manager>@metamask/base-controller": {
"globals": {
"setTimeout": true
},
"packages": {
"immer": true
}
},
"@metamask/message-manager>jsonschema": {
"packages": {
"browserify>url": true
Expand Down Expand Up @@ -2182,23 +2190,16 @@
"crypto": true
},
"packages": {
"@metamask/base-controller": true,
"@metamask/eth-query>json-rpc-random-id": true,
"@metamask/ppom-validator>@metamask/base-controller": true,
"@metamask/ppom-validator>@metamask/controller-utils": true,
"@metamask/ppom-validator>crypto-js": true,
"@metamask/ppom-validator>elliptic": true,
"@metamask/rpc-errors": true,
"await-semaphore": true,
"browserify>buffer": true
}
},
"@metamask/ppom-validator>@metamask/base-controller": {
"globals": {
"setTimeout": true
},
"packages": {
"immer": true
}
},
"@metamask/ppom-validator>@metamask/controller-utils": {
"globals": {
"URL": true,
Expand Down
Loading

0 comments on commit cebe1a7

Please sign in to comment.