diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..6b61833 --- /dev/null +++ b/.circleci/config.yml @@ -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 diff --git a/src/index.js b/src/index.js index 3c74972..e72f551 100644 --- a/src/index.js +++ b/src/index.js @@ -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") diff --git a/src/utils/ethutil.js b/src/utils/ethutil.js index 5ebde03..2cb1026 100644 --- a/src/utils/ethutil.js +++ b/src/utils/ethutil.js @@ -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) }