refactor auths broadcast cmd in alignment with #6216 (#6713)

* refactor auths broadcast cmd in alignment with #6216

* add TxResponse proto definition, and related refactoring

* re-run make proto-gen, updating staking.pb.go

* cleanup TxResponse tests to handle nil return values

* properly handle nil Tx value in TxResponse's implementation of UnpackInterfaces

Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
This commit is contained in:
Cory
2020-07-17 17:17:21 +00:00
committed by GitHub
co-authored by Federico Kunze
parent 5c86ecd1f8
commit 32de79d0aa
11 changed files with 2168 additions and 720 deletions
+15
View File
@@ -83,6 +83,21 @@ func (any *Any) Pack(x proto.Message) error {
return nil
}
// UnsafePackAny packs the value x in the Any and instead of returning the error
// in the case of a packing failure, keeps the cached value. This should only
// be used in situations where compatibility is needed with amino. Amino-only
// values can safely be packed using this method when they will only be
// marshaled with amino and not protobuf
func UnsafePackAny(x interface{}) *Any {
if msg, ok := x.(proto.Message); ok {
any, err := NewAnyWithValue(msg)
if err != nil {
return any
}
}
return &Any{cachedValue: x}
}
// GetCachedValue returns the cached value from the Any if present
func (any *Any) GetCachedValue() interface{} {
return any.cachedValue