Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { Transaction as EthTx, TxData } from 'ethereumjs-tx';
import mapValues from 'lodash/mapValues';
import { translateRaw } from 'v2/translations';
import TrezorConnect from 'trezor-connect';
import { getTransactionFields } from 'v2/services/EthService';
import { stripHexPrefixAndLower, padLeftEven } from 'v2/services/EthService/utils';
import { HardwareWallet, ChainCodeResponse } from './hardware';
// read more: https://github.com/trezor/connect/blob/develop/docs/index.md#trezor-connect-manifest
TrezorConnect.manifest({
email: 'support@mycrypto.com',
appUrl: 'https://mycrypto.com/'
});
export class TrezorWallet extends HardwareWallet {
public static getChainCode(dpath: string): Promise {
return new Promise(resolve => {
TrezorConnect.getPublicKey({
path: dpath
}).then((res: any) => {
if (res.success) {
resolve({
publicKey: res.payload.publicKey,
chainCode: res.payload.chainCode
});
} else {
public async initialize(): Promise {
TrezorConnect.manifest({
email: 'maarten@zuidhoorn.com',
appUrl: 'https://findeth.io'
});
this.cache = {};
// Fetch a random address to ensure the connection works
await this.getAddress(DEFAULT_ETH, 50);
}
constructor() {
Trezor.manifest({
email: 'dev@myetherwallet.com',
appUrl: 'https://www.myetherwallet.com'
});
this.identifier = trezorType;
this.isHardware = true;
this.needPassword = NEED_PASSWORD;
this.supportedPaths = bip44Paths[trezorType];
}
async init(basePath) {
constructor() {
Trezor.manifest({
email: 'dev@myetherwallet.com',
appUrl: 'https://www.myetherwallet.com'
});
this.identifier = trezorType;
this.isHardware = true;
this.needPassword = NEED_PASSWORD;
this.supportedPaths = bip44Paths[trezorType];
}
async init(basePath) {
getAddress = async () => {
TrezorConnect.manifest({
email: 'dev@tronscan.org',
appUrl: 'https://tronscan.org'
});
console.log("getting address!");
try {
let {payload, success} = await TrezorConnect.tronGetAddress({
"path": "m/44'/195'/0'/0/0",
"showOnTrezor": true
});
console.log("result", {
payload,
success,
});
async values => {
TrezorConnect.manifest({
email: 'bridge-trezor@urbit.org',
appUrl: 'https://github.com/urbit/bridge',
});
const { success, payload } = await TrezorConnect.getPublicKey({
path: values.hdPath,
});
if (!success) {
return { [FORM_ERROR]: 'Failed to authenticate with your Trezor.' };
}
const publicKey = Buffer.from(payload.publicKey, 'hex');
const chainCode = Buffer.from(payload.chainCode, 'hex');
const pub = secp256k1.publicKeyConvert(publicKey, true);
const hd = bip32.fromPublicKey(pub, chainCode);
import React, { Component } from "react";
import DerivationPath, { NUM_DERIVATION_PATHS_TO_DISPLAY } from "modules/auth/helpers/derivation-path";
import TrezorConnect, { DEVICE_EVENT, DEVICE } from "trezor-connect";
import HardwareWallet from "modules/auth/components/common/hardware-wallet";
import { TREZOR_MANIFEST_EMAIL, TREZOR_MANIFEST_APPURL } from "modules/common/constants";
TrezorConnect.manifest({
email: TREZOR_MANIFEST_EMAIL,
appUrl: TREZOR_MANIFEST_APPURL,
});
interface TrezorConnectWrapperProps {
loginWithTrezor: Function;
showAdvanced: boolean;
showError: Function;
hideError: Function;
error: boolean;
onSuccess: Function;
setIsLoading: Function;
setShowAdvancedButton: Function;
isClicked: boolean;
isLoading: boolean;
logout: Function;
constructor(props) {
super(props);
this.connectWallet = this.connectWallet.bind(this);
TrezorConnect.manifest({
email: TREZOR_MANIFEST_EMAIL,
appUrl: TREZOR_MANIFEST_APP
});
}
async pollDevice() {
const { setWallet, setWalletHdPath } = this.props;
const { hdpath } = this.state;
TrezorConnect.manifest({
email: 'bridge-trezor@urbit.org',
appUrl: 'https://github.com/urbit/bridge',
});
TrezorConnect.getPublicKey({ path: hdpath }).then(info => {
if (info.success === true) {
const payload = info.payload;
const publicKey = Buffer.from(payload.publicKey, 'hex');
const chainCode = Buffer.from(payload.chainCode, 'hex');
const pub = secp256k1.publicKeyConvert(publicKey, true);
const hd = bip32.fromPublicKey(pub, chainCode);
setWallet(Maybe.Just(hd));
setWalletHdPath(hdpath);
} else {
setWallet(Maybe.Nothing());
}
});
import { Signer, utils } from 'ethers'
import TrezorConnect from 'trezor-connect'
import { constants } from 'adex-models'
const DEFAULT_HD_PATH = "m/44'/60'/0'/0"
TrezorConnect.manifest({
email: 'contactus@adex.network',
appUrl: 'http://adex.network',
})
export default class TrezorSigner extends Signer {
constructor(provider, opts = {}) {
super()
this._provider = provider
this._path = opts.path || DEFAULT_HD_PATH
}
get path() {
return this._path
}
get provider() {
return this._provider