Skip to content

Commit

Permalink
Merge PR: optimize txdecoder decode simulate situation (#2752)
Browse files Browse the repository at this point in the history
* optimize simulate

* add blank

* rm error

Co-authored-by: KamiD <[email protected]>
  • Loading branch information
ItsFunny and KamiD authored Dec 1, 2022
1 parent c9f5ba4 commit 87e95ee
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions libs/cosmos-sdk/x/auth/ibc-tx/decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package ibc_tx

import (
"fmt"

"github.com/okex/exchain/libs/cosmos-sdk/codec"
"github.com/okex/exchain/libs/cosmos-sdk/codec/unknownproto"
"github.com/okex/exchain/libs/cosmos-sdk/crypto/types"
Expand All @@ -10,6 +11,7 @@ import (
"github.com/okex/exchain/libs/cosmos-sdk/types/tx/signing"
"github.com/okex/exchain/libs/cosmos-sdk/x/auth/ibc-tx/internal/adapter"
"google.golang.org/protobuf/encoding/protowire"

//"github.com/okex/exchain/libs/cosmos-sdk/codec/unknownproto"
sdk "github.com/okex/exchain/libs/cosmos-sdk/types"

Expand Down Expand Up @@ -166,11 +168,20 @@ func constructMsgs(ibcTx *tx.Tx) ([]sdk.Msg, []sdk.Msg, error) {
}

func convertSignature(ibcTx *tx.Tx) []authtypes.StdSignature {
signatures := []authtypes.StdSignature{}
ret := make([]authtypes.StdSignature, len(ibcTx.Signatures))

for i, s := range ibcTx.Signatures {
var pkData types.PubKey
if ibcTx.AuthInfo.SignerInfos != nil {
var ok bool
if ibcTx.AuthInfo.SignerInfos[i].PublicKey == nil {
// maybe it is a simulate request
ret[i] = authtypes.StdSignature{
Signature: s,
PubKey: nil,
}
continue
}
pkData, ok = ibcTx.AuthInfo.SignerInfos[i].PublicKey.GetCachedValue().(types.PubKey)
if !ok {
return []authtypes.StdSignature{}
Expand All @@ -181,14 +192,13 @@ func convertSignature(ibcTx *tx.Tx) []authtypes.StdSignature {
return []authtypes.StdSignature{}
}

signatures = append(signatures,
authtypes.StdSignature{
Signature: s,
PubKey: pubKey,
},
)
ret[i] = authtypes.StdSignature{
Signature: s,
PubKey: pubKey,
}
}
return signatures

return ret
}

func convertFee(authInfo tx.AuthInfo) (authtypes.StdFee, authtypes.IbcFee, string, error) {
Expand Down

0 comments on commit 87e95ee

Please sign in to comment.