Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
transaction,
assets,
nativeCurrency,
timestampInMs
);
}
if (payload.method === SIGN) {
const message = get(payload, 'params[1]');
const result = getMessageDisplayDetails(message, timestampInMs);
return result;
}
if (payload.method === PERSONAL_SIGN) {
let message = get(payload, 'params[0]');
try {
if (isHexString(message)) {
message = convertHexToUtf8(message);
}
} catch (error) {
// TODO error handling
}
return getMessageDisplayDetails(message, timestampInMs);
}
if (payload.method === SIGN_TYPED || payload.method === SIGN_TYPED_V3) {
const request = get(payload, 'params[1]', null);
const jsonRequest = JSON.stringify(request.message);
return getMessageDisplayDetails(jsonRequest, timestampInMs);
}
return {};
};
export function convertHexToUtf8IfPossible(hex: string) {
try {
return convertHexToUtf8(hex);
} catch(e) {
return hex;
}
}
return getTransactionDisplayDetails(
transaction,
assets,
prices,
nativeCurrency,
timestampInMs,
);
}
if (payload.method === 'eth_sign') {
const message = get(payload, 'params[1]');
return getMessageDisplayDetails(message, timestampInMs);
}
if (payload.method === 'personal_sign') {
let message = '';
try {
message = convertHexToUtf8(get(payload, 'params[0]'));
} catch (error) {
message = get(payload, 'params[0]');
}
return getMessageDisplayDetails(message, timestampInMs, 'messagePersonal');
}
if (payload.method === 'eth_signTypedData'
|| payload.method === 'eth_signTypedData_v3') {
const request = get(payload, 'params[1]', null);
const jsonRequest = JSON.stringify(request.message);
return getMessageDisplayDetails(jsonRequest, timestampInMs);
}
return {};
};