How to use the @keepkey/device-protocol/lib/messages-cosmos_pb.CosmosSignTx 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
return transport.lockDuring(async () => {
    const signTx = new CosmosSignTx()
    signTx.setAddressNList(msg.addressNList)
    signTx.setAccountNumber(msg.account_number)
    signTx.setChainId(msg.chain_id)
    signTx.setFeeAmount(parseInt(msg.tx.value.fee.amount[0].amount))
    signTx.setGas(parseInt(msg.tx.value.fee.gas))
    signTx.setSequence(msg.sequence)
    if (msg.tx.value.memo !== undefined) signTx.setMemo(msg.tx.value.memo)
    signTx.setMsgCount(msg.tx.value.msg.length)

    let resp = await transport.call(MessageType.MESSAGETYPE_COSMOSSIGNTX, signTx, Core.LONG_TIMEOUT, /*omitLock=*/true)

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

    for (let m of msg.tx.value.msg) {
      if (resp.message_enum !== MessageType.MESSAGETYPE_COSMOSMSGREQUEST) {
        throw new Error(`cosmos: unexpected response ${resp.message_type}`)