How to use the @keepkey/device-protocol/lib/messages_pb.MessageType.MESSAGETYPE_ETHEREUMSIGNTX function in @keepkey/device-protocol

To help you get started, we’ve selected a few @keepkey/device-protocol examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github shapeshift / hdwallet / packages / hdwallet-keepkey / src / ethereum.ts View on Github external
}

    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,
github shapeshift / hdwallet / packages / hdwallet-keepkey / src / ethereum.ts View on Github external
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

@keepkey/device-protocol

The proto buffer files from the KeepKey device, packed for consumption by the client.

ISC
Latest version published 3 months ago

Package Health Score

60 / 100
Full package analysis

Similar packages