Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
signMessage(data: string, account: any, cb: (err: any, res?: any) => any) {
TrezorConnect.ethereumSignMessage(path, data, (result: any) => {
const { payload, success } = result;
if (!success) {
cb(payload.error);
return;
}
cb(undefined, payload.signature);
});
},
async signTransaction(txData: any, cb: (err: any, res?: any) => any): Promise {
return new Promise(async (resolve, reject) => {
const result = await TrezorConnect.ethereumSignMessage({
path: this.path,
message,
});
if (result.success) {
resolve(result.payload.signature);
}
reject(result.payload.error);
});
}
const msgSigner = async msg => {
const result = await Trezor.ethereumSignMessage({
path: this.basePath + '/' + idx,
message: Misc.toBuffer(msg).toString('hex'),
hex: true
});
if (!result.success) throw new Error(result.payload.error);
return getBufferFromHex(result.payload.signature);
};
const displayAddress = async () => {
signMessage = async (message, opts = {}) => {
const { success, payload } = await TrezorConnect.ethereumSignMessage({
path: this.path,
message: message,
hex: !!opts.hex,
})
if (success) {
const res = {
/*
* NOTE: SignatureTypes.GETH
* Current TrezorConnect window does not
* accept device with old firmware
*/
signature: '0x' + payload.signature,
hash: message,
mode: constants.SignatureModes.GETH,
address: payload.address,
const msgSigner = async msg => {
const result = await Trezor.ethereumSignMessage({
path: this.basePath + '/' + idx,
message: toBuffer(msg).toString('hex'),
hex: true
});
if (!result.success) throw new Error(result.payload.error);
return getBufferFromHex(result.payload.signature);
};
const displayAddress = async () => {