Skip to content

Commit

Permalink
Initialize NetworkController.provider with chainId (#2164)
Browse files Browse the repository at this point in the history
  • Loading branch information
rekmarks authored Jan 25, 2021
1 parent d2d8d57 commit e664c4f
Showing 1 changed file with 25 additions and 28 deletions.
53 changes: 25 additions & 28 deletions app/core/Engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,37 +78,34 @@ class Engine {
}),
new PersonalMessageManager(),
new MessageManager(),
new NetworkController(
{
infuraProjectId: process.env.MM_INFURA_PROJECT_ID || EMPTY,
providerConfig: {
static: {
eth_sendTransaction: async (payload, next, end) => {
const { TransactionController } = this.datamodel.context;
try {
const hash = await (await TransactionController.addTransaction(
payload.params[0],
payload.origin
)).result;
end(undefined, hash);
} catch (error) {
end(error);
}
new NetworkController({
infuraProjectId: process.env.MM_INFURA_PROJECT_ID || EMPTY,
providerConfig: {
static: {
eth_sendTransaction: async (payload, next, end) => {
const { TransactionController } = this.datamodel.context;
try {
const hash = await (await TransactionController.addTransaction(
payload.params[0],
payload.origin
)).result;
end(undefined, hash);
} catch (error) {
end(error);
}
},
getAccounts: (end, payload) => {
const { approvedHosts, privacyMode } = store.getState();
const isEnabled = !privacyMode || approvedHosts[payload.hostname];
const { KeyringController } = this.datamodel.context;
const isUnlocked = KeyringController.isUnlocked();
const selectedAddress = this.datamodel.context.PreferencesController.state
.selectedAddress;
end(null, isUnlocked && isEnabled && selectedAddress ? [selectedAddress] : []);
}
},
getAccounts: (end, payload) => {
const { approvedHosts, privacyMode } = store.getState();
const isEnabled = !privacyMode || approvedHosts[payload.hostname];
const { KeyringController } = this.datamodel.context;
const isUnlocked = KeyringController.isUnlocked();
const selectedAddress = this.datamodel.context.PreferencesController.state
.selectedAddress;
end(null, isUnlocked && isEnabled && selectedAddress ? [selectedAddress] : []);
}
},
{ network: '1', provider: { type: MAINNET } }
),
}
}),
new PhishingController(),
new PreferencesController(
{},
Expand Down

0 comments on commit e664c4f

Please sign in to comment.