mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-22 09:23:21 +01:00
[MMI] Adding missing logic to handle custodian approval in token allowance (#20662)
This commit is contained in:
parent
ec0a02fe40
commit
3376ea4e95
@ -641,9 +641,10 @@ export default class MMIController extends EventEmitter {
|
||||
|
||||
async setAccountAndNetwork(origin, address, chainId) {
|
||||
await this.appStateController.getUnlockPromise(true);
|
||||
const addressToLowerCase = address.toLowerCase();
|
||||
const selectedAddress = this.preferencesController.getSelectedAddress();
|
||||
if (selectedAddress.toLowerCase() !== address.toLowerCase()) {
|
||||
this.preferencesController.setSelectedAddress(address);
|
||||
if (selectedAddress.toLowerCase() !== addressToLowerCase) {
|
||||
this.preferencesController.setSelectedAddress(addressToLowerCase);
|
||||
}
|
||||
const selectedChainId = parseInt(
|
||||
this.networkController.state.providerConfig.chainId,
|
||||
@ -667,7 +668,7 @@ export default class MMIController extends EventEmitter {
|
||||
|
||||
getPermissionBackgroundApiMethods(
|
||||
this.permissionController,
|
||||
).addPermittedAccount(origin, address);
|
||||
).addPermittedAccount(origin, addressToLowerCase);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -176,7 +176,14 @@ export default function ConfirmApprove({
|
||||
if (assetStandard === undefined) {
|
||||
return <ConfirmContractInteraction />;
|
||||
}
|
||||
if (assetStandard === TokenStandard.ERC20) {
|
||||
|
||||
let tokenAllowanceImprovements = true;
|
||||
|
||||
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
||||
tokenAllowanceImprovements = false;
|
||||
///: END:ONLY_INCLUDE_IN
|
||||
|
||||
if (tokenAllowanceImprovements && assetStandard === TokenStandard.ERC20) {
|
||||
return (
|
||||
<GasFeeContextProvider transaction={transaction}>
|
||||
<TransactionModalContextProvider>
|
||||
@ -224,6 +231,7 @@ export default function ConfirmApprove({
|
||||
</GasFeeContextProvider>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<GasFeeContextProvider transaction={transaction}>
|
||||
<ConfirmTransactionBase
|
||||
|
@ -52,27 +52,42 @@ export function getCustodianIconForAddress(state, address) {
|
||||
}
|
||||
|
||||
export function getIsCustodianSupportedChain(state) {
|
||||
const selectedIdentity = getSelectedIdentity(state);
|
||||
const accountType = getAccountType(state);
|
||||
const providerConfig = getProviderConfig(state);
|
||||
try {
|
||||
const selectedIdentity = getSelectedIdentity(state);
|
||||
const accountType = getAccountType(state);
|
||||
const providerConfig = getProviderConfig(state);
|
||||
|
||||
const supportedChains =
|
||||
accountType === 'custody'
|
||||
? getCustodyAccountSupportedChains(state, selectedIdentity.address)
|
||||
: null;
|
||||
if (!selectedIdentity || !accountType || !providerConfig) {
|
||||
throw new Error('Invalid state');
|
||||
}
|
||||
|
||||
return supportedChains?.supportedChains
|
||||
? supportedChains.supportedChains.includes(
|
||||
hexToDecimal(providerConfig.chainId),
|
||||
)
|
||||
: true;
|
||||
if (accountType !== 'custody') {
|
||||
return true;
|
||||
}
|
||||
|
||||
const supportedChains = getCustodyAccountSupportedChains(
|
||||
state,
|
||||
selectedIdentity.address,
|
||||
);
|
||||
|
||||
if (!supportedChains || !supportedChains.supportedChains) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return supportedChains.supportedChains.includes(
|
||||
hexToDecimal(providerConfig.chainId),
|
||||
);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
export function getMMIAddressFromModalOrAddress(state) {
|
||||
return (
|
||||
state.appState.modal.modalState.props.address ||
|
||||
state.metamask.selectedAddress
|
||||
);
|
||||
const modalAddress = state?.appState?.modal?.modalState?.props?.address;
|
||||
const selectedAddress = state?.metamask?.selectedAddress;
|
||||
|
||||
return modalAddress || selectedAddress;
|
||||
}
|
||||
|
||||
export function getMMIConfiguration(state) {
|
||||
|
Loading…
Reference in New Issue
Block a user