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

feat: update rosetta for v0.50 #1927

Open
wants to merge 17 commits into
base: v0.50.6b
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
6 changes: 3 additions & 3 deletions app/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ package app

import (
sdkerrors "cosmossdk.io/errors"
"cosmossdk.io/store/types"
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
"github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/errors"
sdkante "github.com/cosmos/cosmos-sdk/x/auth/ante"
ibcante "github.com/cosmos/ibc-go/v7/modules/core/ante"
ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper"
ibcante "github.com/cosmos/ibc-go/v8/modules/core/ante"
ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper"

"github.com/NibiruChain/nibiru/app/ante"
devgasante "github.com/NibiruChain/nibiru/x/devgas/v1/ante"
Expand Down
2 changes: 1 addition & 1 deletion app/ante/commission.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
)

func MAX_COMMISSION() sdk.Dec { return math.LegacyMustNewDecFromStr("0.25") }
func MAX_COMMISSION() math.LegacyDec { return math.LegacyMustNewDecFromStr("0.25") }

var _ sdk.AnteDecorator = (*AnteDecoratorStakingCommission)(nil)

Expand Down
4 changes: 2 additions & 2 deletions app/ante/commission_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (s *AnteTestSuite) TestAnteDecoratorStakingCommission() {
}

valAddr := sdk.ValAddress(testutil.AccAddress()).String()
commissionRatePointer := new(sdk.Dec)
commissionRatePointer := new(math.LegacyDec)
*commissionRatePointer = math.LegacyNewDecWithPrec(10, 2)
happyMsgs := []sdk.Msg{
&stakingtypes.MsgCreateValidator{
Expand Down Expand Up @@ -63,7 +63,7 @@ func (s *AnteTestSuite) TestAnteDecoratorStakingCommission() {

sadMsgEditVal := new(stakingtypes.MsgEditValidator)
*sadMsgEditVal = *(happyMsgs[1]).(*stakingtypes.MsgEditValidator)
newCommissionRate := new(sdk.Dec)
newCommissionRate := new(math.LegacyDec)
*newCommissionRate = math.LegacyNewDecWithPrec(26, 2)
sadMsgEditVal.CommissionRate = newCommissionRate

Expand Down
4 changes: 2 additions & 2 deletions app/ante/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package ante

import (
sdkerrors "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
"cosmossdk.io/math"
)

var errorCodeIdx uint32 = 1
Expand All @@ -18,7 +18,7 @@ var (
ErrMaxValidatorCommission = registerError("validator commission rate is above max")
)

func NewErrMaxValidatorCommission(gotCommission sdk.Dec) error {
func NewErrMaxValidatorCommission(gotCommission math.LegacyDec) error {
return ErrMaxValidatorCommission.Wrapf(
"got (%s), max rate is (%s)", gotCommission, MAX_COMMISSION())
}
5 changes: 3 additions & 2 deletions app/ante/fixed_gas_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

sdkioerrors "cosmossdk.io/errors"
"cosmossdk.io/math"
storetypes "cosmossdk.io/store/types"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand All @@ -26,7 +27,7 @@ func (suite *AnteTestSuite) TestOraclePostPriceTransactionsHaveFixedPrice() {
tests := []struct {
name string
messages []sdk.Msg
expectedGas sdk.Gas
expectedGas storetypes.Gas
expectedErr error
}{
{
Expand Down Expand Up @@ -218,7 +219,7 @@ func (suite *AnteTestSuite) TestOraclePostPriceTransactionsHaveFixedPrice() {
suite.NoError(suite.txBuilder.SetMsgs(tc.messages...))

privs, accNums, accSeqs := []cryptotypes.PrivKey{priv1}, []uint64{11}, []uint64{0}
tx, err := suite.CreateTestTx(privs, accNums, accSeqs, suite.ctx.ChainID())
tx, err := suite.CreateTestTx(suite.ctx, privs, accNums, accSeqs, suite.ctx.ChainID())
suite.NoErrorf(err, "tx: %v", tx)
suite.NoError(tx.ValidateBasic())
suite.ValidateTx(tx, suite.T())
Expand Down
18 changes: 8 additions & 10 deletions app/ante/gas.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,38 @@ package ante
import (
"fmt"

storetypes "github.com/cosmos/cosmos-sdk/store/types"

"github.com/cosmos/cosmos-sdk/types"
storetypes "cosmossdk.io/store/types"
)

type fixedGasMeter struct {
consumed types.Gas
consumed storetypes.Gas
}

// NewFixedGasMeter returns a reference to a new fixedGasMeter.
func NewFixedGasMeter(fixedGas types.Gas) types.GasMeter {
func NewFixedGasMeter(fixedGas storetypes.Gas) storetypes.GasMeter {
return &fixedGasMeter{
consumed: fixedGas,
}
}

func (g *fixedGasMeter) GasConsumed() types.Gas {
func (g *fixedGasMeter) GasConsumed() storetypes.Gas {
return g.consumed
}

func (g *fixedGasMeter) GasConsumedToLimit() types.Gas {
func (g *fixedGasMeter) GasConsumedToLimit() storetypes.Gas {
return g.consumed
}

func (g *fixedGasMeter) Limit() types.Gas {
func (g *fixedGasMeter) Limit() storetypes.Gas {
return g.consumed
}

func (g *fixedGasMeter) GasRemaining() storetypes.Gas {
return g.consumed
}

func (g *fixedGasMeter) ConsumeGas(types.Gas, string) {}
func (g *fixedGasMeter) RefundGas(types.Gas, string) {}
func (g *fixedGasMeter) ConsumeGas(storetypes.Gas, string) {}
func (g *fixedGasMeter) RefundGas(storetypes.Gas, string) {}

func (g *fixedGasMeter) IsPastLimit() bool {
return false
Expand Down
23 changes: 16 additions & 7 deletions app/ante/testutil_test.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package ante_test

import (
"context"
"testing"
"time"

"github.com/cosmos/cosmos-sdk/x/auth/ante"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
ibcante "github.com/cosmos/ibc-go/v7/modules/core/ante"
ibcante "github.com/cosmos/ibc-go/v8/modules/core/ante"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/tx"
Expand Down Expand Up @@ -41,7 +42,8 @@ func (suite *AnteTestSuite) SetupTest() {
encodingConfig := app.MakeEncodingConfig()
suite.app = testapp.NewNibiruTestApp(app.NewDefaultGenesisState(encodingConfig.Codec))
chainId := "test-chain-id"
ctx := suite.app.NewContext(true, tmproto.Header{
ctx := suite.app.NewContext(true)
ctx.WithBlockHeader(tmproto.Header{
Height: 1,
ChainID: chainId,
Time: time.Now().UTC(),
Expand All @@ -54,7 +56,7 @@ func (suite *AnteTestSuite) SetupTest() {
WithChainID(chainId).
WithLegacyAmino(encodingConfig.Amino)

err := suite.app.AccountKeeper.SetParams(ctx, authtypes.DefaultParams())
err := suite.app.AccountKeeper.Params.Set(ctx, authtypes.DefaultParams())
suite.Require().NoError(err)
params := suite.app.AccountKeeper.GetParams(ctx)
suite.Require().NoError(params.Validate())
Expand Down Expand Up @@ -84,15 +86,17 @@ func (suite *AnteTestSuite) SetupTest() {
}

// CreateTestTx is a helper function to create a tx given multiple inputs.
func (suite *AnteTestSuite) CreateTestTx(privs []cryptotypes.PrivKey, accNums []uint64, accSeqs []uint64, chainID string) (xauthsigning.Tx, error) {
func (suite *AnteTestSuite) CreateTestTx(ctx context.Context, privs []cryptotypes.PrivKey, accNums []uint64, accSeqs []uint64, chainID string) (xauthsigning.Tx, error) {
// First round: we gather all the signer infos. We use the "set empty
// signature" hack to do that.
signMode := signing.SignMode_SIGN_MODE_DIRECT

var sigsV2 []signing.SignatureV2
for i, priv := range privs {
sigV2 := signing.SignatureV2{
PubKey: priv.PubKey(),
Data: &signing.SingleSignatureData{
SignMode: suite.clientCtx.TxConfig.SignModeHandler().DefaultMode(),
SignMode: signMode,
Signature: nil,
},
Sequence: accSeqs[i],
Expand All @@ -117,8 +121,13 @@ func (suite *AnteTestSuite) CreateTestTx(privs []cryptotypes.PrivKey, accNums []
Sequence: accSeqs[i],
}
sigV2, err := tx.SignWithPrivKey(
suite.clientCtx.TxConfig.SignModeHandler().DefaultMode(), signerData,
suite.txBuilder, priv, suite.clientCtx.TxConfig, accSeqs[i])
ctx,
signMode,
signerData,
suite.txBuilder,
priv,
suite.clientCtx.TxConfig,
accSeqs[i])
if err != nil {
return nil, err
}
Expand Down
17 changes: 8 additions & 9 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,34 @@ import (

"github.com/NibiruChain/nibiru/app/wasmext"

storetypes "cosmossdk.io/store/types"
dbm "github.com/cometbft/cometbft-db"
abci "github.com/cometbft/cometbft/abci/types"
"github.com/cometbft/cometbft/libs/log"
tmos "github.com/cometbft/cometbft/libs/os"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
_ "github.com/cosmos/cosmos-sdk/client/docs/statik"
"github.com/cosmos/cosmos-sdk/client/grpc/cmtservice"
"github.com/cosmos/cosmos-sdk/client/grpc/node"
"github.com/cosmos/cosmos-sdk/client/grpc/tmservice"
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/server/api"
"github.com/cosmos/cosmos-sdk/server/config"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/version"
authante "github.com/cosmos/cosmos-sdk/x/auth/ante"
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper"
"github.com/cosmos/cosmos-sdk/x/crisis"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper"
ibctesting "github.com/cosmos/ibc-go/v7/testing"
"github.com/cosmos/ibc-go/v7/testing/types"
capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper"
ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper"
ibctesting "github.com/cosmos/ibc-go/v8/testing"
"github.com/cosmos/ibc-go/v8/testing/types"
"github.com/gorilla/mux"
"github.com/prometheus/client_golang/prometheus"
"github.com/rakyll/statik/fs"
Expand Down Expand Up @@ -346,7 +345,7 @@ func (app *NibiruApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.API
// Register new tx routes from grpc-gateway.
authtx.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)
// Register new tendermint queries routes from grpc-gateway.
tmservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)
cmtservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)

// Register legacy and grpc-gateway routes for all modules.
ModuleBasics.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)
Expand All @@ -366,7 +365,7 @@ func (app *NibiruApp) RegisterTxService(clientCtx client.Context) {

// RegisterTendermintService implements the Application.RegisterTendermintService method.
func (app *NibiruApp) RegisterTendermintService(clientCtx client.Context) {
tmservice.RegisterTendermintService(
cmtservice.RegisterTendermintService(
clientCtx,
app.BaseApp.GRPCQueryRouter(),
app.interfaceRegistry,
Expand Down
2 changes: 1 addition & 1 deletion app/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/json"
"log"

tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
tmproto "github.com/cometbft/cometbft/types"

servertypes "github.com/cosmos/cosmos-sdk/server/types"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down
1 change: 1 addition & 0 deletions app/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func AppStateFromGenesisFileFn(r io.Reader, cdc codec.JSONCodec, genesisFile str
}

var genesis tmtypes.GenesisDoc

// NOTE: Tendermint uses a custom JSON decoder for GenesisDoc
err = tmjson.Unmarshal(bytes, &genesis)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions app/ibc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (

"cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
ibctesting "github.com/cosmos/ibc-go/v7/testing"
transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
ibctesting "github.com/cosmos/ibc-go/v8/testing"
"github.com/stretchr/testify/suite"

"github.com/NibiruChain/nibiru/app"
Expand Down
Loading
Loading