Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
let response: EthereumTxRequest
let nextResponse = await transport.call(MessageType.MESSAGETYPE_ETHEREUMSIGNTX, est, LONG_TIMEOUT, /*omitLock=*/true)
if (nextResponse.message_enum === MessageType.MESSAGETYPE_FAILURE) {
throw nextResponse
}
response = nextResponse.proto as EthereumTxRequest
try {
while (response.hasDataLength()) {
const dataLength = response.getDataLength()
dataChunk = dataRemaining.slice(0, dataLength)
dataRemaining = dataRemaining.slice(dataLength, dataRemaining.length)
nextResponse = await transport.call(MessageType.MESSAGETYPE_ETHEREUMSIGNTX, est, LONG_TIMEOUT, /*omitLock=*/true)
if (nextResponse.message_enum === MessageType.MESSAGETYPE_FAILURE) {
throw nextResponse
}
response = nextResponse.proto as EthereumTxRequest
}
} catch(error) {
console.error({ error })
throw new Error('Failed to sign ETH transaction')
}
const r = '0x' + toHexString(response.getSignatureR_asU8())
const s = '0x' + toHexString(response.getSignatureS_asU8())
const v = '0x' + response.getSignatureV().toString(16)
const utx = {
to: msg.to,
let dataRemaining = undefined
if (msg.data) {
dataRemaining = arrayify(msg.data)
est.setDataLength(dataRemaining.length)
dataChunk = dataRemaining.slice(0, 1024)
dataRemaining = dataRemaining.slice(dataChunk.length)
est.setDataInitialChunk(dataChunk)
}
if (msg.chainId !== undefined) {
est.setChainId(msg.chainId)
}
let response: EthereumTxRequest
let nextResponse = await transport.call(MessageType.MESSAGETYPE_ETHEREUMSIGNTX, est, LONG_TIMEOUT, /*omitLock=*/true)
if (nextResponse.message_enum === MessageType.MESSAGETYPE_FAILURE) {
throw nextResponse
}
response = nextResponse.proto as EthereumTxRequest
try {
while (response.hasDataLength()) {
const dataLength = response.getDataLength()
dataChunk = dataRemaining.slice(0, dataLength)
dataRemaining = dataRemaining.slice(dataLength, dataRemaining.length)
nextResponse = await transport.call(MessageType.MESSAGETYPE_ETHEREUMSIGNTX, est, LONG_TIMEOUT, /*omitLock=*/true)
if (nextResponse.message_enum === MessageType.MESSAGETYPE_FAILURE) {
throw nextResponse
}
response = nextResponse.proto as EthereumTxRequest