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

refactor!: use x/tx/signing in client.TxConfig #15822

Merged
merged 66 commits into from
Apr 20, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
db53c1d
Hard break client.TxConfig
kocubinski Apr 12, 2023
0019cb9
incorporate changes from #15713
kocubinski Apr 12, 2023
f44fee6
Hard fixing
kocubinski Apr 12, 2023
49c18df
Merge branch 'main' into kocubinski/tx-config-break
kocubinski Apr 12, 2023
14539c4
go mod tidy
kocubinski Apr 12, 2023
5f2b4de
fix breakage in codec from latest main
kocubinski Apr 12, 2023
02c2340
Merge branch 'main' of github.com:cosmos/cosmos-sdk into kocubinski/t…
kocubinski Apr 13, 2023
147cbdf
remove replace for x/tx
kocubinski Apr 13, 2023
55e1d36
revert codec/ compat for x/tx 0.6.0
kocubinski Apr 13, 2023
55acfe3
x/tx v0.5.1
kocubinski Apr 13, 2023
bedd4b9
add err handling
kocubinski Apr 13, 2023
21927ef
checkpoint, proto gen
kocubinski Apr 13, 2023
623bacf
adjust lots of tests
kocubinski Apr 13, 2023
43ea1b4
fixed ante tests
kocubinski Apr 13, 2023
e32f007
Merge branch 'main' of github.com:cosmos/cosmos-sdk into kocubinski/t…
kocubinski Apr 13, 2023
bff8090
merged fix
kocubinski Apr 13, 2023
0a25910
revert (temporarily) x/tx to 0.5.1
kocubinski Apr 13, 2023
3f0a4f2
rm files
kocubinski Apr 13, 2023
d24dbc2
fix tx_test
kocubinski Apr 13, 2023
2e62758
revert x/tx
kocubinski Apr 13, 2023
2c9bd78
comment
kocubinski Apr 14, 2023
863c869
Merge branch 'main' of github.com:cosmos/cosmos-sdk into kocubinski/t…
kocubinski Apr 14, 2023
e0cecb1
maybe some fixes
kocubinski Apr 14, 2023
d0317b3
fix more test/build failures
kocubinski Apr 14, 2023
8365099
use x/tx 0.5.3
kocubinski Apr 14, 2023
ec82685
Merge branch 'main' into kocubinski/tx-config-break
kocubinski Apr 14, 2023
dc0d717
update rosetta go.mod
kocubinski Apr 14, 2023
c4c4cdd
Merge branch 'kocubinski/tx-config-break' of github.com:cosmos/cosmos…
kocubinski Apr 14, 2023
6e691fc
liniting
kocubinski Apr 14, 2023
0010ceb
linting fixes
kocubinski Apr 14, 2023
0b9eb03
lint fix
kocubinski Apr 14, 2023
4843d63
Merge branch 'main' of github.com:cosmos/cosmos-sdk into kocubinski/t…
kocubinski Apr 17, 2023
caf6987
clean up config
kocubinski Apr 17, 2023
a246afc
go mod tidy
kocubinski Apr 17, 2023
c6f2033
tidy rosetta
kocubinski Apr 17, 2023
978f4f4
rwmutex
kocubinski Apr 17, 2023
a8069dc
lint fix
kocubinski Apr 17, 2023
3851398
proper lazy init with sync.once
kocubinski Apr 17, 2023
6c363f5
clean up todos
kocubinski Apr 18, 2023
c66aefd
Merge branch 'main' of github.com:cosmos/cosmos-sdk into kocubinski/t…
kocubinski Apr 18, 2023
8fc3108
clean up, comments
kocubinski Apr 18, 2023
7364f41
attempt remove redundant arg
kocubinski Apr 18, 2023
a0acb58
move lazy registry
kocubinski Apr 18, 2023
f04a10c
store init error
kocubinski Apr 18, 2023
59ab3ce
test fixes
kocubinski Apr 18, 2023
ae3fe65
Merge branch 'main' of github.com:cosmos/cosmos-sdk into kocubinski/t…
kocubinski Apr 18, 2023
79c0f89
Merge branch 'main' of github.com:cosmos/cosmos-sdk into kocubinski/t…
kocubinski Apr 18, 2023
d4bb593
handle default sign mode todos
kocubinski Apr 18, 2023
96a693d
x/tx 0.5.5
kocubinski Apr 18, 2023
0796a6c
go mod tidy
kocubinski Apr 18, 2023
ad658b5
rm more todos
kocubinski Apr 18, 2023
c270393
lint fix
kocubinski Apr 18, 2023
4ad00c5
clean up handler creation API
kocubinski Apr 18, 2023
8e516b2
fix more test bugs
kocubinski Apr 18, 2023
f138251
finish simd/root command
kocubinski Apr 18, 2023
8973802
Merge branch 'main' of github.com:cosmos/cosmos-sdk into kocubinski/t…
kocubinski Apr 18, 2023
76c6363
a little clean up
kocubinski Apr 19, 2023
dd3cd93
Merge branch 'main' of github.com:cosmos/cosmos-sdk into kocubinski/t…
kocubinski Apr 19, 2023
05d52af
Add CHANGELOG entries for API breaks
kocubinski Apr 19, 2023
f3211b8
Add UPGRADING entries
kocubinski Apr 19, 2023
147dc83
Merge branch 'main' into kocubinski/tx-config-break
kocubinski Apr 19, 2023
d1af44c
PR fixes
kocubinski Apr 19, 2023
e8398d2
Merge branch 'main' of github.com:cosmos/cosmos-sdk into kocubinski/t…
kocubinski Apr 19, 2023
cd4f11f
lint fix
kocubinski Apr 19, 2023
2bb6750
Refactor NewTxConfig
kocubinski Apr 20, 2023
3bcaa98
lazy loading won't work in InterfaceRegistry ctr won't work yet.
kocubinski Apr 20, 2023
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
14 changes: 7 additions & 7 deletions client/tx/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,8 @@ func SignWithPrivKey(
var sigV2 signing.SignatureV2

// Generate the bytes to be signed.
signBytes, err := authsigning.GetSignBytesWithContext(txConfig.SignModeHandler(), ctx, signMode, signerData, txBuilder.GetTx())
if err != nil {
return sigV2, err
}
signBytes, err := authsigning.AdaptSigningArgs(
Fixed Show fixed Hide fixed
ctx, txConfig.TxEncoder(), txConfig.SignModeHandler(), signMode, signerData, priv.PubKey(), txBuilder.GetTx())

// Sign those bytes
signature, err := priv.Sign(signBytes)
Expand Down Expand Up @@ -251,7 +249,8 @@ func Sign(ctx context.Context, txf Factory, name string, txBuilder client.TxBuil
signMode := txf.signMode
if signMode == signing.SignMode_SIGN_MODE_UNSPECIFIED {
// use the SignModeHandler's default mode if unspecified
signMode = txf.txConfig.SignModeHandler().DefaultMode()
// TODO default mode in handler map?
signMode = signing.SignMode_SIGN_MODE_DIRECT
}

k, err := txf.keybase.Key(name)
Expand Down Expand Up @@ -313,8 +312,9 @@ func Sign(ctx context.Context, txf Factory, name string, txBuilder client.TxBuil
return err
}

// Generate the bytes to be signed.
bytesToSign, err := authsigning.GetSignBytesWithContext(txf.txConfig.SignModeHandler(), ctx, signMode, signerData, txBuilder.GetTx())
bytesToSign, err := authsigning.AdaptSigningArgs(
ctx, txf.txConfig.TxEncoder(), txf.txConfig.SignModeHandler(),
signMode, signerData, pubKey, txBuilder.GetTx())
if err != nil {
return err
}
Expand Down
3 changes: 2 additions & 1 deletion client/tx_config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package client

import (
txsigning "cosmossdk.io/x/tx/signing"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/tx"
signingtypes "github.com/cosmos/cosmos-sdk/types/tx/signing"
Expand All @@ -27,7 +28,7 @@ type (

NewTxBuilder() TxBuilder
WrapTxBuilder(sdk.Tx) (TxBuilder, error)
SignModeHandler() signing.SignModeHandler
SignModeHandler() *txsigning.HandlerMap
}

// TxBuilder defines an interface which an application-defined concrete transaction
Expand Down
46 changes: 36 additions & 10 deletions codec/proto_codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type ProtoCodecMarshaler interface {
// encoding.
type ProtoCodec struct {
interfaceRegistry types.InterfaceRegistry
getSignersCtx *signing.GetSignersContext
signersCtx *signing.Context
}

var (
Expand All @@ -39,16 +39,16 @@ var (

// NewProtoCodec returns a reference to a new ProtoCodec
func NewProtoCodec(interfaceRegistry types.InterfaceRegistry) *ProtoCodec {
getSignersCtx, err := signing.NewGetSignersContext(
signing.GetSignersOptions{
ProtoFiles: interfaceRegistry,
signerCtx, err := signing.NewContext(
signing.Options{
FileResolver: interfaceRegistry,
})
if err != nil {
panic(err)
}
return &ProtoCodec{
interfaceRegistry: interfaceRegistry,
getSignersCtx: getSignersCtx,
signersCtx: signerCtx,
}
}

Expand Down Expand Up @@ -286,18 +286,44 @@ func (pc ProtoCodec) GetMsgAnySigners(msg *types.Any) ([]string, proto.Message,
return nil, nil, err
}

signers, err := pc.getSignersCtx.GetSigners(msgv2)
return signers, msgv2, err
bzSigners, err := pc.signersCtx.GetSigners(msgv2)
if err != nil {
return nil, nil, err
}

strSigners := make([]string, len(bzSigners))
for i, bz := range bzSigners {
strSigners[i] = string(bz)
}
return strSigners, msgv2, err
}

func (pc *ProtoCodec) GetMsgV2Signers(msg proto.Message) ([]string, error) {
return pc.getSignersCtx.GetSigners(msg)
bzSigners, err := pc.signersCtx.GetSigners(msg)
if err != nil {
return nil, err
}

strSigners := make([]string, len(bzSigners))
for i, bz := range bzSigners {
strSigners[i] = string(bz)
}
return strSigners, nil
}

func (pc *ProtoCodec) GetMsgV1Signers(msg gogoproto.Message) ([]string, proto.Message, error) {
if msgV2, ok := msg.(proto.Message); ok {
signers, err := pc.getSignersCtx.GetSigners(msgV2)
return signers, msgV2, err
bzSigners, err := pc.signersCtx.GetSigners(msgV2)
if err != nil {
return nil, nil, err
}

strSigners := make([]string, len(bzSigners))
for i, bz := range bzSigners {
strSigners[i] = string(bz)
}

return strSigners, msgV2, err
}
a, err := types.NewAnyWithValue(msg)
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ require (
github.com/hashicorp/go-plugin v1.4.9 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hashicorp/yamux v0.1.1 // indirect
github.com/iancoleman/strcase v0.2.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jmhodges/levigo v1.0.0 // indirect
github.com/klauspost/compress v1.16.3 // indirect
Expand Down Expand Up @@ -161,6 +162,7 @@ require (

// Below are the long-lived replace of the Cosmos SDK
replace (
cosmossdk.io/x/tx => ./x/tx
// use cosmos fork of keyring
github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0
// dgrijalva/jwt-go is deprecated and doesn't receive security updates.
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ cosmossdk.io/math v1.0.0 h1:ro9w7eKx23om2tZz/VM2Pf+z2WAbGX1yDQQOJ6iGeJw=
cosmossdk.io/math v1.0.0/go.mod h1:Ygz4wBHrgc7g0N+8+MrnTfS9LLn9aaTGa9hKopuym5k=
cosmossdk.io/store v0.1.0-alpha.1.0.20230328185921-37ba88872dbc h1:9piuA+NYmhe+SyMPtMoboLw/djgDbrI3dD5TG020Tnk=
cosmossdk.io/store v0.1.0-alpha.1.0.20230328185921-37ba88872dbc/go.mod h1:UFF5rmjN7WYVfxo6ArdY/l1+yyWMURBWOmSJypGqFHQ=
cosmossdk.io/x/tx v0.5.1-0.20230407182919-057d2e09bd63 h1:zHqj2VwZ/MStFmR7SUe/7gErOFhL9v2rkjmWPB/st34=
cosmossdk.io/x/tx v0.5.1-0.20230407182919-057d2e09bd63/go.mod h1:Oh3Kh+IPOfMEILNxVd2e8SLqRrIjYHpdGBfDg4ghU/k=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
filippo.io/edwards25519 v1.0.0 h1:0wAIcmJUqRdI8IJ/3eGi5/HwXZWPujYXXlkrQogz0Ek=
filippo.io/edwards25519 v1.0.0/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns=
Expand Down Expand Up @@ -494,6 +492,8 @@ github.com/huandu/skiplist v1.2.0 h1:gox56QD77HzSC0w+Ws3MH3iie755GBJU1OER3h5VsYw
github.com/huandu/skiplist v1.2.0/go.mod h1:7v3iFjLcSAzO4fN5B8dvebvo/qsfumiLiDXMrPiHF9w=
github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg=
github.com/hydrogen18/memlistener v0.0.0-20200120041712-dcc25e7acd91/go.mod h1:qEIFzExnS6016fRpRfxrExeVn2gbClQA99gQhnIcdhE=
github.com/iancoleman/strcase v0.2.0 h1:05I4QRnGpI0m37iZQRuskXh+w77mr6Z41lwQzuHLwW0=
github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/imkira/go-interpol v1.1.0/go.mod h1:z0h2/2T3XF8kyEPpRgJ3kmNv+C43p+I/CoI+jC3w2iA=
Expand Down
7 changes: 4 additions & 3 deletions server/grpc/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import (
"fmt"
"net"

"cosmossdk.io/log"
"google.golang.org/grpc"

"cosmossdk.io/log"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/server/config"
Expand Down Expand Up @@ -44,8 +45,8 @@ func NewGRPCServer(clientCtx client.Context, app types.Application, cfg config.G
// time.
err := reflection.Register(grpcSrv, reflection.Config{
SigningModes: func() map[string]int32 {
modes := make(map[string]int32, len(clientCtx.TxConfig.SignModeHandler().Modes()))
for _, m := range clientCtx.TxConfig.SignModeHandler().Modes() {
modes := make(map[string]int32, len(clientCtx.TxConfig.SignModeHandler().SupportedModes()))
for _, m := range clientCtx.TxConfig.SignModeHandler().SupportedModes() {
kocubinski marked this conversation as resolved.
Show resolved Hide resolved
modes[m.String()] = (int32)(m)
}

Expand Down
2 changes: 2 additions & 0 deletions simapp/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ require (
github.com/hashicorp/yamux v0.1.1 // indirect
github.com/hdevalence/ed25519consensus v0.1.0 // indirect
github.com/huandu/skiplist v1.2.0 // indirect
github.com/iancoleman/strcase v0.2.0 // indirect
github.com/improbable-eng/grpc-web v0.15.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
Expand Down Expand Up @@ -202,6 +203,7 @@ replace (
cosmossdk.io/x/evidence => ../x/evidence
cosmossdk.io/x/feegrant => ../x/feegrant
cosmossdk.io/x/nft => ../x/nft
cosmossdk.io/x/tx => ../x/tx
cosmossdk.io/x/upgrade => ../x/upgrade
)

Expand Down
4 changes: 2 additions & 2 deletions simapp/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,6 @@ cosmossdk.io/log v1.0.0 h1:NGKZ/A5rd4PduDfoscgABklX557PWjQINbosZy/m3Jk=
cosmossdk.io/log v1.0.0/go.mod h1:CwX9BLiBruZb7lzLlRr3R231d/fVPUXk8gAdV4LQap0=
cosmossdk.io/math v1.0.0 h1:ro9w7eKx23om2tZz/VM2Pf+z2WAbGX1yDQQOJ6iGeJw=
cosmossdk.io/math v1.0.0/go.mod h1:Ygz4wBHrgc7g0N+8+MrnTfS9LLn9aaTGa9hKopuym5k=
cosmossdk.io/x/tx v0.5.1-0.20230407182919-057d2e09bd63 h1:zHqj2VwZ/MStFmR7SUe/7gErOFhL9v2rkjmWPB/st34=
cosmossdk.io/x/tx v0.5.1-0.20230407182919-057d2e09bd63/go.mod h1:Oh3Kh+IPOfMEILNxVd2e8SLqRrIjYHpdGBfDg4ghU/k=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
filippo.io/edwards25519 v1.0.0 h1:0wAIcmJUqRdI8IJ/3eGi5/HwXZWPujYXXlkrQogz0Ek=
filippo.io/edwards25519 v1.0.0/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns=
Expand Down Expand Up @@ -697,6 +695,8 @@ github.com/huandu/skiplist v1.2.0 h1:gox56QD77HzSC0w+Ws3MH3iie755GBJU1OER3h5VsYw
github.com/huandu/skiplist v1.2.0/go.mod h1:7v3iFjLcSAzO4fN5B8dvebvo/qsfumiLiDXMrPiHF9w=
github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg=
github.com/hydrogen18/memlistener v0.0.0-20200120041712-dcc25e7acd91/go.mod h1:qEIFzExnS6016fRpRfxrExeVn2gbClQA99gQhnIcdhE=
github.com/iancoleman/strcase v0.2.0 h1:05I4QRnGpI0m37iZQRuskXh+w77mr6Z41lwQzuHLwW0=
github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/imkira/go-interpol v1.1.0/go.mod h1:z0h2/2T3XF8kyEPpRgJ3kmNv+C43p+I/CoI+jC3w2iA=
Expand Down
9 changes: 7 additions & 2 deletions simapp/simd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@ import (
"io"
"os"

"cosmossdk.io/log"
cmtcfg "github.com/cometbft/cometbft/config"
dbm "github.com/cosmos/cosmos-db"
"github.com/spf13/cobra"
"github.com/spf13/viper"

"cosmossdk.io/log"
"cosmossdk.io/simapp"
"cosmossdk.io/simapp/params"
confixcmd "cosmossdk.io/tools/confix/cmd"
rosettaCmd "cosmossdk.io/tools/rosetta/cmd"
"github.com/cosmos/cosmos-sdk/x/auth/signing"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/config"
Expand Down Expand Up @@ -90,9 +91,13 @@ func NewRootCmd() *cobra.Command {
if err != nil {
return err
}
signModes, err := signing.APISignModesToInternal(encodingConfig.TxConfig.SignModeHandler().SupportedModes())
if err != nil {
return err
}
txConfigWithTextual := tx.NewTxConfigWithTextual(
codec.NewProtoCodec(encodingConfig.InterfaceRegistry),
encodingConfig.TxConfig.SignModeHandler().Modes(),
signModes,
txt,
)
initClientCtx = initClientCtx.WithTxConfig(txConfigWithTextual)
Expand Down
9 changes: 7 additions & 2 deletions testutil/sims/tx_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ func GenSignedMockTx(r *rand.Rand, txConfig client.TxConfig, msgs []sdk.Msg, fee
// create a random length memo
memo := simulation.RandStringOfLength(r, simulation.RandIntBetween(r, 0, 100))

signMode := txConfig.SignModeHandler().DefaultMode()
// TODO
// support default mode?
//signMode := txConfig.SignModeHandler().DefaultMode()
signMode := signing.SignMode_SIGN_MODE_DIRECT

// 1st round: set SignatureV2 with empty signatures, to set correct
// signer infos.
Expand Down Expand Up @@ -63,7 +66,9 @@ func GenSignedMockTx(r *rand.Rand, txConfig client.TxConfig, msgs []sdk.Msg, fee
PubKey: p.PubKey(),
}

signBytes, err := authsign.GetSignBytesWithContext(txConfig.SignModeHandler(), context.Background(), signMode, signerData, tx.GetTx())
signBytes, err := authsign.AdaptSigningArgs(
context.Background(), txConfig.TxEncoder(), txConfig.SignModeHandler(), signMode, signerData, p.PubKey(),
tx.GetTx())
if err != nil {
panic(err)
}
Expand Down
8 changes: 7 additions & 1 deletion testutil/testnet/genesis.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package testnet

import (
"context"
"encoding/json"
"fmt"
"strconv"
"time"

cmttypes "github.com/cometbft/cometbft/types"

"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
Expand Down Expand Up @@ -143,7 +145,10 @@ func (b *GenesisBuilder) GenTx(privVal secp256k1.PrivKey, val cmttypes.GenesisVa
}

// Generate bytes to be signed.
bytesToSign, err := txConf.SignModeHandler().GetSignBytes(
bytesToSign, err := authsigning.AdaptSigningArgs(
context.Background(),
txConf.TxEncoder(),
txConf.SignModeHandler(),
signing.SignMode_SIGN_MODE_DIRECT,
authsigning.SignerData{
ChainID: b.chainID,
Expand All @@ -152,6 +157,7 @@ func (b *GenesisBuilder) GenTx(privVal secp256k1.PrivKey, val cmttypes.GenesisVa

// No account or sequence number for gentx.
},
pubKey,
txb.GetTx(),
)
if err != nil {
Expand Down
19 changes: 15 additions & 4 deletions tools/rosetta/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@ package rosetta

import (
"bytes"
"context"
"encoding/json"
"fmt"
"reflect"

sdkmath "cosmossdk.io/math"
crgerrs "cosmossdk.io/tools/rosetta/lib/errors"
crgtypes "cosmossdk.io/tools/rosetta/lib/types"
rosettatypes "github.com/coinbase/rosetta-sdk-go/types"
abci "github.com/cometbft/cometbft/abci/types"
"github.com/cometbft/cometbft/crypto"
tmcoretypes "github.com/cometbft/cometbft/rpc/core/types"
cmttypes "github.com/cometbft/cometbft/types"
secp "github.com/decred/dcrd/dcrec/secp256k1/v4"

sdkmath "cosmossdk.io/math"
crgerrs "cosmossdk.io/tools/rosetta/lib/errors"
crgtypes "cosmossdk.io/tools/rosetta/lib/types"

sdkclient "github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
Expand Down Expand Up @@ -113,7 +115,16 @@ func NewConverter(cdc *codec.ProtoCodec, ir codectypes.InterfaceRegistry, cfg sd
txDecode: cfg.TxDecoder(),
txEncode: cfg.TxEncoder(),
bytesToSign: func(tx authsigning.Tx, signerData authsigning.SignerData) (b []byte, err error) {
bytesToSign, err := cfg.SignModeHandler().GetSignBytes(signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON, signerData, tx)
// TODO
// which pubkey?
pubkeys, err := tx.GetPubKeys()
if err != nil {
return nil, err
}

bytesToSign, err := authsigning.AdaptSigningArgs(
context.Background(), cfg.TxEncoder(), cfg.SignModeHandler(),
signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON, signerData, pubkeys[0], tx)
if err != nil {
return nil, err
}
Expand Down
8 changes: 6 additions & 2 deletions tools/rosetta/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ require (

require (
cosmossdk.io/api v0.4.0 // indirect
cosmossdk.io/collections v0.0.0-20230309163709-87da587416ba // indirect
cosmossdk.io/collections v0.0.0-20230411101845-3d1a0b8840e4 // indirect
cosmossdk.io/core v0.6.1 // indirect
cosmossdk.io/depinject v1.0.0-alpha.3 // indirect
cosmossdk.io/errors v1.0.0-beta.7 // indirect
cosmossdk.io/store v0.1.0-alpha.1.0.20230328185921-37ba88872dbc // indirect
cosmossdk.io/x/tx v0.5.0 // indirect
cosmossdk.io/x/tx v0.5.1-0.20230407182919-057d2e09bd63 // indirect
filippo.io/edwards25519 v1.0.0 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
github.com/99designs/keyring v1.2.1 // indirect
Expand Down Expand Up @@ -82,6 +82,7 @@ require (
github.com/hashicorp/yamux v0.1.1 // indirect
github.com/hdevalence/ed25519consensus v0.1.0 // indirect
github.com/huandu/skiplist v1.2.0 // indirect
github.com/iancoleman/strcase v0.2.0 // indirect
github.com/improbable-eng/grpc-web v0.15.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/klauspost/compress v1.16.3 // indirect
Expand Down Expand Up @@ -137,3 +138,6 @@ require (
pgregory.net/rapid v0.5.5 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)

// temp to use local version of cosmos-sdk while in dev
replace github.com/cosmos/cosmos-sdk => ../..
Loading