Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/coolwallet [v5] #2087

Merged
merged 27 commits into from
Mar 20, 2020
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
f6c046e
CoolWallet starting point
gamalielhere Feb 27, 2020
baa8ea8
Fix conflicts
gamalielhere Mar 3, 2020
d0bd4ee
Setup stopping point
gamalielhere Mar 3, 2020
c80acd2
Workflow setup
gamalielhere Mar 4, 2020
00ccc14
Fix conflicts
gamalielhere Mar 10, 2020
381f905
Stopping point
gamalielhere Mar 10, 2020
cc4595f
Stopping point
gamalielhere Mar 10, 2020
5912d7f
Sync with develop
gamalielhere Mar 11, 2020
cca07b5
Some cleanup
gamalielhere Mar 12, 2020
2601da6
Get coolwallet access to work
gamalielhere Mar 12, 2020
2cd2dac
Get sign tx to work, get sign msg to work
gamalielhere Mar 12, 2020
a2a6b72
Wait for register to be done before fetching accounts
gamalielhere Mar 12, 2020
041dba1
Update changelog
gamalielhere Mar 12, 2020
def4fba
Fix conflicts
gamalielhere Mar 12, 2020
3077d6c
Remove console
gamalielhere Mar 12, 2020
d6bc58a
Update link and logo on Hardware access:
gamalielhere Mar 13, 2020
403ef1f
Add cool wallet to hardware affiliates
gamalielhere Mar 16, 2020
c0e4620
Update description, waiting on link
gamalielhere Mar 16, 2020
5813375
Fix conflicts
gamalielhere Mar 20, 2020
5b56e34
Add error
gamalielhere Mar 20, 2020
59b8c2b
Fix conflicts
gamalielhere Mar 20, 2020
d534d05
Remove test that's removed from a different branch
gamalielhere Mar 20, 2020
e05d2d6
Dont transform coolwallet
gamalielhere Mar 20, 2020
037948d
Fix conflicts
gamalielhere Mar 20, 2020
d3ff5f5
Fix build
gamalielhere Mar 20, 2020
7ed1a92
Merge with bcvault
gamalielhere Mar 20, 2020
909a740
New tokens
gamalielhere Mar 20, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### Feature

- Cool Wallet integration [#2087](https://github.com/MyEtherWallet/MyEtherWallet/pull/2087)

### Release v5.4.2-hotfix.1

### Bugs
Expand Down
1,040 changes: 486 additions & 554 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.14.0",
"@sentry/integrations": "5.14.0",
"@unstoppabledomains/resolution": "1.2.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,23 @@ 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
SecalotWallet,
CoolWallet
} from '@/wallets';
import {
LEDGER as LEDGER_TYPE,
TREZOR as TREZOR_TYPE,
BITBOX as BITBOX_TYPE,
SECALOT as SECALOT_TYPE,
KEEPKEY as KEEPKEY_TYPE,
XWALLET as XWALLET_TYPE
XWALLET as XWALLET_TYPE,
COOLWALLET as COOLWALLET_TYPE
} from '@/wallets/bip44/walletTypes';
export default {
components: {
Expand Down Expand Up @@ -166,6 +170,14 @@ export default {
disabled: false,
msg: '',
link: 'http://lddy.no/a4im'
},
{
name: COOLWALLET_TYPE,
imgPath: keepkey,
text: 'CoolWallet',
disabled: false,
msg: '',
link: 'http://lddy.no/a4im'
}
]
};
Expand Down Expand Up @@ -258,6 +270,39 @@ export default {
this.openXwallet();
this.$refs.hardware.hide();
break;
case COOLWALLET_TYPE:
// eslint-disable-next-line
const hasStoredPw = store.get('cwPass') || null;
gamalielhere marked this conversation as resolved.
Show resolved Hide resolved
if (hasStoredPw) {
cwsTransportLib.listen(async (error, device) => {
if (device) {
const transport = await cwsTransportLib.connect(device);
CoolWallet(transport, hasStoredPw)
.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;
default:
Toast.responseHandler(
new Error('No switch address for given account.'),
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';
import store from 'store';
export default {
props: {
walletConstructor: {
Expand Down Expand Up @@ -78,12 +80,32 @@ 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);
Comment on lines +85 to +87
Copy link
Contributor

Choose a reason for hiding this comment

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

this should be moved inside the wallet init function? I think previous unlockWallet function should be sufficient

Copy link
Contributor Author

Choose a reason for hiding this comment

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

moving it here fixed the scoping issue

store.set('cwPass', this.password.toString());
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: 1 addition & 1 deletion src/partners/kyber/config/currenciesETH.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/partners/partnersConfig/EthereumTokens.json

Large diffs are not rendered by default.

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 ledgerError from './errors-ledger/en_US';
import secalotError from './errors-secalot/en_US';
import keepkeyError from './errors-keepkey/en_US';
Expand Down Expand Up @@ -57,6 +58,7 @@ const en_US = {
withoutWallet: withoutWallet,
errorsGlobal: errorsGlobal,
trezorError: trezorError,
coolWalletError: coolWalletError,
ledgerError: ledgerError,
secalotError: secalotError,
keepkeyError: keepkeyError,
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!"
}
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
};
4 changes: 3 additions & 1 deletion src/wallets/bip44/walletTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const WEB3_WALLET = 'web3_wallet';
const PRIV_KEY = 'priv_key';
const WATCH_ONLY = 'watchOnly';
const XWALLET = 'xwallet';
const COOLWALLET = 'cool_wallet';
export {
LEDGER,
TREZOR,
Expand All @@ -22,5 +23,6 @@ export {
WEB3_WALLET,
PRIV_KEY,
WATCH_ONLY,
XWALLET
XWALLET,
COOLWALLET
};
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