Skip to content

Commit

Permalink
merge main and solve yarn lock conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
tommasini committed Apr 12, 2024
2 parents a91e54a + 5440541 commit afe52bd
Show file tree
Hide file tree
Showing 20 changed files with 276 additions and 201 deletions.
2 changes: 1 addition & 1 deletion app/components/UI/AddCustomToken/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ class AddCustomToken extends PureComponent {
if (!(await this.validateCustomToken())) return;
const { TokensController } = Engine.context;
const { address, symbol, decimals, name } = this.state;
await TokensController.addToken(address, symbol, decimals, { name });
await TokensController.addToken({ address, symbol, decimals, name });

this.props.metrics.trackEvent(
MetaMetricsEvents.TOKEN_ADDED,
Expand Down
2 changes: 1 addition & 1 deletion app/components/UI/Ramp/hooks/useHandleSuccessfulOrder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function useHandleSuccessfulOrder() {
toLowerCaseEquals(t.address, address),
)
) {
await TokensController.addToken(address, symbol, decimals, { name });
await TokensController.addToken({ address, symbol, decimals, name });
}
},
[selectedChainId],
Expand Down
5 changes: 4 additions & 1 deletion app/components/UI/SearchTokenAutocomplete/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,10 @@ const SearchTokenAutocomplete = ({ navigation }: Props) => {
const addToken = useCallback(
async ({ address, symbol, decimals, iconUrl, name }) => {
const { TokensController } = Engine.context as any;
await TokensController.addToken(address, symbol, decimals, {
await TokensController.addToken({
address,
symbol,
decimals,
image: iconUrl,
name,
});
Expand Down
2 changes: 1 addition & 1 deletion app/components/UI/Swaps/QuotesView.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ async function addTokenToAssetsController(newToken) {
)
) {
const { address, symbol, decimals, name } = newToken;
await TokensController.addToken(address, symbol, decimals, { name });
await TokensController.addToken({ address, symbol, decimals, name });
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/components/UI/Swaps/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ function SwapsAmountView({
) {
const { TokensController } = Engine.context;
const { address, symbol, decimals, name } = sourceToken;
await TokensController.addToken(address, symbol, decimals, { name });
await TokensController.addToken({ address, symbol, decimals, name });
}
return navigation.navigate(
'SwapsQuotesView',
Expand Down
5 changes: 4 additions & 1 deletion app/components/Views/confirmations/SendFlow/Confirm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,10 @@ class Confirm extends PureComponent {
const { TokensController } = Engine.context;

if (!contractBalances[address]) {
await TokensController.addToken(address, symbol, decimals, {
await TokensController.addToken({
address,
symbol,
decimals,
image,
name,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ const WatchAssetRequest = ({
decimals,
standard,
}}
dontWatchAsset
/>
</View>
<View style={styles.titleWrapper}>
Expand Down
5 changes: 4 additions & 1 deletion app/components/hooks/useAddressBalance/useAddressBalance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ const useAddressBalance = (
}

if (!contractBalances[contractAddress] && !dontWatchAsset) {
TokensController.addToken(contractAddress, symbol, decimals, {
TokensController.addToken({
address: contractAddress,
symbol,
decimals,
image,
name,
});
Expand Down
3 changes: 2 additions & 1 deletion app/core/BackgroundBridge/BackgroundBridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,8 @@ export class BackgroundBridge extends EventEmitter {
Engine.context,
Engine.controllerMessenger,
origin,
SubjectType.Snap,
// We assume that origins connecting through the BackgroundBridge are websites
SubjectType.Website,
),
);
///: END:ONLY_INCLUDE_IF
Expand Down
11 changes: 2 additions & 9 deletions app/core/Engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,6 @@ class Engine {
onNetworkStateChange: (listener) =>
this.controllerMessenger.subscribe(
AppConstants.NETWORK_STATE_CHANGE_EVENT,
//@ts-expect-error AssetsController needs to be updated to v14 for this error disappears
listener,
),
chainId: networkController.state.providerConfig.chainId,
Expand All @@ -436,7 +435,6 @@ class Engine {
onNetworkStateChange: (listener) =>
this.controllerMessenger.subscribe(
AppConstants.NETWORK_STATE_CHANGE_EVENT,
//@ts-expect-error AssetsController needs to be updated to v14 for this error disappears
listener,
),
// @ts-expect-error TODO: Resolve/patch mismatch between base-controller versions. Before: never, never. Now: string, string, which expects 3rd and 4th args to be informed for restrictedControllerMessengers
Expand Down Expand Up @@ -509,15 +507,15 @@ class Engine {
onNetworkStateChange: (listener) =>
this.controllerMessenger.subscribe(
AppConstants.NETWORK_STATE_CHANGE_EVENT,
//@ts-expect-error AssetsController needs to be updated to v14 for this error disappears
listener,
),
onTokenListStateChange: (listener) =>
this.controllerMessenger.subscribe(
AppConstants.TOKEN_LIST_STATE_CHANGE_EVENT,
listener,
),

getNetworkClientById:
networkController.getNetworkClientById.bind(networkController),
chainId: networkController.state.providerConfig.chainId,
config: {
provider: networkController.getProviderAndBlockTracker().provider,
Expand All @@ -543,7 +541,6 @@ class Engine {
onNetworkStateChange: (listener) =>
this.controllerMessenger.subscribe(
AppConstants.NETWORK_STATE_CHANGE_EVENT,
//@ts-expect-error AssetsController needs to be updated to v14 for this error disappears
listener,
),
// @ts-expect-error TODO: Resolve/patch mismatch between base-controller versions. Before: never, never. Now: string, string, which expects 3rd and 4th args to be informed for restrictedControllerMessengers
Expand Down Expand Up @@ -984,7 +981,6 @@ class Engine {
onNetworkStateChange: (listener) =>
this.controllerMessenger.subscribe(
AppConstants.NETWORK_STATE_CHANGE_EVENT,
//@ts-expect-error AssetsController needs to be updated to v14 for this error disappears
listener,
),
onTokenListStateChange: (listener) =>
Expand All @@ -1008,7 +1004,6 @@ class Engine {
},
getTokensState: () => tokensController.state,
getTokenListState: () => tokenListController.state,
//@ts-expect-error AssetsController needs to be updated to v14 for this error disappears
getNetworkState: () => networkController.state,
getPreferencesState: () => preferencesController.state,
getBalancesInSingleCall:
Expand All @@ -1023,7 +1018,6 @@ class Engine {
onNetworkStateChange: (listener) =>
this.controllerMessenger.subscribe(
AppConstants.NETWORK_STATE_CHANGE_EVENT,
//@ts-expect-error AssetsController needs to be updated to v14 for this error disappears
listener,
),
chainId: networkController.state.providerConfig.chainId,
Expand Down Expand Up @@ -1052,7 +1046,6 @@ class Engine {
onNetworkStateChange: (listener) =>
this.controllerMessenger.subscribe(
AppConstants.NETWORK_STATE_CHANGE_EVENT,
//@ts-expect-error AssetsController needs to be updated to v14 for this error disappears
listener,
),
onPreferencesStateChange: (listener) =>
Expand Down
12 changes: 10 additions & 2 deletions app/core/RPCMethods/wallet_watchAsset.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,11 @@ describe('wallet_watchAsset', () => {
checkTabActive: () => null as any,
hostname: '',
});
expect(spyOnWatchAsset).toHaveBeenCalledWith(correctWBTC, ERC20, '0x123');
expect(spyOnWatchAsset).toHaveBeenCalledWith({
asset: correctWBTC,
type: ERC20,
interactingAddress: '0x123',
});
});
it('should call watchAsset with fake WBTC decimals and symbol', async () => {
const fakeWBTC = {
Expand Down Expand Up @@ -184,6 +188,10 @@ describe('wallet_watchAsset', () => {
checkTabActive: () => null as any,
hostname: '',
});
expect(spyOnWatchAsset).toHaveBeenCalledWith(correctWBTC, ERC20, '0x123');
expect(spyOnWatchAsset).toHaveBeenCalledWith({
asset: correctWBTC,
type: ERC20,
interactingAddress: '0x123',
});
});
});
8 changes: 4 additions & 4 deletions app/core/RPCMethods/wallet_watchAsset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,16 @@ const wallet_watchAsset = async ({
const finalTokenSymbol = fetchedSymbol ?? symbol;
const finalTokenDecimals = fetchedDecimals ?? decimals;

await TokensController.watchAsset(
{
await TokensController.watchAsset({
asset: {
address,
symbol: finalTokenSymbol,
decimals: finalTokenDecimals,
image,
},
type,
safeToChecksumAddress(interactingAddress),
);
interactingAddress: safeToChecksumAddress(interactingAddress),
});

res.result = true;
};
Expand Down
16 changes: 14 additions & 2 deletions app/util/ENSUtils.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import Engine from '../core/Engine';
import ENS from 'ethjs-ens';
import { toLowerCaseEquals } from '../util/general';
import { NetworkId, ChainId, NetworkType } from '@metamask/controller-utils';
import {
ChainId,
InfuraNetworkType,
NetworkType,
} from '@metamask/controller-utils';
const ENS_NAME_NOT_DEFINED_ERROR = 'ENS name not defined';
const INVALID_ENS_NAME_ERROR = 'invalid ENS name';
// One hour cache threshold.
Expand All @@ -27,12 +31,20 @@ export class ENSCache {
*/
const ENS_SUPPORTED_CHAIN_IDS = [ChainId[NetworkType.mainnet]];

/**
* We still need it to support the legacy ENS library that we are using.
*/
const ENS_SUPPORTED_NETWORK_IDS = {
[InfuraNetworkType.mainnet]: '1',
};

/**
* A map of chain ID to network ID for networks supported by the current
* legacy ENS library we are using.
*/
const CHAIN_ID_TO_NETWORK_ID = {
[ChainId[NetworkType.mainnet]]: NetworkId[NetworkType.mainnet],
[ChainId[NetworkType.mainnet]]:
ENS_SUPPORTED_NETWORK_IDS[NetworkType.mainnet],
};

/**
Expand Down
2 changes: 1 addition & 1 deletion docs/readme/environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Install [Android Studio](https://developer.android.com/studio)
Set environment variable `JAVA_HOME=/Applications/Android Studio.app/Contents/jbr/Contents/Home` to use java version shipped on the Android Studio App


- Go to Settings > Appearance & Behavior > System Settings > Android SDK
- Go to Settings > Languages & Frameworks > Android SDK
- Shortcut: Selecting `More Actions` > `SDK Manager` from the "Welcome to Android Studio" page will also bring you here.
- Select `SDK Tools` tab
- Check `Show Package Details` option below the tools list to show available versions
Expand Down
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@
"crypto-js": "4.2.0",
"axios": "1.6.0",
"react-native-ble-plx": "3.1.2",
"**/babel-runtime/regenerator-runtime": "^0.13.8"
"**/babel-runtime/regenerator-runtime": "^0.13.8",
"@metamask/transaction-controller/@metamask/controller-utils": "^5.0.0"

},
"dependencies": {
"@consensys/ledgerhq-metamask-keyring": "0.0.9",
Expand All @@ -137,11 +139,11 @@
"@metamask/accounts-controller": "^10.0.0",
"@metamask/address-book-controller": "^3.0.0",
"@metamask/approval-controller": "3.5.0",
"@metamask/assets-controllers": "12.0.0",
"@metamask/assets-controllers": "^14.0.0",
"@metamask/base-controller": "^4.1.1",
"@metamask/composable-controller": "^3.0.0",
"@metamask/contract-metadata": "^2.1.0",
"@metamask/controller-utils": "^4.0.0",
"@metamask/controller-utils": "^5.0.0",
"@metamask/design-tokens": "^2.0.0",
"@metamask/eth-sig-util": "^4.0.1",
"@metamask/etherscan-link": "^2.0.0",
Expand Down

Large diffs are not rendered by default.

Loading

0 comments on commit afe52bd

Please sign in to comment.