Skip to content

Commit

Permalink
fix: AuxTxBuilder check all AuxSignerData match (cosmos#10547)
Browse files Browse the repository at this point in the history
* Rename file

* Check matching AuxSignerData

* Remove getbody

* Remove useless code

* Add small test

Co-authored-by: Marko <[email protected]>
  • Loading branch information
amaury1093 and tac0turtle authored Nov 16, 2021
1 parent af8ad3d commit 8647474
Show file tree
Hide file tree
Showing 7 changed files with 222 additions and 100 deletions.
19 changes: 19 additions & 0 deletions client/tx/aux_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,15 @@ func (b *AuxTxBuilder) SetMemo(memo string) {
b.checkEmptyFields()

b.body.Memo = memo
b.auxSignerData.SignDoc.BodyBytes = nil
}

// SetTimeoutHeight sets a timeout height in the tx.
func (b *AuxTxBuilder) SetTimeoutHeight(height uint64) {
b.checkEmptyFields()

b.body.TimeoutHeight = height
b.auxSignerData.SignDoc.BodyBytes = nil
}

// SetMsgs sets an array of Msgs in the tx.
Expand All @@ -65,6 +67,7 @@ func (b *AuxTxBuilder) SetMsgs(msgs ...sdk.Msg) error {

b.msgs = msgs
b.body.Messages = anys
b.auxSignerData.SignDoc.BodyBytes = nil

return nil
}
Expand Down Expand Up @@ -132,6 +135,22 @@ func (b *AuxTxBuilder) SetSignature(sig []byte) {
b.auxSignerData.Sig = sig
}

// SetExtensionOptions sets the aux signer's extension options.
func (b *AuxTxBuilder) SetExtensionOptions(extOpts ...*codectypes.Any) {
b.checkEmptyFields()

b.body.ExtensionOptions = extOpts
b.auxSignerData.SignDoc.BodyBytes = nil
}

// SetSignature sets the aux signer's signature.
func (b *AuxTxBuilder) SetNonCriticalExtensionOptions(extOpts ...*codectypes.Any) {
b.checkEmptyFields()

b.body.NonCriticalExtensionOptions = extOpts
b.auxSignerData.SignDoc.BodyBytes = nil
}

// GetSignBytes returns the builder's sign bytes.
func (b *AuxTxBuilder) GetSignBytes() ([]byte, error) {
auxTx := b.auxSignerData
Expand Down
2 changes: 1 addition & 1 deletion proto/cosmos/tx/v1beta1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ message Fee {
// Tip is the tip used for meta-transactions.
message Tip {
// amount is the amount of the tip
repeated cosmos.base.v1beta1.Coin amount = 1 [(gogoproto.nullable) = false];
repeated cosmos.base.v1beta1.Coin amount = 1 [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];
// tipper is the address of the account paying for the tip
string tipper = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}
Expand Down
File renamed without changes.
File renamed without changes.
132 changes: 66 additions & 66 deletions types/tx/tx.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8647474

Please sign in to comment.