Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend ClientConn on TxBuilder #7630

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
9c8486d
Add invoke & NewStream
amaury1093 Oct 22, 2020
2c36489
Remove validate basic
amaury1093 Oct 22, 2020
097c13f
Update test
amaury1093 Oct 22, 2020
b0e89dc
WIP
amaury1093 Oct 22, 2020
55c4a88
Merge branch 'master' of ssh://github.com/cosmos/cosmos-sdk into am-7…
amaury1093 Oct 23, 2020
7b44e68
NewAnyWithWithTypeURL
amaury1093 Oct 23, 2020
7b1e26a
Add todo comment for amino
amaury1093 Oct 23, 2020
2306164
Merge branch 'master' of ssh://github.com/cosmos/cosmos-sdk into am-7…
amaury1093 Oct 23, 2020
12cba1e
Add Changelog
amaury1093 Oct 23, 2020
73af333
Remove println
amaury1093 Oct 23, 2020
383b3e8
Update codec/types/any.go
amaury1093 Oct 23, 2020
24cdb72
Add AppendMsgs
amaury1093 Oct 23, 2020
70c0ebf
Rename SetMsgs to AppendMsgs
amaury1093 Oct 23, 2020
626319a
Merge branch 'am-7541-txbuilder' of ssh://github.com/cosmos/cosmos-sd…
amaury1093 Oct 23, 2020
3b75af0
Merge branch 'master' into am-7541-txbuilder
Oct 23, 2020
9a68044
Merge branch 'master' of ssh://github.com/cosmos/cosmos-sdk into am-7…
amaury1093 Oct 26, 2020
92679a4
Address review comments
amaury1093 Oct 26, 2020
4e2f3a5
Add comment
amaury1093 Oct 26, 2020
dc1613b
Typo
amaury1093 Oct 26, 2020
e5c6106
Merge branch 'master' into am-7541-txbuilder
amaury1093 Oct 26, 2020
b6209de
Merge branch 'master' of ssh://github.com/cosmos/cosmos-sdk into am-7…
amaury1093 Dec 11, 2020
173b75d
Use SetMsgs
amaury1093 Dec 11, 2020
7b9da51
remove AppendMsg
amaury1093 Dec 11, 2020
8083644
Add comments and CHANHGELOG
amaury1093 Dec 11, 2020
ade84b5
Add validate basic
amaury1093 Dec 11, 2020
7afe557
Merge branch 'master' of ssh://github.com/cosmos/cosmos-sdk into am-7…
amaury1093 Dec 15, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

