Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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) {
throw new Error(`cosmos: unexpected response ${resp.message_type}`)
}
const signedTx = resp.proto as CosmosSignedTx