Skip to content

Commit

Permalink
Merge branch 'main' into fix/hide-origin-transaction-header
Browse files Browse the repository at this point in the history
  • Loading branch information
vinistevam authored Nov 5, 2024
2 parents af05fe0 + b50649b commit 8aa5929
Show file tree
Hide file tree
Showing 15 changed files with 120 additions and 61 deletions.
13 changes: 10 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,24 @@

## Current Main Branch

## 7.33.1 - Oct 29, 2024
## 7.33.2 - Nov 1, 2024
### Fixed
- [#10952](https://github.com/MetaMask/metamask-mobile/pull/10952): refactor(ramp): update ramp copy (#10952)

## 7.33.2 - Oct 29, 2024
### Fixed
- [#12073](https://github.com/MetaMask/metamask-mobile/pull/12073): feat: Simulation re-trigger (#12073)

## 7.33.0 - Oct 17, 2024
## 7.33.0 - Oct 3, 2024
### Added
- [#11507](https://github.com/MetaMask/metamask-mobile/pull/11507): feat: 10550 Re-introduce test for measuring cold app start + JS bundle load time (#11507)
- [#11347](https://github.com/MetaMask/metamask-mobile/pull/11347): "chore: revert ""feat: react native fast crypto for notifications"" (#11347)"
- [#11318](https://github.com/MetaMask/metamask-mobile/pull/11318): feat: app event manager and attribution id parameters (#11318)
- [#11445](https://github.com/MetaMask/metamask-mobile/pull/11445): feat: add the abilty to hide the disconnect all button as well as showing and hiding the accounts row when necessary (#11445)
- [#11386](https://github.com/MetaMask/metamask-mobile/pull/11386): feat(3299): add tracking to network switching and confirmation (#11386)
- [#11379](https://github.com/MetaMask/metamask-mobile/pull/11379): refactor: rename the feature flag since it had a typo (#11379)
- [#11239](https://github.com/MetaMask/metamask-mobile/pull/11239): feat(2739): permission summary view gets the ability to disconnect all (#11239)
- [#11382](https://github.com/MetaMask/metamask-mobile/pull/11382): chore(runway): cherry-pick feat: app event manager and attribution id parameters (#11382)
- [#11497](https://github.com/MetaMask/metamask-mobile/pull/11497): feat: simple key-> value component for text value type (#11497)
- [#11478](https://github.com/MetaMask/metamask-mobile/pull/11478): feat: adding title to confirmation page (#11478)
- [#11477](https://github.com/MetaMask/metamask-mobile/pull/11477): feat: adding footer section to confirmation page (#11477)
Expand All @@ -24,7 +31,7 @@
- [#11399](https://github.com/MetaMask/metamask-mobile/pull/11399): feat: add learn more modal component for staking (#11399)
- [#11261](https://github.com/MetaMask/metamask-mobile/pull/11261): feat: STAKE-822 build your balance component (#11261)
- [#11294](https://github.com/MetaMask/metamask-mobile/pull/11294): feat: added KeyValueRow to component-library/components-temp (#11294)
- [#11185](https://github.com/MetaMask/metamask-mobile/pull/11185): feat: display ""Snaps (Beta)"" decorator tag in accounts list (#11185)
- [#11185](https://github.com/MetaMask/metamask-mobile/pull/11185): "feat: display ""Snaps (Beta)"" decorator tag in accounts list (#11185)"
- [#10829](https://github.com/MetaMask/metamask-mobile/pull/10829): feat: Eth snap keyring (#10829)
- [#11455](https://github.com/MetaMask/metamask-mobile/pull/11455): feat: bootstrap a reset notifications feat (#11455)
- [#11466](https://github.com/MetaMask/metamask-mobile/pull/11466): feat: add support for external links (#11466)
Expand Down
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ android {
applicationId "io.metamask"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionName "7.33.1"
versionCode 1471
versionName "7.33.2"
versionCode 1474
testBuildType System.getProperty('testBuildType', 'debug')
missingDimensionStrategy 'react-native-camera', 'general'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down
7 changes: 6 additions & 1 deletion app/components/UI/Stake/hooks/usePoolStakedClaim/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { PooledStake, PooledStakingContract } from '@metamask/stake-sdk';
import { useStakeContext } from '../useStakeContext';
import trackErrorAsAnalytics from '../../../../../util/metrics/TrackError/trackErrorAsAnalytics';
import { WalletDevice } from '@metamask/transaction-controller';
import {
TransactionType,
WalletDevice,
} from '@metamask/transaction-controller';
import { addTransaction } from '../../../../../util/transaction-controller';
import { ORIGIN_METAMASK } from '@metamask/controller-utils';
import {
Expand Down Expand Up @@ -42,6 +45,7 @@ const attemptMultiCallClaimTransaction = async (
return addTransaction(txParams, {
deviceConfirmedOn: WalletDevice.MM_MOBILE,
origin: ORIGIN_METAMASK,
type: TransactionType.stakingClaim,
});
};

Expand Down Expand Up @@ -84,6 +88,7 @@ const attemptSingleClaimTransaction = async (
return addTransaction(txParams, {
deviceConfirmedOn: WalletDevice.MM_MOBILE,
origin: ORIGIN_METAMASK,
type: TransactionType.stakingClaim,
});
};

Expand Down
2 changes: 2 additions & 0 deletions app/components/UI/Stake/hooks/usePoolStakedDeposit/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ChainId, PooledStakingContract } from '@metamask/stake-sdk';
import {
TransactionParams,
TransactionType,
WalletDevice,
} from '@metamask/transaction-controller';
import { ORIGIN_METAMASK, toHex } from '@metamask/controller-utils';
Expand Down Expand Up @@ -63,6 +64,7 @@ const attemptDepositTransaction =
return await addTransaction(txParams, {
deviceConfirmedOn: WalletDevice.MM_MOBILE,
origin: ORIGIN_METAMASK,
type: TransactionType.stakingDeposit,
});
} catch (e) {
const errorMessage = (e as Error).message;
Expand Down
2 changes: 2 additions & 0 deletions app/components/UI/Stake/hooks/usePoolStakedUnstake/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { PooledStakingContract, ChainId } from '@metamask/stake-sdk';
import { useStakeContext } from '../useStakeContext';
import {
TransactionParams,
TransactionType,
WalletDevice,
} from '@metamask/transaction-controller';
import { addTransaction } from '../../../../../util/transaction-controller';
Expand Down Expand Up @@ -50,6 +51,7 @@ const attemptUnstakeTransaction =
return await addTransaction(txParams, {
deviceConfirmedOn: WalletDevice.MM_MOBILE,
origin: ORIGIN_METAMASK,
type: TransactionType.stakingUnstake,
});
} catch (e) {
const errorMessage = (e as Error).message;
Expand Down
6 changes: 3 additions & 3 deletions app/components/Views/confirmations/Approval/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ class Approval extends PureComponent {
*/
trackEditScreen = async () => {
const { transaction } = this.props;
const actionKey = await getTransactionReviewActionKey(transaction);
const actionKey = await getTransactionReviewActionKey({ transaction });
this.props.metrics.trackEvent(
MetaMetricsEvents.TRANSACTIONS_EDIT_TRANSACTION,
{
Expand Down Expand Up @@ -374,8 +374,8 @@ class Approval extends PureComponent {
request_source: this.originIsMMSDKRemoteConn
? AppConstants.REQUEST_SOURCES.SDK_REMOTE_CONN
: this.originIsWalletConnect
? AppConstants.REQUEST_SOURCES.WC
: AppConstants.REQUEST_SOURCES.IN_APP_BROWSER,
? AppConstants.REQUEST_SOURCES.WC
: AppConstants.REQUEST_SOURCES.IN_APP_BROWSER,
};

try {
Expand Down
2 changes: 1 addition & 1 deletion app/components/Views/confirmations/Send/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ class Send extends PureComponent {
*/
trackEditScreen = async () => {
const { transaction } = this.props;
const actionKey = await getTransactionReviewActionKey(transaction);
const actionKey = await getTransactionReviewActionKey({ transaction });
this.props.metrics.trackEvent(
MetaMetricsEvents.TRANSACTIONS_EDIT_TRANSACTION,
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,10 @@ class TransactionReview extends PureComponent {
* Object containing blockaid validation response for confirmation
*/
securityAlertResponse: PropTypes.object,
/**
* Object containing the current transaction metadata
*/
transactionMetadata: PropTypes.object,
};

state = {
Expand Down Expand Up @@ -316,6 +320,7 @@ class TransactionReview extends PureComponent {
const {
transaction,
transaction: { data, to, value },
transactionMetadata,
tokens,
chainId,
tokenList,
Expand All @@ -327,7 +332,13 @@ class TransactionReview extends PureComponent {
showHexData = showHexData || data;
const approveTransaction =
isApprovalTransaction(data) && (!value || isZeroValue(value));
const actionKey = await getTransactionReviewActionKey(transaction, chainId);

const actionKey = await getTransactionReviewActionKey({
...transactionMetadata,
transaction,
txParams: undefined
}, chainId);

if (approveTransaction) {
let contract = tokenList[safeToChecksumAddress(to)];
if (!contract) {
Expand Down Expand Up @@ -701,6 +712,7 @@ const mapStateToProps = (state) => ({
selectCurrentTransactionMetadata(state)?.simulationData,
useTransactionSimulations: selectUseTransactionSimulations(state),
securityAlertResponse: selectCurrentTransactionSecurityAlertResponse(state),
transactionMetadata: selectCurrentTransactionMetadata(state),
});

TransactionReview.contextType = ThemeContext;
Expand Down
57 changes: 34 additions & 23 deletions app/util/transactions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
ERC721,
ERC1155,
} from '@metamask/controller-utils';
import { isEIP1559Transaction } from '@metamask/transaction-controller';
import { isEIP1559Transaction, TransactionType } from '@metamask/transaction-controller';
import { swapsUtils } from '@metamask/swaps-controller';
import Engine from '../../core/Engine';
import I18n, { strings } from '../../../locales/i18n';
Expand Down Expand Up @@ -124,6 +124,9 @@ const reviewActionKeys = {
[SET_APPROVE_FOR_ALL_ACTION_KEY]: strings(
'transactions.tx_review_set_approval_for_all',
),
[TransactionType.stakingClaim]: strings('transactions.tx_review_staking_claim'),
[TransactionType.stakingDeposit]: strings('transactions.tx_review_staking_deposit'),
[TransactionType.stakingUnstake]: strings('transactions.tx_review_staking_unstake'),
};

/**
Expand All @@ -142,6 +145,9 @@ const actionKeys = {
[SET_APPROVE_FOR_ALL_ACTION_KEY]: strings(
'transactions.set_approval_for_all',
),
[TransactionType.stakingClaim]: strings('transactions.tx_review_staking_claim'),
[TransactionType.stakingDeposit]: strings('transactions.tx_review_staking_deposit'),
[TransactionType.stakingUnstake]: strings('transactions.tx_review_staking_unstake'),
};

/**
Expand Down Expand Up @@ -395,33 +401,38 @@ export async function isCollectibleAddress(address, tokenId) {
* @returns {string} - Corresponding transaction action key
*/
export async function getTransactionActionKey(transaction, chainId) {
// This condition is needed until the transaction reducer be refactored
if (!transaction.txParams) {
transaction.txParams = transaction.transaction;
const { type } = transaction ?? {};
const txParams = transaction.txParams ?? transaction.transaction ?? {};
const { data, to } = txParams;

if ([TransactionType.stakingClaim, TransactionType.stakingDeposit, TransactionType.stakingUnstake].includes(type)) {
return type;
}

if (!to) {
return CONTRACT_METHOD_DEPLOY;
}
const { txParams: { data, to } = {} } = transaction;
if (!to) return CONTRACT_METHOD_DEPLOY;
if (to === getSwapsContractAddress(chainId))

if (to === getSwapsContractAddress(chainId)) {
return SWAPS_TRANSACTION_ACTION_KEY;
let ret;
}

// if data in transaction try to get method data
if (data && data !== '0x') {
const methodData = await getMethodData(data);
const { name } = methodData;
const { name } = await getMethodData(data);
if (name) return name;
}

const toSmartContract =
transaction.toSmartContract !== undefined
? transaction.toSmartContract
: await isSmartContractAddress(to);

if (toSmartContract) {
// There is no data or unknown method data, if is smart contract
ret = SMART_CONTRACT_INTERACTION_ACTION_KEY;
} else {
// If there is no data and no smart contract interaction
ret = SEND_ETHER_ACTION_KEY;
return SMART_CONTRACT_INTERACTION_ACTION_KEY;
}
return ret;

return SEND_ETHER_ACTION_KEY;
}

/**
Expand Down Expand Up @@ -455,11 +466,11 @@ export async function getActionKey(tx, selectedAddress, ticker, chainId) {
? strings('transactions.self_sent_unit', { unit: currencySymbol })
: strings('transactions.self_sent_ether')
: currencySymbol
? strings('transactions.received_unit', { unit: currencySymbol })
: strings('transactions.received_ether')
? strings('transactions.received_unit', { unit: currencySymbol })
: strings('transactions.received_ether')
: currencySymbol
? strings('transactions.sent_unit', { unit: currencySymbol })
: strings('transactions.sent_ether');
? strings('transactions.sent_unit', { unit: currencySymbol })
: strings('transactions.sent_ether');
}
const transactionActionKey = actionKeys[actionKey];

Expand All @@ -478,7 +489,7 @@ export async function getActionKey(tx, selectedAddress, ticker, chainId) {
* @returns {string} - Transaction function type
*/
export async function getTransactionReviewActionKey(transaction, chainId) {
const actionKey = await getTransactionActionKey({ transaction }, chainId);
const actionKey = await getTransactionActionKey(transaction, chainId);
const transactionReviewActionKey = reviewActionKeys[actionKey];
if (transactionReviewActionKey) {
return transactionReviewActionKey;
Expand Down Expand Up @@ -1029,7 +1040,7 @@ export const parseTransactionEIP1559 = (
maxPriorityFeeNative,
nativeCurrency,
Boolean(maxPriorityFeePerGasTimesGasLimitHex) &&
maxPriorityFeePerGasTimesGasLimitHex !== '0x0',
maxPriorityFeePerGasTimesGasLimitHex !== '0x0',
);
const renderableMaxPriorityFeeConversion = formatCurrency(
maxPriorityFeeConversion,
Expand Down Expand Up @@ -1528,7 +1539,7 @@ export const getIsSwapApproveOrSwapTransaction = (
(swapsUtils.isValidContractAddress(chainId, to) ||
(data?.startsWith(APPROVE_FUNCTION_SIGNATURE) &&
decodeApproveData(data).spenderAddress?.toLowerCase() ===
swapsUtils.getSwapsContractAddress(chainId)))
swapsUtils.getSwapsContractAddress(chainId)))
);
};

Expand Down
21 changes: 19 additions & 2 deletions app/util/transactions/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import {
} from '.';
import Engine from '../../core/Engine';
import { strings } from '../../../locales/i18n';
import { TransactionType } from '@metamask/transaction-controller';

jest.mock('@metamask/controller-utils', () => ({
...jest.requireActual('@metamask/controller-utils'),
Expand Down Expand Up @@ -1019,6 +1020,19 @@ describe('Transactions utils :: getTransactionActionKey', () => {
const actionKey = await getTransactionActionKey(transaction, chainId);
expect(actionKey).toBe(TOKEN_METHOD_INCREASE_ALLOWANCE);
});

it.each([
TransactionType.stakingClaim,
TransactionType.stakingDeposit,
TransactionType.stakingUnstake,
])('returns transaction type if type is %s', async (type) => {
const transaction = { type };
const chainId = '1';

const actionKey = await getTransactionActionKey(transaction, chainId);

expect(actionKey).toBe(type);
});
});

describe('Transactions utils :: getFourByteSignature', () => {
Expand Down Expand Up @@ -1086,14 +1100,17 @@ describe('Transactions utils :: getTransactionReviewActionKey', () => {
const chainId = '1';
it('returns `Unknown Method` review action key when transaction action key exists', async () => {
const expectedReviewActionKey = 'Unknown Method';
const result = await getTransactionReviewActionKey(transaction, chainId);
const result = await getTransactionReviewActionKey(
{ transaction },
chainId,
);
expect(result).toEqual(expectedReviewActionKey);
});

it('returns correct review action key', async () => {
const expectedReviewActionKey = 'Increase Allowance';
const result = await getTransactionReviewActionKey(
{ ...transaction, data: INCREASE_ALLOWANCE_SIGNATURE },
{ transaction: { ...transaction, data: INCREASE_ALLOWANCE_SIGNATURE } },
chainId,
);
expect(result).toEqual(expectedReviewActionKey);
Expand Down
10 changes: 5 additions & 5 deletions bitrise.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ stages:
- run_tag_smoke_accounts_ios: {}
- run_tag_smoke_accounts_android: {}
- run_tag_smoke_notifications_ios: {}
- run_tag_smoke_notifications_android: {}
# - run_tag_smoke_notifications_android: {}
# - run_tag_smoke_assets_ios: {}
- run_tag_smoke_assets_android: {}
- run_tag_smoke_confirmations_ios: {}
Expand Down Expand Up @@ -1559,16 +1559,16 @@ app:
PROJECT_LOCATION_IOS: ios
- opts:
is_expand: false
VERSION_NAME: 7.33.1
VERSION_NAME: 7.33.2
- opts:
is_expand: false
VERSION_NUMBER: 1471
VERSION_NUMBER: 1474
- opts:
is_expand: false
FLASK_VERSION_NAME: 7.33.1
FLASK_VERSION_NAME: 7.33.2
- opts:
is_expand: false
FLASK_VERSION_NUMBER: 1471
FLASK_VERSION_NUMBER: 1474
- opts:
is_expand: false
ANDROID_APK_LINK: ''
Expand Down
Loading

0 comments on commit 8aa5929

Please sign in to comment.