Skip to content

Commit

Permalink
Merge branch 'main' into STAKE-853--fe-remove-estimated-changes-section
Browse files Browse the repository at this point in the history
  • Loading branch information
amitabh94 authored Oct 31, 2024
2 parents 4c69a03 + 844a2e9 commit 369e861
Show file tree
Hide file tree
Showing 65 changed files with 1,003 additions and 842 deletions.
30 changes: 0 additions & 30 deletions .github/workflows/bump-version-name.yml

This file was deleted.

12 changes: 8 additions & 4 deletions .github/workflows/create-release-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@ on:
semver-version:
description: 'A semantic version. eg: x.x.x'
required: true
version-number:
description: 'A natural version number. eg: 862'
required: true
previous-version-tag:
description: 'Previous release version tag. eg: v7.7.0'
required: true
jobs:
generate-build-version:
uses: MetaMask/metamask-mobile-build-version/.github/workflows/metamask-mobile-build-version.yml@v0.2.0
permissions:
id-token: write

create-release-pr:
runs-on: ubuntu-latest
needs: generate-build-version
permissions:
contents: write
pull-requests: write
Expand All @@ -36,6 +39,7 @@ jobs:
# The workaround is to use a personal access token (BUG_REPORT_TOKEN) instead of
# the default GITHUB_TOKEN for the checkout action.
token: ${{ secrets.BUG_REPORT_TOKEN }}

- name: Set up Node.js
uses: actions/setup-node@v3
with:
Expand All @@ -49,4 +53,4 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
./scripts/create-release-pr.sh ${{ github.event.inputs.previous-version-tag }} ${{ github.event.inputs.semver-version }} ${{ github.event.inputs.version-number }}
./scripts/create-release-pr.sh ${{ github.event.inputs.previous-version-tag }} ${{ github.event.inputs.semver-version }} ${{ needs.generate-build-version.outputs.build-version }}
51 changes: 51 additions & 0 deletions .github/workflows/update-latest-build-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
##############################################################################################
#
# This Workflow is responsible for updating the latest build version of the project.
# You can provide your own base branch, tag, or SHA for git operations and the pull request.
# and it will generate the latest build version & update the neccessary files for you.
#
##############################################################################################
name: Update Latest Build Version


on:
workflow_dispatch:
inputs:
base-branch:
description: 'The base branch, tag, or SHA for git operations and the pull request.'
required: true
jobs:
generate-build-version:
uses: MetaMask/metamask-mobile-build-version/.github/workflows/metamask-mobile-build-version.yml@v0.2.0
permissions:
id-token: write

bump-version:
runs-on: ubuntu-latest
needs: generate-build-version
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ inputs.base-branch }}
token: ${{ secrets.PR_TOKEN }}

