Skip to content

Commit

Permalink
use chain id for enabling ENS IPFS resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
brad-decker committed Feb 23, 2021
1 parent e7a0ca1 commit 19ade66
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 3 additions & 1 deletion app/scripts/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,9 @@ function setupController(initState, initLangCode) {
});

setupEnsIpfsResolver({
getCurrentNetwork: controller.getCurrentNetwork,
getCurrentChainId: controller.networkController.getCurrentChainId.bind(
controller.networkController,
),
getIpfsGateway: controller.preferencesController.getIpfsGateway.bind(
controller.preferencesController,
),
Expand Down
4 changes: 2 additions & 2 deletions app/scripts/lib/ens-ipfs/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const supportedTopLevelDomains = ['eth'];

export default function setupEnsIpfsResolver({
provider,
getCurrentNetwork,
getCurrentChainId,
getIpfsGateway,
}) {
// install listener
Expand All @@ -30,7 +30,7 @@ export default function setupEnsIpfsResolver({
const { tabId, url } = details;
// ignore requests that are not associated with tabs
// only attempt ENS resolution on mainnet
if (tabId === -1 || getCurrentNetwork() !== '1') {
if (tabId === -1 || getCurrentChainId() !== '0x1') {
return;
}
// parse ens name
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import { connect } from 'react-redux';
import { CHAIN_ID_TO_NETWORK_ID_MAP } from '../../../../../../shared/constants/network';
import {
getCurrentNetwork,
getSendTo,
getSendToNickname,
getAddressBookEntry,
getCurrentChainId,
} from '../../../../selectors';
import EnsInput from './ens-input.component';

export default connect((state) => {
const selectedAddress = getSendTo(state);
const chainId = getCurrentChainId(state);
return {
network: getCurrentNetwork(state),
network: CHAIN_ID_TO_NETWORK_ID_MAP[chainId],
selectedAddress,
selectedName: getSendToNickname(state),
contact: getAddressBookEntry(state, selectedAddress),
Expand Down

0 comments on commit 19ade66

Please sign in to comment.