feat(x/auth): batch transactions file format & broadcast multi transactions (#18692)

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
Co-authored-by: Marko <marbar3778@yahoo.com>
This commit is contained in:
Hieu Vu
2023-12-14 10:04:34 +00:00
committed by GitHub
co-authored by Aleksandr Bezobchuk Marko
parent 8fe6d84f2c
commit bea3f9b7a3
4 changed files with 120 additions and 10 deletions
+20 -10
View File
@@ -35,22 +35,32 @@ filename, the command reads from standard input.`),
return errors.New("cannot broadcast tx during offline mode")
}
stdTx, err := authclient.ReadTxFromFile(clientCtx, args[0])
txs, err := authclient.ReadTxsFromFile(clientCtx, args[0])
if err != nil {
return err
}
txBytes, err := clientCtx.TxConfig.TxEncoder()(stdTx)
if err != nil {
return err
}
txEncoder := clientCtx.TxConfig.TxEncoder()
for _, tx := range txs {
txBytes, err1 := txEncoder(tx)
if err1 != nil {
err = errors.Join(err, err1)
continue
}
res, err := clientCtx.BroadcastTx(txBytes)
if err != nil {
return err
res, err2 := clientCtx.BroadcastTx(txBytes)
if err2 != nil {
err = errors.Join(err, err2)
continue
}
if res != nil {
err3 := clientCtx.PrintProto(res)
if err3 != nil {
err = errors.Join(err, err3)
}
}
}
return clientCtx.PrintProto(res)
return err
},
}