- name: Bump script
env:
HEAD_REF: ${{ github.head_ref }}
run: |
./scripts/set-build-version.sh ${{ needs.generate-build-version.outputs.build-version }}
git diff
git config user.name metamaskbot
git config user.email metamaskbot@users.noreply.github.com
git add bitrise.yml
git add package.json
git add ios/MetaMask.xcodeproj/project.pbxproj
git add android/app/build.gradle
git commit -m "Bump version number to ${{ needs.generate-build-version.outputs.build-version }}"
git push origin HEAD:"$HEAD_REF" --force
37 changes: 25 additions & 12 deletions app/components/Base/RemoteImage/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useMemo, useState } from 'react';
import React, { useEffect, useState } from 'react';
import PropTypes from 'prop-types';
import {
Image,
Expand Down Expand Up @@ -67,23 +67,36 @@ const RemoteImage = (props) => {
const chainId = useSelector(selectChainId);
const ticker = useSelector(selectTicker);
const networkName = useSelector(selectNetworkName);
const resolvedIpfsUrl = useMemo(() => {
try {
const url = new URL(props.source.uri);
if (url.protocol !== 'ipfs:') return false;
const ipfsUrl = getFormattedIpfsUrl(ipfsGateway, props.source.uri, false);
return ipfsUrl;
} catch {
return false;
}
}, [props.source.uri, ipfsGateway]);
const [resolvedIpfsUrl, setResolvedIpfsUrl] = useState(false);

const uri = resolvedIpfsUrl || source.uri;
const uri =
resolvedIpfsUrl ||
(source.uri === undefined || source.uri?.startsWith('ipfs')
? ''
: source.uri);

const onError = ({ nativeEvent: { error } }) => setError(error);

const [dimensions, setDimensions] = useState(null);

useEffect(() => {
resolveIpfsUrl();
async function resolveIpfsUrl() {
try {
const url = new URL(props.source.uri);
if (url.protocol !== 'ipfs:') setResolvedIpfsUrl(false);
const ipfsUrl = await getFormattedIpfsUrl(
ipfsGateway,
props.source.uri,
false,
);
setResolvedIpfsUrl(ipfsUrl);
} catch (err) {
setResolvedIpfsUrl(false);
}
}
}, [props.source.uri, ipfsGateway]);

useEffect(() => {
const calculateImageDimensions = (imageWidth, imageHeight) => {
const deviceWidth = Dimensions.get('window').width;
Expand Down
18 changes: 15 additions & 3 deletions app/components/Base/RemoteImage/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React from 'react';
import { shallow } from 'enzyme';
import RemoteImage from './';
import { getFormattedIpfsUrl } from '@metamask/assets-controllers';
import { act, render } from '@testing-library/react-native';

jest.mock('react-redux', () => ({
...jest.requireActual('react-redux'),
Expand All @@ -11,6 +13,12 @@ jest.mock('react-redux', () => ({

jest.mock('../../../components/hooks/useIpfsGateway', () => jest.fn());

jest.mock('@metamask/assets-controllers', () => ({
getFormattedIpfsUrl: jest.fn(),
}));

const mockGetFormattedIpfsUrl = getFormattedIpfsUrl as jest.Mock;

describe('RemoteImage', () => {
it('should render svg correctly', () => {
const wrapper = shallow(
Expand All @@ -34,14 +42,18 @@ describe('RemoteImage', () => {
expect(wrapper).toMatchSnapshot();
});

it('should render ipfs sources', () => {
const wrapper = shallow(
it('should render ipfs sources', async () => {
const testIpfsUri = 'ipfs://QmeE94srcYV9WwJb1p42eM4zncdLUai2N9zmMxxukoEQ23';
mockGetFormattedIpfsUrl.mockResolvedValue(testIpfsUri);
const wrapper = render(
<RemoteImage
source={{
uri: 'ipfs://QmeE94srcYV9WwJb1p42eM4zncdLUai2N9zmMxxukoEQ23',
uri: testIpfsUri,
}}
/>,
);
// eslint-disable-next-line no-empty-function
await act(async () => {});
expect(wrapper).toMatchSnapshot();
});
});
2 changes: 1 addition & 1 deletion app/components/UI/NetworkInfo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { selectUseTokenDetection } from '../../../selectors/preferencesControlle
import Avatar, {
AvatarVariant,
} from '../../../component-library/components/Avatars/Avatar';
import { NetworkEducationModalSelectorsIDs } from '../../../../e2e/selectors/Modals/NetworkEducationModal.selectors';
import { NetworkEducationModalSelectorsIDs } from '../../../../e2e/selectors/Network/NetworkEducationModal.selectors';

const createStyles = (colors: {
background: { default: string };
Expand Down
6 changes: 3 additions & 3 deletions app/components/UI/NetworkModal/NetworkAdded/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import StyledButton from '../../StyledButton';
import { strings } from '../../../../../locales/i18n';
import Text from '../../../Base/Text';
import { useTheme } from '../../../../util/theme';
import { NetworkAddedModalSelectorsIDs } from '../../../../../e2e/selectors/Modals/NetworkAddedModal.selectors';
import { NetworkAddedBottomSheetSelectorsIDs } from '../../../../../e2e/selectors/Network/NetworkAddedBottomSheet.selectors';

// TODO: Replace "any" with type
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down Expand Up @@ -57,7 +57,7 @@ const NetworkAdded = (props: NetworkAddedProps) => {
<View style={styles.buttonView}>
<StyledButton
type={'cancel'}
testID={NetworkAddedModalSelectorsIDs.CLOSE_NETWORK_BUTTON}
testID={NetworkAddedBottomSheetSelectorsIDs.CLOSE_NETWORK_BUTTON}
onPress={closeModal}
containerStyle={[styles.button, styles.cancel]}
>
Expand All @@ -66,7 +66,7 @@ const NetworkAdded = (props: NetworkAddedProps) => {
<StyledButton
type={'confirm'}
onPress={switchNetwork}
testID={NetworkAddedModalSelectorsIDs.SWITCH_NETWORK_BUTTON}
testID={NetworkAddedBottomSheetSelectorsIDs.SWITCH_NETWORK_BUTTON}
containerStyle={[styles.button, styles.confirm]}
>
{strings('networks.switch_network')}
Expand Down
6 changes: 3 additions & 3 deletions app/components/UI/NetworkModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {

import { useTheme } from '../../../util/theme';
import { networkSwitched } from '../../../actions/onboardNetwork';
import { NetworkApprovalModalSelectorsIDs } from '../../../../e2e/selectors/Modals/NetworkApprovalModal.selectors';
import { NetworkApprovalBottomSheetSelectorsIDs } from '../../../../e2e/selectors/Network/NetworkApprovalBottomSheet.selectors';
import { selectUseSafeChainsListValidation } from '../../../selectors/preferencesController';
import BottomSheetFooter, {
ButtonsAlignment,
Expand Down Expand Up @@ -150,7 +150,7 @@ const NetworkModals = (props: NetworkProps) => {
label: strings('accountApproval.cancel'),
size: ButtonSize.Lg,
onPress: showCheckNetworkModal,
testID: NetworkApprovalModalSelectorsIDs.CANCEL_BUTTON,
testID: NetworkApprovalBottomSheetSelectorsIDs.CANCEL_BUTTON,
};

const confirmButtonProps: ButtonProps = {
Expand All @@ -161,7 +161,7 @@ const NetworkModals = (props: NetworkProps) => {
toggleUseSafeChainsListValidation(true);
showCheckNetworkModal();
},
testID: NetworkApprovalModalSelectorsIDs.CONFIRM_NETWORK_CHECK,
testID: NetworkApprovalBottomSheetSelectorsIDs.CONFIRM_NETWORK_CHECK,
};

const useSafeChainsListValidation = useSelector(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import {
toggleUseSafeChainsListValidation,
isMultichainVersion1Enabled,
} from '../../../util/networks';
import { NetworkApprovalModalSelectorsIDs } from '../../../../e2e/selectors/Modals/NetworkApprovalModal.selectors';
import { NetworkApprovalBottomSheetSelectorsIDs } from '../../../../e2e/selectors/Network/NetworkApprovalBottomSheet.selectors';
import hideKeyFromUrl from '../../../util/hideKeyFromUrl';
import { convertHexToDecimal } from '@metamask/controller-utils';

Expand Down Expand Up @@ -407,7 +407,7 @@ const NetworkVerificationInfo = ({
/>
</View>
) : (
<View testID={NetworkApprovalModalSelectorsIDs.CONTAINER}>
<View testID={NetworkApprovalBottomSheetSelectorsIDs.CONTAINER}>
<BottomSheetHeader>
<Text variant={TextVariant.HeadingMD}>
{isCustomNetwork
Expand Down Expand Up @@ -461,14 +461,14 @@ const NetworkVerificationInfo = ({
label: strings('confirmation_modal.cancel_cta'),
variant: ButtonVariants.Secondary,
size: ButtonSize.Lg,
testID: NetworkApprovalModalSelectorsIDs.CANCEL_BUTTON,
testID: NetworkApprovalBottomSheetSelectorsIDs.CANCEL_BUTTON,
},
{
onPress: onConfirm,
label: strings('confirmation_modal.confirm_cta'),
variant: ButtonVariants.Primary,
size: ButtonSize.Lg,
testID: NetworkApprovalModalSelectorsIDs.APPROVE_BUTTON,
testID: NetworkApprovalBottomSheetSelectorsIDs.APPROVE_BUTTON,
},
]}
buttonsAlignment={ButtonsAlignment.Horizontal}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8717,7 +8717,7 @@ exports[`BuildQuote View renders correctly 1`] = `
onLoadEnd={[Function]}
source={
{
"uri": undefined,
"uri": "",
}
}
style={
Expand Down Expand Up @@ -11839,7 +11839,7 @@ exports[`BuildQuote View renders correctly 2`] = `
onLoadEnd={[Function]}
source={
{
"uri": undefined,
"uri": "",
}
}
style={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ exports[`StakeConfirmationView render matches snapshot 1`] = `
onLoadEnd={[Function]}
source={
{
"uri": undefined,
"uri": "",
}
}
style={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ exports[`UnstakeConfirmationView render matches snapshot 1`] = `
onLoadEnd={[Function]}
source={
{
"uri": undefined,
"uri": "",
}
}
style={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ exports[`StakingBalance render matches snapshot 1`] = `
onLoadEnd={[Function]}
source={
{
"uri": undefined,
"uri": "",
}
}
style={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ exports[`TokenValueStack render matches snapshot 1`] = `
onLoadEnd={[Function]}
source={
{
"uri": undefined,
"uri": "",
}
}
style={
Expand Down
6 changes: 3 additions & 3 deletions app/components/UI/Tokens/__snapshots__/index.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ exports[`Tokens should hide zero balance tokens when setting is on 1`] = `
onLoadEnd={[Function]}
source={
{
"uri": undefined,
"uri": "",
}
}
style={
Expand Down Expand Up @@ -1795,7 +1795,7 @@ exports[`Tokens should render correctly 1`] = `
onLoadEnd={[Function]}
source={
{
"uri": undefined,
"uri": "",
}
}
style={
Expand Down Expand Up @@ -3059,7 +3059,7 @@ exports[`Tokens should show all balance tokens when hideZeroBalanceTokens settin
onLoadEnd={[Function]}
source={
{
"uri": undefined,
"uri": "",
}
}
style={
Expand Down
Loading

0 comments on commit 369e861

Please sign in to comment.