1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-25 03:20:23 +01:00

[MMI] Add confirm-transaction-base code fences (#18795)

* Added code fences

* Continue working on this ticket

* Fixed policies

* Added compliance-row component

* Fixed tests and css

* Fixed invalid locale

* Fixing linting

* Add optional check

* Fixing issues

* Fixed storybook

* Added missing dependency

* ran lavamoat auto

* ran dedupe and lavamoat

* lint

* Removed compliance row

* Removed unneeded package

* Removed unneeded proptyes

* updates mmi packages

* updating lavamoat

* formatting main

* Fixed conflicts

* updates lock file

* Moved code fences to have them all in the same place

* Updated yarn.lock and lavamoat

* remove linebreak

* Improved logic in order to not have many code fences and improve readability

* Fixing proptypes issues with eslint

* runs lavamoat auto

* Testing fixes issue e2e tests

* Testing issues

* Reverting code fences container

* Fixing issue with binding

* Added code fences in proptypes

* Reverting code fences

---------

Co-authored-by: Antonio Regadas <antonio.regadas@consensys.net>
Co-authored-by: António Regadas <apregadas@gmail.com>
This commit is contained in:
Albert Olivé 2023-05-29 17:50:56 +02:00 committed by GitHub
parent edf2cc41cb
commit 97a9834182
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 653 additions and 84 deletions

View File

@ -783,6 +783,109 @@
"@babel/runtime": true
}
},
"@metamask-institutional/extension": {
"globals": {
"console.log": true,
"fetch": true
},
"packages": {
"@ethereumjs/tx>@ethereumjs/util": true,
"@metamask-institutional/extension>@metamask-institutional/custody-controller": true,
"@metamask-institutional/extension>@metamask-institutional/sdk": true,
"@metamask-institutional/extension>@metamask-institutional/types": true
}
},
"@metamask-institutional/extension>@metamask-institutional/custody-controller": {
"packages": {
"@ethereumjs/tx>@ethereumjs/util": true,
"@metamask-institutional/extension>@metamask-institutional/custody-keyring": true,
"@metamask/obs-store": true
}
},
"@metamask-institutional/extension>@metamask-institutional/custody-keyring": {
"globals": {
"console.log": true,
"console.warn": true
},
"packages": {
"@ethereumjs/tx>@ethereumjs/util": true,
"@metamask-institutional/extension>@metamask-institutional/custody-keyring>@metamask-institutional/configuration-client": true,
"@metamask-institutional/extension>@metamask-institutional/sdk": true,
"@metamask-institutional/extension>@metamask-institutional/types": true,
"@metamask/obs-store": true,
"browserify>crypto-browserify": true,
"browserify>events": true,
"gulp-sass>lodash.clonedeep": true
}
},
"@metamask-institutional/extension>@metamask-institutional/custody-keyring>@metamask-institutional/configuration-client": {
"globals": {
"console.log": true,
"fetch": true
}
},
"@metamask-institutional/extension>@metamask-institutional/sdk": {
"globals": {
"URLSearchParams": true,
"console.debug": true,
"console.log": true,
"console.warn": true,
"fetch": true
},
"packages": {
"@metamask-institutional/extension>@metamask-institutional/sdk>@metamask-institutional/simplecache": true,
"@metamask-institutional/extension>@metamask-institutional/sdk>bignumber.js": true,
"@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken": true,
"browserify>crypto-browserify": true,
"browserify>events": true
}
},
"@metamask-institutional/extension>@metamask-institutional/sdk>bignumber.js": {
"globals": {
"crypto": true,
"define": true
}
},
"@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken": {
"packages": {
"@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws": true,
"browserify>buffer": true,
"browserify>crypto-browserify": true,
"browserify>process": true,
"lodash": true,
"mocha>ms": true,
"semver": true
}
},
"@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws": {
"packages": {
"@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa": true,
"browserify>buffer": true,
"browserify>process": true,
"browserify>stream-browserify": true,
"browserify>util": true,
"ethereumjs-wallet>safe-buffer": true
}
},
"@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa": {
"packages": {
"@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa>buffer-equal-constant-time": true,
"@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa>ecdsa-sig-formatter": true,
"browserify>crypto-browserify": true,
"browserify>util": true,
"ethereumjs-wallet>safe-buffer": true
}
},
"@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa>buffer-equal-constant-time": {
"packages": {
"browserify>buffer": true
}
},
"@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa>ecdsa-sig-formatter": {
"packages": {
"ethereumjs-wallet>safe-buffer": true
}
},
"@metamask/address-book-controller": {
"packages": {
"@metamask/base-controller": true,

View File

@ -783,6 +783,109 @@
"@babel/runtime": true
}
},
"@metamask-institutional/extension": {
"globals": {
"console.log": true,
"fetch": true
},
"packages": {
"@ethereumjs/tx>@ethereumjs/util": true,
"@metamask-institutional/extension>@metamask-institutional/custody-controller": true,
"@metamask-institutional/extension>@metamask-institutional/sdk": true,
"@metamask-institutional/extension>@metamask-institutional/types": true
}
},
"@metamask-institutional/extension>@metamask-institutional/custody-controller": {
"packages": {
"@ethereumjs/tx>@ethereumjs/util": true,
"@metamask-institutional/extension>@metamask-institutional/custody-keyring": true,
"@metamask/obs-store": true
}
},
"@metamask-institutional/extension>@metamask-institutional/custody-keyring": {
"globals": {
"console.log": true,
"console.warn": true
},
"packages": {
"@ethereumjs/tx>@ethereumjs/util": true,
"@metamask-institutional/extension>@metamask-institutional/custody-keyring>@metamask-institutional/configuration-client": true,
"@metamask-institutional/extension>@metamask-institutional/sdk": true,
"@metamask-institutional/extension>@metamask-institutional/types": true,
"@metamask/obs-store": true,
"browserify>crypto-browserify": true,
"browserify>events": true,
"gulp-sass>lodash.clonedeep": true
}
},
"@metamask-institutional/extension>@metamask-institutional/custody-keyring>@metamask-institutional/configuration-client": {
"globals": {
"console.log": true,
"fetch": true
}
},
"@metamask-institutional/extension>@metamask-institutional/sdk": {
"globals": {
"URLSearchParams": true,
"console.debug": true,
"console.log": true,
"console.warn": true,
"fetch": true
},
"packages": {
"@metamask-institutional/extension>@metamask-institutional/sdk>@metamask-institutional/simplecache": true,
"@metamask-institutional/extension>@metamask-institutional/sdk>bignumber.js": true,
"@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken": true,
"browserify>crypto-browserify": true,
"browserify>events": true
}
},
"@metamask-institutional/extension>@metamask-institutional/sdk>bignumber.js": {
"globals": {
"crypto": true,
"define": true
}
},
"@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken": {
"packages": {
"@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws": true,
"browserify>buffer": true,
"browserify>crypto-browserify": true,
"browserify>process": true,
"lodash": true,
"mocha>ms": true,
"semver": true
}
},
"@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws": {
"packages": {
"@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa": true,
"browserify>buffer": true,
"browserify>process": true,
"browserify>stream-browserify": true,
"browserify>util": true,
"ethereumjs-wallet>safe-buffer": true
}
},
"@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa": {
"packages": {
"@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa>buffer-equal-constant-time": true,
"@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa>ecdsa-sig-formatter": true,
"browserify>crypto-browserify": true,
"browserify>util": true,
"ethereumjs-wallet>safe-buffer": true
}
},
"@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa>buffer-equal-constant-time": {
"packages": {
"browserify>buffer": true
}
},
"@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa>ecdsa-sig-formatter": {
"packages": {
"ethereumjs-wallet>safe-buffer": true
}
},
"@metamask/address-book-controller": {
"packages": {
"@metamask/base-controller": true,

View File

@ -783,6 +783,109 @@
"@babel/runtime": true
}
},
"@metamask-institutional/extension": {
"globals": {
"console.log": true,
"fetch": true
},
"packages": {
"@ethereumjs/tx>@ethereumjs/util": true,
"@metamask-institutional/extension>@metamask-institutional/custody-controller": true,
"@metamask-institutional/extension>@metamask-institutional/sdk": true,
"@metamask-institutional/extension>@metamask-institutional/types": true
}
},
"@metamask-institutional/extension>@metamask-institutional/custody-controller": {
"packages": {
"@ethereumjs/tx>@ethereumjs/util": true,
"@metamask-institutional/extension>@metamask-institutional/custody-keyring": true,
"@metamask/obs-store": true
}
},
"@metamask-institutional/extension>@metamask-institutional/custody-keyring": {
"globals": {
"console.log": true,
"console.warn": true
},
"packages": {
"@ethereumjs/tx>@ethereumjs/util": true,
"@metamask-institutional/extension>@metamask-institutional/custody-keyring>@metamask-institutional/configuration-client": true,
"@metamask-institutional/extension>@metamask-institutional/sdk": true,
"@metamask-institutional/extension>@metamask-institutional/types": true,
"@metamask/obs-store": true,
"browserify>crypto-browserify": true,
"browserify>events": true,
"gulp-sass>lodash.clonedeep": true
}
},
"@metamask-institutional/extension>@metamask-institutional/custody-keyring>@metamask-institutional/configuration-client": {
"globals": {
"console.log": true,
"fetch": true
}
},
"@metamask-institutional/extension>@metamask-institutional/sdk": {
"globals": {
"URLSearchParams": true,
"console.debug": true,
"console.log": true,
"console.warn": true,
"fetch": true
},
"packages": {
"@metamask-institutional/extension>@metamask-institutional/sdk>@metamask-institutional/simplecache": true,
"@metamask-institutional/extension>@metamask-institutional/sdk>bignumber.js": true,
"@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken": true,
"browserify>crypto-browserify": true,
"browserify>events": true
}
},
"@metamask-institutional/extension>@metamask-institutional/sdk>bignumber.js": {
"globals": {
"crypto": true,
"define": true
}
},
"@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken": {
"packages": {
"@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws": true,
"browserify>buffer": true,
"browserify>crypto-browserify": true,
"browserify>process": true,
"lodash": true,
"mocha>ms": true,
"semver": true
}
},
"@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws": {
"packages": {
"@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa": true,
"browserify>buffer": true,
"browserify>process": true,
"browserify>stream-browserify": true,
"browserify>util": true,
"ethereumjs-wallet>safe-buffer": true
}
},
"@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa": {
"packages": {
"@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa>buffer-equal-constant-time": true,
"@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa>ecdsa-sig-formatter": true,
"browserify>crypto-browserify": true,
"browserify>util": true,
"ethereumjs-wallet>safe-buffer": true
}
},
"@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa>buffer-equal-constant-time": {
"packages": {
"browserify>buffer": true
}
},
"@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa>ecdsa-sig-formatter": {
"packages": {
"ethereumjs-wallet>safe-buffer": true
}
},
"@metamask/address-book-controller": {
"packages": {
"@metamask/base-controller": true,

View File

@ -783,6 +783,109 @@
"@babel/runtime": true
}
},
"@metamask-institutional/extension": {
"globals": {
"console.log": true,
"fetch": true
},
"packages": {
"@ethereumjs/tx>@ethereumjs/util": true,
"@metamask-institutional/extension>@metamask-institutional/custody-controller": true,
"@metamask-institutional/extension>@metamask-institutional/sdk": true,
"@metamask-institutional/extension>@metamask-institutional/types": true
}
},
"@metamask-institutional/extension>@metamask-institutional/custody-controller": {
"packages": {
"@ethereumjs/tx>@ethereumjs/util": true,
"@metamask-institutional/extension>@metamask-institutional/custody-keyring": true,
"@metamask/obs-store": true
}
},
"@metamask-institutional/extension>@metamask-institutional/custody-keyring": {
"globals": {
"console.log": true,
"console.warn": true
},
"packages": {
"@ethereumjs/tx>@ethereumjs/util": true,
"@metamask-institutional/extension>@metamask-institutional/custody-keyring>@metamask-institutional/configuration-client": true,
"@metamask-institutional/extension>@metamask-institutional/sdk": true,
"@metamask-institutional/extension>@metamask-institutional/types": true,
"@metamask/obs-store": true,
"browserify>crypto-browserify": true,
"browserify>events": true,
"gulp-sass>lodash.clonedeep": true
}
},
"@metamask-institutional/extension>@metamask-institutional/custody-keyring>@metamask-institutional/configuration-client": {
"globals": {
"console.log": true,
"fetch": true
}
},
"@metamask-institutional/extension>@metamask-institutional/sdk": {
"globals": {
"URLSearchParams": true,
"console.debug": true,
"console.log": true,
"console.warn": true,
"fetch": true
},
"packages": {
"@metamask-institutional/extension>@metamask-institutional/sdk>@metamask-institutional/simplecache": true,
"@metamask-institutional/extension>@metamask-institutional/sdk>bignumber.js": true,
"@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken": true,
"browserify>crypto-browserify": true,
"browserify>events": true
}
},
"@metamask-institutional/extension>@metamask-institutional/sdk>bignumber.js": {
"globals": {
"crypto": true,
"define": true
}
},
"@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken": {
"packages": {
"@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws": true,
"browserify>buffer": true,
"browserify>crypto-browserify": true,
"browserify>process": true,
"lodash": true,
"mocha>ms": true,
"semver": true
}
},
"@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws": {
"packages": {
"@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa": true,
"browserify>buffer": true,
"browserify>process": true,
"browserify>stream-browserify": true,
"browserify>util": true,
"ethereumjs-wallet>safe-buffer": true
}
},
"@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa": {
"packages": {
"@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa>buffer-equal-constant-time": true,
"@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa>ecdsa-sig-formatter": true,
"browserify>crypto-browserify": true,
"browserify>util": true,
"ethereumjs-wallet>safe-buffer": true
}
},
"@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa>buffer-equal-constant-time": {
"packages": {
"browserify>buffer": true
}
},
"@metamask-institutional/extension>@metamask-institutional/sdk>jsonwebtoken>jws>jwa>ecdsa-sig-formatter": {
"packages": {
"ethereumjs-wallet>safe-buffer": true
}
},
"@metamask/address-book-controller": {
"packages": {
"@metamask/base-controller": true,

View File

@ -133,13 +133,15 @@ export default class ConfirmTransactionBase extends Component {
hardwareWalletRequiresConnection: PropTypes.bool,
isMultiLayerFeeNetwork: PropTypes.bool,
isBuyableChain: PropTypes.bool,
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
accountType: PropTypes.string,
isNoteToTraderSupported: PropTypes.bool,
///: END:ONLY_INCLUDE_IN
isApprovalOrRejection: PropTypes.bool,
assetStandard: PropTypes.string,
useCurrencyRateCheck: PropTypes.bool,
isNotification: PropTypes.bool,
accountType: PropTypes.string,
setWaitForConfirmDeepLinkDialog: PropTypes.func,
showTransactionsFailedModal: PropTypes.func,
showCustodianDeepLink: PropTypes.func,
isNoteToTraderSupported: PropTypes.bool,
};
state = {
@ -593,36 +595,81 @@ export default class ConfirmTransactionBase extends Component {
}
handleSubmit() {
let submit = this.handleMainSubmit.bind(this);
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
submit = this.handleMMISubmit.bind(this);
///: END:ONLY_INCLUDE_IN
submit();
}
handleMainSubmit() {
const {
sendTransaction,
txData,
history,
mostRecentOverviewPage,
updateCustomNonce,
maxFeePerGas,
customTokenAmount,
dappProposedTokenAmount,
currentTokenBalance,
maxPriorityFeePerGas,
baseFeePerGas,
methodData,
addToAddressBookIfNew,
toAccounts,
toAddress,
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
accountType,
isNoteToTraderSupported,
///: END:ONLY_INCLUDE_IN
} = this.props;
const {
submitting,
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
noteText,
///: END:ONLY_INCLUDE_IN
} = this.state;
const { name } = methodData;
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
this.updateTxData();
this.setState(
{
submitting: true,
submitError: null,
},
() => {
this._removeBeforeUnload();
sendTransaction(txData)
.then(() => {
if (!this._isMounted) {
return;
}
this.setState(
{
submitting: false,
},
() => {
history.push(mostRecentOverviewPage);
updateCustomNonce('');
},
);
})
.catch((error) => {
if (!this._isMounted) {
return;
}
this.setState({
submitting: false,
submitError: error.message,
});
updateCustomNonce('');
});
},
);
}
handleMMISubmit() {
const {
sendTransaction,
txData,
history,
mostRecentOverviewPage,
updateCustomNonce,
unapprovedTxCount,
accountType,
isNotification,
setWaitForConfirmDeepLinkDialog,
showTransactionsFailedModal,
fromAddress,
isNoteToTraderSupported,
} = this.props;
const { noteText } = this.state;
if (accountType === 'custody') {
txData.custodyStatus = 'created';
@ -632,7 +679,92 @@ export default class ConfirmTransactionBase extends Component {
};
}
}
///: END:ONLY_INCLUDE_IN
this.updateTxData();
this.setState(
{
submitting: true,
submitError: null,
},
() => {
this._removeBeforeUnload();
if (txData.custodyStatus) {
setWaitForConfirmDeepLinkDialog(true);
}
sendTransaction(txData)
.then(() => {
if (!this._isMounted) {
return;
}
if (txData.custodyStatus) {
this.props.showCustodianDeepLink({
fromAddress,
closeNotification: isNotification && unapprovedTxCount === 1,
txId: txData.id,
onDeepLinkFetched: () => {
this.context.trackEvent({
category: 'MMI',
event: 'Show deeplink for transaction',
});
},
onDeepLinkShown: () => {
this.props.clearConfirmTransaction();
this.setState({ submitting: false }, () => {
history.push(mostRecentOverviewPage);
updateCustomNonce('');
});
},
});
} else {
this.setState(
{
submitting: false,
},
() => {
history.push(mostRecentOverviewPage);
updateCustomNonce('');
},
);
}
})
.catch((error) => {
if (!this._isMounted) {
return;
}
showTransactionsFailedModal(error.message, isNotification);
this.setState({
submitting: false,
submitError: error.message,
});
setWaitForConfirmDeepLinkDialog(true);
updateCustomNonce('');
});
},
);
}
updateTxData() {
const {
txData,
maxFeePerGas,
customTokenAmount,
dappProposedTokenAmount,
currentTokenBalance,
maxPriorityFeePerGas,
baseFeePerGas,
addToAddressBookIfNew,
toAccounts,
toAddress,
methodData,
} = this.props;
const { submitting } = this.state;
const { name } = methodData;
if (txData.type === TransactionType.simpleSend) {
addToAddressBookIfNew(toAddress, toAccounts);
@ -678,44 +810,6 @@ export default class ConfirmTransactionBase extends Component {
maxPriorityFeePerGas,
};
}
this.setState(
{
submitting: true,
submitError: null,
},
() => {
this._removeBeforeUnload();
sendTransaction(txData)
.then(() => {
if (!this._isMounted) {
return;
}
this.setState(
{
submitting: false,
},
() => {
history.push(mostRecentOverviewPage);
updateCustomNonce('');
},
);
})
.catch((error) => {
if (!this._isMounted) {
return;
}
this.setState({
submitting: false,
submitError: error.message,
});
updateCustomNonce('');
});
},
);
}
handleSetApprovalForAll() {

View File

@ -1,7 +1,10 @@
import { connect } from 'react-redux';
import { compose } from 'redux';
import { withRouter } from 'react-router-dom';
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
import { showCustodianDeepLink } from '@metamask-institutional/extension';
import { mmiActionsFactory } from '../../store/institutional/institution-background';
///: END:ONLY_INCLUDE_IN
import { clearConfirmTransaction } from '../../ducks/confirm-transaction/confirm-transaction.duck';
import {
@ -48,7 +51,12 @@ import {
getSendToAccounts,
getProviderConfig,
} from '../../ducks/metamask/metamask';
import { addHexPrefix } from '../../../app/scripts/lib/util';
import {
addHexPrefix,
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
getEnvironmentType,
///: END:ONLY_INCLUDE_IN
} from '../../../app/scripts/lib/util';
import {
parseStandardTokenTransactionData,
@ -63,8 +71,11 @@ import {
import { getGasLoadingAnimationIsShowing } from '../../ducks/app/app';
import { isLegacyTransaction } from '../../helpers/utils/transactions.util';
import { CUSTOM_GAS_ESTIMATE } from '../../../shared/constants/gas';
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
import { getAccountType } from '../../selectors/selectors';
import { ENVIRONMENT_TYPE_NOTIFICATION } from '../../../shared/constants/app';
import { getIsNoteToTraderSupported } from '../../selectors/institutional/selectors';
///: END:ONLY_INCLUDE_IN
import {
TransactionStatus,
@ -100,6 +111,11 @@ const mapStateToProps = (state, ownProps) => {
const { id: paramsTransactionId } = params;
const isMainnet = getIsMainnet(state);
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
const envType = getEnvironmentType();
const isNotification = envType === ENVIRONMENT_TYPE_NOTIFICATION;
///: END:ONLY_INCLUDE_IN
const isGasEstimatesLoading = getIsGasEstimatesLoading(state);
const gasLoadingAnimationIsShowing = getGasLoadingAnimationIsShowing(state);
const isBuyableChain = getIsBuyableChain(state);
@ -199,29 +215,20 @@ const mapStateToProps = (state, ownProps) => {
txParamsAreDappSuggested(fullTxData);
const fromAddressIsLedger = isAddressLedger(state, fromAddress);
const nativeCurrency = getNativeCurrency(state);
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
const accountType = getAccountType(state, fromAddress);
const fromChecksumHexAddress = toChecksumHexAddress(fromAddress);
const isNoteToTraderSupported = getIsNoteToTraderSupported(
state,
fromChecksumHexAddress,
);
///: END:ONLY_INCLUDE_IN
const hardwareWalletRequiresConnection =
doesAddressRequireLedgerHidConnection(state, fromAddress);
const isMultiLayerFeeNetwork = getIsMultiLayerFeeNetwork(state);
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
const accountType = getAccountType(state);
const fromChecksumHexAddress = toChecksumHexAddress(fromAddress);
let isNoteToTraderSupported = false;
if (
state.metamask.custodyAccountDetails &&
state.metamask.custodyAccountDetails[fromChecksumHexAddress]
) {
const { custodianName } =
state.metamask.custodyAccountDetails[fromChecksumHexAddress];
isNoteToTraderSupported = state.metamask.mmiConfiguration?.custodians?.find(
(custodian) => custodian.name === custodianName,
)?.isNoteToTraderSupported;
}
///: END:ONLY_INCLUDE_IN
return {
balance,
fromAddress,
@ -275,11 +282,15 @@ const mapStateToProps = (state, ownProps) => {
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
accountType,
isNoteToTraderSupported,
isNotification,
///: END:ONLY_INCLUDE_IN
};
};
export const mapDispatchToProps = (dispatch) => {
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
const mmiActions = mmiActionsFactory();
///: END:ONLY_INCLUDE_IN
return {
tryReverseResolveAddress: (address) => {
return dispatch(tryReverseResolveAddress(address));
@ -316,6 +327,45 @@ export const mapDispatchToProps = (dispatch) => {
dispatch(addToAddressBook(hexPrefixedAddress, nickname));
}
},
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
getCustodianConfirmDeepLink: (id) =>
dispatch(mmiActions.getCustodianConfirmDeepLink(id)),
showCustodyConfirmLink: ({ link, address, closeNotification, custodyId }) =>
dispatch(
mmiActions.showCustodyConfirmLink({
link,
address,
closeNotification,
custodyId,
}),
),
showTransactionsFailedModal: (errorMessage, closeNotification) =>
dispatch(
showModal({
name: 'TRANSACTION_FAILED',
errorMessage,
closeNotification,
}),
),
showCustodianDeepLink: ({
txId,
fromAddress,
closeNotification,
onDeepLinkFetched,
onDeepLinkShown,
}) =>
showCustodianDeepLink({
dispatch,
mmiActions,
txId,
fromAddress,
closeNotification,
onDeepLinkFetched,
onDeepLinkShown,
}),
setWaitForConfirmDeepLinkDialog: (wait) =>
dispatch(mmiActions.setWaitForConfirmDeepLinkDialog(wait)),
///: END:ONLY_INCLUDE_IN
};
};

View File

@ -78,3 +78,16 @@ export function getMMIConfiguration(state) {
export function getInteractiveReplacementToken(state) {
return state.metamask.interactiveReplacementToken || {};
}
export function getIsNoteToTraderSupported(state, fromChecksumHexAddress) {
let isNoteToTraderSupported = false;
if (state.metamask.custodyAccountDetails?.[fromChecksumHexAddress]) {
const { custodianName } =
state.metamask.custodyAccountDetails[fromChecksumHexAddress];
isNoteToTraderSupported = state.metamask.mmiConfiguration?.custodians?.find(
(custodian) => custodian.name === custodianName,
)?.isNoteToTraderSupported;
}
return isNoteToTraderSupported;
}