Skip to content
This repository has been archived by the owner on Sep 27, 2019. It is now read-only.

Commit

Permalink
Merge pull request #131 from trufflesuite/fix/metamask-not-syncing
Browse files Browse the repository at this point in the history
Fix/metamask not syncing
  • Loading branch information
OnlyOneJMJQ authored Oct 22, 2018
2 parents 8cdbe18 + 36e2758 commit 86defd4
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 68 deletions.
92 changes: 64 additions & 28 deletions dist/drizzle.js

Large diffs are not rendered by default.

70 changes: 34 additions & 36 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/drizzleStatus/drizzleStatusSaga.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ function * initializeDrizzle (action) {

const syncAlways = options.syncAlways

if (web3.currentProvider.isMetaMask) {
// Using MetaMask, attempt block polling.
if (web3.currentProvider.isMetaMask && !window.ethereum) {
// Using old MetaMask, attempt block polling.
const interval = options.polls.blocks
yield put({ type: 'BLOCKS_POLLING', drizzle, interval, web3, syncAlways })
} else {
// Not using MetaMask, attempt subscription block listening.
// Not using old MetaMask, attempt subscription block listening.
yield put({ type: 'BLOCKS_LISTENING', drizzle, web3, syncAlways })
}

Expand Down
20 changes: 19 additions & 1 deletion src/web3/web3Saga.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,26 @@ export function * initializeWeb3 ({ options }) {
try {
var web3 = {}

if (window.ethereum) {
const { ethereum } = window
web3 = new Web3(ethereum)
try {
yield call(ethereum.enable)

web3.eth.cacheSendTransaction = txObject =>
put({ type: 'SEND_WEB3_TX', txObject, stackId, web3 })

yield put({ type: 'WEB3_INITIALIZED' })

return web3
} catch (error) {
// User denied account access...
console.log(error)
}
}

// Checking if Web3 has been injected by the browser (Mist/MetaMask)
if (typeof window.web3 !== 'undefined') {
else if (typeof window.web3 !== 'undefined') {
// Use Mist/MetaMask's provider.
web3 = new Web3(window.web3.currentProvider)
web3.eth.cacheSendTransaction = txObject =>
Expand Down

0 comments on commit 86defd4

Please sign in to comment.