Skip to content

Commit

Permalink
change decoder to decode block-sdk first tx to empty tx
Browse files Browse the repository at this point in the history
  • Loading branch information
beer-1 committed Nov 24, 2023
1 parent a2a11d0 commit 8e6c32d
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 7 deletions.
12 changes: 6 additions & 6 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ import (
ibctm "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"

// initia imports
initiaservice "github.com/initia-labs/initia/service"

ibctestingtypes "github.com/initia-labs/initia/x/ibc/testing/types"
icaauth "github.com/initia-labs/initia/x/intertx"
icaauthkeeper "github.com/initia-labs/initia/x/intertx/keeper"
Expand Down Expand Up @@ -993,17 +993,17 @@ func (app *MinitiaApp) Simulate(txBytes []byte) (sdk.GasInfo, *sdk.Result, error

// RegisterTxService implements the Application.RegisterTxService method.
func (app *MinitiaApp) RegisterTxService(clientCtx client.Context) {
initiaservice.RegisterTxService(
authtx.RegisterTxService(
app.BaseApp.GRPCQueryRouter(), clientCtx,
authtx.NewTxServer(clientCtx, app.Simulate, app.interfaceRegistry),
app.Simulate, app.interfaceRegistry,
)
}

// RegisterTendermintService implements the Application.RegisterTendermintService method.
func (app *MinitiaApp) RegisterTendermintService(clientCtx client.Context) {
initiaservice.RegisterTendermintService(
app.BaseApp.GRPCQueryRouter(),
tmservice.NewQueryServer(clientCtx, app.interfaceRegistry, app.Query),
tmservice.RegisterTendermintService(
clientCtx, app.BaseApp.GRPCQueryRouter(),
app.interfaceRegistry, app.Query,
)
}

Expand Down
39 changes: 39 additions & 0 deletions app/params/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package params

import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
signingtypes "github.com/cosmos/cosmos-sdk/types/tx/signing"
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"

blockproposalstypes "github.com/skip-mev/block-sdk/block/proposals/types"
)

type config struct {
client.TxConfig
}

func NewTxConfig(protoCodec codec.ProtoCodecMarshaler, enabledSignModes []signingtypes.SignMode) client.TxConfig {
return config{authtx.NewTxConfig(protoCodec, enabledSignModes)}
}

func (g config) TxDecoder() sdk.TxDecoder {
return func(txBytes []byte) (sdk.Tx, error) {
if tx, err := g.TxConfig.TxDecoder()(txBytes); err != nil {

// convert skip's custom message to empty tx
var metaData blockproposalstypes.ProposalInfo
if err := metaData.Unmarshal(txBytes); err == nil {
txbuilder := g.NewTxBuilder()
txbuilder.SetMemo("Tx is for BlockSDK")

return txbuilder.GetTx(), err
}

return tx, err
} else {
return tx, err
}
}
}
2 changes: 1 addition & 1 deletion app/params/proto.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ func MakeEncodingConfig() EncodingConfig {
amino := codec.NewLegacyAmino()
interfaceRegistry := types.NewInterfaceRegistry()
marshaler := codec.NewProtoCodec(interfaceRegistry)
txCfg := tx.NewTxConfig(marshaler, tx.DefaultSignModes)
txCfg := NewTxConfig(marshaler, tx.DefaultSignModes)

return EncodingConfig{
InterfaceRegistry: interfaceRegistry,
Expand Down

0 comments on commit 8e6c32d

Please sign in to comment.