Skip to content

Commit

Permalink
fix missing import for goerli
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveMieskoski committed Dec 24, 2020
1 parent 23255ed commit 9af7c97
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 21 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### Release v2.1.17
- fix missing import related to goerli, and associated error

### Release v2.1.17-beta.1
- fix error not getting thrown on window close, if desired behavior

Expand Down
15 changes: 13 additions & 2 deletions example/app/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
<button @click="onClick">CONNECT</button>
<h3>{{ userAddress }}</h3>
<button @click="ecrecover">ecrecover</button>
<div v-show="userAddress === ''">
<button @click="selectNetwork(1)">Mainnet</button>
<button @click="selectNetwork(3)">Ropsten</button>
<button @click="selectNetwork(5)">Goerli</button>
<button @click="selectNetwork(42)">Kovan</button>
</div>

<ul v-show="userAddress !== ''">
<li>
Expand Down Expand Up @@ -277,13 +283,13 @@ export default {
// Initialize the provider based client
// this.connect = new mewConnect.Provider({windowClosedError: true, rpcUrl: 'ws://127.0.0.1:8545', /*chainId: 1*/});
// 859569f6decc4446a5da1bb680e7e9cf
this.connect = new mewConnect.Provider({windowClosedError: true, rpcUrl: 'wss://mainnet.infura.io/ws/v3/859569f6decc4446a5da1bb680e7e9cf'});
this.connect = new mewConnect.Provider({windowClosedError: true, chainId: 5, infuraId: '7d06294ad2bd432887eada360c5e1986', /*rpcUrl: 'wss://ropsten.infura.io/ws/v3/7d06294ad2bd432887eada360c5e1986'*/});
this.connect.on('popupWindowClosed', () =>{
console.log(`popup window closed EVENT`);
});
// this.connect = new mewConnect.Provider();
// Create the MEWconnect web3 provider
this.ethereum = this.connect.makeWeb3Provider(1);
this.ethereum = this.connect.makeWeb3Provider();
// Create a web3 instance using the MEWconnect web3 provider
this.web3 = new Web3(this.ethereum);
// See the 'onClick' method below for starting the connection sequence
Expand All @@ -304,6 +310,10 @@ export default {
this.altPopup = new PopUpCreator();
},
methods: {
selectNetwork(chainId){
this.connect = new mewConnect.Provider({windowClosedError: true, chainId: chainId, infuraId: '7d06294ad2bd432887eada360c5e1986', /*rpcUrl: 'wss://ropsten.infura.io/ws/v3/7d06294ad2bd432887eada360c5e1986'*/});
},
animate() {
this.connect.showNotice();
},
Expand Down Expand Up @@ -373,6 +383,7 @@ export default {
sendTx() {
this.web3.eth.getBalance(this.userAddress).then(bal => this.balance);
this.web3.eth.getGasPrice().then(gasPrice => {
console.log(gasPrice); // todo remove dev item
this.web3.eth.getTransactionCount(this.userAddress).then(nonce => {
this.web3.eth
.sendTransaction({
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@myetherwallet/mewconnect-web-client",
"homepage": "https://github.com/myetherwallet/MEWconnect-web-client",
"version": "2.1.17-beta.1",
"version": "2.1.17",
"main": "./dist/index.js",
"module": "./src/index.js",
"scripts": {
Expand Down
14 changes: 10 additions & 4 deletions src/connectProvider/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ const debugErrors = debugLogger('MEWconnectError');
let state = {
wallet: null
};

const infuraUrlFormater = (name, infuraId) =>{
return `wss://${name}.infura.io/ws/v3/${infuraId}`
}
const eventHub = new EventEmitter();
let popUpCreator = {};
const recentDataRecord = [];
Expand Down Expand Up @@ -161,14 +165,16 @@ export default class Integration extends EventEmitter {
const result = this.chainIdMapping.find(value => value.chainId === check);
if (result) return result;
} else if (typeof check === 'string') {
let result = this.chainIdMapping.find(value => value.chainId == check);
let result = this.chainIdMapping.find(value => {
return value.chainId.toString() == check.toLowerCase()
});
if (result) return result;
result = this.chainIdMapping.find(
value => value.name === check.toLowerCase()
value => value.name.toLowerCase() == check.toLowerCase()
);
if (result) return result;
result = this.chainIdMapping.find(
value => value.key === check.toLowerCase()
value => value.key.toLowerCase() == check.toLowerCase()
);
if (result) return result;
}
Expand All @@ -186,7 +192,7 @@ export default class Integration extends EventEmitter {
const defaultNetwork = Networks[chain.key][0];
state.network = defaultNetwork;
if (this.infuraId && !this.RPC_URL) {
RPC_URL = `wss://${chain.name}.infura.io/ws/v3/${this.infuraId}`;
RPC_URL = infuraUrlFormater(chain.name, this.infuraId);
}
const hostUrl = url.parse(RPC_URL || defaultNetwork.url);
const options = {
Expand Down
1 change: 0 additions & 1 deletion src/connectProvider/web3Provider/networks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,4 @@ Object.keys(nodes).forEach(key => {
nodeList[nodes[key].type.name].push(nodes[key]);
}
});

export default nodeList;
10 changes: 10 additions & 0 deletions src/connectProvider/web3Provider/networks/nodes/goerli-mew-ws.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { GOERLI } from '../types';
export default {
type: GOERLI,
service: 'myetherwallet.com-ws',
url: 'wss://nodes.mewapi.io/ws/goerli',
port: 443,
auth: false,
username: '',
password: ''
};
3 changes: 2 additions & 1 deletion src/connectProvider/web3Provider/networks/nodes/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import ethmewws from './eth-mew-ws';
import kovmewws from './kov-mew-ws';
import ropmewws from './rop-mew-ws';
import goerlimewws from './goerli-mew-ws'

export { ethmewws, kovmewws, ropmewws };
export { ethmewws, kovmewws, ropmewws, goerlimewws };
14 changes: 2 additions & 12 deletions src/connectProvider/web3Provider/networks/types/GOERLI.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,13 @@
// import tokens from '@/tokens/tokens-goerli.json';
// import contracts from '@/contracts/contract-abi-goerli.json';
// import { GOERLI } from '../tlds';
// import goerli from '@/assets/images/icons/network.svg';

export default {
name: 'GOERLI',
name_long: 'Goerli',
homePage: 'https://github.com/goerli/testnet',
blockExplorerTX: 'https://blockscout.com/eth/goerli/tx/[[txHash]]',
blockExplorerAddr: 'https://blockscout.com/eth/goerli/address/[[address]]',
blockExplorerTX: 'https://goerli.etherscan.io/tx/[[txHash]]',
blockExplorerAddr: 'https://goerli.etherscan.io/address/[[address]]',
chainID: 5,
tokens: [],
contracts: [],
// ens: {
// registry: '0x112234455c3a32fd11230c42e7bccd4a84e02010',
// registrarTLD: 'eth',
// registrarType: 'permanent',
// supportedTld: GOERLI
// },
// icon: goerli,
currencyName: 'GöETH'
};

0 comments on commit 9af7c97

Please sign in to comment.