mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-25 03:20:23 +01:00
2070e5e42a
* 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 * Removed institutional from main lavamoat * Added code fences in confirm transaction base component * Adding tests for handleMainSubmit * Improving code * Added test for handleMainSubmit * Removed waitFor --------- Co-authored-by: Antonio Regadas <antonio.regadas@consensys.net> Co-authored-by: António Regadas <apregadas@gmail.com>
94 lines
2.8 KiB
JavaScript
94 lines
2.8 KiB
JavaScript
import { toChecksumAddress } from 'ethereumjs-util';
|
|
import { getSelectedIdentity, getAccountType } from '../selectors';
|
|
import { getProviderConfig } from '../../ducks/metamask/metamask';
|
|
|
|
export function getWaitForConfirmDeepLinkDialog(state) {
|
|
return state.metamask.waitForConfirmDeepLinkDialog;
|
|
}
|
|
|
|
export function getTransactionStatusMap(state) {
|
|
return state.metamask.custodyStatusMaps;
|
|
}
|
|
|
|
export function getCustodyAccountDetails(state) {
|
|
return state.metamask.custodyAccountDetails;
|
|
}
|
|
|
|
export function getCustodyAccountSupportedChains(state, address) {
|
|
return state.metamask.custodianSupportedChains
|
|
? state.metamask.custodianSupportedChains[toChecksumAddress(address)]
|
|
: [];
|
|
}
|
|
|
|
export function getMmiPortfolioEnabled(state) {
|
|
return state.metamask.mmiConfiguration?.portfolio?.enabled;
|
|
}
|
|
|
|
export function getMmiPortfolioUrl(state) {
|
|
return state.metamask.mmiConfiguration?.portfolio?.url;
|
|
}
|
|
|
|
export function getConfiguredCustodians(state) {
|
|
return state.metamask.mmiConfiguration?.custodians || [];
|
|
}
|
|
|
|
export function getCustodianIconForAddress(state, address) {
|
|
let custodianIcon;
|
|
|
|
const checksummedAddress = toChecksumAddress(address);
|
|
if (state.metamask.custodyAccountDetails?.[checksummedAddress]) {
|
|
const { custodianName } =
|
|
state.metamask.custodyAccountDetails[checksummedAddress];
|
|
custodianIcon = state.metamask.mmiConfiguration?.custodians?.find(
|
|
(custodian) => custodian.name === custodianName,
|
|
)?.iconUrl;
|
|
}
|
|
|
|
return custodianIcon;
|
|
}
|
|
|
|
export function getIsCustodianSupportedChain(state) {
|
|
const selectedIdentity = getSelectedIdentity(state);
|
|
const accountType = getAccountType(state);
|
|
const providerConfig = getProviderConfig(state);
|
|
|
|
const supportedChains =
|
|
accountType === 'custody'
|
|
? getCustodyAccountSupportedChains(state, selectedIdentity.address)
|
|
: null;
|
|
|
|
return supportedChains?.supportedChains
|
|
? supportedChains.supportedChains.includes(
|
|
Number(providerConfig.chainId).toString(),
|
|
)
|
|
: true;
|
|
}
|
|
|
|
export function getMMIAddressFromModalOrAddress(state) {
|
|
return (
|
|
state.appState.modal.modalState.props.address ||
|
|
state.metamask.selectedAddress
|
|
);
|
|
}
|
|
|
|
export function getMMIConfiguration(state) {
|
|
return state.metamask.mmiConfiguration || [];
|
|
}
|
|
|
|
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;
|
|
}
|