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(x/tx): rm dependency on core #22281

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Core dependencies not mentioned here as compatible across all maintained SDK ver

| Cosmos SDK | cosmossdk.io/core | cosmossdk.io/api | cosmossdk.io/x/tx |
| ---------- | ----------------- | ---------------- | ----------------- |
| 0.52.z | 1.y.z | 0.8.z | 0.14.z |
| 0.52.z | 1.y.z | 0.8.z | 1.y.z |
| 0.50.z | 0.11.z | 0.7.z | 0.13.z |
| 0.47.z | 0.5.z | 0.3.z | N/A |

Expand Down
2 changes: 2 additions & 0 deletions x/tx/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ Since v0.13.0, x/tx follows Cosmos SDK semver: https://github.com/cosmos/cosmos-

## [Unreleased]

## [v1.0.0-alpha.1](https://github.com/cosmos/cosmos-sdk/releases/tag/x/tx/v1.0.0-alpha.1) - 2024-10-17

* [#21782](https://github.com/cosmos/cosmos-sdk/pull/21782) Fix JSON attribute sort order on messages with oneof fields.
* [#21825](https://github.com/cosmos/cosmos-sdk/pull/21825) Fix decimal encoding and field ordering in Amino JSON encoder.
* [#21850](https://github.com/cosmos/cosmos-sdk/pull/21850) Support bytes field as signer.
Expand Down
10 changes: 6 additions & 4 deletions x/tx/decode/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"google.golang.org/protobuf/types/dynamicpb"

v1beta1 "cosmossdk.io/api/cosmos/tx/v1beta1"
"cosmossdk.io/core/transaction"
errorsmod "cosmossdk.io/errors"
"cosmossdk.io/x/tx/signing"
)
Expand All @@ -32,8 +31,11 @@ type DecodedTx struct {
cachedBytes []byte
cachedHashed bool
}

var _ transaction.Tx = &DecodedTx{}
type Msg = interface {
Reset()
String() string
ProtoMessage()
}

type gogoProtoCodec interface {
Unmarshal([]byte, gogoproto.Message) error
Expand Down Expand Up @@ -192,7 +194,7 @@ func (dtx *DecodedTx) GetGasLimit() (uint64, error) {
return dtx.Tx.AuthInfo.Fee.GasLimit, nil
}

func (dtx *DecodedTx) GetMessages() ([]transaction.Msg, error) {
func (dtx *DecodedTx) GetMessages() ([]Msg, error) {
if dtx == nil || dtx.Messages == nil {
return nil, errors.New("messages not available or are nil")
}
Expand Down
1 change: 0 additions & 1 deletion x/tx/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ go 1.23

require (
cosmossdk.io/api v0.7.6
cosmossdk.io/core v1.0.0-alpha.4
cosmossdk.io/errors v1.0.1
cosmossdk.io/math v1.3.0
github.com/cosmos/cosmos-proto v1.0.0-beta.5
Expand Down
2 changes: 0 additions & 2 deletions x/tx/go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
cosmossdk.io/api v0.7.6 h1:PC20PcXy1xYKH2KU4RMurVoFjjKkCgYRbVAD4PdqUuY=
cosmossdk.io/api v0.7.6/go.mod h1:IcxpYS5fMemZGqyYtErK7OqvdM0C8kdW3dq8Q/XIG38=
cosmossdk.io/core v1.0.0-alpha.4 h1:9iuroT9ejDYETCsGkzkvs/wAY/5UFl7nCIINFRxyMJY=
cosmossdk.io/core v1.0.0-alpha.4/go.mod h1:3u9cWq1FAVtiiCrDPpo4LhR+9V6k/ycSG4/Y/tREWCY=
cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0=
cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U=
cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE=
Expand Down
20 changes: 12 additions & 8 deletions x/tx/signing/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,27 @@ import (
"google.golang.org/protobuf/reflect/protoregistry"

msgv1 "cosmossdk.io/api/cosmos/msg/v1"
"cosmossdk.io/core/address"
)

type TypeResolver interface {
protoregistry.MessageTypeResolver
protoregistry.ExtensionTypeResolver
}

type AddressCodec interface {
StringToBytes(string) ([]byte, error)
BytesToString([]byte) (string, error)
}

// Context is a context for retrieving the list of signers from a
// message where signers are specified by the cosmos.msg.v1.signer protobuf
// option. It also contains the ProtoFileResolver and address.Codec's used
// for resolving message descriptors and converting addresses.
type Context struct {
fileResolver ProtoFileResolver
typeResolver protoregistry.MessageTypeResolver
addressCodec address.Codec
validatorAddressCodec address.Codec
addressCodec AddressCodec
validatorAddressCodec AddressCodec
getSignersFuncs sync.Map
customGetSignerFuncs map[protoreflect.FullName]GetSignersFunc
maxRecursionDepth int
Expand All @@ -45,10 +49,10 @@ type Options struct {
TypeResolver TypeResolver

// AddressCodec is the codec for converting addresses between strings and bytes.
AddressCodec address.Codec
AddressCodec AddressCodec

// ValidatorAddressCodec is the codec for converting validator addresses between strings and bytes.
ValidatorAddressCodec address.Codec
ValidatorAddressCodec AddressCodec

// CustomGetSigners is a map of message types to custom GetSignersFuncs.
CustomGetSigners map[protoreflect.FullName]GetSignersFunc
Expand Down Expand Up @@ -323,7 +327,7 @@ func (c *Context) makeGetSignersFunc(descriptor protoreflect.MessageDescriptor)
}, nil
}

func (c *Context) getAddressCodec(field protoreflect.FieldDescriptor) address.Codec {
func (c *Context) getAddressCodec(field protoreflect.FieldDescriptor) AddressCodec {
scalarOpt := proto.GetExtension(field.Options(), cosmos_proto.E_Scalar)
addrCdc := c.addressCodec
if scalarOpt != nil {
Expand Down Expand Up @@ -367,12 +371,12 @@ func (c *Context) GetSigners(msg proto.Message) ([][]byte, error) {
}

// AddressCodec returns the address codec used by the context.
func (c *Context) AddressCodec() address.Codec {
func (c *Context) AddressCodec() AddressCodec {
return c.addressCodec
}

// ValidatorAddressCodec returns the validator address codec used by the context.
func (c *Context) ValidatorAddressCodec() address.Codec {
func (c *Context) ValidatorAddressCodec() AddressCodec {
return c.validatorAddressCodec
}

Expand Down
5 changes: 0 additions & 5 deletions x/tx/signing/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

bankv1beta1 "cosmossdk.io/api/cosmos/bank/v1beta1"
groupv1 "cosmossdk.io/api/cosmos/group/v1"
"cosmossdk.io/core/address"
"cosmossdk.io/x/tx/internal/testpb"
)

Expand Down Expand Up @@ -280,8 +279,6 @@ func (d dummyAddressCodec) BytesToString(bz []byte) (string, error) {
return hex.EncodeToString(bz), nil
}

var _ address.Codec = dummyAddressCodec{}

type dummyValidatorAddressCodec struct{}

func (d dummyValidatorAddressCodec) StringToBytes(text string) ([]byte, error) {
Expand All @@ -291,5 +288,3 @@ func (d dummyValidatorAddressCodec) StringToBytes(text string) ([]byte, error) {
func (d dummyValidatorAddressCodec) BytesToString(bz []byte) (string, error) {
return "val" + hex.EncodeToString(bz), nil
}

var _ address.Codec = dummyValidatorAddressCodec{}
3 changes: 0 additions & 3 deletions x/tx/signing/directaux/direct_aux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"cosmossdk.io/api/cosmos/crypto/secp256k1"
signingv1beta1 "cosmossdk.io/api/cosmos/tx/signing/v1beta1"
txv1beta1 "cosmossdk.io/api/cosmos/tx/v1beta1"
"cosmossdk.io/core/address"
"cosmossdk.io/x/tx/signing"
"cosmossdk.io/x/tx/signing/directaux"
)
Expand Down Expand Up @@ -158,5 +157,3 @@ func (d dummyAddressCodec) StringToBytes(text string) ([]byte, error) {
func (d dummyAddressCodec) BytesToString(bz []byte) (string, error) {
return hex.EncodeToString(bz), nil
}

var _ address.Codec = dummyAddressCodec{}
Loading