Skip to content

Commit

Permalink
Merge pull request #53 from StillFantastic/bugfix-50-console-warning
Browse files Browse the repository at this point in the history
Update window.ethereum from deprecated method
  • Loading branch information
StillFantastic authored Jan 11, 2021
2 parents 4e72794 + c25d56a commit f3da5f1
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
37 changes: 37 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Javascript Node CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
#
version: 2
jobs:
build:
docker:
# specify the version you desire here
- image: circleci/node:11.0.0

# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/
# - image: circleci/mongo:3.4.4

working_directory: ~/repo

steps:
- checkout

# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-

- run: npm install

- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}

# run tests!
- run: npm run lint
6 changes: 5 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,12 @@ window.addEventListener("load", async() => {

if (window.ethereum) {
window.web3 = new constants.Web3(window.ethereum)
window.ethereum.autoRefreshOnNetworkChange = false
window.ethereum.on("chainChanged", () => {
document.location.reload()
})
try {
await window.ethereum.enable()
await window.ethereum.request({method: "eth_requestAccounts"})
} catch (error) {
console.error(error)
console.error("Refresh the page to approve/reject again")
Expand Down
2 changes: 1 addition & 1 deletion src/utils/ethutil.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,5 +188,5 @@ function logger(req, res, next, end) {
}

export function attachLogger() {
web3.currentProvider.rpcEngine._middleware.unshift(logger)
web3.currentProvider._rpcEngine._middleware.unshift(logger)
}

0 comments on commit f3da5f1

Please sign in to comment.