Skip to content

Commit

Permalink
Merge branch 'feat/off-ramp' of https://github.com/MetaMask/metamask-…
Browse files Browse the repository at this point in the history
…mobile into feat/offramp-region-copy-update
  • Loading branch information
georgeweiler committed Nov 8, 2023
2 parents 535b11f + df7a01f commit 26b1819
Show file tree
Hide file tree
Showing 19 changed files with 197 additions and 118 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ describe('AccordionHeader', () => {
);
expect(titleElement.props().children).toBe(SAMPLE_ACCORDIONHEADER_TITLE);
});
it('should render the proper arrow up icon', () => {
it('should render the proper arrow down icon', () => {
const wrapper = shallow(
<AccordionHeader title={SAMPLE_ACCORDIONHEADER_TITLE} />,
);
const iconElement = wrapper.findWhere(
(node) => node.prop('testID') === TESTID_ACCORDIONHEADER_ARROWICON,
);
expect(iconElement.props().name).toBe(IconName.ArrowUp);
expect(iconElement.props().name).toBe(IconName.ArrowDown);
});
//TODO: Add Test for Pressed state and animation
});
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const AccordionHeader = ({
testID={TESTID_ACCORDIONHEADER_ARROWICON_ANIMATION}
>
<Icon
name={IconName.ArrowUp}
name={IconName.ArrowDown}
size={IconSize.Sm}
color={styles.title.color}
testID={TESTID_ACCORDIONHEADER_ARROWICON}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ exports[`AccordionHeader - Snapshot should render a rotated down Arrow if isExpa
>
<Icon
color="#0376C9"
name="ArrowUp"
name="ArrowDown"
size="16"
testID="accordionheader-arrow-icon"
/>
Expand Down Expand Up @@ -96,7 +96,7 @@ exports[`AccordionHeader - Snapshot should render default settings correctly 1`]
>
<Icon
color="#0376C9"
name="ArrowUp"
name="ArrowDown"
size="16"
testID="accordionheader-arrow-icon"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ import {
SheetBottomRef,
} from './SheetBottom.types';

/**
* @deprecated The `<SheetBottom>` component has been deprecated in favor of the new `<BottomSheet>` component from the component-library.
* Please update your code to use the new `<BottomSheet>` component instead, which can be found at app/component-library/components/BottomSheets/BottomSheet/BottomSheet.tsx.
* You can find documentation for the new BottomSheet component in the README:
* {@link https://github.com/MetaMask/metamask-mobile/tree/main/app/component-library/components/BottomSheets/BottomSheet/README.md}
* If you would like to help with the replacement of the old `SheetBottom` component, please submit a pull request against this GitHub issue:
* {@link https://github.com/MetaMask/metamask-mobile/issues/7658}
*/
const SheetBottom = forwardRef<SheetBottomRef, SheetBottomProps>(
(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ exports[`BlockaidBanner should render correctly 1`] = `
<SvgMock
color="#0376C9"
height={16}
name="ArrowUp"
name="ArrowDown"
style={
Object {
"height": 16,
Expand Down Expand Up @@ -378,7 +378,7 @@ exports[`BlockaidBanner should render correctly with list attack details 1`] = `
<SvgMock
color="#0376C9"
height={16}
name="ArrowUp"
name="ArrowDown"
style={
Object {
"height": 16,
Expand Down Expand Up @@ -618,7 +618,7 @@ exports[`BlockaidBanner should render correctly with reason "raw_signature_farmi
<SvgMock
color="#0376C9"
height={16}
name="ArrowUp"
name="ArrowDown"
style={
Object {
"height": 16,
Expand Down Expand Up @@ -946,7 +946,7 @@ exports[`BlockaidBanner should render something does not look right with contact
<SvgMock
color="#0376C9"
height={16}
name="ArrowUp"
name="ArrowDown"
style={
Object {
"height": 16,
Expand Down
2 changes: 2 additions & 0 deletions app/components/UI/Navbar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import {
import { EDIT_BUTTON } from '../../../../wdio/screen-objects/testIDs/Common.testIds';
import Icon from '../../../component-library/components/Icons/Icon/Icon';
import { SendLinkViewSelectorsIDs } from '../../../../e2e/selectors/SendLinkView.selectors';
import Routes from '../../../../app/constants/navigation/Routes';

const trackEvent = (event) => {
InteractionManager.runAfterInteractions(() => {
Expand Down Expand Up @@ -964,6 +965,7 @@ export function getWalletNavbarOptions(
function openQRScanner() {
navigation.navigate('QRScanner', {
onScanSuccess,
origin: Routes.WALLET_VIEW,
});
trackEvent(MetaMetricsEvents.WALLET_QR_SCANNER);
}
Expand Down
3 changes: 2 additions & 1 deletion app/components/Views/QRScanner/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ const QRScanner = () => {

if (
origin === Routes.SEND_FLOW.SEND_TO ||
origin === Routes.SETTINGS.CONTACT_FORM
origin === Routes.SETTINGS.CONTACT_FORM ||
origin === Routes.WALLET_VIEW
) {
if (!isValidAddressInputViaQRCode(content)) {
showAlertForInvalidAddress();
Expand Down
6 changes: 3 additions & 3 deletions app/core/Engine.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ describe('Engine', () => {
const engine = Engine.init({});
const backgroundState = engine.datamodel.state;
// Replace phishing controller fallback config, as it bloats the test fixture too much
backgroundState.PhishingController.listState.allowlist = [];
backgroundState.PhishingController.listState.blocklist = [];
backgroundState.PhishingController.listState.fuzzylist = [];
backgroundState.PhishingController.phishingLists[0].allowlist = [];
backgroundState.PhishingController.phishingLists[0].blocklist = [];
backgroundState.PhishingController.phishingLists[0].fuzzylist = [];
delete backgroundState.PPOMController.chainStatus['0x1'].lastVisited;

expect(engine.datamodel.state).toStrictEqual(initialState);
Expand Down
15 changes: 7 additions & 8 deletions app/core/Engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ import {
SignatureControllerActions,
SignatureControllerEvents,
} from '@metamask/signature-controller';
import { hasProperty, Json } from '@metamask/controller-utils';
import { hasProperty, Json } from '@metamask/utils';
// TODO: Export this type from the package directly
import { SwapsState } from '@metamask/swaps-controller/dist/SwapsController';
import { ethErrors } from 'eth-rpc-errors';
Expand Down Expand Up @@ -239,7 +239,6 @@ class Engine {
this.controllerMessenger = new ControllerMessenger();

const approvalController = new ApprovalController({
// @ts-expect-error Error might be caused by base controller version mismatch
messenger: this.controllerMessenger.getRestricted({
name: 'ApprovalController',
}),
Expand Down Expand Up @@ -280,7 +279,7 @@ class Engine {
// noop
},
};

// @ts-expect-error Error might be caused by base controller version mismatch
const networkController = new NetworkController(networkControllerOpts);
networkController.initializeProvider();

Expand Down Expand Up @@ -341,6 +340,7 @@ class Engine {
provider: networkController.getProviderAndBlockTracker().provider,
chainId: networkController.state.providerConfig.chainId,
},
// @ts-expect-error Error might be caused by base controller version mismatch
messenger: this.controllerMessenger.getRestricted({
name: 'TokensController',
allowedActions: [`${approvalController.name}:addRequest`],
Expand All @@ -358,12 +358,14 @@ class Engine {
AppConstants.NETWORK_STATE_CHANGE_EVENT,
listener,
),
// @ts-expect-error Error might be caused by base controller version mismatch
messenger: this.controllerMessenger.getRestricted({
name: 'TokenListController',
allowedEvents: ['NetworkController:providerConfigChange'],
}),
});
const currencyRateController = new CurrencyRateController({
// @ts-expect-error Error might be caused by base controller version mismatch
messenger: this.controllerMessenger.getRestricted({
name: 'CurrencyRateController',
}),
Expand All @@ -372,6 +374,7 @@ class Engine {
currencyRateController.start();

const gasFeeController = new GasFeeController({
// @ts-expect-error Error might be caused by base controller version mismatch
messenger: this.controllerMessenger.getRestricted({
name: 'GasFeeController',
}),
Expand Down Expand Up @@ -433,7 +436,6 @@ class Engine {
preferencesController,
),
encryptor,
// @ts-expect-error Error might be caused by base controller version mismatch
messenger: this.controllerMessenger.getRestricted({
name: 'KeyringController',
allowedEvents: [
Expand Down Expand Up @@ -568,6 +570,7 @@ class Engine {
},
updateTransactions: true,
},
// @ts-expect-error Error might be caused by base controller version mismatch
messenger: this.controllerMessenger.getRestricted({
name: 'TransactionController',
allowedActions: [`${approvalController.name}:addRequest`],
Expand Down Expand Up @@ -609,7 +612,6 @@ class Engine {
gasFeeController,
approvalController,
new PermissionController({
// @ts-expect-error Error might be caused by base controller version mismatch
messenger: this.controllerMessenger.getRestricted({
name: 'PermissionController',
allowedActions: [
Expand All @@ -633,7 +635,6 @@ class Engine {
unrestrictedMethods,
}),
new SignatureController({
// @ts-expect-error Error might be caused by base controller version mismatch
messenger: this.controllerMessenger.getRestricted({
name: 'SignatureController',
allowedActions: [`${approvalController.name}:addRequest`],
Expand All @@ -657,7 +658,6 @@ class Engine {
},
}),
new LoggingController({
// @ts-expect-error Error might be caused by base controller version mismatch
messenger: this.controllerMessenger.getRestricted({
name: 'LoggingController',
}),
Expand All @@ -671,7 +671,6 @@ class Engine {
chainId: addHexPrefix(networkController.state.providerConfig.chainId),
blockaidPublicKey: process.env.BLOCKAID_PUBLIC_KEY as string,
cdnBaseUrl: process.env.BLOCKAID_FILE_CDN as string,
// @ts-expect-error Error might be caused by base controller version mismatch
messenger: this.controllerMessenger.getRestricted({
name: 'PPOMController',
}),
Expand Down
2 changes: 1 addition & 1 deletion app/core/SDKConnect/Connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import getRpcMethodMiddleware, {
} from '../RPCMethods/RPCMethodMiddleware';

import { ApprovalController } from '@metamask/approval-controller';
import { Json } from '@metamask/controller-utils';
import { Json } from '@metamask/utils';
import { KeyringController } from '@metamask/keyring-controller';
import { PreferencesController } from '@metamask/preferences-controller';
import {
Expand Down
40 changes: 40 additions & 0 deletions app/store/migrations.js
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,46 @@ export const migrations = {
return state;
}
},
/**
* This migration is to free space of unused data in the user devices
* regarding the phishing list property listState, that is no longer used
* @param {any} state - Redux state
* @returns
*/
26: (state) => {
const phishingControllerState =
state.engine.backgroundState.PhishingController;
if (phishingControllerState?.listState) {
delete state.engine.backgroundState.PhishingController.listState;
} else {
captureException(
new Error(
`Migration 26: Invalid PhishingControllerState controller state: '${JSON.stringify(
state.engine.backgroundState.PhishingController,
)}'`,
),
);
}

if (
phishingControllerState?.hotlistLastFetched &&
phishingControllerState?.stalelistLastFetched
) {
// This will make the list be fetched again when the user updates the app
state.engine.backgroundState.PhishingController.hotlistLastFetched = 0;
state.engine.backgroundState.PhishingController.stalelistLastFetched = 0;
} else {
captureException(
new Error(
`Migration 26: Invalid PhishingControllerState hotlist and stale list fetched: '${JSON.stringify(
state.engine.backgroundState.PhishingController,
)}'`,
),
);
}

return state;
},
// If you are implementing a migration it will break the migration tests,
// please write a unit for your specific migration version
};
Expand Down
Loading

0 comments on commit 26b1819

Please sign in to comment.