* (x/staking) [\#7499](https://github.com/cosmos/cosmos-sdk/pull/7499) `BondStatus` is now a protobuf `enum` instead of an `int32`, and JSON serialized using its protobuf name, so expect names like `BOND_STATUS_UNBONDING` as opposed to `Unbonding`.
* (x/evidence) [\#7538](https://github.com/cosmos/cosmos-sdk/pull/7538) The ABCI's `Result.Data` field of `MsgSubmitEvidence` does not contain the raw evidence's hash, but the encoded `MsgSubmitEvidenceResponse` struct.
* (client) [\#7630](https://github.com/cosmos/cosmos-sdk/pull/7630) `TxBuilder`'s `SetMsgs` method has been converted to `AppendMsgs`. Moreover, `TxBuilder` extends `grpc.ClientConn` to be able to create txs with ADR 031 service `Msg`s.

### API Breaking

Expand Down
2 changes: 1 addition & 1 deletion baseapp/msg_service_router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestMsgService(t *testing.T) {
txBuilder := encCfg.TxConfig.NewTxBuilder()
txBuilder.SetFeeAmount(testdata.NewTestFeeAmount())
txBuilder.SetGasLimit(testdata.NewTestGasLimit())
err := txBuilder.SetMsgs(msg)
err := txBuilder.AppendMsgs(msg)
require.NoError(t, err)

// First round: we gather all the signer infos. We use the "set empty
Expand Down
2 changes: 1 addition & 1 deletion client/grpc/simulate/simulate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (s IntegrationTestSuite) TestSimulateService() {

// Create a txBuilder.
txBuilder := s.clientCtx.TxConfig.NewTxBuilder()
txBuilder.SetMsgs(msg)
txBuilder.AppendMsgs(msg)
txBuilder.SetMemo(memo)
txBuilder.SetFeeAmount(feeAmount)
txBuilder.SetGasLimit(gasLimit)
Expand Down
2 changes: 1 addition & 1 deletion client/tx/legacy.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func ConvertTxToStdTx(codec *codec.LegacyAmino, tx signing.Tx) (legacytx.StdTx,
// different transaction formats. If ignoreSignatureError is true, copying will continue
// tx even if the signature cannot be set in the target builder resulting in an unsigned tx.
func CopyTx(tx signing.Tx, builder client.TxBuilder, ignoreSignatureError bool) error {
err := builder.SetMsgs(tx.GetMsgs()...)
err := builder.AppendMsgs(tx.GetMsgs()...)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion client/tx/legacy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func buildTestTx(t *testing.T, builder client.TxBuilder) {
builder.SetMemo(memo)
builder.SetGasLimit(gas)
builder.SetFeeAmount(fee)
err := builder.SetMsgs(msg)
err := builder.AppendMsgs(msg)
require.NoError(t, err)
err = builder.SetSignatures(sig)
require.NoError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion client/tx/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ func BuildUnsignedTx(txf Factory, msgs ...sdk.Msg) (client.TxBuilder, error) {

tx := txf.txConfig.NewTxBuilder()

if err := tx.SetMsgs(msgs...); err != nil {
if err := tx.AppendMsgs(msgs...); err != nil {
return nil, err
}

Expand Down
5 changes: 4 additions & 1 deletion client/tx_config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package client

import (
gogogrpc "github.com/gogo/protobuf/grpc"

sdk "github.com/cosmos/cosmos-sdk/types"
signingtypes "github.com/cosmos/cosmos-sdk/types/tx/signing"
"github.com/cosmos/cosmos-sdk/x/auth/signing"
Expand Down Expand Up @@ -34,9 +36,10 @@ type (
// signatures, and provide canonical bytes to sign over. The transaction must
// also know how to encode itself.
TxBuilder interface {
gogogrpc.ClientConn
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think an update to ADR 020 is really needed, wdyt?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not. But just wondering is it better to change the interface, or create a separate struct that implements ClientConn wraps TxBuilder?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea of creating ClientConn. I was confused with the Invoke method initially. Maybe we can call the new interface: MsgSrvClient?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ping?

Copy link
Contributor Author

@amaury1093 amaury1093 Dec 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure here. Are you proposing:

type MsgSrvClient struct {
  txBuilder TxBuilder
}

var _ gogogrpc.ClientConn = MsgSrvClient{}

? I feel yet another struct creates more confusion. At some point we should revisit #7630 (comment), which imo is the ideal way forward.

GetTx() signing.Tx

SetMsgs(msgs ...sdk.Msg) error
AppendMsgs(msg ...sdk.Msg) error
amaury1093 marked this conversation as resolved.
Show resolved Hide resolved
SetSignatures(signatures ...signingtypes.SignatureV2) error
SetMemo(memo string)
SetFeeAmount(amount sdk.Coins)
Expand Down
31 changes: 26 additions & 5 deletions codec/types/any.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,25 @@ func NewAnyWithValue(value proto.Message) (*Any, error) {
return any, nil
}

// Pack packs the value x in the Any or returns an error. This also caches
// the packed value so that it can be retrieved from GetCachedValue without
// unmarshaling
func (any *Any) Pack(x proto.Message) error {
any.TypeUrl = "/" + proto.MessageName(x)
// NewAnyWithTypeURL constructs a new Any packed with the value provided
// and a custom TypeURL. It returns an error if that value couldn't be packed.
// This also cachesthe packed value so that it can be retrieved from
// GetCachedValue without unmarshaling.
//
// Ex:
// This will allow us to pack service methods in Any's using the full method name
// as the type URL and the request body as the value.
func NewAnyWithTypeURL(typeURL string, value proto.Message) (*Any, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function looks dangerous.

Is the protobuf generated code already providing it? Maybe there is a method already for this?

Copy link
Contributor Author

@amaury1093 amaury1093 Oct 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the protobuf generated code already providing it? Maybe there is a method already for this?

I don't think so, because we have our own implementation of Any.

any := &Any{}

return any, any.packWithCustomTypeURL(typeURL, value)
}
amaury1093 marked this conversation as resolved.
Show resolved Hide resolved

// PackWithCustomTypeURL packs the value x in the Any or returns an error,
// allowing for a custom TypeUrl. This also caches the packed value so that it
// can be retrieved fromGetCachedValue without unmarshaling.
func (any *Any) packWithCustomTypeURL(typeURL string, x proto.Message) error {
any.TypeUrl = typeURL
bz, err := proto.Marshal(x)
if err != nil {
return err
Expand All @@ -84,6 +98,13 @@ func (any *Any) Pack(x proto.Message) error {
return nil
}

// Pack packs the value x in the Any or returns an error. This also caches
// the packed value so that it can be retrieved from GetCachedValue without
// unmarshaling
func (any *Any) Pack(x proto.Message) error {
return any.packWithCustomTypeURL("/"+proto.MessageName(x), x)
}

// 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
Expand Down
2 changes: 1 addition & 1 deletion simapp/helpers/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func GenTx(gen client.TxConfig, msgs []sdk.Msg, feeAmt sdk.Coins, gas uint64, ch
}

tx := gen.NewTxBuilder()
err := tx.SetMsgs(msgs...)
err := tx.AppendMsgs(msgs...)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion simapp/simd/cmd/testnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ func InitTestnet(
}

txBuilder := clientCtx.TxConfig.NewTxBuilder()
if err := txBuilder.SetMsgs(createValMsg); err != nil {
if err := txBuilder.AppendMsgs(createValMsg); err != nil {
return err
}

Expand Down
2 changes: 1 addition & 1 deletion testutil/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ func New(t *testing.T, cfg Config) *Network {
memo := fmt.Sprintf("%s@%s:%s", nodeIDs[i], p2pURL.Hostname(), p2pURL.Port())
fee := sdk.NewCoins(sdk.NewCoin(fmt.Sprintf("%stoken", nodeDirName), sdk.NewInt(0)))
txBuilder := cfg.TxConfig.NewTxBuilder()
require.NoError(t, txBuilder.SetMsgs(createValMsg))
require.NoError(t, txBuilder.AppendMsgs(createValMsg))
txBuilder.SetFeeAmount(fee) // Arbitrary fee
txBuilder.SetGasLimit(1000000) // Need at least 100386
txBuilder.SetMemo(memo)
Expand Down
6 changes: 3 additions & 3 deletions x/auth/ante/ante_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func (suite *AnteTestSuite) TestAnteHandlerSigErrors() {
privs, accNums, accSeqs = []crypto.PrivKey{}, []uint64{}, []uint64{}

// Create tx manually to test the tx's signers
suite.Require().NoError(suite.txBuilder.SetMsgs(msgs...))
suite.Require().NoError(suite.txBuilder.AppendMsgs(msgs...))
tx, err := suite.CreateTestTx(privs, accNums, accSeqs, suite.ctx.ChainID())
suite.Require().NoError(err)
// tx.GetSigners returns addresses in correct order: addr1, addr2, addr3
Expand Down Expand Up @@ -837,7 +837,7 @@ func (suite *AnteTestSuite) TestAnteHandlerSetPubKey() {

privs, accNums, accSeqs = []crypto.PrivKey{accounts[1].priv}, []uint64{1}, []uint64{0}
msgs = []sdk.Msg{testdata.NewTestMsg(accounts[1].acc.GetAddress())}
suite.txBuilder.SetMsgs(msgs...)
suite.txBuilder.AppendMsgs(msgs...)
suite.txBuilder.SetFeeAmount(feeAmount)
suite.txBuilder.SetGasLimit(gasLimit)

Expand Down Expand Up @@ -1062,7 +1062,7 @@ func (suite *AnteTestSuite) TestAnteHandlerReCheck() {

msg := testdata.NewTestMsg(accounts[0].acc.GetAddress())
msgs := []sdk.Msg{msg}
suite.Require().NoError(suite.txBuilder.SetMsgs(msgs...))
suite.Require().NoError(suite.txBuilder.AppendMsgs(msgs...))

suite.txBuilder.SetMemo("thisisatestmemo")

Expand Down
8 changes: 4 additions & 4 deletions x/auth/ante/basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func (suite *AnteTestSuite) TestValidateBasic() {
msg := testdata.NewTestMsg(addr1)
feeAmount := testdata.NewTestFeeAmount()
gasLimit := testdata.NewTestGasLimit()
suite.Require().NoError(suite.txBuilder.SetMsgs(msg))
suite.Require().NoError(suite.txBuilder.AppendMsgs(msg))
suite.txBuilder.SetFeeAmount(feeAmount)
suite.txBuilder.SetGasLimit(gasLimit)

Expand Down Expand Up @@ -65,7 +65,7 @@ func (suite *AnteTestSuite) TestValidateMemo() {
msg := testdata.NewTestMsg(addr1)
feeAmount := testdata.NewTestFeeAmount()
gasLimit := testdata.NewTestGasLimit()
suite.Require().NoError(suite.txBuilder.SetMsgs(msg))
suite.Require().NoError(suite.txBuilder.AppendMsgs(msg))
suite.txBuilder.SetFeeAmount(feeAmount)
suite.txBuilder.SetGasLimit(gasLimit)

Expand Down Expand Up @@ -115,7 +115,7 @@ func (suite *AnteTestSuite) TestConsumeGasForTxSize() {
for _, tc := range testCases {
suite.Run(tc.name, func() {
suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder()
suite.Require().NoError(suite.txBuilder.SetMsgs(msg))
suite.Require().NoError(suite.txBuilder.AppendMsgs(msg))
suite.txBuilder.SetFeeAmount(feeAmount)
suite.txBuilder.SetGasLimit(gasLimit)
suite.txBuilder.SetMemo(strings.Repeat("01234567890", 10))
Expand Down Expand Up @@ -207,7 +207,7 @@ func (suite *AnteTestSuite) TestTxHeightTimeoutDecorator() {
suite.Run(tc.name, func() {
suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder()

suite.Require().NoError(suite.txBuilder.SetMsgs(msg))
suite.Require().NoError(suite.txBuilder.AppendMsgs(msg))

suite.txBuilder.SetFeeAmount(feeAmount)
suite.txBuilder.SetGasLimit(gasLimit)
Expand Down
4 changes: 2 additions & 2 deletions x/auth/ante/fee_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func (suite *AnteTestSuite) TestEnsureMempoolFees() {
msg := testdata.NewTestMsg(addr1)
feeAmount := testdata.NewTestFeeAmount()
gasLimit := testdata.NewTestGasLimit()
suite.Require().NoError(suite.txBuilder.SetMsgs(msg))
suite.Require().NoError(suite.txBuilder.AppendMsgs(msg))
suite.txBuilder.SetFeeAmount(feeAmount)
suite.txBuilder.SetGasLimit(gasLimit)

Expand Down Expand Up @@ -72,7 +72,7 @@ func (suite *AnteTestSuite) TestDeductFees() {
msg := testdata.NewTestMsg(addr1)
feeAmount := testdata.NewTestFeeAmount()
gasLimit := testdata.NewTestGasLimit()
suite.Require().NoError(suite.txBuilder.SetMsgs(msg))
suite.Require().NoError(suite.txBuilder.AppendMsgs(msg))
suite.txBuilder.SetFeeAmount(feeAmount)
suite.txBuilder.SetGasLimit(gasLimit)

Expand Down
4 changes: 2 additions & 2 deletions x/auth/ante/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func (suite *AnteTestSuite) TestSetup() {
msg := testdata.NewTestMsg(addr1)
feeAmount := testdata.NewTestFeeAmount()
gasLimit := testdata.NewTestGasLimit()
suite.Require().NoError(suite.txBuilder.SetMsgs(msg))
suite.Require().NoError(suite.txBuilder.AppendMsgs(msg))
suite.txBuilder.SetFeeAmount(feeAmount)
suite.txBuilder.SetGasLimit(gasLimit)

Expand Down Expand Up @@ -56,7 +56,7 @@ func (suite *AnteTestSuite) TestRecoverPanic() {
msg := testdata.NewTestMsg(addr1)
feeAmount := testdata.NewTestFeeAmount()
gasLimit := testdata.NewTestGasLimit()
suite.Require().NoError(suite.txBuilder.SetMsgs(msg))
suite.Require().NoError(suite.txBuilder.AppendMsgs(msg))
suite.txBuilder.SetFeeAmount(feeAmount)
suite.txBuilder.SetGasLimit(gasLimit)

Expand Down
10 changes: 5 additions & 5 deletions x/auth/ante/sigverify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (suite *AnteTestSuite) TestSetPubKey() {
suite.app.AccountKeeper.SetAccount(suite.ctx, acc)
msgs[i] = testdata.NewTestMsg(addr)
}
suite.Require().NoError(suite.txBuilder.SetMsgs(msgs...))
suite.Require().NoError(suite.txBuilder.AppendMsgs(msgs...))

feeAmount := testdata.NewTestFeeAmount()
gasLimit := testdata.NewTestGasLimit()
Expand Down Expand Up @@ -167,7 +167,7 @@ func (suite *AnteTestSuite) TestSigVerification() {
suite.ctx = suite.ctx.WithIsReCheckTx(tc.recheck)
suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() // Create new txBuilder for each test

suite.Require().NoError(suite.txBuilder.SetMsgs(msgs...))
suite.Require().NoError(suite.txBuilder.AppendMsgs(msgs...))
suite.txBuilder.SetFeeAmount(feeAmount)
suite.txBuilder.SetGasLimit(gasLimit)

Expand Down Expand Up @@ -252,7 +252,7 @@ func (suite *AnteTestSuite) TestSigVerification_ExplicitAmino() {
suite.ctx = suite.ctx.WithIsReCheckTx(tc.recheck)
suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() // Create new txBuilder for each test

suite.Require().NoError(suite.txBuilder.SetMsgs(msgs...))
suite.Require().NoError(suite.txBuilder.AppendMsgs(msgs...))
suite.txBuilder.SetFeeAmount(feeAmount)
suite.txBuilder.SetGasLimit(gasLimit)

Expand Down Expand Up @@ -309,7 +309,7 @@ func (suite *AnteTestSuite) runSigDecorators(params types.Params, _ bool, privs
accNums[i] = uint64(i)
accSeqs[i] = uint64(0)
}
suite.Require().NoError(suite.txBuilder.SetMsgs(msgs...))
suite.Require().NoError(suite.txBuilder.AppendMsgs(msgs...))

feeAmount := testdata.NewTestFeeAmount()
gasLimit := testdata.NewTestGasLimit()
Expand Down Expand Up @@ -342,7 +342,7 @@ func (suite *AnteTestSuite) TestIncrementSequenceDecorator() {
suite.app.AccountKeeper.SetAccount(suite.ctx, acc)

msgs := []sdk.Msg{testdata.NewTestMsg(addr)}
suite.Require().NoError(suite.txBuilder.SetMsgs(msgs...))
suite.Require().NoError(suite.txBuilder.AppendMsgs(msgs...))
privs := []crypto.PrivKey{priv}
accNums := []uint64{suite.app.AccountKeeper.GetAccount(suite.ctx, addr).GetAccountNumber()}
accSeqs := []uint64{suite.app.AccountKeeper.GetAccount(suite.ctx, addr).GetSequence()}
Expand Down
2 changes: 1 addition & 1 deletion x/auth/ante/testutil_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ type TestCase struct {
// CreateTestTx is a helper function to create a tx given multiple inputs.
func (suite *AnteTestSuite) RunTestCase(privs []crypto.PrivKey, msgs []sdk.Msg, feeAmount sdk.Coins, gasLimit uint64, accNums, accSeqs []uint64, chainID string, tc TestCase) {
suite.Run(fmt.Sprintf("Case %s", tc.desc), func() {
suite.Require().NoError(suite.txBuilder.SetMsgs(msgs...))
suite.Require().NoError(suite.txBuilder.AppendMsgs(msgs...))
suite.txBuilder.SetFeeAmount(feeAmount)
suite.txBuilder.SetGasLimit(gasLimit)

Expand Down
4 changes: 2 additions & 2 deletions x/auth/client/cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ func TestGetBroadcastCommand_WithoutOfflineFlag(t *testing.T) {
require.NoError(t, err)
to, err := sdk.AccAddressFromBech32("cosmos1cxlt8kznps92fwu3j6npahx4mjfutydyene2qw")
require.NoError(t, err)
err = builder.SetMsgs(banktypes.NewMsgSend(from, to, sdk.Coins{sdk.NewInt64Coin("stake", 10000)}))
err = builder.AppendMsgs(banktypes.NewMsgSend(from, to, sdk.Coins{sdk.NewInt64Coin("stake", 10000)}))
require.NoError(t, err)
txContents, err := txCfg.TxJSONEncoder()(builder.GetTx())
txFileName := filepath.Join(testDir, "tx.json")
Expand Down Expand Up @@ -847,7 +847,7 @@ func (s *IntegrationTestSuite) TestTxWithoutPublicKey() {
msg := banktypes.NewMsgSend(val1.Address, val1.Address, sdk.NewCoins(
sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10)),
))
err := txBuilder.SetMsgs(msg)
err := txBuilder.AppendMsgs(msg)
s.Require().NoError(err)
txBuilder.SetFeeAmount(sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(150))))
txBuilder.SetGasLimit(testdata.NewTestGasLimit())
Expand Down
2 changes: 1 addition & 1 deletion x/auth/client/rest/rest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ func (s *IntegrationTestSuite) createTestStdTx(val *network.Validator, sequence
txBuilder := txConfig.NewTxBuilder()
feeAmount := sdk.Coins{sdk.NewInt64Coin(s.cfg.BondDenom, 10)}
gasLimit := testdata.NewTestGasLimit()
txBuilder.SetMsgs(msg)
txBuilder.AppendMsgs(msg)
txBuilder.SetFeeAmount(feeAmount)
txBuilder.SetGasLimit(gasLimit)
txBuilder.SetMemo("foobar")
Expand Down
33 changes: 33 additions & 0 deletions x/auth/legacy/legacytx/msg_service.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package legacytx

import (
gocontext "context"
"fmt"

"google.golang.org/grpc"

sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)

// Invoke implements the grpc ClientConn.Invoke method. This is so that we can
// use ADR-031 service `Msg`s with StdTxBuilder.
// TODO Full amino support still needs to be added as part of https://github.com/cosmos/cosmos-sdk/issues/7541.
amaury1093 marked this conversation as resolved.
Show resolved Hide resolved
func (s *StdTxBuilder) Invoke(_ gocontext.Context, method string, args, reply interface{}, _ ...grpc.CallOption) error {
req, ok := args.(sdk.MsgRequest)
if !ok {
return sdkerrors.Wrapf(sdkerrors.ErrInvalidType, "%T should implement %T", args, (*sdk.MsgRequest)(nil))
}

s.AppendMsgs(sdk.ServiceMsg{
MethodName: method,
Request: req,
})

return nil
}

// NewStream implements the grpc ClientConn.NewStream method.
func (s *StdTxBuilder) NewStream(gocontext.Context, *grpc.StreamDesc, string, ...grpc.CallOption) (grpc.ClientStream, error) {
return nil, fmt.Errorf("not supported")
}
6 changes: 3 additions & 3 deletions x/auth/legacy/legacytx/stdtx_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ func (s *StdTxBuilder) GetTx() authsigning.Tx {
return s.StdTx
}

// SetMsgs implements TxBuilder.SetMsgs
func (s *StdTxBuilder) SetMsgs(msgs ...sdk.Msg) error {
s.Msgs = msgs
// AppendMsgs implements TxBuilder.AppendMsgs
func (s *StdTxBuilder) AppendMsgs(msgs ...sdk.Msg) error {
s.Msgs = append(s.Msgs, msgs...)
return nil
}

Expand Down
Loading