Skip to content

Commit

Permalink
Merge pull request #2087 from MyEtherWallet/feature/coolwallet
Browse files Browse the repository at this point in the history
Feature/coolwallet [v5]
  • Loading branch information
gamalielhere authored Mar 20, 2020
2 parents 0d5e0dc + 909a740 commit 2c5981f
Show file tree
Hide file tree
Showing 29 changed files with 873 additions and 1,047 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### Feature

- Cool Wallet integration [#2087](https://github.com/MyEtherWallet/MyEtherWallet/pull/2087)
- WalletConnect & WalletLink Support [#1924](https://github.com/MyEtherWallet/MyEtherWallet/pull/1924)

### Bug
Expand Down
2 changes: 1 addition & 1 deletion fetchLists/lists/tokens.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ module.exports = {
'\\.md': '<rootDir>/tests/unit/__mocks__/mdMockup.js'
},
transformIgnorePatterns: [
'node_modules/(?!(vue-router|bootstrap|register-service-worker|vue-tel-input|@ledgerhq/hw-transport-u2f))'
'node_modules/(?!(vue-router|bootstrap|register-service-worker|vue-tel-input|@ledgerhq/hw-transport-u2f|@coolwallets))'
],
moduleDirectories: ['node_modules'],
snapshotSerializers: ['jest-serializer-vue'],
Expand Down
1,544 changes: 530 additions & 1,014 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
},
"dependencies": {
"@aave/protocol-js": "0.2.4",
"@coolwallets/eth": "0.1.13",
"@coolwallets/transport-web-ble": "0.1.0",
"@coolwallets/wallet": "0.0.14",
"@sentry/browser": "5.15.0",
"@sentry/integrations": "5.15.0",
"@unstoppabledomains/resolution": "1.2.2",
Expand Down
Binary file added src/assets/images/affiliates/coolwallet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions src/assets/images/icons/HardwareWallet/coolwallet.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions src/containers/FooterContainer/affiliates.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ const affiliates = [
currency: '',
logo: ''
},
{
text: 'footer.cool-wallet',
price: '99.00',
description: 'buyHardwareWallet.desc.coolwallet',
href: 'https://www.stateofthedapps.com/',
currency: '$',
logo: 'coolwallet'
},
{
text: 'footer.bcvault',
price: '159.99',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,20 @@ import trezor from '@/assets/images/icons/HardwareWallet/trezor.svg';
import keepkey from '@/assets/images/icons/HardwareWallet/keepkey.svg';
import finney from '@/assets/images/icons/button-finney-hover.png';
import xwallet from '@/assets/images/icons/HardwareWallet/xwallet.svg';
import coolwallet from '@/assets/images/icons/HardwareWallet/coolwallet.svg';
import bcvault from '@/assets/images/icons/HardwareWallet/bcvault.svg';
import WalletOption from '../WalletOption';
import { Toast } from '@/helpers';
import { isSupported } from 'u2f-api';
import platform from 'platform';
import store from 'store';
import cwsTransportLib from '@coolwallets/transport-web-ble';
import {
KeepkeyWallet,
TrezorWallet,
BitBoxWallet,
SecalotWallet,
CoolWallet,
BCVaultWallet
} from '@/wallets';
import {
Expand All @@ -73,6 +77,7 @@ import {
KEEPKEY as KEEPKEY_TYPE,
XWALLET as XWALLET_TYPE,
FINNEY as FINNEY_TYPE,
COOLWALLET as COOLWALLET_TYPE,
BCVAULT as BCVAULT_TYPE
} from '@/wallets/bip44/walletTypes';
export default {
Expand Down Expand Up @@ -175,6 +180,15 @@ export default {
msg: '',
link: 'http://lddy.no/a4im'
},
{
name: COOLWALLET_TYPE,
imgPath: coolwallet,
text: 'CoolWallet',
disabled: false,
msg: '',
link:
'https://coolwallet.io/product/coolwallet/?ref=myetherwalletmyetherwallet'
},
{
name: BCVAULT_TYPE,
imgPath: bcvault,
Expand Down Expand Up @@ -274,6 +288,39 @@ export default {
this.openXwallet();
this.$refs.hardware.hide();
break;
case COOLWALLET_TYPE:
// eslint-disable-next-line
const isRegistered = store.get('appId') || null;
if (isRegistered) {
cwsTransportLib.listen(async (error, device) => {
if (device) {
const transport = await cwsTransportLib.connect(device);
CoolWallet(transport, null)
.then(_newWallet => {
if (_newWallet) {
this.$emit('hardwareWalletOpen', _newWallet);
} else {
Toast.responseHandler(
new Error('No wallet instance!'),
Toast.ERROR
);
}
})
.catch(() => {
Toast.responseHandler(
new Error('Having issues with pairing cool wallet'),
Toast.ERROR
);
});
}
});
} else {
this.$emit('hardwareRequiresPassword', {
walletConstructor: CoolWallet,
hardwareBrand: 'CoolWallet'
});
}
break;
case BCVAULT_TYPE:
// eslint-disable-next-line
const bcvaultInstance = BCVaultWallet();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
</template>

<script>
import cwsTransportLib from '@coolwallets/transport-web-ble';
export default {
props: {
walletConstructor: {
Expand Down Expand Up @@ -78,12 +80,31 @@ export default {
this.password == '';
this.$refs.passwordInput.focus();
},
unlockWallet() {
this.walletConstructor('', this.password)
.then(_newWallet => {
this.$emit('hardwareWalletOpen', _newWallet);
})
.catch(this.walletConstructor.errorHandler);
async unlockWallet() {
if (this.hardwareBrand === 'CoolWallet') {
await cwsTransportLib.listen(async (error, device) => {
if (device) {
const transport = await cwsTransportLib.connect(device);
this.walletConstructor(transport, this.password.toString())
.then(_newWallet => {
if (_newWallet) {
this.$emit('hardwareWalletOpen', _newWallet);
} else {
this.walletConstructor.errorHandler({
name: 'NoWalletInstance'
});
}
})
.catch(this.walletConstructor.errorHandler);
}
});
} else {
this.walletConstructor('', this.password)
.then(_newWallet => {
this.$emit('hardwareWalletOpen', _newWallet);
})
.catch(this.walletConstructor.errorHandler);
}
},
switchViewPassword() {
this.show = !this.show;
Expand Down
2 changes: 2 additions & 0 deletions src/translations/en_US.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import popover from './popover/en_US';
import withoutWallet from './without-wallet/en_US';
import errorsGlobal from './errors-global/en_US';
import trezorError from './errors-trezor/en_US';
import coolWalletError from './errors-coolwallet/en_US';
import bcvaultError from './errors-bcvault/en_US';
import ledgerError from './errors-ledger/en_US';
import secalotError from './errors-secalot/en_US';
Expand Down Expand Up @@ -58,6 +59,7 @@ const en_US = {
withoutWallet: withoutWallet,
errorsGlobal: errorsGlobal,
trezorError: trezorError,
coolWalletError: coolWalletError,
ledgerError: ledgerError,
bcvaultError: bcvaultError,
secalotError: secalotError,
Expand Down
6 changes: 6 additions & 0 deletions src/translations/errors-coolwallet/en_US.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"wrong-password": "Wrong password for app registration.",
"card-locked": "Card locked! Please unlock through the app",
"already-registered": "App is already registered! If you're having trouble, please reregister the app by removing it from the wallet app.",
"no-wallet-instance": "No wallet instance!"
}
1 change: 1 addition & 0 deletions src/translations/errors-global/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
"no-mobile-support": "Hardware wallet not supported by mobile browser!",
"something-went-wrong": "Something went wrong!",
"signer-address-different": "Signer address is different from the derived address!",
"invalid-network-id-sig": "Invalid networkId signature returned. Expected: {expected}, Got: {got}",
"high-gas-limit-warning": "Warning: High gas prices mean higher transaction fees."
}
1 change: 1 addition & 0 deletions src/translations/footer/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"sotd": "State of the Dapps",
"mew-connect": "MEWconnect",
"mew-wallet": "MEW wallet",
"cool-wallet": "CoolWallet",
"donation": {
"desc": "MyEtherWallet is open-source and free to the community. Your donations go a long way towards making that possible.",
"ether": "Ethereum Donation",
Expand Down
1 change: 1 addition & 0 deletions src/translations/other/buy-hardware-wallet/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"trezor": "The most trusted hardware wallet in the world. Get yours today!",
"secalot": "Your all-in-one digital security companion. it is a small USB dongle that packs a wide range of features.",
"keepkey": "Protect your cryptocurrencies, store your private keys offline, and safeguard your assets from hackers.",
"coolwallet": "Security the size of a credit card. Connect via Bluetooth to an iOS or Android app on your smartphone.",
"bcvault": "BC Vault gives you full control of your private keys. Backup, Encrypt, Export, Delete. Your choice."
},
"caption-starting-from": "Starting From",
Expand Down
2 changes: 2 additions & 0 deletions src/wallets/bip44/coolWalletPaths.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import { ethereum } from './paths';
export default [ethereum];
7 changes: 5 additions & 2 deletions src/wallets/bip44/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,23 @@ import {
BITBOX,
SECALOT,
KEEPKEY,
MNEMONIC
MNEMONIC,
COOLWALLET
} from './walletTypes';
import ledgerPaths from './ledgerPaths';
import trezorPaths from './trezorPaths';
import bitboxPaths from './bitboxPaths';
import secalotPaths from './secalotPaths';
import keepkeyPaths from './keepkeyPaths';
import mnemonicPaths from './mnemonicPaths';
import coolWalletPaths from './coolWalletPaths';

export default {
[LEDGER]: ledgerPaths,
[TREZOR]: trezorPaths,
[BITBOX]: bitboxPaths,
[SECALOT]: secalotPaths,
[KEEPKEY]: keepkeyPaths,
[MNEMONIC]: mnemonicPaths
[MNEMONIC]: mnemonicPaths,
[COOLWALLET]: coolWalletPaths
};
2 changes: 2 additions & 0 deletions src/wallets/bip44/walletTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const PRIV_KEY = 'priv_key';
const FINNEY = 'finney';
const WATCH_ONLY = 'watchOnly';
const XWALLET = 'xwallet';
const COOLWALLET = 'cool_wallet';
const BCVAULT = 'bc_vault';
export {
LEDGER,
Expand All @@ -30,5 +31,6 @@ export {
FINNEY,
WATCH_ONLY,
XWALLET,
COOLWALLET,
BCVAULT
};
9 changes: 5 additions & 4 deletions src/wallets/hardware/bitbox/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
calculateChainIdFromV
} from '../../utils';
import commonGenerator from '@/helpers/commonGenerator';
import Vue from 'vue';

const NEED_PASSWORD = true;

Expand Down Expand Up @@ -54,10 +55,10 @@ class BitBoxWallet {
if (signedChainId !== networkId)
Toast.responseHandler(
new Error(
'Invalid networkId signature returned. Expected: ' +
networkId +
', Got: ' +
signedChainId,
Vue.$i18n.t('errorsGlobal.invalid-network-id-sig', {
got: signedChainId,
expected: networkId
}),
'InvalidNetworkId'
),
false
Expand Down
28 changes: 28 additions & 0 deletions src/wallets/hardware/coolwallet/errorHandler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { Toast } from '@/helpers';
import Vue from 'vue';
const ERRORS = {
WrongPassword: 'coolWalletError.wrong-password',
CardLocked: 'coolWalletError.card-locked',
AlreadyRegistered: 'coolWalletError.already-registered',
NoWalletInstance: 'coolWalletError.no-wallet-instance'
};
const WARNING = {};

export default err => {
const errorValues = Object.keys(ERRORS);
const warningValues = Object.keys(WARNING);
const foundError = errorValues.find(item => {
return err.name ? err.name.includes(item) : err.includes(item);
});
const foundWarning = warningValues.find(item => {
return err.name ? err.name.includes(item) : err.includes(item);
});

if (foundError) {
Toast.responseHandler(`${Vue.$i18n.t(ERRORS[foundError])}`, Toast.ERROR);
} else if (foundWarning) {
Toast.responseHandler(`${Vue.$i18n.t(WARNING[foundWarning])}`, Toast.WARN);
} else {
Toast.responseHandler(err, false);
}
};
Loading

1 comment on commit 2c5981f

@mew-bot
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.