Skip to content

Commit

Permalink
Release: v2.2.0-beta.7
Browse files Browse the repository at this point in the history
  • Loading branch information
kvhnuke committed Aug 19, 2021
1 parent 4798985 commit 4f34918
Show file tree
Hide file tree
Showing 13 changed files with 5,629 additions and 652 deletions.
3,053 changes: 2,792 additions & 261 deletions dist/cjs/index.js

Large diffs are not rendered by default.

3,053 changes: 2,792 additions & 261 deletions dist/esm/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package-lock.json

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

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.2.0-beta.6",
"version": "2.2.0-beta.7",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"scripts": {
Expand Down
90 changes: 38 additions & 52 deletions src/connectProvider/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Initiator from '../connectClient/MewConnectInitiator';
import Web3 from 'web3';
import MEWProvider from './web3Provider/web3-provider/index';
import MEWconnectWallet from './web3Provider/MEWconnect/index';
import Networks from './web3Provider/networks/index';
import * as Networks from './web3Provider/networks/types';
import url from 'url';
import EventEmitter from 'events';
import EventNames from './web3Provider/web3-provider/events';
Expand Down Expand Up @@ -62,27 +62,19 @@ export default class Integration extends EventEmitter {

formatNewNetworks(newNetwork) {
return {
type: {
name: newNetwork.name,
name_long: newNetwork.name_long || newNetwork.name,
homePage: newNetwork.homePage || '',
blockExplorerTX: newNetwork.blockExplorerTX || '',
blockExplorerAddr: newNetwork.blockExplorerAddr || '',
chainID: newNetwork.chainId
? newNetwork.chainId
: newNetwork.chainID
? newNetwork.chainID
: this.CHAIN_ID,
tokens: newNetwork.tokens || [],
contracts: [],
currencyName: newNetwork.currencyName || newNetwork.name
},
service: newNetwork.serviceName || newNetwork.name,
url: newNetwork.url || this.RPC_URL,
port: 443,
auth: false,
username: '',
password: ''
name: newNetwork.name,
name_long: newNetwork.name_long || newNetwork.name,
homePage: newNetwork.homePage || '',
blockExplorerTX: newNetwork.blockExplorerTX || '',
blockExplorerAddr: newNetwork.blockExplorerAddr || '',
chainID: newNetwork.chainId
? newNetwork.chainId
: newNetwork.chainID
? newNetwork.chainID
: this.CHAIN_ID,
tokens: newNetwork.tokens || [],
contracts: [],
currencyName: newNetwork.currencyName || newNetwork.name
};
}

Expand All @@ -92,29 +84,25 @@ export default class Integration extends EventEmitter {
const additional = newNetworks
.map(this.formatNewNetworks)
.reduce((acc, curr) => {
acc[curr.type.name] = curr;
acc[curr.name] = curr;
}, {});
networks = { ...networks, ...additional };
networks = Object.assign(networks, additional);
this.networks = networks;
} catch (e) {
// eslint-disable-next-line
console.error(e);
}
return Object.keys(networks).reduce(
(acc, curr) => {
if (networks[curr].length === 0) return acc;
acc.push({
name:
networks[curr][0].type.name_long === 'Ethereum'
? 'mainnet'
: networks[curr][0].type.name_long.toLowerCase(),
chainId: networks[curr][0].type.chainID,
key: networks[curr][0].type.name
});
this.knownNetworks.add(networks[curr][0].type.chainID);
return acc;
},
[{ name: 'mainnet', chainId: 1, key: 'ETH' }]
);
return Object.keys(networks).reduce((acc, curr) => {
acc.push({
name:
networks[curr].name_long === 'Ethereum'
? 'mainnet'
: networks[curr].name_long.toLowerCase(),
chainId: networks[curr].chainID,
key: networks[curr].name
});
this.knownNetworks.add(networks[curr].chainID);
return acc;
}, []);
}

showNotifierDemo(details) {
Expand All @@ -123,7 +111,7 @@ export default class Integration extends EventEmitter {
type: messageConstants.sent,
hash:
'0x543284135d7821e0271272df721101420003cb0e43e8c2e2eed1451cdb571fa4',
explorerPath: state.network.type.blockExplorerTX
explorerPath: state.network.blockExplorerTX
});
} else {
this.popUpHandler.showNotice(details);
Expand Down Expand Up @@ -269,17 +257,15 @@ export default class Integration extends EventEmitter {
web3Provider = window.ethereum;
}
} else {
let chain, defaultNetwork;
if (this.knownNetworks.has(CHAIN_ID)) {
chain = this.identifyChain(CHAIN_ID || 1);
defaultNetwork = Networks[chain.key][0];
state.network = defaultNetwork;
const chain = this.identifyChain(CHAIN_ID || 1);
state.network = this.networks[chain.key];
} else {
chain = { name: 'unknown' };
defaultNetwork = this.formatNewNetworks({ name: 'unknown' });
state.network = defaultNetwork;
throw new Error(
'Unknown network, please add your network to the constructor'
);
}
const hostUrl = url.parse(RPC_URL || defaultNetwork.url);
const hostUrl = url.parse(RPC_URL);
const options = {
subscriptionNotFoundNoThrow: this.subscriptionNotFoundNoThrow
};
Expand Down Expand Up @@ -583,7 +569,7 @@ export default class Integration extends EventEmitter {
{
type: messageConstants.sent,
hash: hash,
explorerPath: state.network.type.blockExplorerTX
explorerPath: state.network.blockExplorerTX
},
10000
);
Expand All @@ -601,7 +587,7 @@ export default class Integration extends EventEmitter {
{
type: messageConstants.failed,
hash: this.lastHash,
explorerPath: state.network.type.blockExplorerTX
explorerPath: state.network.blockExplorerTX
},
10000
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ const getTimer = () => {
const url = URL.createObjectURL(
new Blob([workerCode()], { type: 'text/javascript' })
);
const worker = new Worker(url);
worker = new Worker(url);
worker.onmessage = Timer.onmessage;
return Timer;
}
Expand Down
25 changes: 0 additions & 25 deletions src/connectProvider/web3Provider/networks/index.js

This file was deleted.

11 changes: 0 additions & 11 deletions src/connectProvider/web3Provider/networks/nodes/eth-mew-ws.js

This file was deleted.

10 changes: 0 additions & 10 deletions src/connectProvider/web3Provider/networks/nodes/goerli-mew-ws.js

This file was deleted.

6 changes: 0 additions & 6 deletions src/connectProvider/web3Provider/networks/nodes/index.js

This file was deleted.

11 changes: 0 additions & 11 deletions src/connectProvider/web3Provider/networks/nodes/kov-mew-ws.js

This file was deleted.

11 changes: 0 additions & 11 deletions src/connectProvider/web3Provider/networks/nodes/rop-mew-ws.js

This file was deleted.

5 changes: 4 additions & 1 deletion src/connectProvider/web3Provider/networks/types/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@ import ETH from './ETH.js';
import GOERLI from './GOERLI.js';
import KOV from './KOV.js';
import ROP from './ROP';
import MATIC from './MATIC';
import BSC from './BSC';
import ETC from './ETC';

export { ETH, GOERLI, KOV, ROP };
export { ETH, GOERLI, KOV, ROP, MATIC, BSC, ETC };

0 comments on commit 4f34918

Please sign in to comment.