Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
0db630c
update network controller to v17, update the patch, update gas fee co…
tommasini Apr 24, 2024
9fdf78f
allow gas fee controller to use network did change, update network co…
tommasini Apr 24, 2024
9ef6d3e
update resolutions, and controller utils dependency to v^8.0.4, re-ap…
tommasini Apr 24, 2024
7c84539
merge main and solve conflicts
tommasini Apr 29, 2024
e9251af
update yarn lock
tommasini Apr 29, 2024
505a40a
Update assets controllers to v^26, create patch
tommasini Apr 30, 2024
7000f46
merge main, assets controllers controllers that now based from v2 are…
tommasini May 7, 2024
d2cc100
clean empty lines engine file
tommasini May 7, 2024
c886680
merge main and solve conflicts
tommasini May 7, 2024
c1ec53e
remove unnecessary ts expect error
tommasini May 7, 2024
d13f85b
change TokenBalancesController to subscribe tokensController on the E…
tommasini May 7, 2024
6ef5ac5
update NftController with displayNftMedia variable
tommasini May 7, 2024
40cd484
change getERC20BalanceOf to be called always from assets contract con…
tommasini May 7, 2024
6d8ecd2
fix lint ts issues with TokenBalancesState and Nft Controller config …
tommasini May 7, 2024
da94f88
fix linea sepolia transactions
tommasini May 8, 2024
35a64b7
merge main and solve conflicts
tommasini May 8, 2024
0e50475
fixes display nft when imported with display nft media privacy toggle…
tommasini May 8, 2024
c47062c
add reservoir changes to fetch nfts
tommasini May 8, 2024
d220274
fix gasLimitHex variable type
tommasini May 8, 2024
ef27d5f
refined trackEvent to be with the properties that it was when detecte…
tommasini May 8, 2024
5a53b39
merge main and solve conflicts
tommasini May 8, 2024
bebc37f
fix dedupe and lint tsc
tommasini May 8, 2024
1780fab
fix dedupe and lint tsc
tommasini May 8, 2024
764fd74
update naming of the branch on the patch of assets controllers and on…
tommasini May 8, 2024
b9a470d
delete unnecessary patch
tommasini May 8, 2024
9307de6
change networkDidChange event on gasFeeController to use AppConstants
tommasini May 8, 2024
0a4e7c5
add TokenBalancesControllerState export from assets controllers index…
tommasini May 8, 2024
2a70a85
added patch to return the hexadecimal on remove0x funciton of metamas…
tommasini May 8, 2024
88e630c
revert patch
tommasini May 8, 2024
1f59d84
change substring for slice on metamask utils remove0x
tommasini May 8, 2024
8d79e6a
revert patch
tommasini May 9, 2024
87bce7c
update contractBalances used from TokenBalancesController to convert …
tommasini May 9, 2024
41609ad
merge main and solve conflicts
tommasini May 9, 2024
1295d83
Merge branch 'main' into update/network-controller-v17-gas-fee-contro…
tommasini May 9, 2024
2e2c065
merge main and solve conflicts
tommasini May 9, 2024
14e186c
update selector to be sent unit on this case of the e2e Sent TST
tommasini May 9, 2024
ff4544a
merge main and solve conflicts
tommasini May 9, 2024
3d38c2a
fix e2e
tommasini May 9, 2024
3b83b10
merge main and solve conflicts
tommasini May 9, 2024
dc0d18b
Merge branch 'main' into update/network-controller-v17-gas-fee-contro…
tommasini May 10, 2024
1f600cc
merge main and solve conflicts. Was introduced a comment on the migra…
tommasini May 10, 2024
de54fb4
merge main and solve conflicts
tommasini May 10, 2024
d3be97a
forgot to push this files 041 migration
tommasini May 10, 2024
1c3f6ca
Merge branch 'main' into update/network-controller-v17-gas-fee-contro…
tommasini May 14, 2024
b1250c2
fix import type outside of the code fence at selectors types
tommasini May 15, 2024
3291839
Merge branch 'main' into update/network-controller-v17-gas-fee-contro…
tommasini May 15, 2024
d3fc16f
merge main and solve conflicts
tommasini May 16, 2024
4282014
change transaction controller patch change, since it is not needed
tommasini May 16, 2024
586e3a3
fix ts removing unneeded ts expect error
tommasini May 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions app/components/UI/CollectibleContracts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
selectProviderType,
} from '../../../selectors/networkController';
import {
selectDisplayNftMedia,
selectIsIpfsGatewayEnabled,
selectSelectedAddress,
selectUseNftDetection,
Expand Down Expand Up @@ -102,6 +103,7 @@ const CollectibleContracts = ({
removeFavoriteCollectible,
useNftDetection,
isIpfsGatewayEnabled,
displayNftMedia,
}) => {
const collectibles = allCollectibles.filter(
(singleCollectible) => singleCollectible.isCurrentlyOwned === true,
Expand Down Expand Up @@ -188,14 +190,22 @@ const CollectibleContracts = ({
);

useEffect(() => {
if (!isIpfsGatewayEnabled && !displayNftMedia) {
return;
}
// TO DO: Move this fix to the controllers layer
const updatableCollectibles = collectibles.filter((single) =>
shouldUpdateCollectibleMetadata(single),
);
if (updatableCollectibles.length !== 0) {
updateAllCollectibleMetadata(updatableCollectibles);
}
}, [collectibles, updateAllCollectibleMetadata]);
}, [
collectibles,
updateAllCollectibleMetadata,
isIpfsGatewayEnabled,
displayNftMedia,
]);

/* const updateCollectibleMetadata = useCallback(
async (collectible) => {
Expand Down Expand Up @@ -424,9 +434,13 @@ CollectibleContracts.propTypes = {
*/
useNftDetection: PropTypes.bool,
/**
* Boolean to show if NFT detection is enabled
* Boolean to show content stored on IPFS
*/
isIpfsGatewayEnabled: PropTypes.bool,
/**
* Boolean to show Nfts media stored on third parties
*/
displayNftMedia: PropTypes.bool,
};

const mapStateToProps = (state) => ({
Expand All @@ -438,6 +452,7 @@ const mapStateToProps = (state) => ({
collectibles: collectiblesSelector(state),
favoriteCollectibles: favoritesCollectiblesSelector(state),
isIpfsGatewayEnabled: selectIsIpfsGatewayEnabled(state),
displayNftMedia: selectDisplayNftMedia(state),
});

const mapDispatchToProps = (dispatch) => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,7 @@ class Amount extends PureComponent {
weiBalance = hexToBN(accounts[selectedAddress].balance);
weiInput = weiValue.add(estimatedTotalGas);
} else {
weiBalance = contractBalances[selectedAsset.address];
weiBalance = hexToBN(contractBalances[selectedAsset.address]);
weiInput = toTokenMinimalUnit(value, selectedAsset.decimals);
}
// TODO: weiBalance is not always guaranteed to be type BN. Need to consolidate type.
Expand Down
12 changes: 9 additions & 3 deletions app/components/Views/confirmations/SendFlow/Confirm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,11 +337,15 @@ class Confirm extends PureComponent {
* Remove token that was added to the account temporarily
* Ref.: https://github.com/MetaMask/metamask-mobile/pull/3989#issuecomment-1367558394
*/
if (selectedAsset.isETH || selectedAsset.tokenId) {
if (
selectedAsset.isETH ||
selectedAsset.tokenId ||
!selectedAsset.address
) {
return;
}

const weiBalance = contractBalances[selectedAsset.address];
const weiBalance = hexToBN(contractBalances[selectedAsset.address]);
if (weiBalance?.isZero()) {
await TokensController.ignoreTokens([selectedAsset.address]);
}
Expand Down Expand Up @@ -730,7 +734,9 @@ class Confirm extends PureComponent {
}
} else {
const [, , amount] = decodeTransferData('transfer', transaction.data);
weiBalance = contractBalances[selectedAsset.address];

weiBalance = hexToBN(contractBalances[selectedAsset.address]);

weiInput = hexToBN(amount);
error =
weiBalance && weiBalance.gte(weiInput)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ class ApproveTransactionReview extends PureComponent {
tokenList,
tokenAllowanceState,
} = this.props;
const { TokenBalancesController } = Engine.context;
const { AssetsContractController } = Engine.context;

let host;

Expand All @@ -362,7 +362,7 @@ class ApproveTransactionReview extends PureComponent {
decodeApproveData(data);
const encodedDecimalAmount = hexToBN(encodedHexAmount).toString();

const erc20TokenBalance = await TokenBalancesController.getERC20BalanceOf(
const erc20TokenBalance = await AssetsContractController.getERC20BalanceOf(
to,
from,
);
Expand Down
4 changes: 2 additions & 2 deletions app/components/hooks/useTokenBalance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ const useTokenBalance = (
useState<boolean>(true);
const [error, setError]: [boolean, Dispatch<SetStateAction<boolean>>] =
useState<boolean>(false);
const { TokenBalancesController }: any = Engine.context;
const { AssetsContractController }: any = Engine.context;

const fetchBalance = async (
tokenAddress: string,
userAddress: string,
): Promise<void> => {
TokenBalancesController.getERC20BalanceOf(tokenAddress, userAddress)
AssetsContractController.getERC20BalanceOf(tokenAddress, userAddress)
.then((balance: BN) => setTokenBalance(balance))
.catch(() => setError(true))
.finally(() => setLoading(false));
Expand Down
1 change: 1 addition & 0 deletions app/core/AppConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ export default {
CANCEL_RATE: 'Transactions (Cancel)',
SPEED_UP_RATE: 'Transactions (Speed Up)',
NETWORK_STATE_CHANGE_EVENT: 'NetworkController:stateChange',
NETWORK_DID_CHANGE_EVENT: 'NetworkController:networkDidChange',
KEYRING_STATE_CHANGE_EVENT: 'KeyringController:stateChange',
TOKEN_LIST_STATE_CHANGE_EVENT: 'TokenListController:stateChange',
ETH_SIGN_ERROR: 'eth_sign requires 32 byte message hash',
Expand Down
Loading