How to use the @keepkey/device-protocol/lib/messages-cosmos_pb.CosmosMsgSend 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 / cosmos.ts View on Github external
throw new Error(`cosmos: unexpected response ${resp.message_type}`)
      }

      let ack

      if (m.type === 'cosmos-sdk/MsgSend') {
        if (m.value.amount.length !== 1) {
          throw new Error('cosmos: Multiple amounts per msg not supported')
        }

        const denom = m.value.amount[0].denom
        if (denom !== 'uatom') {
          throw new Error('cosmos: Unsupported denomination: ' + denom)
        }

        const send = new CosmosMsgSend()
        send.setFromAddress(m.value.from_address)
        send.setToAddress(m.value.to_address)
        send.setAmount(m.value.amount[0].amount)

        ack = new CosmosMsgAck()
        ack.setSend(send)
      } else {
        throw new Error(`cosmos: Message ${m.type} is not yet supported`)
      }

      resp = await transport.call(MessageType.MESSAGETYPE_COSMOSMSGACK, ack, Core.LONG_TIMEOUT, /*omitLock=*/true)

      if (resp.message_type === Core.Events.FAILURE) throw resp
    }

    if (resp.message_enum !== MessageType.MESSAGETYPE_COSMOSSIGNEDTX) {